[VXA] Individual Strikes when Dual Wielding

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
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


Code: [Select]
#==============================================================================
#    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


  • modern algebra

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.
« Last Edit: February 03, 2013, 02:30:44 AM by modern algebra »

***
Rep:
Level 76
RMRK Junior
How would Yanfly's Weapon Attack Replace work with this? Would it use both attack skills as set on both weapons?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Well, I've never looked at that script before, but judging by its name, I assume it is essentially like my Weapon Damage Formula script? If so and if it is similarly designed, then yes. Why not try it out and get back to me if you discover it doesn't work?
« Last Edit: September 24, 2012, 08:17:03 PM by modern algebra »

***
Rep:
Level 76
RMRK Junior
All Yanfly's script seems to be doing is stopping yours from working correctly, though it's hard to tell using the default battle system. It just displays one attack, simply says "(name) attacks!"; but giving one weapon an attack that merely poisons without fail and an attack that merely blinds without fail(both with 1000% chance) has them both work.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
That sounds fine? What should happen is that it should say:

"(name) attacks"
"x damage dealt"

And then "x damage dealt" should be replaced with the damage of the second weapon.

I assume that both animations are shown?

***
Rep:
Level 76
RMRK Junior
Both animations seem to be shown, the second one appears mirrored which I believe is normal

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Yeah, then I think it's working as intended. Is there a problem with the way it executes?

***
Rep:
Level 76
RMRK Junior
Not as far as I can tell. I didn't test it too extensively, not every single possible combination, but I couldn't see anything wrong, just the "(name) attacks!" only appearing once.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Alright, then I think that's fine. It's only supposed to show "(name) attacks" once.

**
Rep: +0/-0Level 69
RMRK Junior
Will this script use the damage formulas of both weapons if they have custom formulas using this script: http://grimoirecastle.wordpress.com/2011/12/13/custom-weapon-formulas/ by Kread-Ex?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Hmm, my guess is yes. Why not try it out and see?
« Last Edit: September 28, 2012, 11:04:27 PM by modern algebra »

**
Rep: +0/-0Level 69
RMRK Junior
Just tried it out and it seems to be working, except it subtracts one from the damage of each weapon, and the off hand weapon seems to never miss.  I need to test the off hand weapon more, but in three battles of ten to twenty rounds it never missed, though the main weapon did about half the time.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Well, the lessened damage might be because this script unequips the non-attacking weapon for each attack, in order that the stats of the non-attacking weapon don't affect the damage of the attacking one.

As for the off-hand weapon not missing, err, don't know? Nothing in this script should affect hit rate.

**
Rep: +0/-0Level 69
RMRK Junior
Thanks, unequipping a weapon shouldn't have changed the damage because I used an set damage of 10 for main weapon, and 5 for off-hand weapon, no stats or anything else effecting it so I could see if I was getting expected values.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
And the damage formula for the skills you are using is purely just actor.atk? It doesn't subtract from the opponent's defence, it has no variance, etc.?

Anyway, are you asking me to do something? If so, then please clarify, and also create a new project with both scripts in it and recreate the error, then upload it to me so I can see what's going on.

**
Rep: +0/-0Level 73
RMRK Junior
can you make it where you can select the hand you attack with?

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Not with this script, no. You always attack with both.

It would be possible to add that option, but I don't intend to write that.

**
Rep: +0/-0Level 69
RMRK Junior
@modern algebra, no there is no request I just others trying use both scripts would like to know how they worked together, and to test them I just placed 10 in the main hand formula and 5 in the off hand weapon formula so I knew exactly what the damage was supposed to be, in actual game the formulas will be a bit more complex.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Alright, thank you for doing that. It is very helpful for those other users and I will add that information to the initial post.

*
Rep: +0/-0Level 41
RMRK Junior
There seems to be a bug in your script.
When using a healing item with dual wielding character, such as a potion, instead of healing it damages.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Thank you for reporting that bug! I've updated the script to v. 1.0.1 to fix it.