Advertisement
Fomar0153

Fomar0153 - Counter Attack Skills 1.0

May 16th, 2012
1,475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.93 KB | None | 0 0
  1. =begin
  2. Counter Attack Skills
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Allows you to counter attack using skills.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. Notetag the actor, class, enemy or state:
  13. <counterskill x>
  14. where x is the skill id
  15. ----------------------
  16. Known bugs
  17. ----------------------
  18. None
  19. =end
  20. module Vocab
  21.   CounterAttack   = "%s counter attacked with %s!"
  22. end
  23.  
  24. class Window_BattleLog < Window_Selectable
  25.   def display_counter(target, item)
  26.     Sound.play_evasion
  27.     add_text(sprintf(Vocab::CounterAttack, target.name, $data_skills[target.counterskill].name))
  28.     wait
  29.   end
  30. end
  31.  
  32. class RPG::BaseItem
  33.   def counterskill
  34.     if @counterskill.nil?
  35.       if @note =~ /<counterskill (.*)>/i
  36.         @counterskill = $1.to_i
  37.       else
  38.         @counterskill = 1
  39.       end
  40.     end
  41.     @counterskill
  42.   end
  43. end
  44.  
  45. class Game_Actor < Game_Battler
  46.  
  47.   def counterskill
  48.     for state in states
  49.       return state.counterskill if state.counterskill > 1
  50.     end
  51.     return actor.counterskill
  52.   end
  53.  
  54. end
  55.  
  56. class Game_Enemy < Game_Battler
  57.  
  58.   def counterskill
  59.     for state in states
  60.       return state.counterskill if state.counterskill > 1
  61.     end
  62.     return enemy.counterskill
  63.   end
  64. end
  65.  
  66. class Scene_Battle
  67.   def invoke_counter_attack(target, item)
  68.     @log_window.display_counter(target, item)
  69.     attack_skill = $data_skills[target.counterskill]
  70.     if attack_skill.for_opponent?
  71.       if attack_skill.for_all?
  72.         show_animation(target.opponents_unit.alive_members, attack_skill.animation_id)
  73.         for t in target.opponents_unit.alive_members
  74.           t.item_apply(target, attack_skill)
  75.           refresh_status
  76.           @log_window.display_action_results(t, attack_skill)
  77.         end
  78.       else
  79.         show_animation([@subject], attack_skill.animation_id)
  80.         @subject.item_apply(target, attack_skill)
  81.         refresh_status
  82.         @log_window.display_action_results(@subject, attack_skill)
  83.       end
  84.     else
  85.       if attack_skill.for_all?
  86.         if attack_skill.for_dead_friend?
  87.           show_animation(target.friends_unit.dead_members, attack_skill.animation_id)
  88.           for t in target.friends_unit.dead_members
  89.             t.item_apply(target, attack_skill)
  90.             refresh_status
  91.             @log_window.display_action_results(t, attack_skill)
  92.           end
  93.         else
  94.           show_animation(target.friends_unit.alive_members, attack_skill.animation_id)
  95.           for t in target.friends_unit.alive_members
  96.             t.item_apply(target, attack_skill)
  97.             refresh_status
  98.             @log_window.display_action_results(t, attack_skill)
  99.           end
  100.         end
  101.       else
  102.         show_animation([target], attack_skill.animation_id)
  103.         target.item_apply(target, attack_skill)
  104.         refresh_status
  105.         @log_window.display_action_results(target, attack_skill)
  106.       end
  107.     end
  108.   end
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement