Hello, I'm back after a month of hiatus (had to do other stuff for university...). Now I have about a month free, so here I am again, full of questions and troubles.
So, surely no one remembers, but a few months ago I asked here how to create a skill that deals damage to both enemies and yourself. Today I was testing it and SURPRISE, it doesn't work properly. Basically, the skill does two things: it deals damage and increases TP to the enemy (which is a BAD thing in my game, TP should be as low as possible). When you deal enough damage to kill an enemy, though, I noticed that the index that I'm using to reference enemies is advancing automatically (e.g.: I have two bats, Index 0 and 1 respectively, but 0 dies from the damage, so Index becomes 1 immediately, without returning to the loop... at least that's what I figured?). The problem is that later in the code, I check if the enemy died from the attack and perform collpase on him. But since the index increases, this won't happen. I'll post my code for clarity.
So the question is: since apparently members() doesn't include dead enemeis, is there some function that includes both alive and dead troop members? I tried also allMembers, but no luck. In case that doesn't exist (or there is something else I'm not considering... which is likely, since I'm super rusty), how else can I fix this?
Thanks in advance.
So, surely no one remembers, but a few months ago I asked here how to create a skill that deals damage to both enemies and yourself. Today I was testing it and SURPRISE, it doesn't work properly. Basically, the skill does two things: it deals damage and increases TP to the enemy (which is a BAD thing in my game, TP should be as low as possible). When you deal enough damage to kill an enemy, though, I noticed that the index that I'm using to reference enemies is advancing automatically (e.g.: I have two bats, Index 0 and 1 respectively, but 0 dies from the damage, so Index becomes 1 immediately, without returning to the loop... at least that's what I figured?). The problem is that later in the code, I check if the enemy died from the attack and perform collpase on him. But since the index increases, this won't happen. I'll post my code for clarity.
Code:
<Custom Regenerate Effect>
user.gainHp(-Math.ceil(user.atk));
for (i=0;i<$gameTroop.members().length;i++){
if($gameTroop.members()[i].isAlive()){
currentAttack= (user.atk*2-$gameTroop.members()[i].def)*$gameTroop.members()[i].elementRate(5);
$gameTroop.members()[i].gainTp(Math.ceil(currentAttack*10/100));
$gameTroop.members()[i].gainHp(-Math.ceil(currentAttack));
if($gameTroop.members()[i].isDead()){
$gameTroop.members()[i].performCollapse();
}
}}
</Custom Regenerate Effect>
So the question is: since apparently members() doesn't include dead enemeis, is there some function that includes both alive and dead troop members? I tried also allMembers, but no luck. In case that doesn't exist (or there is something else I'm not considering... which is likely, since I'm super rusty), how else can I fix this?
Thanks in advance.