modern_algebra

[VXA] Individual Strikes When Dual Wielding

Feb 2nd, 2013
276
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #    Individual Strikes when Dual Wielding
  3. #    Version: 1.0.1
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: 2 February 2013
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #    
  9. #    This script changes the dual wielding option so that, instead of the actor
  10. #   attacking only once with increased damage, the actor attacks twice, once
  11. #   with each weapon. Additionally, this script allows you to modify the
  12. #   damage formula when dual wielding, thus allowing you to, for instance, make
  13. #   the actor's proficiency with dual wielding dependent on the actor's
  14. #   dexterity or some other stat.
  15. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16. #  Instructions:
  17. #    
  18. #    Paste this script into its own slot in the Script Editor, above Main but
  19. #   below Materials.
  20. #
  21. #    If you wish, you can assign a modifying formula at line 38. What that will
  22. #   do is allow you to change the damage formula for a weapon when you are dual
  23. #   wielding, and it serves as a way to assign a penalty to dual wielding for
  24. #   balance purposes.
  25. #==============================================================================
  26.  
  27. $imported ||= {}
  28. $imported[:MA_DWIndividualStrikes] = true
  29.  
  30. #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  31. #  BEGIN Editable Region
  32. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  33. #  By modifying this constant, you are able to modify the damage formula when
  34. # dual wielding. It must be a string, and the original damage formula will
  35. # replace the %s. In other words, if the original damage formula is something
  36. # like "a.atk * 4 - b.def * 2", and you assign the constant to the following:
  37. #    MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)*0.75"
  38. # then the formula when dual wielding would be: "(a.atk * 4 - b.def * 2)*0.75"
  39. MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)"
  40. #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  41. #  END Editable Region
  42. #//////////////////////////////////////////////////////////////////////////////
  43.  
  44. #==============================================================================
  45. # ** Scene_Battle
  46. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47. #  Summary of Changes:
  48. #    aliased method - apply_item_effects
  49. #==============================================================================
  50.  
  51. class Scene_Battle
  52.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53.   # * Apply Skill/Item Effect
  54.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55.   alias maisdw_aplyitm_2uv7 apply_item_effects
  56.   def apply_item_effects(target, item, *args)
  57.     # If Actor attacking with more than one weapon
  58.     if @subject.actor? && !item.is_a?(RPG::Item) &&
  59.       item.id == @subject.attack_skill_id && @subject.weapons.size > 1
  60.       @subject.weapons.each { |weapon|
  61.         maisdw_dual_wield_attack(target, item, weapon, *args) }
  62.     else
  63.       maisdw_aplyitm_2uv7(target, item, *args) # Call original method
  64.     end
  65.   end
  66.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67.   # * Dual Wield Attack
  68.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69.   def maisdw_dual_wield_attack(target, item, weapon, *args)
  70.     #  Select from equips to record position, accounting for extra equip
  71.     # scripts that might change order.
  72.     equips_to_replace = [] # Record which equips are removed
  73.     selected = false
  74.     for i in 0...@subject.equips.size
  75.       equip = @subject.equips[i]
  76.       if equip.is_a?(RPG::Weapon)
  77.         # Actual identity in case using an instantiated item system
  78.         if weapon.equal?(equip) && !selected
  79.           selected = true # Only keep it once if two of the same item
  80.           next
  81.         end
  82.         equips_to_replace << [i, equip] # Preserve weapon
  83.         @subject.change_equip(i, nil)   # Remove weapon
  84.       end
  85.     end
  86.     # Get the attack skill
  87.     attack_skill = $data_skills[@subject.attack_skill_id]
  88.     attack_skill = item if attack_skill.nil?
  89.     real_formula = attack_skill.damage.formula.dup # Preserve Formula
  90.     # Modify damage formula
  91.     unless MAISDW_DUAL_DAMAGE_MODIFIER.empty?
  92.       attack_skill.damage.formula = sprintf(MAISDW_DUAL_DAMAGE_MODIFIER, real_formula)
  93.     end
  94.     # Call original apply_item_effects method
  95.     maisdw_aplyitm_2uv7(target, attack_skill, *args)
  96.     attack_skill.damage.formula = real_formula # Restore damage formula
  97.     # Replace removed equips
  98.     equips_to_replace.each { |i, weapon| @subject.change_equip(i, weapon) }
  99.   end
  100. end
RAW Paste Data