So I want to make passive that "have a 33% chance to Heal MP for entire Party" when this character basic attack.
Thanks
Thanks
<Custom Initiate Effect>
if (this.isAttack() && 3 * Math.random() < 1) {
for (var actor of $gameParty.members()) {
actor.gainMp(10);
actor.startDamagePopup();
}
}
</Custom Initiate Effect>Careful with this!
Math.randomInt(2) returns 0 or 1. For a 33% chance, you'd want Math.randomInt(3) here.var actor line is actually dependent on the conditions. 😅<Custom Battle Effect>
$gameParty.members().forEach((actor) => actor.clearResult());
</Custom Battle Effect>
<Custom Confirm Effect>
if (this._item._itemId == 1 && Math.randomInt(2) == 0 && this._subjectEnemyIndex < 0) {
for (var i = 0; i < $gameParty.aliveMembers().length; i++) {
var actor = $gameParty.aliveMembers()[i];
actor.gainMp(Math.max(Math.floor(value / 10), 1));
if (i > 0) actor.startDamagePopup();
};
};
</Custom Confirm Effect>
The problem with this is that $gameParty.aliveMembers()[0] is one specific actor. It is not necessarily going to be the actor using the skill (in fact, 75% of the time it won't be).
if (actor!=user)
This works, but could more simply be
user.isActor()Nope. Anything a plugin says is JavaScript is JavaScript and follows standard syntax.
It just gets passed through an
eval. I think I see why you're seeing that, though: if var actor doesn't get defined, that causes an error when the next line tries to reference it. Yanfly's plugin processes the eval in a try-catch block, and just outputs a message to the console on error: try {
eval(code);
} catch (e) {
Yanfly.Util.displayError(e, code,
'CUSTOM STATE ' + stateId + ' CODE ERROR');
}
<Custom Requirement>
value=false;
</Custom Requirement>
Original thread: https://forums.rpgmakerweb.com/threads/passive-that-heal-mp-on-basic-attack.160155/