Dual Wield: Show Off-Hand Weapon when attacking

Discussion in 'Javascript/Plugin Support' started by alcreator440, Jun 21, 2019.

  1. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Is it possible to temporarily just show the swing/missile/thrust weapon animations of the actor's Off-Hand weapon instead of their Main-Hand weapon when dual wielding? I'm using Yanfly's Weapon Animations if this helps at all.

    Edit: I think the line below is what I need to use by I'm not sure how to implement it:
    user.attackAnimationId1()

    Maybe: user.attackAnimationId1() = 0? Any help would be appreciated.
     
    Last edited: Jun 21, 2019
    #1
  2. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    bump
     
    #2
  3. AsuranFish

    AsuranFish Veteran Veteran

    Messages:
    112
    Likes Received:
    80
    First Language:
    English
  4. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks for the reply but all I need is potentially one line of code. His plugin would be overkill for what I'm trying to do.
     
    #4
  5. AsuranFish

    AsuranFish Veteran Veteran

    Messages:
    112
    Likes Received:
    80
    First Language:
    English
  6. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm, close but that's not quite it. I need a line of code that will allow me to only show the user's second equipped weapon when they attack. I'm sure it's simple and I'm certain it can be done but I just need to find out what it is. I've even look at lines in dual wielding scripts(and attempted to modify them) to get the specific line of code I need but no luck yet.
     
    #6
  7. caethyril

    caethyril ^_^ Veteran

    Messages:
    946
    Likes Received:
    586
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    It's probably possible but would likely look very ugly in the action sequence without a plugin to abbreviate it to a single function call. For reference, here's performAttack from the base code, which handles the user motion and weapon sprite display:
    Code:
    Game_Actor.prototype.performAttack = function() {
        var weapons = this.weapons();
        var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
        var attackMotion = $dataSystem.attackMotions[wtypeId];
        if (attackMotion) {
            if (attackMotion.type === 0) {
                this.requestMotion('thrust');
            } else if (attackMotion.type === 1) {
                this.requestMotion('swing');
            } else if (attackMotion.type === 2) {
                this.requestMotion('missile');
            }
            this.startWeaponAnimation(attackMotion.weaponImageId);
        }
    };
    I think you'd basically just need to invoke this code, except reference weapons[1] (second weapon) instead.
     
    #7
    alcreator440 likes this.
  8. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks a lot! I'm going to fool around with this and see if I can come up with something but any more help into breaking it down to a function call would be appreciated. I almost have a unique dual wielding setup for my game. I'm so close!

    Also where exactly did you find that line of code? Perhaps I can modify the code so that when a particular state is applied to the user(which would be applied when the actor is getting ready to use their second weapon) it will use "weapons[1] (second weapon)" instead.
     
    #8
  9. caethyril

    caethyril ^_^ Veteran

    Messages:
    946
    Likes Received:
    586
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    I found the code in rpg_objects.js. That said, editing the base code files is generally inadvisable. Better to write edits as plugins instead...that way it's easier to keep track of edits, you can turn them on/off at will, updates are less likely to mess things up, etc. :kaophew:

    With that in mind, you could try saving this as a .js file (Save As > File Type: All Files, Filename: whatever.js) and import it like a plugin:
    Code:
    Game_Actor.prototype.performAttackOffhand = function() {
        var weapons = this.weapons();
        var wtypeId = weapons[1] ? weapons[1].wtypeId : 0;
        var attackMotion = $dataSystem.attackMotions[wtypeId];
        if (attackMotion) {
            if (attackMotion.type === 0) {
                this.requestMotion('thrust');
            } else if (attackMotion.type === 1) {
                this.requestMotion('swing');
            } else if (attackMotion.type === 2) {
                this.requestMotion('missile');
            }
            this.startWeaponAnimation(attackMotion.weaponImageId);
        }
    };
    Then in an action sequence, try something like this:
    Code:
    eval: user.performAttackOffhand();
    Note: I haven't tried any of this myself, hopefully I haven't missed anything important. :kaoswt:

    Basically, the plugin thing should add a new method called performAttackOffhand, identical to performAttack except it checks the second equipped weapon rather than the first. (I think performAttack is called as part of Yanfly's perform action action.) Then the eval action (Action Sequence Pack 1) can be used to call that new method. :kaopride:
     
    #9
  10. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm, I tried it but this line: user.performAttackOffhand();, only makes them swing with the first equipped weapon. I even moved the plugin around and disabled another dual wield plugin but no luck.
     
    #10
  11. caethyril

    caethyril ^_^ Veteran

    Messages:
    946
    Likes Received:
    586
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    OK I just tested and it works fine for me; plugins Battle Engine Core, Action Sequence Pack 1, and this little performAttackOffhand thing, loaded in that order. Here's my "Offhand Attack" skill action sequence, for reference:
    Code:
    <target action>
    wait for movement
    eval: user.performAttackOffhand();
    motion wait: user
    action effect: target
    action animation: target
    wait: 10
    </target action>
    Check you're using different weapons in each hand and remember that battle test does not necessarily use the actors' starting equipment. Save before testing, too, otherwise any plugin changes since you last saved will be ignored. Press F8 during test to show the console, if there are any errors, the messages will display in red text in the console window. :)
     
    #11
  12. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    Sorry for the super late reply(I haven't had a chance to test things out until now) but it still doesn't work for me. I think it may be due to Yanfly's Weapon Animation plugin that I have installed. There really isn't any way of getting around this plugin because it's crucial for my game. Maybe there's a way the plugin can be modified to fit my needs.
     
    #12
  13. caethyril

    caethyril ^_^ Veteran

    Messages:
    946
    Likes Received:
    586
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh I see, the <Weapon Image: x> notetag seems to affect all equipped weapons simultaneously...I should've checked that earlier. I think the necessary edit/rewrite to enable the behaviour you want is a bit beyond me at present, sorry. :kaoslp:

    It seems there's an older, deprecated version of Ramza's plugin called True Dual Wield, which states compatibility with YEP_WeaponAnimation (I haven't tested). If that doesn't cut it, I'm assuming the supported, paid version (indirectly linked near the start of this thread) will also be compatible with the WeaponAnimation plugin. :)
     
    #13
  14. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV
    I've actually already looked at his dual wield script. I does successfully change the images but it's wonky since in my game each individual weapon has it's own specific skill. The way I'm approaching dual wield is by forcing the user to use a specific action at the end of an action sequence by using a line such as this:

    if (user.isStateAffected(1830))
    Eval: BattleManager.queueForceAction(user, 2730, target);
    end

    You see at the beginning of skill 2730 I would run the necessary code to disable the weapon image for whatever weapon skill that preceded it. The process I'm using works perfectly, I just need to find the proper code to disable the weapon image for the first weapon from appearing. Here is a small preview below showcasing two individual skills being combined to create the illusion of dual wielding a sword and an ax(the sword is the first equip):
    [​IMG]

    However in Ramza's plugin at line 258
    I've noticed this code below:
    Code:
    //swap values of mainhand and offhand
    $dataWeapons[$gameActors._data[subject.actorId()]._equips[0]._itemId].weaponImageIndex = $dataWeapons[$gameActors._data[subject.actorId()]._equips[1]._itemId].weaponImageIndex
    $dataWeapons[$gameActors._data[subject.actorId()]._equips[0]._itemId].weaponAttackMotion = $dataWeapons[$gameActors._data[subject.actorId()]._equips[1]._itemId].weaponAttackMotion
    I think this is what he uses to to get the images to swap but I haven't figured out how to do that in my game. I know yanfly limits you to one line of code for his "Eval:" command but perhaps I can run a common event instead to get more code processed.
     
    #14
  15. alcreator440

    alcreator440 Veteran Veteran

    Messages:
    148
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMMV

Share This Page