Add State Based on Armor and Weapon Type Equipped?

So I just asked a question yesterday (and it was answered and I am still so happy about it!), but I am terrible at JS. I'm hoping someone could help me with this one too.


Basically I am attempting to activate a Passive State when the actor has a certain armor and weapon type equipped. Essentially a set bonus. I haven't been able to find a plugin to do this for me (most are not compatible with Yanfly's Equip Core, which I am using for random pre/suffixes). So what I am trying to accomplish is:

  • If actor has weapon type 1 equipped, and armor type 1 equipped, add state 15
  • If actor has weapon type 2 equipped, and armor type 2 equipped, add state 15
  • If actor has weapon type 3 equipped, and armor type 3 equipped, add state 15
  • If actor has weapon type 4 equipped, and armor type 4 equipped, add state 15



I tried doing this with a common event, but it didn't work. So now I am trying to do it with Yanfly's Auto Passive States but I can't get the custom conditional to work.


Right now, this is the notetag for the "BONUS" state:


<Custom Passive Condition>
if ($gameActors.actor(1).isWtypeEquipped(1))
{
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>


1. This doesn't work


2. If we can get it to work, how would I add "and armor type (1) equipped"?


Thanks for any help you might have 🙂
So using the plugin parameters I put state 4 as a global actor passive.


Then in state 4 notetag if I try your notetag I get an error: maximum call stack size exceeded.


But by using this I get a working result:


<Custom Passive Condition>
if (user.isWtypeEquipped(2)) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>




There's no default function to check for armor types equipped that I could find, so I just adapted one from the weapon function; paste this in a .js file.


Game_Actor.prototype.isAtypeEquipped = function (atypeId) {
return this.armors().some(function(armor) {
return armor.atypeId === atypeId;
});
}




My final notetag is:


<Custom Passive Condition>
if (user.isWtypeEquipped(2) && user.isAtypeEquipped(1)) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>


And it's working perfectly.


I tested it with item core and dreamX's plugins too.
@Astfgl66 I should just start messaging you directly with all of my questions, haha.


This is amazing. Thank you so much!  🤣 🤣

Original thread: https://forums.rpgmakerweb.com/threads/add-state-based-on-armor-and-weapon-type-equipped.71233/