blucalm

the ratbs alpha + YF Random Skill Invoke Compatibility

Apr 14th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.06 KB | None | 0 0
  1. #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
  2. # * Random Skill Invoke Compatibility
  3. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  4. # Author: Eshra
  5. # Compatibility: RPG Maker VX Ace
  6. # Dependencies: raTBS-Alpha
  7. #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
  8. # Usage:
  9. #
  10. # Paste this below the other TBS Classes and Modules. This snippet allows some
  11. # compatibility with the script found here:
  12. # http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/random-skill-invoke/
  13. #
  14. # Updates:
  15. # 14 April 2013 - Init Release
  16. #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
  17.  
  18. module Era
  19.   module AI
  20.     def self.invoke_on_target(target_ev, user_ev, tb_item, prev = false)
  21.      
  22.       # add conditionals to support friendly hits on or off
  23.       return false if target_ev.nil? || target_ev.tb_unit.nil? # or if the target is not an tb_unit.
  24.       return false if (target = target_ev.tb_unit.battler).nil?
  25.        
  26.       user = user_ev.tb_unit.battler
  27.        
  28.       # Try to use the skill on the target...
  29.      
  30.       if tb_item.is_a?(RPG::Skill)
  31.         user.tb_set_action(Game_Action.new(user).set_skill(tb_item.id))
  32.       elsif tb_item.is_a?(RPG::Item)
  33.         user.tb_set_action(Game_Action.new(user).set_item(tb_item.id))
  34.       end
  35.      
  36.       user.invoke_random_skill
  37.       tb_item = item = user.current_action.item
  38.      
  39.       if user.actions[0].valid?
  40.          
  41.         item = user.current_action.item
  42.         if prev
  43.           target = Marshal.load(Marshal.dump(target))
  44.           user = Marshal.load(Marshal.dump(user))
  45.         else
  46.           temp = target_ev.animation_id = item.animation_id
  47.           target_ev.animation_id = 1 if temp < 0 # default basic attack
  48.         end
  49.        
  50.         result = target.item_apply(user, item) # @subject.invoke_random_skill
  51.        
  52.         return sar_brief(result, user_ev, target, target_ev, tb_item, prev)
  53.       else; return false
  54.       end
  55.     end # invoke_on_target
  56.   end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment