Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Enemy HP/MP Icons v1.01
- # by mjshi. OK for use in any project.
- #-------------------------------------------------------------------------------
- # Installation: Put above Main, preferably also above other custom scripts.
- #-------------------------------------------------------------------------------
- # Update notes:
- #- Minor optimizations.
- #-------------------------------------------------------------------------------
- module EnemyHPMPIcons
- #-----------------------------------------------------------------------------
- # **CONFIGURATION**
- #-----------------------------------------------------------------------------
- # Which icons should the script use next to the HP and MP values?
- HP_ICON = 187
- MP_ICON = 188
- #
- # How much should the text be offset?
- X_OFFSET = 0
- Y_OFFSET = 0
- #
- # How much personal space should we have between the icons and text?
- SPACING = 2
- #
- # How much personal longitude should we have between the icons and text?
- Y_SPACING = 2
- #
- # Make this bigger if stuff is getting cut off
- WINDOW_WIDTH = 120
- #
- #-----------------------------------------------------------------------------
- # What color should the text be? [R, G, B] -OR- windowskin color index
- # ex: TEXTCOLOR = 0 on a fresh project would make the text white, and
- # TEXTCOLOR = 1 would make it blue.
- # also:
- # TEXTCOLOR = [255, 255, 255] makes text white
- # TEXTCOLOR = [0, 0, 0] makes text black (will look bad unless
- # HIDE_TEXT_SHADOW = true)
- TEXTCOLOR = 0
- #
- # There's this really annoying blurry outline that shows up around stuff...
- # Want me to kill it?
- HIDE_OUTLINE = false
- #
- # How large ought the text be?
- TEXT_SIZE = 24
- #
- # Drop a shadow under it?
- TEXT_DROP_SHADOW = false
- #
- #-----------------------------------------------------------------------------
- end
- class Sprite_Battler
- def create_ehpmpwindow
- height = EnemyHPMPIcons::TEXT_SIZE*3
- @ehpmp_window = Window_Base.new(0,0,EnemyHPMPIcons::WINDOW_WIDTH,height)
- @ehpmp_window.x = self.x - @ehpmp_window.width / 2 + EnemyHPMPIcons::X_OFFSET
- @ehpmp_window.y = self.y + EnemyHPMPIcons::Y_OFFSET - self.height - @ehpmp_window.height
- @ehpmp_window.x = 0 if @ehpmp_window.x < 0
- @ehpmp_window.y = 0 if @ehpmp_window.y < 0
- @ehpmp_window.contents.font.outline = !EnemyHPMPIcons::HIDE_OUTLINE
- @ehpmp_window.contents.font.size = EnemyHPMPIcons::TEXT_SIZE
- @ehpmp_window.contents.font.shadow = EnemyHPMPIcons::TEXT_DROP_SHADOW
- @ehpmp_window.opacity = 0
- @ehpmp_window.z = self.z + 1
- @ehpmp_window.viewport = self.viewport
- end
- def update_hpmpinfo
- create_ehpmpwindow if @ehpmp_window.nil?
- @ehpmp_window.visible = @battler.alive? || @battler.hidden?
- return if !@battler.alive? || !@ehpmp_window.visible
- @ehpmp_window.update
- @ehpmp_window.contents_opacity = self.opacity if @ehpmp_window.contents_opacity != self.opacity
- @ehpmp_window.y = self.y + EnemyHPMPIcons::Y_OFFSET - self.height - @ehpmp_window.height
- @ehpmp_window.y = 0 if @ehpmp_window.y < 0
- @ehpmp_window.contents.clear
- @ehpmp_window.draw_icon(EnemyHPMPIcons::HP_ICON, 0, 0)
- @ehpmp_window.draw_icon(EnemyHPMPIcons::MP_ICON, 0, EnemyHPMPIcons::TEXT_SIZE + EnemyHPMPIcons::Y_SPACING)
- width = @ehpmp_window.contents.width - @ehpmp_window.padding
- if EnemyHPMPIcons::TEXTCOLOR.is_a?(Array)
- @ehpmp_window.contents.font.color.set(Color.new(EnemyHPMPIcons::TEXTCOLOR[0], EnemyHPMPIcons::TEXTCOLOR[1], EnemyHPMPIcons::TEXTCOLOR[2]))
- else
- @ehpmp_window.change_color(@ehpmp_window.text_color(EnemyHPMPIcons::TEXTCOLOR))
- end
- @ehpmp_window.draw_text(24 + EnemyHPMPIcons::SPACING, 0, width, EnemyHPMPIcons::TEXT_SIZE, @battler.hp.to_s + "/" + @battler.mhp.to_s)
- @ehpmp_window.draw_text(24 + EnemyHPMPIcons::SPACING, EnemyHPMPIcons::TEXT_SIZE + EnemyHPMPIcons::Y_SPACING, width, EnemyHPMPIcons::TEXT_SIZE, @battler.mp.to_s + "/" + @battler.mmp.to_s)
- end
- alias _enemyhpmpicons_update update
- def update
- _enemyhpmpicons_update
- return unless @battler.is_a?(Game_Enemy)
- update_hpmpinfo if @battler
- end
- alias _enemyhpmpicons_dispose dispose
- def dispose
- @ehpmp_window.dispose if @ehpmp_window
- _enemyhpmpicons_dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement