Kill Actor That Uses Skill

I'm trying to make a skill with two specific effects.
  1. Will deal more damage when actor using skill has higher HP.
  2. Will kill actor after skill is used.

To do this, I'm trying to use the damage formula to set a variable to be the Actor ID of the actor using the skill, and then using a common event to kill said actor.

Damage Formula: $gameVariables.setValue(1, a.id);(a.hp + a.mhp) * (a.level / 30)

As you can see, I'm setting variable 1, "selfDestruct," to be equal to the user's Actor ID, and then using the variable to kill the actor with that specific ID. When I use the skill though, it kills the entire party. What am I doing wrong? Also, if there is a simpler way to set up a skill like this, it would be appreciated!
does your game use yanfly's skill core?
Not currently, but I might soon, if it would help with skills like this one.
Instead of using a variable and a common event, why not add state #1 to the user via the damage formula? States are, if I remember correctly, run after damage has been dealt.
In Ace the syntax would be a.add_state(1)
I think in MV this translates to a.addState(1)
That's close, but it adds the state before dealing damage, making the "a.hp" have virtually no meaning in the formula anymore.
Assign the formula to a variable first.

dmg = (a.hp + a.mhp) * (a.level / 30); a.addState(1); dmg
Thanks, that worked! Would this same formula work for an attack intended for multiple enemies or should something be changed in that case?
It won't quite work for multiple enemies; the damage will be recalculated from the second hit onwards so a.hp will return 0.
Oh well, thanks anyway, you've been a big help.
If you're using Yanfly's Action Sequences plugin you could achieve this effect with that doing the full damage to all targets.
@VapidLight
If you want something like this for multiple enemies, your original idea was almost correct - you just don't do it with a variable.

Create a new state "kill me" that is invisible (no icon) and does nothing itself. Add that state instead of the regular death state.
Add a common event to be executed on the end of combat turn.
In the common event, have a branch for every actor testing if that actor has the "kill me" state - and if yes, kill it and remove the state.
That also works. Good idea, Andar!

If you have a lot of actors to run through or want a more convenient way to do this common event, you can use this script call instead of event commands:

Code:
$gameParty.members().forEach(function(member) {
  if (member.isStateAffected(id of 'kill me' state)) {
    member.addState(1);
  }
});
Thank you both! It works exactly as I wanted now.

Original thread: https://forums.rpgmakerweb.com/threads/kill-actor-that-uses-skill.76933/