Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # ♫ ~ Wounded state by TheoAllen ~ ♫
- # Version : 1.1
- # Requires : N/A
- # Contact : www.rpgmakerid.com
- # =============================================================================
- # ♫ UPDATES :
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2013.03.04 - Add notetags for actor and enemy
- # 2013.02.22 - Started and finished script
- #
- # =============================================================================
- # ♫ DESCRIPTION :
- # This script allow you to automatically add state if the characters or enemy
- # in wounded condition. To disable this automatic add state for some enemies or
- # characters, just simply put resist state in feature system
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # ♫ INSTRUCTION :
- # Put this script below material but above main in script editor. Don't forget
- # to save.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # ♫ HOW TO USE :
- # -------------------------------
- # ACTOR AND ENEMY NOTETAGS
- # -------------------------------
- # <wounded cond: x%>
- # To specify wounded condition. Default value can be configured below.
- #
- # <wounded state: x>
- # To specify which state will be add if the battler met the wounded condition.
- # Default value can be configured below.
- # =============================================================================
- # ♫ TERMS OF USE :
- # - Credit me, TheoAllen. If you think it's necessary.
- # - You may use and edit this script both commercial and non-commercial or even
- # adult game as long as u don't claim it's yours.
- # - I'll be glad if you give me a free copy of your game if you use this script
- # in your commercial project.
- # =============================================================================
- $imported = {} if $imported.nil?
- $imported["Theo-WoundedState"] = true
- # =============================================================================
- # ♫ CONFIGURATIONS ~ ♫
- # =============================================================================
- module THEOLIZED
- module WS
- WOUNDED_CONDITION = 0.25 # default percentage of wounded condition.
- WOUNDED_STATE_ID = 0 # default wounded state ID
- end
- end
- # =============================================================================
- # ♫ Do not edit unless you know what to do ~ ♫
- # =============================================================================
- # SCRIPT INFOS :
- # -------------------------------------
- # Rewriten method :
- # N/A
- # -------------------------------------
- # Aliased method :
- # - DataManager
- # def self.load_database
- # - Game_BattlerBase
- # def refresh
- # =============================================================================
- # ♫ NOTETAGS ~ ♫
- # =============================================================================
- module THEOLIZED
- module NOTETAGS_WS
- WOUNDED_COND = /<(?:WOUNDED COND|wounded cond):[ ]*(\d+)([%%])>/i
- WOUNDED_STATE = /<(?:WOUNDED STATE|wounded state):[ ]*(\d+)>/i
- end
- end
- # =============================================================================
- # ♫ Module DataManager ~ ♫
- # =============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ♫ Aliased load database
- #--------------------------------------------------------------------------
- class <<self; alias theolized_load_ws_db load_database; end
- def self.load_database
- theolized_load_ws_db
- theolized_load_ws_notetags
- end
- #--------------------------------------------------------------------------
- # ♫ Load wounded state notetags
- #--------------------------------------------------------------------------
- def self.theolized_load_ws_notetags
- groups = [$data_enemies, $data_actors]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.theolized_load_ws_notetags
- end
- end
- end
- end
- # =============================================================================
- # ♫ RPG::Actor ~ ♫
- # =============================================================================
- class RPG::Actor
- attr_accessor :wound_state
- attr_accessor :wound_cond
- #--------------------------------------------------------------------------
- # ♫ Load wounded state notetags
- #--------------------------------------------------------------------------
- def theolized_load_ws_notetags
- @wound_state = THEOLIZED::WS::WOUNDED_STATE_ID
- @wound_cond = THEOLIZED::WS::WOUNDED_CONDITION
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when THEOLIZED::NOTETAGS_WS::WOUNDED_COND
- @wound_cond = $1.to_f * 0.01
- when THEOLIZED::NOTETAGS_WS::WOUNDED_STATE
- @wound_state = $1.to_i
- end
- }
- end
- end
- # =============================================================================
- # ♫ RPG::Enemy~ ♫
- # =============================================================================
- class RPG::Enemy
- attr_accessor :wound_state
- attr_accessor :wound_cond
- #--------------------------------------------------------------------------
- # ♫ Load wounded state notetags
- #--------------------------------------------------------------------------
- def theolized_load_ws_notetags
- @wound_state = THEOLIZED::WS::WOUNDED_STATE_ID
- @wound_cond = THEOLIZED::WS::WOUNDED_CONDITION
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when THEOLIZED::NOTETAGS_WS::WOUNDED_COND
- @wound_cond = $1.to_f * 0.01
- when THEOLIZED::NOTETAGS_WS::WOUNDED_STATE
- @wound_state = $1.to_i
- end
- }
- end
- end
- # =============================================================================
- # ♫ Game_BattlerBase ♫
- # =============================================================================
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # ♫ Aliased refresh
- #--------------------------------------------------------------------------
- alias theo_wound_refresh refresh
- def refresh
- theo_wound_refresh
- apply_wounded_state
- end
- #--------------------------------------------------------------------------
- # ♫ Check wounded
- #--------------------------------------------------------------------------
- def wounded?
- return false
- end
- #--------------------------------------------------------------------------
- # ♫ Get wounded state id
- #--------------------------------------------------------------------------
- def wounded_state_id
- return 0
- end
- #--------------------------------------------------------------------------
- # ♫ Apply wounded state
- #--------------------------------------------------------------------------
- def apply_wounded_state
- return if wounded_state_id <= 0
- wounded? ? add_state(wounded_state_id) : remove_state(wounded_state_id)
- end
- end
- # =============================================================================
- # ♫ Game_Actor ♫
- # =============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ♫ Check wounded
- #--------------------------------------------------------------------------
- def wounded?
- return hp_rate <= $data_actors[id].wound_cond
- end
- #--------------------------------------------------------------------------
- # ♫ Get wounded state id
- #--------------------------------------------------------------------------
- def wounded_state_id
- return $data_actors[id].wound_state
- end
- end
- # =============================================================================
- # ♫ Game_Enemy ♫
- # =============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ♫ Check wounded
- #--------------------------------------------------------------------------
- def wounded?
- return hp_rate <= $data_enemies[@enemy_id].wound_cond
- end
- #--------------------------------------------------------------------------
- # ♫ Get wounded state id
- #--------------------------------------------------------------------------
- def wounded_state_id
- return $data_enemies[@enemy_id].wound_state
- end
- end
- # =============================================================================
- # ♫ End of Script ♫
- # =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement