Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Shanghai Simple Script - Critical Buffs
- # Last Date Updated: 2010.06.09
- # Level: Normal
- #
- # This script allows equipment to give actors more stat boosts when they reach
- # critical HP state.
- #===============================================================================
- # 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 stat: +x>
- # <critical stat: -x>
- # Put this in your equipment noteboxes. They'll give stat boosts when the user
- # is in a critical state. Replace stat with maxhp, maxmp, atk, def, spi, agi,
- # dex, or res. Dex and res only works if you have Yanfly Engine Melody's
- # New Stats.
- #
- # <critical state: x>
- # <critical state: x, x, x>
- # Put this in your equipment noteboxes. They'll give status effects when the
- # user is in a critical state. Replace x with the state ID you want added.
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["CriticalBuff"] = true
- module SSS
- # What percent the actor's HP must be under to considered in critical status.
- CRITICAL_PERCENT = 25
- end
- #==============================================================================
- # RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # critical_buffs
- #--------------------------------------------------------------------------
- def critical_buffs
- return @critical_buffs if @critical_buffs != nil
- @critical_buffs = {} if @critical_buffs.nil?
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<(?:CRITICAL|crit)[ ](.*):[ ]([\+\-]\d+)>/i
- case $1.upcase
- when "MAXHP", "HP"
- @critical_buffs[:maxhp] = $2.to_i
- when "MAXMP", "MP"
- @critical_buffs[:maxmp] = $2.to_i
- when "ATK"
- @critical_buffs[:atk] = $2.to_i
- when "DEF"
- @critical_buffs[:def] = $2.to_i
- when "SPI"
- @critical_buffs[:spi] = $2.to_i
- when "AGI"
- @critical_buffs[:agi] = $2.to_i
- when "DEX"
- @critical_buffs[:dex] = $2.to_i
- when "RES"
- @critical_buffs[:res] = $2.to_i
- end
- end
- }
- return @critical_buffs
- end
- #--------------------------------------------------------------------------
- # critical_states
- #--------------------------------------------------------------------------
- def critical_states
- return @critical_states if @critical_states != nil
- @critical_states = []
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<(?:CRITICAL STATE|crit state):[ ](\d+(?:\s*,\s*\d+)*)>/i
- $1.scan(/\d+/).each { |num|
- @critical_states.push($data_states[num.to_i]) if num.to_i > 0 }
- end
- }
- return @critical_states
- end
- end
- #==============================================================================
- # ** Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # * Change HP
- #--------------------------------------------------------------------------
- alias hp_sss_critical_buffs hp= unless $@
- def hp=(hp)
- previous_crit = @critical_status
- hp_sss_critical_buffs(hp)
- @critical_status = @hp < self.maxhp * SSS::CRITICAL_PERCENT / 100
- if $imported["BattleEngineMelody"] and previous_crit != @critical_status
- @update_maxhp = true
- @update_maxmp = true
- @update_states = true
- @update_commands = true
- clear_battle_cache
- end
- end
- #--------------------------------------------------------------------------
- # * Get Current States as an Object Array
- #--------------------------------------------------------------------------
- alias states_sss_critical_buffs states unless $@
- def states
- n = states_sss_critical_buffs
- n |= critical_states if actor? and critical_status?
- return n
- end
- end
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Critical Status
- #--------------------------------------------------------------------------
- def critical_status?
- return @critical_status
- end
- #--------------------------------------------------------------------------
- # * Critical States
- #--------------------------------------------------------------------------
- def critical_states
- n = []
- for equip in equips.compact do n |= equip.critical_states end
- return n.uniq
- end
- #--------------------------------------------------------------------------
- # * Get Basic Maximum HP
- #--------------------------------------------------------------------------
- alias base_maxhp_sss_critical_buffs base_maxhp unless $@
- def base_maxhp
- n = base_maxhp_sss_critical_buffs
- type = :maxhp
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Maximum MP
- #--------------------------------------------------------------------------
- alias base_maxmp_sss_critical_buffs base_maxmp unless $@
- def base_maxmp
- n = base_maxmp_sss_critical_buffs
- type = :maxmp
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Attack
- #--------------------------------------------------------------------------
- alias base_atk_sss_critical_buffs base_atk unless $@
- def base_atk
- n = base_atk_sss_critical_buffs
- type = :atk
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Defense
- #--------------------------------------------------------------------------
- alias base_def_sss_critical_buffs base_def unless $@
- def base_def
- n = base_def_sss_critical_buffs
- type = :def
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Spirit
- #--------------------------------------------------------------------------
- alias base_spi_sss_critical_buffs base_spi unless $@
- def base_spi
- n = base_spi_sss_critical_buffs
- type = :spi
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Agility
- #--------------------------------------------------------------------------
- alias base_agi_sss_critical_buffs base_agi unless $@
- def base_agi
- n = base_agi_sss_critical_buffs
- type = :agi
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- #--------------------------------------------------------------------------
- # * Get Basic Dexterity
- #--------------------------------------------------------------------------
- if $imported["DEX Stat"]
- alias base_dex_sss_critical_buffs base_dex unless $@
- def base_dex
- n = base_dex_sss_critical_buffs
- type = :dex
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- end
- #--------------------------------------------------------------------------
- # * Get Basic Resist
- #--------------------------------------------------------------------------
- if $imported["RES Stat"]
- alias base_res_sss_critical_buffs base_res unless $@
- def base_res
- n = base_res_sss_critical_buffs
- type = :res
- for equip in equips.compact
- break unless critical_status?
- next if equip.critical_buffs[type].nil?
- n += equip.critical_buffs[type]
- end
- return n
- end
- end
- end
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement