Okay, so here's the breakdown:
In my game, I have a series of skills called Weapon Skills. Weapon Skills, as you might guess, are skills utilized not with any kind of magic, but with the user's weapon. I know, so unique, right? I'm such a forward thinker. lol
Anyway, the deal comes in here: what weapon skills you can do is defined by what weapon you currently have equipped. For example, there's 9 skills you can only do with a sword, 9 skills you can only do with a lance, 9 skills you can only do with an axe... and so on. You get the idea. Now, personally, I was happy with this format when I first thought of it, and I'm happy with it now.
Except for one part that I didn't really think about at the time... the menu.
It's an issue across the board, but one character in particular has access to five different weapon types. That's a total of 45 skills in his Weapon Skill menu when he gets all of his, 36 of which he can't even use, yet they're there. And if the weapon he's using is the lowest on the list? He's gotta scroll down all the way to the bottom every time he wants to use a skill. As you can imagine, there's a problem there, especially if you've got a party of four characters all using skills located at the bottom of the list.
Is there anything I can use to outright hide these options?
With Yanfly's Skill Core plugin, try a Custom Eval in the skill notes. I think it will look something like this:
<Custom Show Eval>
if (user.equips()[0] = weaponTypeId) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
Replace weaponTypeId with the ID of the weapon type in your database. That should make it so the skill is only visible when the right weapon is equipped.
Hmm... I've been toying around with that statement, but I can't seem to get it to work.
I tried subbing out the user.equips bit for user.level just to see if maybe there was something wrong with the {visible = whatever} bits, but it worked right when I did it that way. But no matter what I do with user.equips, nothing shows up even if I have the intended weapon equipped. So weird...
Thanks for the lead, though. With a little more work I might be able to figure the rest of this out myself (though I'll gladly accept outside help!)
I got this figured out but I have a couple questions.
1: How do you want dual wielding to work? (for example: if I have a dagger in mainhand and a shortsword offhan, do I get both skills, or just dagger skills?)
2: would you prefer it automated to weapon type or weapon id? (edit: nvm on this, I'll give you both)
Ah, thank you! Darn, I feel stupid for missing you by a whole hour, though.
1. my game doesn't actually feature any dual wielding... although, each "weapon type" is actually two weapon types (I wanted unique weapon sprites for the "ultimate" weapon of each type... completely unaware for a long while that there was a Yanfly plugin that did exactly that, and more, without splitting things up), so if an "or" statement could be worked out that'd be great. Unfortunately, I'm not terribly proficient in JavaScript, so I'm not sure how to write one. (otherwise I could probably take some time and streamline my game a bit since I am now using the plugin I mentioned)
2. definitely type. Any weapons that have unique skills, I just put the skill on the weapon itself. Early game weapons don't really have too many unique properties, meaning that when the unique properties do come along you're probably respectably deep into the game anyway, so your progress through the game shouldn't really matter in that vein of skill balancing.
Changed my mind, instead of saying yes or no I'll just give you the tested code with dual wield support and annotate it with proper removal instructions! To hide a skill based on the weapons ID (example, this particular sword can use a super special skill) use this
//based on Weapon ID
<custom show eval>
//set this to the weapon ID
var wepId = 1;
var equipList = user._equips[0];
var currentEquip = equipList._itemId;
//dualwield support start, optional.
var equipOffhand = user._equips[1];
var offhandId = equipOffhand._itemId;
var offIsWep = equipOffhand._dataClass;
//dualwield support end, if undesired remove the above code till the start point, as well as "|| offIsWep == "weapon" && offhandId == wepId" from next line
if (currentEquip == wepId || offIsWep == "weapon" && offhandId == wepId){
visible = true;
} else {
visible = false;
}
</custom show eval>
For code based on weapon type (example: So long as it's a sword I'll do it!) use this!
//Based on Weapon Type
<custom show eval>
//set this to the weapon type ID
var wepTypeId = 1;
var equipMainhand = user._equips[0];
var mainhandId = equipMainhand._itemId;
var MainWeaponType = $dataWeapons[mainhandId].wtypeId;
//Dualwield support start, optional.
var equipOffhand = user._equips[1];
var offhandId = equipOffhand._itemId;
var offIsWep = equipOffhand._dataClass;
var offWeaponType = $dataWeapons[offhandId].wtypeId;
//dualwield support end, if undesired remove the above code till the start point, as well as "|| offIsWep == "weapon" && offWeaponType == wepTypeId" from next line
(if MainWeaponType = wepTypeId || offIsWep == "weapon" && offWeaponType == wepTypeId){
visible = true;
} else {
visible = false;
}
</custom show eval>
just follow the notes in the code if you don't want dual wielding support
I'll make some quick edits to allow for an ultimate weapontype
Okay, so I got that working fine and dandy! I found that it makes the client crash if the skill list is accessed while a character is unarmed though. but the fix is easy! so first go to
Your Games folder/data/weapons.json
and WITH RPGMAKER CLOSED where it says "null," replace it with this
{"wtypeId":-2147483648,"traits":[],"params":[null,null,0],"animationId":0,"price":0,"name":""},
it'll prevent the crash and it doesn't harm your game (or even show up in your editor)
now the code! (I took out the dual wield stuff since you don't use it)
//Based on Weapon Type
<custom show eval>
//set this to the weapon type ID
var wepTypeId = 120;
//set this to ult Wep Type ID
var ultWepTypeId = 4;
var equipMainhand = user._equips[0];
var mainhandId = equipMainhand._itemId;
var MainWeaponType = $dataWeapons[mainhandId].wtypeId;
if (MainWeaponType == wepTypeId || MainWeaponType == ultWepTypeId){
visible = true;
} else {
visible = false;
}
</custom show eval>
Hope it all works well for you ^_^
OK, I think I found the problem with that code I gave you earlier.
This:
<Custom Show Eval>
if (user.equips()[0] = weaponTypeId) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
Should be this:
<Custom Show Eval>
if (user.equips()[0].wtypeId = weaponTypeId) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
I forget to include the equipment type ID by adding wtypeId.
Oh my gosh, it works! You guys are both awesome, thank you!
Hello all! Sorry to necro this thread but I've been looking for something like this but unfortunately my knowledge of this sort of thing is fairly limited. This:
<Custom Show Eval>
if (user.equips()[0].wtypeId = weaponTypeId) {
visible = true;
} else {
visible = false;
}
</Custom Show Eval>
is confirmed to work with Yanfly skill core and is meant to be typed in the note field for a specific skill, correct?
This is a noob question but is a weapon's ID the number displayed along side it in the database or is it stored elsewhere? If the latter, how might I find a weapon's ID? Thanks for any help you might be able to give!
Change
"if (user.equips()[0].wtypeId = weaponTypeId)"
To
"if (user.equips()[0].wtypeId == weaponTypeId)"
With only one = you're setting it to be equal instead of checking if it's equal
But weapon ID is just its number in the database.
It should be 3 equal signs in js.
Its most easily shown with numbers.
With == 1 and "1" are equivalent as are 1 and 1
With === 1 and "1" are not the same but 1 and 1 is.