Advertisement
LiTTleDRAgo

[RGSS/2/3] Critical Hp Warning

Feb 1st, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.98 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # [XP/VX/VX-A] Critical HP Warning
  3. # Version: 1.20
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. VX  = defined?(Window_BattleMessage)
  7. VXA = defined?(Window_KeyItem)
  8. module LiTTleDRAgo
  9.  
  10.   LOWHP = 25 #%               #  Persentase HP Untuk mengaktifkan Warning
  11.   SE = "057-Wrong01"          #  Sound Effect pas warning
  12.   FLASH = true                #  Nyalain flash apa ngga pas warning
  13.   LOOP = 35                   #  Loop tiap warningnya
  14.  
  15. end
  16. #==============================================================================
  17. # ** Game_Player
  18. #------------------------------------------------------------------------------
  19. #  This class handles maps. It includes event starting determinants and map
  20. # scrolling functions. The instance of this class is referenced by $game_map.
  21. #==============================================================================
  22. class Game_Player < Game_Character
  23.   #--------------------------------------------------------------------------
  24.   # * Frame Update
  25.   #--------------------------------------------------------------------------
  26.   alias_method :drago_hp_warn_update, :update
  27.   def update
  28.     @warn      = @warn.nil? || @warn > LiTTleDRAgo::LOOP ? 0 : @warn + 1
  29.     game_party = VX || VXA ? $game_party.members : $game_party.actors
  30.     screen     = VX || VXA ? $game_map.screen : $game_screen
  31.     (0...game_party.size).each {|i|  actor = game_party[i]
  32.       cond = actor.hp * 100 / (VXA ? actor.mhp : actor.maxhp)
  33.       if cond <= LiTTleDRAgo::LOWHP && @warn == 1
  34.         Audio.se_play("Audio/SE/#{LiTTleDRAgo::SE}" ,100,100) rescue nil
  35.         screen.start_flash(Color.new(255,50,0,128), 10) if LiTTleDRAgo::FLASH
  36.       end }
  37.     drago_hp_warn_update
  38.   end
  39. end
  40. #==============================================================================
  41. # ** Scene_Battle
  42. #------------------------------------------------------------------------------
  43. #  This class performs battle screen processing.
  44. #==============================================================================
  45. class Scene_Battle
  46.   #--------------------------------------------------------------------------
  47.   # * Frame Update
  48.   #--------------------------------------------------------------------------
  49.   alias_method :drago_hp_warn_update, :update
  50.   def update
  51.     @warn      = @warn.nil? || @warn > LiTTleDRAgo::LOOP ? 0 : @warn + 1
  52.     game_party = VX || VXA ? $game_party.members : $game_party.actors
  53.     screen     = VX || VXA ? $game_troop.screen : $game_screen
  54.     (0...game_party.size).each {|i|  actor = game_party[i]
  55.       cond = actor.hp * 100 / (VXA ? actor.mhp : actor.maxhp)
  56.       if cond <= LiTTleDRAgo::LOWHP && @warn == 1 && actor.hp > 0
  57.         Audio.se_play("Audio/SE/#{LiTTleDRAgo::SE}" ,100,100) rescue nil
  58.         screen.start_flash(Color.new(255,50,0,128), 10) if LiTTleDRAgo::FLASH
  59.       end }
  60.     drago_hp_warn_update
  61.   end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement