Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- #
- # L'James Expire Skill
- #
- #
- # Requires L'James Notetag System
- #==============================================================================
- # Description
- #==============================================================================
- #
- # This script allows to execute skill when state expires.
- #
- #==============================================================================
- # Instruction
- #==============================================================================
- #
- # Insert script between L'JNT and Main.
- # Use notetag in state
- #
- # <expire skill x1,x2,x3> - after state expires, skills x1, x2 and x3 will be
- # called in that order. For damage calculation skill uses character parameters
- # in a moment when state was added.
- #
- #==============================================================================
- # Terms of use
- #==============================================================================
- # Free to use in commercial and non-commercial projects as long as you give
- # credit to L'James
- #==============================================================================
- module LJ::EXPIRESKILL
- LJ::NOTETAGS.extension do
- declare_state do
- register :expire_skill, array(:int).set_unique(false)
- end
- end
- end
- class Object
- def deep_copy
- Marshal.load(Marshal.dump(self))
- end
- end
- class Game_Battler < Game_BattlerBase
- alias item_apply_ljexpireskill item_apply
- def item_apply(user, item)
- @expired_users ||= {}
- @attacker_sub_queue ||= []
- @attacker_substitute = @attacker_sub_queue.shift
- item_apply_ljexpireskill(user, item)
- if @result.hit?
- @result.added_state_objects.reject{|x| x.expire_skill.empty?}.each do
- |state|
- sub = (@attacker_substitute || user).deep_copy
- sub.clear_actions
- @expired_users[state.id] = [sub, user]
- end
- end
- end
- alias item_test_ljexpireskill item_test
- def item_test(user, item)
- item_test_ljexpireskill(@attacker_substitute || user, item)
- end
- alias item_effect_apply_ljexpireskill item_effect_apply
- def item_effect_apply(user, item, effect)
- item_effect_apply_ljexpireskill(@attacker_substitute || user, item, effect)
- end
- alias make_damage_value_ljexpireskill make_damage_value
- def make_damage_value(user, item)
- make_damage_value_ljexpireskill(@attacker_substitute || user, item)
- end
- def execute_skill_now_ljexpsk(skill_id, target_index)
- action = Game_Action.new(self, true)
- action.set_skill(skill_id)
- action.target_index = target_index
- @actions.push(action)
- BattleManager.force_action(self)
- end
- alias remove_states_auto_ljexpireskill remove_states_auto
- def remove_states_auto(timing)
- @expired_users ||= {}
- states.reject{|x| x.expire_skill.empty?}.each do |state|
- if @state_turns[state.id] == 0 && state.auto_removal_timing == timing
- remove_state(state.id)
- sub = @expired_users[state.id][0]
- state.expire_skill.each do
- |skill_id|
- @attacker_sub_queue.push sub
- @expired_users[state.id][1].execute_skill_now_ljexpsk(skill_id, index)
- end
- @expired_users.delete(state)
- end
- end
- remove_states_auto_ljexpireskill(timing)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement