Self-destruct ability

Hey.
I'm trying to create a self-destruct ability for an enemy, which is obviously meant to kill the user and inflict damage on the party.

I've googled for this and came up with a few suggestions that said to create the skill and have it hit One Enemy and have Recover HP -100% and other with Add State: Death and third that uses Yanfly's Skill Cost Manager.
Sadly however, none of these have worked and I'm honestly out of options.

Is there any sort of way to go about making this skill?
in the damage formula, enter
a.hp -= a.hp; return a.hp


if the target is "enemy", use that formula.
if the target is "the user", you'll need a common event.
in the damage formula, enter
a.hp -= a.hp; return a.hp


if the target is "enemy", use that formula.
if the target is "the user", you'll need a common event.
Thank you for that. It seems to work for the most part, but I don't know if I'm doing something wrong or understanding something wrong, but upon the use of the self-destruct skill, while the enemy dies, the party receives no damage from it.
if the skill is set to target the user, then the party will recieve no damage.
if you want to damage the party with a self-damage skill, you need a common event to handle that *outside* of the skill event (which is only damaging the user, by default, and by use of the damage formula)
The skill is set to damage All Enemies. Here's what the skill looks like in the database:
Spoiler
Self-destruct.png

Does this look right or do I need to use common events?
try
b.hp *= 0.5

on the damage formula, just to test if the skill is being correctly applied.
it should set all the HPs to 50%.
Sorry for the stupid question, but should I use just that in the formula or where should I place that in the full formula?
So should it look simply like
b.hp *= 0.5
or should I put that somewhere in the
a.hp -= a.hp; return a.hp
part of the formula?

The former on its own did indeed do damage. The b.hp *= 0.5 that is
ok, so the skill is being applied as usual.

try
Code:
a.hp -= a.hp; return b.hp -= a.hp

somebody pointed out a while ago that doing multiple assignments on damage formulas, by default, would not return the correct result unless you make the formula an actual calculation.
......... or something like that...
That seems to have done it. I tried that and it worked perfectly.
Thank you very much for your help with this.

I don't exactly know these damage formula things all that well, so lot of it quite literally goes way over my head, so I appreciate the help with this.
Nevermind.
I don't exactly know these damage formula things all that well, so lot of it quite literally goes way over my head, so I appreciate the help with this.

look into the help files, find the section for RPG::UsableItem:: Damage
at the bottom of the page you have the code for the actual object.
you'll see that "formula" affects the result of *the object's function 'eval' *, which is tied to the program's code via Game_Battler's function "make_damage_value"

basically, at the time of applying the item, the damage comes up to be *whatever the 'formula' field says*, which is normally one number, but since the actual definition of it (in the item object) comes up to be *run the code contained in the formula field under the main program*, then you can use the formula field to run a small calculation before passing it down to the next process.

"return b.hp -= a.hp" is what is passed down as *the result of the formula field*, while "a.hp -= a.hp" is snuck by before the calculation and still processed as valid.
somebody pointed out a while ago that doing multiple assignments on damage formulas, by default, would not return the correct result unless you make the formula an actual calculation.
......... or something like that...

Last part must contain a damage formula (an actual calculation so you are correct)

For example, for your self-destruct, you can use the following (x = variable ID):
v[x] = a.hp; a.add_state(1); v[x]
First part makes a variable equal to caster's HP. 2nd part adds state 1 (death) and then the last part is the damage formula.

If I do this:
v[x] = a.hp; v[x]; a.add_state(1)

Nothing will happen. You'll most likely deal 0 damage and I'm pretty sure (if I remember correctly) the state won't even be inflicted (so order matters)

You don't have to use v[x] as RM Vx Ace allows you to make up variables.

For example:
ABCXYZ = a.hp; a.add_state(1); ABCXYZ
^ This will actually work.

This is my recommended approach for things like this. You can use a.hp -= a.hp instead (as you already did).

Hope this helps ^_^

Original thread: https://forums.rpgmakerweb.com/threads/self-destruct-ability.92281/