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,069
Reaction score
2,478
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
489
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
489
Reaction score
263
First Language
English
Primarily Uses
RMMZ
Nice.. glad you got it working.
 

Latest Threads

Latest Profile Posts

Quest_Shop_Plugin.png

Harold will need to do a lot of shopping on his quest, so I thought I'd try tackling the shop design tonight.
Never play a random encounter RPG on the toilet. Just don't. Especially not one with save points instead of menu saving.
spent the entire day working on problems I was having in battle. enemy's tagging in and out was one of them.
Check out the Driftwood gamejam submissions, there's some pretty good projects in there.
Define purpose in your own words.
And assuming it doesn't contradict your definition: if someone takes your purpose away, can you get a new one?

Forum statistics

Threads
121,962
Messages
1,145,481
Members
160,235
Latest member
minimint
Top