Advertisement
Vlue

Basic Combos

Jan 27th, 2014
4,630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.71 KB | None | 0 0
  1. #Basic Combos v1.2f.01
  2. #----------#
  3. #Features: Allows heroes to combine their attacks to use greater skills.
  4. #           Currently allows a chance for two heroes to cast a stronger
  5. #           skill for greater damage if both heroes cast the same spell
  6. #           on the same target, and the skill has a combo skill.
  7. #
  8. #Usage:    Set up notetags and let the skills fly
  9. #           Skill notetags:
  10. #             id1 is the skill to combo with, and id2 is the new skill to use
  11. #            <COMBO id1, id2>  
  12. #
  13. #----------#
  14. #-- Script by: V.M of D.T
  15. #
  16. #- Questions or comments can be:
  17. #    given by email: sumptuaryspade@live.ca
  18. #    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
  19. #   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
  20. #
  21. #- Free to use in any project with credit given, donations always welcome!
  22. module COMBO
  23.   #Default values below can be overridden by placing the note tags:
  24.  
  25.   #This one goes in the original skill:
  26.   #<COMBO_CHANCE #>  for a #% chance of combo occuring
  27.   #These ones are used in the combo skill:
  28.   #<COMBO_DAMAGE #>  for #% more damage
  29.   #<COMBO_FINISHER>  for combo abilities that are in addition to other attacks
  30.  
  31.   #Extra damage a combo ability does
  32.   EXTRA_DAMAGE = 1.5
  33.   #Chance for a combo attack to occur under right conditions out of 100
  34.   COMBO_CHANCE = 65
  35. end
  36.  
  37. class Scene_Battle < Scene_Base
  38.   def process_action
  39.     return if scene_changing?
  40.     if !@subject || !@subject.current_action
  41.       @subject = BattleManager.next_subject
  42.     end
  43.     return turn_end unless @subject
  44.     if @subject.current_action
  45.       item = @subject.current_action.item
  46.       @subject.pay_skill_cost(item) if item.is_a?(RPG::Skill)
  47.       check_for_combo
  48.       if @subject.current_action.combo
  49.         $game_troop.screen.start_tone_change(Tone.new(-25,-25,-25), 15)
  50.         15.times do
  51.           $game_troop.screen.update
  52.           @spriteset.update
  53.           Graphics.update
  54.         end
  55.       end
  56.       @subject.current_action.prepare
  57.       @status_window.open
  58.       execute_action
  59.       $game_troop.screen.start_tone_change(Tone.new(0,0,0), 15)
  60.         15.times do
  61.         $game_troop.screen.update
  62.         @spriteset.update
  63.         Graphics.update
  64.       end
  65.       @subject.remove_current_action
  66.     end
  67.     process_action_end unless @subject.current_action
  68.   end
  69.   def check_for_combo
  70.     @extra_damage = 0
  71.     next_battlers = BattleManager.active_battlers
  72.     combo_battler = nil
  73.     return unless @subject.current_action.item.is_a?(RPG::Skill)
  74.     return unless rand(100) < @subject.current_action.item.combo_chance
  75.     combo_skills = @subject.current_action.item.combo
  76.     next_battlers.each do |battler|
  77.       begin
  78.         next unless battler
  79.         next if battler.is_a?(Game_Enemy)
  80.         next unless battler.current_action.target_index == @subject.current_action.target_index
  81.         next unless combo_skills.include?(battler.current_action.item.id)
  82.         combo_battler = battler
  83.       rescue
  84.         next
  85.       end
  86.     end
  87.     return unless combo_battler
  88.     new_skill = combo_skills[combo_battler.current_action.item.id]
  89.     if $data_skills[new_skill].combo_finisher
  90.       combo = Game_Action.new(combo_battler)
  91.       combo.set_skill(new_skill)
  92.       combo.target_index = @subject.current_action.target_index
  93.       combo.combo = true
  94.       combo_battler.actions.push(combo)
  95.       targets = combo.make_targets.compact
  96.       combo.extra_damage = combo.item.damage.eval(combo_battler, targets[0], $game_variables)
  97.       combo_battler.casting_name = @subject.name + " and " + combo_battler.name
  98.     else
  99.       @subject.current_action.set_skill(new_skill)
  100.       @subject.current_action.combo = true
  101.       combo_battler.pay_skill_cost($data_skills[new_skill])
  102.       targets = @subject.current_action.make_targets.compact
  103.       @subject.current_action.extra_damage = combo_battler.current_action.item.damage.eval(combo_battler, targets[0], $game_variables)
  104.       combo_battler.remove_current_action
  105.       @subject.casting_name = @subject.name + " and " + combo_battler.name
  106.     end
  107.   end
  108. end
  109.  
  110. class RPG::Skill
  111.   def combo
  112.     cnote = self.note.clone
  113.     combo = {}
  114.     cnote =~ /<COMBO (\d+), (\d+)/
  115.     while $1
  116.       cnote =~ /<COMBO (\d+), (\d+)/
  117.       combo[$1.to_i] = $2.to_i if $1
  118.       cnote[cnote.index("<COMBO")] = "&" unless cnote.index("<COMBO").nil?
  119.     end
  120.     combo
  121.   end
  122.   def combo_chance
  123.     self.note =~ /<COMBO_CHANCE (\d+)>/
  124.     return $1.to_i if $1
  125.     return COMBO::COMBO_CHANCE
  126.   end
  127.   def combo_damage
  128.     self.note =~ /<COMBO_DAMAGE (\d+)>/
  129.     return $1.to_i / 100 if $1
  130.     return COMBO::EXTRA_DAMAGE
  131.   end
  132.   def combo_finisher
  133.     self.note =~ /<COMBO_FINISHER>/
  134.     return true if $~
  135.     return false
  136.   end
  137. end
  138.  
  139. module BattleManager
  140.   def self.active_battlers
  141.     @action_battlers
  142.   end
  143. end
  144.  
  145. class Game_Battler
  146.   attr_accessor   :casting_name
  147.   def use_item(item)
  148.     return unless item
  149.     consume_item(item)   if item.is_a?(RPG::Item)
  150.     item.effects.each {|effect| item_global_effect_apply(effect) }
  151.   end
  152.   def make_damage_value(user, item)
  153.     value = item.damage.eval(user, self, $game_variables)
  154.     if SceneManager.scene.is_a?(Scene_Battle) and user.current_action.combo
  155.       value += user.current_action.extra_damage
  156.       value *= item.combo_damage if item.is_a?(RPG::Skill)
  157.     end
  158.     value *= item_element_rate(user, item)
  159.     value *= pdr if item.physical?
  160.     value *= mdr if item.magical?
  161.     value *= rec if item.damage.recover?
  162.     value = apply_critical(value) if @result.critical
  163.     value = apply_variance(value, item.damage.variance)
  164.     value = apply_guard(value)
  165.     @result.make_damage(value.to_i, item)
  166.   end
  167. end
  168.  
  169. class Game_Actor
  170.   alias combo_init initialize
  171.   def initialize(*args)
  172.     combo_init(*args)
  173.     @casting_name = actor.name
  174.   end
  175. end
  176.  
  177. class Game_Enemy
  178.   alias combo_init initialize
  179.   def initialize(*args)
  180.     combo_init(*args)
  181.     @casting_name = enemy.name
  182.   end
  183. end
  184.    
  185. class Window_BattleLog
  186.   def display_use_item(subject, item)
  187.     if item.is_a?(RPG::Skill)
  188.       if subject.current_action.combo
  189.         add_text(subject.casting_name + item.message1)
  190.         subject.casting_name = subject.name
  191.       else
  192.         add_text(subject.name + item.message1)
  193.       end
  194.       unless item.message2.empty?
  195.         wait
  196.         add_text(item.message2)
  197.       end
  198.     elsif item.is_a?(RPG::Item)
  199.       add_text(sprintf(Vocab::UseItem, subject.name, item.name))
  200.     end
  201.   end
  202. end
  203.  
  204. class Game_Action
  205.   attr_accessor :combo
  206.   attr_accessor :extra_damage
  207.   alias combo_initialize initialize
  208.   def initialize(*args)
  209.     combo_initialize(*args)
  210.     @combo = false
  211.     @extra_damage = 0
  212.   end
  213. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement