MZ Variable Weaponry-Check Plugin OR Skill.

Hi everyone i'm working on dual wielding and reloading and so far it's only one step away from completion, i've been searching EVERYWHERE for a way to make a conditional branch check if an actor is equip with two of the same weapon ID.

Now concerning script calls I can only find one source which checks if atleast 1 is in an actors hand:

$gameActors.actor(1).hasWeapon($dataWeapons[15])

I cannot find a code anywhere that addresses if x2 Weapon 15 are being held by the actor which is unfortunate, even within the script call flow chart there seems to be no code to address anything remotely close to dual wielding in this regard.

Alternatively I figured I could somehow have a weapon add a single value to a variable- double that with another being held resulting in 2 in total and run through a conditional branch check to apply the effects I want, the problem with that is I need some way to have weapons operate such a way.


So to put it into perspective, both in theory would work but I do not have the means to do it and I need help.
I have a similar plugin in use that drives class change based on what weapons are being dual wielded.


Welcome to dig into it and see if any of it helps you out. I'm using Maliki's Dual Wield MZ as a dependency, but that shouldn't be a need for you.
$gameActors.actor(1)._equips would bring you the list of equipment that actor 1 is currently wearing.
If you didn't change the order of equips in your game, the first one (so 0, since arrays in javascript start from 0) should be the main hand.

then this:
JavaScript:
$gameActors.actor(1)._equips[0]
brings you information about what weapon is equipped in the actor's first equipment slot, such as the data class and the item id.
Similarly, if your off-hand is equipment slot 2, $gameActors.actor(1)._equips[1] should suffice.
To get the item id of an equipment, you can call it's '_itemId' variable.

So assuming your main hand and off hand slots are 1st and 2nd character equipment slots:
JavaScript:
if($gameActors.actor(1)._equips[0]._itemId ===15){
    console.log("actor 1 is wearing item 15 in the main hand.")
//this would be similar to $gameActors.actor(1).hasWeapon($dataWeapons[15])
}
if($gameActors.actor(1)._equips[1]._itemId ===15){
    console.log("actor 1 is wearing item 15 in the off hand.")
}
if($gameActors.actor(1)._equips[0]._itemId ===15 && $gameActors.actor(1)._equips[1]._itemId ===15){
    console.log("actor 1 is dual wielding item 15.")
}

or in a generic dual wield test sense:
JavaScript:
if($gameActors.actor(1)._equips[0]._itemId === $gameActors.actor(1)._equips[1]._itemId){
    console.log("actor 1 is dual wielding some item.")
}
Or alternatively:

JavaScript:
if ($gameActors.actor(1).weapons().length === 2 && $gameActors.actor(1).weapons()[0].id === $gameActors.actor(1).weapons()[1].id)

@Cyon The potential wrinkle in your code is that it will still return true if the actor isn't dual-wielding but has weapon 15 in slot 0 and armour 15 in slot 1.
Thank you all for rushing to help me, I was just finishing up multiple tests and ran into a few bumps.

I have a similar plugin in use that drives class change based on what weapons are being dual wielded.


Welcome to dig into it and see if any of it helps you out. I'm using Maliki's Dual Wield MZ as a dependency, but that shouldn't be a need for you.
I am actually using that very plugin to control the way my weapons operate with dual wielding and skill unlocks, it's a very good plugin!

$gameActors.actor(1)._equips would bring you the list of equipment that actor 1 is currently wearing.
If you didn't change the order of equips in your game, the first one (so 0, since arrays in javascript start from 0) should be the main hand.

then this:
JavaScript:
$gameActors.actor(1)._equips[0]
brings you information about what weapon is equipped in the actor's first equipment slot, such as the data class and the item id.
Similarly, if your off-hand is equipment slot 2, $gameActors.actor(1)._equips[1] should suffice.
To get the item id of an equipment, you can call it's '_itemId' variable.

So assuming your main hand and off hand slots are 1st and 2nd character equipment slots:
JavaScript:
if($gameActors.actor(1)._equips[0]._itemId ===15){
    console.log("actor 1 is wearing item 15 in the main hand.")
//this would be similar to $gameActors.actor(1).hasWeapon($dataWeapons[15])
}
if($gameActors.actor(1)._equips[1]._itemId ===15){
    console.log("actor 1 is wearing item 15 in the off hand.")
}
if($gameActors.actor(1)._equips[0]._itemId ===15 && $gameActors.actor(1)._equips[1]._itemId ===15){
    console.log("actor 1 is dual wielding item 15.")
}

or in a generic dual wield test sense:
JavaScript:
if($gameActors.actor(1)._equips[0]._itemId === $gameActors.actor(1)._equips[1]._itemId){
    console.log("actor 1 is dual wielding some item.")
}
These worked fairly well and gave me a few options to consider, however like Trihan pointed out- there was that one small detail that could be overlooked, that small change of script certainly changes things and I appreciate you all for taking the time to help me!
Just wanted to further ask because I stumbled upon a problem. Basically I ran the conditional branch to check if it's referring to only actor 0001.


JavaScript:
$gameActors.actor(1).weapons().length === 2 && $gameActors.actor(1).weapons()[0].id === $gameActors.actor(1).weapons()[1].id

Instead if I found out through testing party member 0005 is still capable of running this check and not the else branch which gives a different result. Through testing it seems that it's registering if actor 0001 is using the dual pair it will give the same outcome to anyone else who uses the same skill despite not being the same actor.

If anyone can further help me by making it specifically for that actor only- not to just be present with that equiptment in battle?

What did I overlook here?
  • $gameActors.actor(1) gets the data for Actor ID 1.
  • $gameParty.members()[0] gets the data for the party leader, i.e. position 0 in the party.
  • In the damage formula, a is the user and b is the current target.
Which actor do you want to reference, and in what context? E.g. if it's a tag from a plugin, then which tag & plugin?
There is no plugin in use besides visustella battle core which is using <Custom action sequence> to activate the common event
that refers to the reload/skill animation.

I am however trying to only refer to an actor partaking in the skill who must fufill the need to have two of the same weapons in main and off hand equip slots.
There is no plugin in use besides visustella battle core which is using <Custom action sequence> to activate the common event
that refers to the reload/skill animation.

I am however trying to only refer to an actor partaking in the skill who must fufill the need to have two of the same weapons in main and off hand equip slots.
I haven't tested it, but I believe this will work:
JavaScript:
BattleManager._subject.weapons().length === 2 && BattleManager._subject.weapons()[0].id === BattleManager._subject.weapons()[1].id

This is assuming that the actor using the skill is the actor that you're checking.
JavaScript:
BattleManager._subject.weapons().length === 2 && BattleManager._subject.weapons()[0].id === BattleManager._subject.weapons()[1].id
This is assuming that the actor using the skill is the actor that you're checking.

It would appear this is working, I ran the same tests that I used to discover the previous fault so from my understanding it is addressing the actor using the skill, I haven't gotten to a stage where another actor can use the same skill but have a different animation following a conditional branch, how could this be modified to check a differen't actor ID?
It would appear this is working, I ran the same tests that I used to discover the previous fault so from my understanding it is addressing the actor using the skill, I haven't gotten to a stage where another actor can use the same skill but have a different animation following a conditional branch, how could this be modified to check a differen't actor ID?
If you wanted to check a specific actor you'd just do the same thing you had originally but change the 1 to whatever actor number you're checking.
So just trying to get my head around it:

BattleManager._subject.weapons().length === 2 && BattleManager._subject.weapons()[0].id === BattleManager._subject.weapons()[1].id
Using this script - it detects the User dual wielding weaponry in action on main and off hand, however it apears to not mention a specific actor of choice to inject animation frames specific to that actor.


If you wanted to check a specific actor you'd just do the same thing you had originally but change the 1 to whatever actor number you're checking.
The only drawback was I found that regardless if actor 1 was found to have been dual wielding- any other actor using the same skill that this falls into would also hijack the injected animation frames. But maybe if I make a sub-conditional branch checking:
Code:
$gameActors.actor(1).weapons().length === 2 && $gameActors.actor(1).weapons()[0].id === $gameActors.actor(1).weapons()[1].id
It may narrow it down to then targeting a specific actor ID?


I apologise in advance if this gets confusing guys.
So just trying to get my head around it:


Using this script - it detects the User dual wielding weaponry in action on main and off hand, however it apears to not mention a specific actor of choice to inject animation frames specific to that actor.



The only drawback was I found that regardless if actor 1 was found to have been dual wielding- any other actor using the same skill that this falls into would also hijack the injected animation frames. But maybe if I make a sub-conditional branch checking:

It may narrow it down to then targeting a specific actor ID?


I apologise in advance if this gets confusing guys.
Ohh, I see where your issue lies.

Yeah, your animation frame injection will have to be branched depending on who the subject is. How are you currently doing said frame injection?
Ohh, I see where your issue lies.

Yeah, your animation frame injection will have to be branched depending on who the subject is. How are you currently doing said frame injection?
I'm using VS Battle core for the animation frame injection, so far only actor 1 has the special dual reload skill and there are plans to have other actors capable of having unique dual wielding reload animations so it would seem additional branching is essential.
Like mentioned before without actor specification any other actor using the dual wielding reload will hijack the frames, so from my method of madness I've been experimenting and figured the best way to do it is to have the first conditional check for actors wielding two weapons and then boils it down to whom is doing it.

Here's the common event page I have worked so far.

Code:
◆Comment:[CHECK FOR DUAL WIELDING]
◆If:Script:BattleManager._subject.weapons().length === 2 && BattleManager._subject.weapons()[0].id === BattleManager._subject.weapons()[1].id
  ◆Comment:>Dual wield detected
  ◆Comment:[Check IF Actor is Dual Wielding]
  ◆If:Script:$gameActors.actor(1).weapons().length === 2 && $gameActors.actor(1).weapons()[0].id === $gameActors.actor(1).weapons()[1].id
    ◆If:Script:BattleManager._subject.weapons().length === 2 && BattleManager._subject.weapons()[0].id === BattleManager._subject.weapons()[1].id
      ◆Script:this._MagDrop = Math.floor(Math.random() * 2) + 1;
      ◆If:Script:this._MagDrop === 1
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Out/SMG_Mag_Out-01 (90, 100, 0)
        ◆
      :End
      ◆If:Script:this._MagDrop === 2
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Out/SMG_Mag_Out-02 (90, 100, 0)
        ◆
      :End
      ◆Wait:6 frames
      ◆Comment:[MAG INSERT]
      ◆Script:this._MagInsert = Math.floor(Math.random() * 2) + 1;
      ◆If:Script:this._MagInsert === 1
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Insert/SMG_Mag_Insert-01 (90, 100, 0)
        ◆
      :End
      ◆If:Script:this._MagInsert === 2
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Insert/SMG_Mag_Insert-01 (90, 100, 0)
        ◆
      :End
      ◆Comment:[DUAL RELOAD ANIMATION]
      ◆Common Event:Dual Wield SMG Reload Injected
      ◆Comment:[MAG ANIMATION]
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
      :              :Coordinates =
      :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
      :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
      :              :Settings =
      :              :Picture Filename = Weapon Pictures/SMG Magazine Dual
      :              :Duration = 15
      :              :Wait For Projectile? = true
      :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Animation
      :              :Coordinates =
      :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
      :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
      :              :Settings =
      :              :Animation ID = 7
      :              :Duration = 20
      :              :Wait For Projectile? = false
      :              :Wait For Animation? = false
      :              :Extra Settings = {"AutoAngle:eval":"true","AngleOffset:eval…
      ◆Comment:[MAGAZINE HIT FLOOR SFX]
      ◆Script:this._MagFloor = Math.floor(Math.random() * 3) + 1;
      ◆If:Script:this._MagFloor === 1
        ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-01 (15, 100, 0)
        ◆
      :End
      ◆If:Script:this._MagFloor === 2
        ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-02 (15, 100, 0)
        ◆
      :End
      ◆If:Script:this._MagFloor === 3
        ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-03 (15, 100, 0)
        ◆
      :End
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
      :              :Coordinates =
      :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
      :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
      :              :Settings =
      :              :Picture Filename = Weapon Pictures/SMG Magazine Dual
      :              :Duration = 20
      :              :Wait For Projectile? = true
      :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
      :              :Coordinates =
      :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
      :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
      :              :Settings =
      :              :Picture Filename = Weapon Pictures/SMG Magazine Dual 1
      :              :Duration = 28
      :              :Wait For Projectile? = false
      :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
      :              :Coordinates =
      :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
      :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
      :              :Settings =
      :              :Picture Filename = Weapon Pictures/SMG Magazine Dual 1
      :              :Duration = 25
      :              :Wait For Projectile? = false
      :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
      ◆Wait:2 frames
      ◆Comment:[COCK WEAPON]
      ◆Script:this._Cock = Math.floor(Math.random() * 2) + 1;
      ◆If:Script:this._Cock === 1
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Cock/SMG_Heavy_Cock-01 (90, 100, 0)
        ◆
      :End
      ◆If:Script:this._Cock === 2
        ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Cock/SMG_Heavy_Cock-02 (90, 100, 0)
        ◆
      :End
      ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, MOTION: Wait By Motion Frame
      :              :Motion Frames to Wait? = 6
      ◆
    :End
    ◆
  :End
  ◆
:Else
  ◆Comment:[SINGLE WEAPON USE]
  :       :[ACTOR AND ENEMY IS NOT DUAL WIELDING]
  :       :(Enemy dual wielding requires unique reload skills + common events)
  ◆Comment:[MAG RELEASE]
  ◆Script:this._MagDrop = Math.floor(Math.random() * 2) + 1;
  ◆If:Script:this._MagDrop === 1
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Out/SMG_Mag_Out-01 (90, 100, 0)
    ◆
  :End
  ◆If:Script:this._MagDrop === 2
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Out/SMG_Mag_Out-02 (90, 100, 0)
    ◆
  :End
  ◆Comment:[BEGIN RELOAD ANIMATION/MOTION]
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, MOTION: Motion Type
  :              :Targets = ["user"]
  :              :Motion Type = chant
  :              :Show Weapon? = false
  ◆Wait:6 frames
  ◆Comment:[MAG INSERT]
  ◆Script:this._MagInsert = Math.floor(Math.random() * 2) + 1;
  ◆If:Script:this._MagInsert === 1
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Insert/SMG_Mag_Insert-01 (90, 100, 0)
    ◆
  :End
  ◆If:Script:this._MagInsert === 2
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Mag Insert/SMG_Mag_Insert-01 (90, 100, 0)
    ◆
  :End
  ◆Comment:[MAG ANIMATION]
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
  :              :Coordinates =
  :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
  :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
  :              :Settings =
  :              :Picture Filename = Weapon Pictures/SMG Magazine
  :              :Duration = 15
  :              :Wait For Projectile? = true
  :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Animation
  :              :Coordinates =
  :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
  :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
  :              :Settings =
  :              :Animation ID = 7
  :              :Duration = 20
  :              :Wait For Projectile? = false
  :              :Wait For Animation? = false
  :              :Extra Settings = {"AutoAngle:eval":"true","AngleOffset:eval…
  ◆Comment:[MAGAZINE HIT FLOOR SFX]
  ◆Script:this._MagFloor = Math.floor(Math.random() * 3) + 1;
  ◆If:Script:this._MagFloor === 1
    ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-01 (15, 100, 0)
    ◆
  :End
  ◆If:Script:this._MagFloor === 2
    ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-02 (15, 100, 0)
    ◆
  :End
  ◆If:Script:this._MagFloor === 3
    ◆Play SE:Guns/Reload/Magazine_Floor/Magazine_Drop_Floor-03 (15, 100, 0)
    ◆
  :End
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
  :              :Coordinates =
  :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
  :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
  :              :Settings =
  :              :Picture Filename = Weapon Pictures/SMG Magazine
  :              :Duration = 20
  :              :Wait For Projectile? = true
  :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, PROJECTILE: Picture
  :              :Coordinates =
  :              :Start Location = {"Type:str":"target","Targets:arraystr":"[…
  :              :Goal Location = {"Type:str":"target","Targets:arraystr":"[\…
  :              :Settings =
  :              :Picture Filename = Weapon Pictures/SMG Magazine
  :              :Duration = 25
  :              :Wait For Projectile? = false
  :              :Extra Settings = {"AutoAngle:eval":"false","AngleOffset:eva…
  ◆Wait:2 frames
  ◆Comment:[COCK WEAPON]
  ◆Script:this._Cock = Math.floor(Math.random() * 2) + 1;
  ◆If:Script:this._Cock === 1
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Cock/SMG_Heavy_Cock-01 (90, 100, 0)
    ◆
  :End
  ◆If:Script:this._Cock === 2
    ◆Play SE:Guns/Reload/SMG/Magazine_Heavy/Cock/SMG_Heavy_Cock-02 (90, 100, 0)
    ◆
  :End
  ◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, MOTION: Wait By Motion Frame
  :              :Motion Frames to Wait? = 6
  ◆
:End
◆Comment:[REPLENISH WEAPON AMMO CAPACITY]
◆Plugin Command:VISUSTELLA/VisuMZ_1_BattleCore, ACSET: Finish Action
:              :Immortal: Off = true
:              :Wait For New Line = true
:              :Wait For Effects = true
:              :Clear Battle Log = true
:              :Home Reset = true
:              :Wait For Movement = true

Original thread: https://forums.rpgmakerweb.com/threads/variable-weaponry-check-plugin-or-skill.155015/