Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Simple HP Gauge
- # -- Author : Dekita
- # -- Version : 1.2
- # -- Level : Very Easy
- # -- Requires : N/A
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:NME_Gauges]=true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # o3/o4/2o13 - Update, (notetag for diff width)
- # 3o/o3/2o13 - Update, (only visible when enemy hit)
- # 28/o3/2o13 - Started, Finished,
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # A Simple Script to show Enemy Hp Gauges in battle, some customizable options
- # such as color, height, width.
- #
- # May also show for actors depending on your battle system :)
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- #
- #===============================================================================
- module NME_HP_Bars
- #===============================================================================
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ☆ Basic Settings
- #--------------------------------------------------------------------------
- # Importance Value (reccommended = 200)
- Gauge_z = 200
- # Gauge Colors
- Hp_Color_1 = Color.new(182,64,0)
- Hp_Color_2 = Color.new(212,212,64)
- Outline_Color = Color.new(0,0,0,182)
- Empty_Color = Color.new(0,0,0,98)
- # Gauge Size
- Height = 5
- Width = 52
- # Visibility of Gauge
- Opacity = 255
- # Make this true to always see the hp gauge(s)
- Always_See = false
- Notetag = /<HPW:(.*)>/i
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- class NME_HUD < Sprite
- #===============================================================================
- #--------------------------------------------------------------------------
- # Initialize
- #--------------------------------------------------------------------------
- def initialize(viewport = nil, battler = nil)
- super(viewport)
- @battler = battler
- @width = get_width
- @height = NME_HP_Bars::Height
- self.bitmap = Bitmap.new(@width,@height)
- bgrap = Cache.battler(@battler.battler_name, 0)
- @_X = (@battler.screen_x) - (self.bitmap.width/2)
- @_Y = (@battler.screen_y) - (bgrap.height)
- reset_the_gauge(true)
- self.opacity = 0 unless NME_HP_Bars::Always_See
- end
- #--------------------------------------------------------------------------
- # Get Gauge Width
- #--------------------------------------------------------------------------
- def get_width
- width = NME_HP_Bars::Width
- if @battler.is_a?(Game_Enemy)
- if @battler.enemy.note =~ NME_HP_Bars::Notetag
- width = $1.to_i
- end
- else # is actor
- if @battler.actor.note =~ NME_HP_Bars::Notetag
- width = $1.to_i
- end
- end
- return width
- end
- #--------------------------------------------------------------------------
- # Reset Gauge
- #--------------------------------------------------------------------------
- def reset_the_gauge(init=false)
- self.bitmap = Bitmap.new(@width,@height)
- empty_color = Color.new(0,0,0,128)
- color_1 = NME_HP_Bars::Hp_Color_1
- color_2 = NME_HP_Bars::Hp_Color_2
- @hp = @battler.hp
- @old_hp = @hp
- @max_hp = @battler.mhp
- rate = @battler.hp_rate
- fill = [(@width * rate).to_i, @width].min
- self.bitmap.fill_rect(0, 0, @width, @height, NME_HP_Bars::Outline_Color)
- self.bitmap.fill_rect(1, 1, @width-2, @height-2, NME_HP_Bars::Empty_Color)
- self.bitmap.gradient_fill_rect(1, 1, fill-2, @height-2, color_1, color_2)
- self.z = NME_HP_Bars::Gauge_z
- self.x = @_X
- self.y = @_Y - self.bitmap.height
- self.opacity = NME_HP_Bars::Opacity if @hp > 0 unless init
- end
- #--------------------------------------------------------------------------
- # Dispose
- #--------------------------------------------------------------------------
- def dispose
- super
- end
- #--------------------------------------------------------------------------
- # Update
- #--------------------------------------------------------------------------
- def update
- super
- reset_the_gauge if @battler.hp != @old_hp
- self.opacity -= 1 if self.opacity > 0 unless NME_HP_Bars::Always_See
- self.opacity -= 2 if @battler.hp <= 0
- end
- end
- #===============================================================================
- class Sprite_Battler < Sprite_Base
- #===============================================================================
- #--------------------------------------------------------------------------
- # Alias List
- #--------------------------------------------------------------------------
- alias :init_simple_gauge :initialize
- alias :dispose_simple_gauge :dispose
- alias :update_simple_gauge :update
- #--------------------------------------------------------------------------
- # Object Initialization
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- init_simple_gauge(viewport, battler)
- @gauge = NME_HUD.new(viewport, battler) if @battler
- end
- #--------------------------------------------------------------------------
- # Free
- #--------------------------------------------------------------------------
- def dispose
- @gauge.dispose if @gauge
- dispose_simple_gauge
- end
- #--------------------------------------------------------------------------
- # Frame Update
- #--------------------------------------------------------------------------
- def update
- update_simple_gauge
- @gauge.update if @gauge && @battler
- end
- end
- #==============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #==============================================================================#
- end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement