Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** ThornSkills
- #
- # * Author: Szyu
- # * Version: 1.0
- # * Pastebin: http://adf.ly/4920670/thornskills
- # * Description:
- # Adds the ability to define thorn-effects, which trigger certain skills on
- # damage, if specific state conditions are met.
- #
- # * Requirements:
- # - Szyu's StateConditions
- #
- # * How To Use:
- # "<thorn_skill: id>" in states notes where id represents the skill id
- #
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["Szyu_ThornSkills"] = true
- if $imported["Szyu_StateConditions"]
- #==============================================================================
- # ** Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- alias szstco_execute_damage execute_damage
- #--------------------------------------------------------------------------
- # * state_conditions_met
- #--------------------------------------------------------------------------
- def state_conditions_met(state_conditions, target)
- state_conditions.each do |sid|
- return false if not target.states.any?{|s| s.id == sid}
- end
- return true
- end
- #--------------------------------------------------------------------------
- # * actor_battle_index
- #--------------------------------------------------------------------------
- def actor_battle_index(actor_id)
- return $game_party.battle_members.index{|a| a.id == actor_id}
- end
- #--------------------------------------------------------------------------
- # * execute_damage
- #--------------------------------------------------------------------------
- def execute_damage(user)
- szstco_execute_damage(user)
- return if user == self
- state_conditions = []
- thorn_skills= []
- states.select{|s| s!= nil }.each do |x|
- if x.thorn_skill
- state_conditions.concat(x.state_conditions) if x.state_conditions.size > 0
- thorn_skills.concat(x.thorn_skill).uniq!
- end
- end
- if state_conditions.size == 0 || state_conditions_met(state_conditions, self)
- thorn_skills.each do |tsid|
- action = Game_Action.new(self, true)
- action.set_skill(tsid)
- action.target_index = actor_battle_index(user.id) if user.is_a?(Game_Actor)
- action.target_index = user.index if user.is_a?(Game_Enemy)
- action.target_index = self.index if self.is_a?(Game_Enemy) && action.item.scope >= 7
- action.target_index = actor_battle_index(self.id) if self.is_a?(Game_Actor) && action.item.scope >= 7
- @actions.insert(0, action)
- end
- end
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- alias szstco_process_action_end process_action_end
- #--------------------------------------------------------------------------
- # * process_action_end
- #--------------------------------------------------------------------------
- def process_action_end
- if check_actors_thorns.size > 0
- check_actors_thorns.each do |sub|
- @subject = sub
- @subject.actions.each do |act|
- act.prepare
- if act.valid?
- @status_window.open
- execute_action
- end
- @subject.remove_current_action
- end
- end
- end
- szstco_process_action_end
- end
- #--------------------------------------------------------------------------
- # * check_actors_thorns
- #--------------------------------------------------------------------------
- def check_actors_thorns
- return $game_party.battle_members.select{|a| a.dead? == false && a.actions.size > 0}
- end
- end
- #==============================================================================
- # ** RPG::State
- #==============================================================================
- class RPG::State < RPG::BaseItem
- #--------------------------------------------------------------------------
- # * thorn_skill
- #--------------------------------------------------------------------------
- def thorn_skill
- ts = []
- self.note.downcase.each_line do |line|
- if line =~ /<thorn_skill:\s*(\d+)>/i
- ts.push($1.to_i)
- end
- end
- return ts.size > 0 ? ts : nil
- end
- end
- end
Add Comment
Please, Sign In to add comment