Individual Strikes when Dual Wielding
Version: 1.0.1
Author: modern algebra
Date: 2 February 2013
Version History
- <Version 1.0.1> 2013.02.02 - Fixed a bug where use of item 1 by dual wielding characters would be replaced with an attack.
- <Version 1.0.0> 2012.09.22 - Original Release
Description
This script changes the dual wielding option so that, instead of the actor attacking only once with increased damage, the actor attacks twice, once with each weapon. Additionally, this script allows you to modify the damage formula when dual wielding, thus allowing you to, for instance, make the actor's proficiency with dual wielding dependent on the actor's dexterity or some other stat.
Features
- Individual Strikes when dual wielding
- An easy way to modify the damage formula when dual wielding for balance purposes
- Compatible with Weapon Damage Formulas
Instructions
Paste the script into its own slot in the Script Editor, above Main but below Materials.
If you wish, you can assign a modifying formula at line 38. What that will do is allow you to change the damage formula for a weapon when you are dual wielding, and it serves as a way to assign a penalty to dual wielding for balance purposes.
Script
#==============================================================================
# Individual Strikes when Dual Wielding
# Version: 1.0.1
# Author: modern algebra (rmrk.net)
# Date: 2 February 2013
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script changes the dual wielding option so that, instead of the actor
# attacking only once with increased damage, the actor attacks twice, once
# with each weapon. Additionally, this script allows you to modify the
# damage formula when dual wielding, thus allowing you to, for instance, make
# the actor's proficiency with dual wielding dependent on the actor's
# dexterity or some other stat.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials.
#
# If you wish, you can assign a modifying formula at line 38. What that will
# do is allow you to change the damage formula for a weapon when you are dual
# wielding, and it serves as a way to assign a penalty to dual wielding for
# balance purposes.
#==============================================================================
$imported ||= {}
$imported[:MA_DWIndividualStrikes] = true
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# BEGIN Editable Region
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# By modifying this constant, you are able to modify the damage formula when
# dual wielding. It must be a string, and the original damage formula will
# replace the %s. In other words, if the original damage formula is something
# like "a.atk * 4 - b.def * 2", and you assign the constant to the following:
# MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)*0.75"
# then the formula when dual wielding would be: "(a.atk * 4 - b.def * 2)*0.75"
MAISDW_DUAL_DAMAGE_MODIFIER = "(%s)"
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END Editable Region
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - apply_item_effects
#==============================================================================
class Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Apply Skill/Item Effect
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maisdw_aplyitm_2uv7 apply_item_effects
def apply_item_effects(target, item, *args)
# If Actor attacking with more than one weapon
if @subject.actor? && !item.is_a?(RPG::Item) &&
item.id == @subject.attack_skill_id && @subject.weapons.size > 1
@subject.weapons.each { |weapon|
maisdw_dual_wield_attack(target, item, weapon, *args) }
else
maisdw_aplyitm_2uv7(target, item, *args) # Call original method
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dual Wield Attack
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maisdw_dual_wield_attack(target, item, weapon, *args)
# Select from equips to record position, accounting for extra equip
# scripts that might change order.
equips_to_replace = [] # Record which equips are removed
selected = false
for i in 0...@subject.equips.size
equip = @subject.equips[i]
if equip.is_a?(RPG::Weapon)
# Actual identity in case using an instantiated item system
if weapon.equal?(equip) && !selected
selected = true # Only keep it once if two of the same item
next
end
equips_to_replace << [i, equip] # Preserve weapon
@subject.change_equip(i, nil) # Remove weapon
end
end
# Get the attack skill
attack_skill = $data_skills[@subject.attack_skill_id]
attack_skill = item if attack_skill.nil?
real_formula = attack_skill.damage.formula.dup # Preserve Formula
# Modify damage formula
unless MAISDW_DUAL_DAMAGE_MODIFIER.empty?
attack_skill.damage.formula = sprintf(MAISDW_DUAL_DAMAGE_MODIFIER, real_formula)
end
# Call original apply_item_effects method
maisdw_aplyitm_2uv7(target, attack_skill, *args)
attack_skill.damage.formula = real_formula # Restore damage formula
# Replace removed equips
equips_to_replace.each { |i, weapon| @subject.change_equip(i, weapon) }
end
end
If you're using Internet Explorer, then code boxes do not play nice. You might need to retrieve the script from
Pastebin instead.
Credit
Thanks
- Lytanathan, as I borrowed some ideas on implementation from his Dual Wield Separate Attacks
- SiliconDragon, for testing the script with Kread-Ex's Weapon Damage Formulas
- Ven01273, for a bug report
Support
Please post in this topic at RMRK for support.
Known Compatibility Issues
I am not currently aware of any compatibility issues.
SiliconDragon
reports that it appears to work well with Kread-EX's
Custom Weapon Formulas, but that the expected damage is mildly reduced.
Author's Notes
I wrote this script basically to complement my
Weapon Damage Formulas script since the default dual wielding scheme did not accomodate for a situation where the two weapons have different formulas.
Terms of Use
I adopt RMRK's default
Terms of Use.