How would I get the GainHP/TP/MP commands to work? In my case I have a passive called Alcoholic which if the item is alcohol it gives them boosted benifets, but I can't change anything but what the skill is for. My command is:
b.isStateAffected(43) ? b.gainHp(400) b.gainMp(400) b.gainTp(400) : b.gainHp(200) b.gainMp(200) b.gainTp(200);
and it always comes out to 0. I tried a few differant ways but it probably just better to ask.
You're getting a 0 out of that formula because of a syntax error. You can't call those functions like that because the things in between the ? and the : are supposed to be expressions. Also, I don't believe that the gainX methods return a value, so if you could call those methods like that you still wouldn't get a number back. The correct way to do this would be to use an if statement instead of a ternary operator (e.g. ? : ).
So, it would go something like this:
Code:
if b.isStateAffected(43) { b.gainHp(400); b.gainMp(400); b.gainTp(400) } else { b.gainHp(400); b.gainMp(400); b.gainTp(400) }
This would properly increase the HP, MP, and TP of the target, but this would sill end up with a 0 since you aren't producing a number. Considering that you're using gainHp, I'm going to assume this is a healing skill, in which case gainHp is redundant as the number the formula gives is the amount of HP healed.
Try this:
Code:
var heal = b.isStateAffected(43) ? 400 : 200; b.gainMp(heal); b.gainTp(heal); heal
PS. Are the code tags in an unreadable light grey on white text box for anyone else?
EDIT:
It works!!!
b.isStateAffected(65) ? b.addState(32): b.addState(65); 0
I don't know which plugin caused it to need a damage portion, but without the ';0' it crashed again, but with the ';0' it was completely successful! Thank you so much! :D
Please don't use the ternary operator like this. The ternary operator returns one of two values depends on the truth of the value it is applied to. It is not an if statement and it only works here by complete accident. That's part of why you needed to add a ;0 to the end. Since the addState method doesn't return a value.
Please write this as if (b.isStateAffected(65)) { b.addState(32) } else { b.addState(65) }; 0