Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
- # * Random Skill Invoke Compatibility
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Author: Eshra
- # Compatibility: RPG Maker VX Ace
- # Dependencies: raTBS-Alpha
- #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
- # Usage:
- #
- # Paste this below the other TBS Classes and Modules. This snippet allows some
- # compatibility with the script found here:
- # http://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/random-skill-invoke/
- #
- # Updates:
- # 14 April 2013 - Init Release
- #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
- module Era
- module AI
- def self.invoke_on_target(target_ev, user_ev, tb_item, prev = false)
- # add conditionals to support friendly hits on or off
- return false if target_ev.nil? || target_ev.tb_unit.nil? # or if the target is not an tb_unit.
- return false if (target = target_ev.tb_unit.battler).nil?
- user = user_ev.tb_unit.battler
- # Try to use the skill on the target...
- if tb_item.is_a?(RPG::Skill)
- user.tb_set_action(Game_Action.new(user).set_skill(tb_item.id))
- elsif tb_item.is_a?(RPG::Item)
- user.tb_set_action(Game_Action.new(user).set_item(tb_item.id))
- end
- user.invoke_random_skill
- tb_item = item = user.current_action.item
- if user.actions[0].valid?
- item = user.current_action.item
- if prev
- target = Marshal.load(Marshal.dump(target))
- user = Marshal.load(Marshal.dump(user))
- else
- temp = target_ev.animation_id = item.animation_id
- target_ev.animation_id = 1 if temp < 0 # default basic attack
- end
- result = target.item_apply(user, item) # @subject.invoke_random_skill
- return sar_brief(result, user_ev, target, target_ev, tb_item, prev)
- else; return false
- end
- end # invoke_on_target
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment