I want to check for enemy index, but it doesn't work
if (user == $gameTroop.members()[0])
if (user == $gameTroop.members()[0])
if (user == $gameTroop.members()[1]) {$gameVariables.setValue(282, $gameTroop.members()[1].name());$gameVariables.setValue(285, $gameTroop.members()[1]._brPotency * $gameTroop.members()[1]._brStack);$gameTemp.reserveCommonEvent(522);}which one are you using
what about it "isnt working"? what you wrote is set up correctly. as long as user is a defined variable in whatever tag youre using, your condition will pass if the user is the second enemy.
the tag on the website is JS Post-End Turn, not JS Post-Turn End.
<Reapply Rules: Add>---<JS Post-End Turn>//Check if can burnif ($gameVariables.value(155) >= 4 && !user.isStateAffected(47)) {//Proc burn damageuser.gainHp(Math.ceil(user._brPotency * user._brStack * -1));user._brStack += 1;user.addState(47)//Get user name for combat logif (user.actorId() == 1) {$gameVariables.setValue(277, $gameParty.members()[0].name());$gameVariables.setValue(279, $gameParty.members()[0]._brPotency * $gameParty.members()[0]._brStack);$gameTemp.reserveCommonEvent(519);}if (user.actorId() == 2) {$gameVariables.setValue(278, $gameParty.members()[1].name());$gameVariables.setValue(280, $gameParty.members()[1]._brPotency * $gameParty.members()[1]._brStack);$gameTemp.reserveCommonEvent(520);}if (user == $gameTroop.members()[0]) {$gameVariables.setValue(281, $gameTroop.members()[0].name());$gameVariables.setValue(284, $gameTroop.members()[0]._brPotency * $gameTroop.members()[0]._brStack);$gameTemp.reserveCommonEvent(521);}if (user == $gameTroop.members()[1]) {$gameVariables.setValue(282, $gameTroop.members()[1].name());$gameVariables.setValue(285, $gameTroop.members()[1]._brPotency * $gameTroop.members()[1]._brStack);$gameTemp.reserveCommonEvent(522);}if (user == $gameTroop.members()[2]) {$gameVariables.setValue(283, $gameTroop.members()[2].name());$gameVariables.setValue(286, $gameTroop.members()[2]._brPotency * $gameTroop.members()[2]._brStack);$gameTemp.reserveCommonEvent(523);}//Get Potency / 3 for further application$gameVariables.setValue(69, Math.ceil(user._brPotency / 3));$gameTemp.reserveCommonEvent(16);}//Remove 'BurnBlock' after 'Burn' procif ($gameVariables.value(155) < 4) {user.removeState(47);}</JS Post-End Turn>---<JS On Add State>//Start burn count if 0this._brPotency = this._brPotency || 1;this._brStack = this._brStack || 1;this.setStateDisplay(55, this._brPotency);</JS On Add State>---<JS On Erase State>delete this._brPotency;delete this._brStack;</JS On Erase State>---<JS On Expire State>delete this._brPotency;delete this._brStack;</JS On Expire State>---<Help Description>At end of every 2-3 player turns:Deals %1 * Stack Amount DMG\nReapplies 1/3 of user potency to random battler\nWill proc this turn?: \V[156]</Help Description>...
//Get user name for combat log
if (user.isActor()) {
$gameVariables.setValue(276 + user.actorId(), user.name());
$gameVariables.setValue(278 + user.actorId(), user._brPotency * user._brStack);
$gameTemp.reserveCommonEvent(518+user.actorId());
} else {
$gameVariables.setValue(281 + user.index(), user.name());
$gameVariables.setValue(284 + user.index(), user._brPotency * user._brStack);
$gameTemp.reserveCommonEvent(520+user.index());
}
//Remove 'BurnBlock' after 'Burn' proc
...
thats exactly what its doing for the enemies. the index function returns their index number. you already have sequential variables, so instead of explicitly typing out what to do in each case you can just add a little math to automatically assign variables
what does it display for actors?
did you see the variable values from the common event, or the console? I did make a mistake with the enemy common events. the last line for the else block should have 521, not 520. so the wrong common events would be playing for enemies, but the variable assignments should have still been correct
if (!user.isStateAffected(47)) { //removed variable check for testing purposes. add it back
//Proc burn damage
user.gainHp(Math.ceil(user._brPotency * user._brStack * -1));
user._brStack += 1;
user.addState(47)
//Get user name for combat log
if (user.isActor()) {
$gameVariables.setValue(276 + user.actorId(), user.name());
$gameVariables.setValue(278 + user.actorId(), user._brPotency * user._brStack);
$gameTemp.reserveCommonEvent(518+user.actorId());
} else {
$gameVariables.setValue(281 + user.index(), user.name());
$gameVariables.setValue(284 + user.index(), user._brPotency * user._brStack);
$gameTemp.reserveCommonEvent(521 + user.index());
}
//Get Potency / 3 for further application
$gameVariables.setValue(69, Math.ceil(user._brPotency / 3));
//$gameTemp.reserveCommonEvent(524);
//Remove 'BurnBlock' after 'Burn' proc
if ($gameVariables.value(155) < 4) {
user.removeState(47);
}
}
Original thread: https://forums.rpgmakerweb.com/threads/problems-checking-for-enemy-index.169206/