Advertisement
KhegayIV

[RGSS3] L'James Expire Skill

Oct 6th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.45 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. #
  4. #                           L'James Expire Skill
  5. #
  6. #
  7. # Requires L'James Notetag System
  8. #==============================================================================
  9. #                                Description
  10. #==============================================================================
  11. #
  12. # This script allows to execute skill when state expires.
  13. #
  14. #==============================================================================
  15. #                                Instruction
  16. #==============================================================================
  17. #
  18. # Insert script between L'JNT and Main.
  19. # Use notetag in state
  20. #
  21. # <expire skill x1,x2,x3> - after state expires, skills x1, x2 and x3 will be
  22. # called in that order. For damage calculation skill uses character parameters
  23. # in a moment when state was added.
  24. #
  25. #==============================================================================
  26. #                                Terms of use
  27. #==============================================================================
  28. # Free to use in commercial and non-commercial projects as long as you give
  29. # credit to L'James
  30. #==============================================================================
  31. module LJ::EXPIRESKILL
  32.   LJ::NOTETAGS.extension do
  33.     declare_state do
  34.       register :expire_skill, array(:int).set_unique(false)
  35.     end
  36.   end
  37. end
  38.  
  39. class Object
  40.   def deep_copy
  41.     Marshal.load(Marshal.dump(self))
  42.   end
  43. end
  44.  
  45. class Game_Battler < Game_BattlerBase
  46.    
  47.   alias item_apply_ljexpireskill item_apply
  48.   def item_apply(user, item)
  49.     @expired_users ||= {}
  50.     @attacker_sub_queue ||= []
  51.     @attacker_substitute = @attacker_sub_queue.shift
  52.     item_apply_ljexpireskill(user, item)
  53.     if @result.hit?
  54.       @result.added_state_objects.reject{|x| x.expire_skill.empty?}.each do
  55.         |state|
  56.         sub = (@attacker_substitute || user).deep_copy
  57.         sub.clear_actions
  58.         @expired_users[state.id] = [sub, user]
  59.       end
  60.     end
  61.   end
  62.  
  63.   alias item_test_ljexpireskill item_test
  64.   def item_test(user, item)
  65.     item_test_ljexpireskill(@attacker_substitute || user, item)
  66.   end
  67.  
  68.   alias item_effect_apply_ljexpireskill item_effect_apply
  69.   def item_effect_apply(user, item, effect)
  70.     item_effect_apply_ljexpireskill(@attacker_substitute || user, item, effect)
  71.   end
  72.  
  73.   alias make_damage_value_ljexpireskill make_damage_value
  74.   def make_damage_value(user, item)
  75.     make_damage_value_ljexpireskill(@attacker_substitute || user, item)
  76.   end
  77.  
  78.   def execute_skill_now_ljexpsk(skill_id, target_index)
  79.     action = Game_Action.new(self, true)    
  80.     action.set_skill(skill_id)
  81.     action.target_index = target_index
  82.     @actions.push(action)
  83.     BattleManager.force_action(self)
  84.   end
  85.  
  86.   alias remove_states_auto_ljexpireskill remove_states_auto
  87.   def remove_states_auto(timing)
  88.     @expired_users ||= {}
  89.     states.reject{|x| x.expire_skill.empty?}.each do |state|
  90.       if @state_turns[state.id] == 0 && state.auto_removal_timing == timing
  91.         remove_state(state.id)
  92.         sub = @expired_users[state.id][0]
  93.         state.expire_skill.each do
  94.           |skill_id|
  95.           @attacker_sub_queue.push sub
  96.           @expired_users[state.id][1].execute_skill_now_ljexpsk(skill_id, index)
  97.         end
  98.         @expired_users.delete(state)
  99.       end
  100.     end
  101.     remove_states_auto_ljexpireskill(timing)
  102.   end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement