How to make enemies "faint" after setting their hp to 0

Hello, so I have an enemy skill that deals damage and knocks out the user.


My battle formula is: a.setHp(0); 1000


The problem is the enemy stays on the battle screen and doesn't go through the whole standard "knocked-out" sequence, such as being killed by an actor. For example, when the enemy uses the attack the battle ends and says the party is victorious but the enemy remains on the screen. I tried inserting a.addState(1) into the formula, where 1 is the "KO state", and that didn't do anything either. What am I missing here? Thanks for the help!
Why can't you just add the death state through the skill effects instead of through the formula?
a.addState(1):damage formula would work
Why can't you just add the death state through the skill effects instead of through the formula?



That would cause the enemy's target to instantly die, not the user.

a.addState(1):damage formula would work



I tried this, but it's not working. I disabled all my plugins and it's still not working. The a.addState(1) does the same thing as a.setHp(0)


I attached a screenshot of the skill in question:

Capture.PNG
Have you tried adding a Common Event to the skill and add the KO state to the user via common event?
Is this enemy immune to KO, or have you changed state 1 at all?
Have you tried adding a Common Event to the skill and add the KO state to the user via common event?



Yes I have, and it does kill the enemy properly, but I believe a.addState(1) should work in the damage formula in the same way. I just don't understand why it isn't working - whether it's something I'm doing wrong.

Is this enemy immune to KO, or have you changed state 1 at all?



The enemy is not immune to KO and I have not changed state 1 at all. Interestingly, if I direct the skill to target all allies instead of all enemies it works just fine using a.addState(1) in the damage formula. The enemy uses the skill, damages all allies, and it properly goes through the KO sequence.
Hmm.. have you considered trying a plug-in and making the skill cost 100% HP? If that works then you would really only have to set the damage in the damage formula and not the self-death..
@MiacuroThis is something that should work with just the damage formula though. 


@carpg123It's weird, I have a similar skill in my game that does inflict ko on the enemy that uses it but now the enemy doesn't collapse.
@MiacuroThis is something that should work with just the damage formula though. 


@carpg123It's weird, I have a similar skill in my game that does inflict ko on the enemy that uses it but now the enemy doesn't collapse.



Yeah, it might be a bug or something. Ugh, very annoying.

Have you tried adding a Common Event to the skill and add the KO state to the user via common event?



Actually I misread this. I want to try this out but I don't know the proper syntax to write in the common event page. Do you know what it is? I know there's a way to specify specific enemies based on the troop composition, but I would like to use code to state, "apply KO state to user" so any time the skill is used the user will be "KO'd".
Have you tried:


a.die(); 1000;


Or


a.performCollapse(); 1000;
Have you tried:


a.die(); 1000;


Or


a.performCollapse(); 1000;



Okay, I just tested this out and I have some interesting results to share:


a.die(); 1000 still experiences the same problem as a.setHp(0) and a.addState(1)


a.performCollapse(); 1000 causes the enemy to collapse and then re-emerge. This happens 4 times in a row since the attack hits each of the 4 actors.


So then I decided to try both of them combined a.die(); a.performCollapse(); 1000


The combined version kind of works, but not quite. The enemy launches the attack and properly collapses now! BUT each time an actor takes damage from the attack the "collapse sound effect" plays instead of the usual "hit sound effect". So close...but it's still not right. Is there a way to perform the collapse once and not every time an actor takes damage? I also tried a.addState(1); a.performCollapse(); 1000 and it does the same thing.
*EDIT*


So, I just made a make-shift Sacrifice skill, that causes damage to all foes, and then KO's the Skeleton.. using one skill, one common event call, and no plug-in's/formulae necessary.. so if you wanna answer the Q's below, I can set you up step-by-step on how to do this. 🙂


Just to clarify,


This skill is ENEMY use only?


This skill is HERO use only?


This skill can be used by HEROES and ENEMIES?


This skill KO's the skill Caster, and has no actual HP?MP/TP Cost?


This skill causes 1,000 HP Damage to all ALLIES? ENEMIES?


I'm 99% sure this can be easily Common Evented with just two skils and two common events.. And I'll gladly help you set it up if you just clarify the questions above. 🙂


There are several skill Targeting plug-ins that you could use as well, but I find Common Eventing/Battle Eventing usually to be more applicable and customized.
*EDIT*


So, I just made a make-shift Sacrifice skill, that causes damage to all foes, and then KO's the Skeleton.. using one skill, one common event call, and no plug-in's/formulae necessary.. so if you wanna answer the Q's below, I can set you up step-by-step on how to do this. 🙂


Just to clarify,


This skill is ENEMY use only?


This skill is HERO use only?


This skill can be used by HEROES and ENEMIES?


This skill KO's the skill Caster, and has no actual HP?MP/TP Cost?


This skill causes 1,000 HP Damage to all ALLIES? ENEMIES?


I'm 99% sure this can be easily Common Evented with just two skils and two common events.. And I'll gladly help you set it up if you just clarify the questions above. 🙂


There are several skill Targeting plug-ins that you could use as well, but I find Common Eventing/Battle Eventing usually to be more applicable and customized.



Awesome, really appreciate the help! I will answer the questions as follows:


This skill is ENEMY use only? Yes.


This skill is HERO use only? No.


This skill can be used by HEROES and ENEMIES? No.


This skill KO's the skill Caster, and has no actual HP/MP/TP Cost? Yes.


This skill causes 1,000 HP Damage to all ALLIES? ENEMIES? Only enemies.


I would like to know how you design this skill properly so I can learn the process and technical details. So later on if I want to modify it so heroes can use it, or change the damage amount or target, I would know how. I'm fairly new to RPGmaker so I'm trying to learn as much as possible. 🙂 Thanks again for the help!
Kk, thanks!! This is actually


REALLY easy to do within the system itself without formulae etc. I'll give you a play-by-play (when I have some down time this evening) with pictures. ? (Sorry, I'm mostly just running errands right now.)
Oh, i have another suggestion. Another way of doing a self-destruct skill is to deal damage to the user like this:


a.gainHp(-a.hp); 1000;


You can even do the damage based on the user's remaining HP;


a.gainHp(-a.hp); a.hp * 8;
Kk, thanks!! This is actually


REALLY easy to do within the system itself without formulae etc. I'll give you a play-by-play (when I have some down time this evening) with pictures. ? (Sorry, I'm mostly just running errands right now.)



Great, thank you. Just let me know whenever you have time, there's no rush 🙂

Oh, i have another suggestion. Another way of doing a self-destruct skill is to deal damage to the user like this:


a.gainHp(-a.hp); 1000;


You can even do the damage based on the user's remaining HP;


a.gainHp(-a.hp); a.hp * 8;



Okay, my enemy has 100 HP and this is what happens:


The enemy uses the skill and when the first actor takes 1000 damage, the enemy takes 100 damage. Next, as each of my remaining actors take damage, the enemy keeps taking "0" damage per hit. Once this sequence is over the battle ends and says my party victorious. Unfortunately the enemy still doesn't collapse properly.
((Sorry for the quality of pics))


image1.JPG


Step 1) Create Common Event. Name it "Sacrifice" "Bomb" "Revenge" whatever you want to name it. Set it up as in Image 1:


-Change Enemy HP


-Enemy #1


-(x) Decrease


-Constant: 9999 (or however much dmg you want them to take, 9999 is enough to kill them, but won't work if you use a plug in that allows for exceeding default stats. If so, use the [Change Enemy State] instead)


-[x] Allow Knock Out


image2.JPG


Step 2) Create the Skill


-Set as image 2.. be sure to choose your own Icon, MP, TP, Animation (to be played on the targets), etc.


-Set as All Enemies


image3.JPG


-Set as HP Damage and choose an Element type.


-Set the Damage you wish the skill to cause (either constant, percentile, special formula, or even variances, etc.)


-Add Common Event and Sacrifice Skill Used (or whatever you named it) to Effects.


image4.JPG


Step 3) Assign the skill to an Enemy


-Choose the conditions and priority rating in which you want the enemy to use the skill. If you want the enemy to use the skill absolutely under specific conditions, use Battle Events for that.


-In this example I have made, Sacrifice is the highest priority attack, and will trigger when their HP is between 0% and 25% of their Max HP.


image5.JPG


Step 4) This one is important. Whenever you create a troop of enemies, be sure to add the Skeleton FIRST. That puts the Skeleton in the first position. If you recall, we created the common event to affect the enemy in the first position. so that's important that whomever is using this skill be #1.


-If you want to have several skeletons in the same Troop, just create a second, third, fourth, etc. Common Event targeted at those positions, and a copy/paste skill calling the second, third, fourth, etc. Common Event... and then be sure that those enemies are in those positions in the troop.


I hope this makes sense. I am not an expert tutorial writer. LOL!! There may even be easier ways to accomplish this that you will find or others may tell you.


But, this is a simple way to get'r'done.


You may even add explosion animations to the Battler using the skill.. or a death message.. so long as you use the Wait function until it's complete before setting the Skeleton to die. 🙂
Just test out @Miacuro's solution. Worked for me. And by the way, Miacuro, you can use Alt+ Print Screen to take a screen shot of your active window and slap it in the paint program (If you're using windows) for easier screenshots.
Just test out @Miacuro's solution. Worked for me. And by the way, Miacuro, you can use Alt+ Print Screen to take a screen shot of your active window and slap it in the paint program (If you're using windows) for easier screenshots.



No, no I cant. Lol. For ... reasons... I just can't on my laptop. Believe you me, I wish I could. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-enemies-faint-after-setting-their-hp-to-0.60885/