SUN_furawa

SSS-Enemy Critical

Jul 26th, 2011
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Enemy Critical Image
  4. # Last Date Updated: 2010.06.11
  5. # Level: Normal
  6. #
  7. # This makes enemies change their enemy image when they reach a critical HP
  8. # condition to show they're injured or whatever.
  9. #===============================================================================
  10. # Instructions
  11. # -----------------------------------------------------------------------------
  12. # To install this script, open up your script editor and copy/paste this script
  13. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  14. #
  15. # <critical: string, x>
  16. # Replace string with the battler image you want the enemy to change to when
  17. # it reaches critical status. x is the color hue the enemy will shift to.
  18. #===============================================================================
  19.  
  20. $imported = {} if $imported == nil
  21. $imported["EnemyCriticalImage"] = true
  22.  
  23. module SSS
  24. # What percent the enemy's HP must be under to considered in critical status.
  25. CRITICAL_PERCENT = 25
  26. end
  27.  
  28. #==============================================================================
  29. # RPG::Enemy
  30. #==============================================================================
  31.  
  32. class RPG::Enemy
  33. #--------------------------------------------------------------------------
  34. # critical_image
  35. #--------------------------------------------------------------------------
  36. def critical_image
  37. return @critical_image if @critical_image != nil
  38. @critical_image = false
  39. self.note.split(/[\r\n]+/).each { |line|
  40. case line
  41. when /<(?:CRITICAL|crit):[ ](.*),[ ]*(\d+)>/i
  42. @critical_image = [$1.to_s, $2.to_i]
  43. end
  44. }
  45. return @critical_image
  46. end
  47. end
  48.  
  49. #==============================================================================
  50. # ** Game_Battler
  51. #==============================================================================
  52.  
  53. class Game_Battler
  54. #--------------------------------------------------------------------------
  55. # * Change HP
  56. #--------------------------------------------------------------------------
  57. alias hp_sss_critical_image hp= unless $@
  58. def hp=(hp)
  59. hp_sss_critical_image(hp)
  60. change_critical_image if self.is_a?(Game_Enemy)
  61. end
  62. end
  63.  
  64. #==============================================================================
  65. # ** Game_Enemy
  66. #==============================================================================
  67.  
  68. class Game_Enemy < Game_Battler
  69. #--------------------------------------------------------------------------
  70. # * Change Critical Image
  71. #--------------------------------------------------------------------------
  72. def change_critical_image
  73. return if dead?
  74. return if enemy.critical_image == false
  75. return if @critical_hp_status and maxhp*SSS::CRITICAL_PERCENT/100 > @hp
  76. return if !@critical_hp_status and @hp > maxhp*SSS::CRITICAL_PERCENT/100
  77. if !@critical_hp_status and maxhp*SSS::CRITICAL_PERCENT/100 > @hp
  78. @critical_hp_status = true
  79. @battler_name = enemy.critical_image[0]
  80. @battler_hue = enemy.critical_image[1]
  81. elsif @critical_hp_status and @hp > maxhp*SSS::CRITICAL_PERCENT/100
  82. @critical_hp_status = false
  83. @battler_name = enemy.battler_name
  84. @battler_hue = enemy.battler_hue
  85. end
  86. end
  87. end
  88.  
  89. #===============================================================================
  90. #
  91. # END OF FILE
  92. #
  93. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment