When I kill an enemy with "die()", it dies, but it won't disappear from the screen!

schulliya

Veteran
Veteran
Joined
May 13, 2020
Messages
36
Reaction score
14
First Language
portuguese
Primarily Uses
RMMV
Hi.

It actually doesn't matter how I kill the enemy, even if I make some math and it makes it's HP go to 0, or add the dead state, its graphics still remain on the screen, but I can't target it anymore.
This only happens when I try to kill another thing, that's not the initial target of the skill.

My Damage Formula is like this:
$gameTroop.members()[0].die(); 20;

And what happens is this:
1643421333287.png
I targeted Crow D
I am using VisuStella's free plugins for MZ.
As I said, the graphic remains on the screen.

How can I kill another battler, without targeting it directly? Or how do I fix this?
Thanks!
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,147
Reaction score
2,534
First Language
English
Primarily Uses
RMMV
You can try adding:
if ($gameTroop.members()[0].isDead()) $gameTroop.members()[0].performCollapse()

But also be careful, because once that happens once (or the first enemy gets killed by any other means), you're going to be calling functions on an already-dead enemy, which won't have any effect - I don't know if that's what you want.

You may want to use aliveMembers() instead.
 

schulliya

Veteran
Veteran
Joined
May 13, 2020
Messages
36
Reaction score
14
First Language
portuguese
Primarily Uses
RMMV
You can try adding:
if ($gameTroop.members()[0].isDead()) $gameTroop.members()[0].performCollapse()

But also be careful, because once that happens once (or the first enemy gets killed by any other means), you're going to be calling functions on an already-dead enemy, which won't have any effect - I don't know if that's what you want.

You may want to use aliveMembers() instead.
thank you ♥
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
490
Reaction score
263
First Language
English
Primarily Uses
RMMZ
What exactly are you looking to achieve. This is a magic spell which instantly kills the party leader?
 

schulliya

Veteran
Veteran
Joined
May 13, 2020
Messages
36
Reaction score
14
First Language
portuguese
Primarily Uses
RMMV
What exactly are you looking to achieve. This is a magic spell which instantly kills the party leader?
No, that was just an exemple.
I made a skill that deals damage to other enemies when the target dies from it. But when the other enemies die by this, they wouldn't disappear from the screen.
I ended up making a kinda big formula, but it works now, with the help of ATT_Turan.

JavaScript:
var dmg = 100000; var splitDmg = (dmg - target.hp) - ($gameTroop.members().length - 1); $gameVariables.setValue(9, splitDmg); if(dmg >= target.hp){ for(var i = 0; i < $gameTroop.members().length; i++){ $gameTroop.members()[i].setHp($gameTroop.members()[i].hp - splitDmg); }; }; for(var j = 0; j < $gameTroop.deadMembers().length; j++){ $gameTroop.deadMembers()[j].performCollapse(); }; dmg;
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
490
Reaction score
263
First Language
English
Primarily Uses
RMMZ
Nice.. glad you got it working.
 

Latest Threads

Latest Profile Posts

Firefly130984 wrote on WallCat's profile.
Hello, I would try to beta test your game.
Parallel I would write a guide.
I am already planning some games to make in Unite... I hope it gets a solid release date soon!
Remember to do even 0,01% progress on your game today! You can!

Forum statistics

Threads
122,130
Messages
1,146,773
Members
160,422
Latest member
AlftheflA
Top