Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Shanghai Simple Script - Enemy Critical Image
- # Last Date Updated: 2010.06.11
- # Level: Normal
- #
- # This makes enemies change their enemy image when they reach a critical HP
- # condition to show they're injured or whatever.
- #===============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # <critical: string, x>
- # Replace string with the battler image you want the enemy to change to when
- # it reaches critical status. x is the color hue the enemy will shift to.
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["EnemyCriticalImage"] = true
- module SSS
- # What percent the enemy's HP must be under to considered in critical status.
- CRITICAL_PERCENT = 25
- end
- #==============================================================================
- # RPG::Enemy
- #==============================================================================
- class RPG::Enemy
- #--------------------------------------------------------------------------
- # critical_image
- #--------------------------------------------------------------------------
- def critical_image
- return @critical_image if @critical_image != nil
- @critical_image = false
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<(?:CRITICAL|crit):[ ](.*),[ ]*(\d+)>/i
- @critical_image = [$1.to_s, $2.to_i]
- end
- }
- return @critical_image
- end
- end
- #==============================================================================
- # ** Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # * Change HP
- #--------------------------------------------------------------------------
- alias hp_sss_critical_image hp= unless $@
- def hp=(hp)
- hp_sss_critical_image(hp)
- change_critical_image if self.is_a?(Game_Enemy)
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # * Change Critical Image
- #--------------------------------------------------------------------------
- def change_critical_image
- return if dead?
- return if enemy.critical_image == false
- return if @critical_hp_status and maxhp*SSS::CRITICAL_PERCENT/100 > @hp
- return if !@critical_hp_status and @hp > maxhp*SSS::CRITICAL_PERCENT/100
- if !@critical_hp_status and maxhp*SSS::CRITICAL_PERCENT/100 > @hp
- @critical_hp_status = true
- @battler_name = enemy.critical_image[0]
- @battler_hue = enemy.critical_image[1]
- elsif @critical_hp_status and @hp > maxhp*SSS::CRITICAL_PERCENT/100
- @critical_hp_status = false
- @battler_name = enemy.battler_name
- @battler_hue = enemy.battler_hue
- end
- end
- end
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment