MV YEP_SkillCore Dual-wielding Weapon-specific Skills / JavaScript Assistance (SOLVED)

Community,

Utilizing YEP_SkillCore plugin, is there a way via JavaScript to make certain Skills only visible if you're dual-wielding two of the same weapons- i.e. x2 daggers??

Similar to the script below, in which skills are only visible when user is in "Stealth" state. I would greatly appreciate the assistance. Thanks!

<Custom Show Eval>
if (user.isStateAffected(15)) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
Community,

Utilizing YEP_SkillCore plugin, is there a way via JavaScript to make certain Skills only visible if you're dual-wielding two of the same weapons- i.e. x2 daggers??

Similar to the script below, in which skills are only visible when user is in "Stealth" state. I would greatly appreciate the assistance. Thanks!

<Custom Show Eval>
if (user.isStateAffected(15)) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
Code:
<Custom Show Eval>
var wpnType1 = (user.equips()[0]) ? user.equips()[0].wtypeId : 0
var wpnType2 = (user.equips()[1]) ? user.equips()[1].wtypeId : 0
  if (wpnType1 == wpnType2) {
    visible = true;
  } else {
    visible = false;
  }
  </Custom Show Eval>
Checks if the user has weapons in his hands, then sets variables to their wtypeId if they exist. Then shows the skill if the user has two weapons with the same type (or two barehands).
Code:
<Custom Show Eval>
var wpnType1 = (user.equips()[0]) ? user.equips()[0].wtypeId : 0
var wpnType2 = (user.equips()[1]) ? user.equips()[1].wtypeId : 0
  if (wpnType1 == wpnType 2) {
    visible = true;
  } else {
    visible = false;
  }
  </Custom Show Eval>
Checks if the user has weapons in his hands, then sets variables to their wtypeId if they exist. Then shows the skill if the user has two weapons with the same type (or two barehands).

This is what I came up with, and I'm having trouble getting it to work:

<Custom Show Eval>
var wpnType1 = (user.equips()[0]) ? user.equips()[0].wtypeId : 1
var wpnType2 = (user.equips()[1]) ? user.equips()[1].wtypeId : 1
if (wpnType1 == wpnType 2) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>


Is it "wtypeId: 1" for both lines, because type 1 in my game = dagger, correct? I wasn't sure where to put the ID for dagger...

Sorry I'm a noob to scripting XD
the type 0 is barehanded. I did that because if it detects no weapon at all, attempting to pull it's wtypeId will cause a game crash instead.
the type 0 is barehanded. I did that because if it detects no weapon at all, attempting to pull it's wtypeId will cause a game crash instead.
Won't it crash too if the actor is holding a shield in the offhand?
Won't it crash too if the actor is holding a shield in the offhand?
You're right, but an actor who can used a weapon in their offhand cannot put a shield there. While technically it would crash, the point was to have the skill be hidden if they weren't dual wielding two weapons that were the same wtype, so anyone who cannot dual wield shouldn't have access to the skill in the first place.

If you want to make absolutely sure it doesn't crash anyway, you can add a second check to the ternary operator:
wpnType1 = (user.equips()[0] && user.equips()[0].wtypeId) ? user.equips()[0].wtypeId : 0

A ternary operator is a special way to declare a variable, where it does one of two things based on some checks. In this case it is checking to see if the item in the main hand exists, and then if that item is a weapon. Then, if that condition is met, it sets the variable equal to the wtypeId of the equipped weapon. If not it uses 0, because 0 is barehanded.
You're right, but an actor who can used a weapon in their offhand cannot put a shield there. While technically it would crash, the point was to have the skill be hidden if they weren't dual wielding two weapons that were the same wtype, so anyone who cannot dual wield shouldn't have access to the skill in the first place.

If you want to make absolutely sure it doesn't crash anyway, you can add a second check to the ternary operator:
wpnType1 = (user.equips()[0] && user.equips()[0].wtypeId) ? user.equips()[0].wtypeId : 0

A ternary operator is a special way to declare a variable, where it does one of two things based on some checks. In this case it is checking to see if the item in the main hand exists, and then if that item is a weapon. Then, if that condition is met, it sets the variable equal to the wtypeId of the equipped weapon. If not it uses 0, because 0 is barehanded.
Using the original code if my actor is barehanded she can use the skill, if I have any other weapons equipped whether dual-wielding or one-handed the skill cannot be used. The skill is not hidden regardless of what combination of weapons I use.

The end goal would be to have dual dagger (Id 1) only skills, dual pistol (Id 9) only skills, and dagger/pistol only skills. Example of Skill with code ATTACHED.

I need to take a JavaScript class 😛
I see the problem, the if check line has a space between wpnType and 2. it should be if (wpnType1 == wpnType2)
Seemed to help some. If my character is using one dagger, I cannot see the skill. If they're using x2 daggers, I can see the skill, and they can execute it. If they're barehanded or using x2 pistols, the skill is visible, but grayed-out/they cannot use it.

Ultimately, I would like for the skill to be completely invisible if they're not using x2 daggers. Then I could replicate for the dual-pistol skills, etc.
I'm happy with current results. Solved.
I see the problem, the if check line has a space between wpnType and 2. it should be if (wpnType1 == wpnType2)
Thanks again, Ramza!
Thanks again, Ramza!
If you want it to only be seen by specific weapons, you can change the if check a bit:

if (wpnType1 == wpnType2 && wpnType1 == 1)
That will make it so it's only visible if both weapons are the same type, and that type is wtypeId 1 (which you said was your dagger, before).
If you want it to only be seen by specific weapons, you can change the if check a bit:

if (wpnType1 == wpnType2 && wpnType1 == 1)
That will make it so it's only visible if both weapons are the same type, and that type is wtypeId 1 (which you said was your dagger, before).
Outstanding, it works perfect! Ramza, you're the man! Thank you very much! Now it's SOLVED!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/yep_skillcore-dual-wielding-weapon-specific-skills-javascript-assistance-solved.132088/