Creating more strange abilities

Hello everyone, sorry for bothering.
I'm trying to make a series of somewhat... strange skills and I know they require plugins, but the problem is I don't know how to configure them.
I have the plugins Skill Core, Auto Passive States, Life Steal, etc. (and many more) from Yanfly, but the problem is I don't know how to use codes very well and I was hoping someone could help me.
I'm going to put here the skills I haven't managed to do, in case someone dares to help me, even with a few.

1- A skill (or passive status) that, when it kills the enemy, regardless of the damage it causes, recovers 1 HP to the user and grants them a status.

2- A passive state that allows the user to deal 1 damage to an enemy by dodging their attack (similar to counterattack).

3- Similar to the previous one, but the damage caused to all enemies, not just the one that attacked the user.

4- A passive state that allows the user to deal 1 damage to an enemy by dodging their attack and heal 1 HP to themselves.

5- A skill that, if you kill the enemy, causes 1 damage to the rest of the enemies.

6- A skill that allows you to deal damage to yourself to increase your own attack or agility BEFORE dealing damage to the enemy.

7- A skill that deals damage the more steps you take during the game.

8- A skill that damages only 1 enemy, but can give a status to all enemies.

A thousand thanks to everyone who helps me!
A good resource for you is to Google the pinned thread of MV script calls. Most of what you're asking is very basic stuff, codewise, so you could at least have a start for it using that sheet and then you can ask for help with anything that doesn't work correctly.

1- A skill (or passive status) that, when it kills the enemy, regardless of the damage it causes, recovers 1 HP to the user and grants them a status.
Code:
<Post-Damage Eval>
if (target.hp<=0)
{
    user.gainHp(1);
    user.addState(X);
}
</Post-Damage Eval>
Here, and all other places, X is the ID of the state you want to add, no leading zeros.

2- A passive state that allows the user to deal 1 damage to an enemy by dodging their attack (similar to counterattack).
Code:
<Custom Deselect Effect>
if (this.result.evaded)
    user.gainHp(-1);
</Custom Deselect Effect>

3- Similar to the previous one, but the damage caused to all enemies, not just the one that attacked the user.
Code:
<Custom Deselect Effect>
if (this.result.evaded)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(-1));
</Custom Deselect Effect>

4- A passive state that allows the user to deal 1 damage to an enemy by dodging their attack and heal 1 HP to themselves.
Code:
<Custom Deselect Effect>
if (this.result.evaded)
{
    user.gainHp(-1);
    target.gainHp(1);
}
</Custom Deselect Effect>

5- A skill that, if you kill the enemy, causes 1 damage to the rest of the enemies.
Code:
<Post-Damage Eval>
if (target.hp<=0)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(-1));
</Post-Damage Eval>

6- A skill that allows you to deal damage to yourself to increase your own attack or agility BEFORE dealing damage to the enemy.
For dealing damage to yourself, you'd follow the instructions in Yanfly's Skill Core to add an HP Cost to the skill. Then you can change the damage formula to reference a.atk plus/multiplied by some value. And just make the skill speed faster rather than modifying agility.

Or do you mean to grant a buff to those parameters that lasts beyond this one skill's execution? It's not clear.

7- A skill that deals damage the more steps you take during the game.
This doesn't require any plugins, just reference $gameParty.steps() in your damage formula.

8- A skill that damages only 1 enemy, but can give a status to all enemies.
Code:
<Post-Damage Eval>
$gameTroop.aliveMembers().forEach(enemy => enemy.addState(X));
</Post-Damage Eval>

I almost had it in time!
so close... so close😀
Action results are stored on the battler, not the action. So I think instead of this:
JavaScript:
this.result.evaded
...it should be this?
JavaScript:
target.result().evaded
Otherwise looks good!
Yup, @caethyril, oops!
A good resource for you is to Google the pinned thread of MV script calls. Most of what you're asking is very basic stuff, codewise, so you could at least have a start for it using that sheet and then you can ask for help with anything that doesn't work correctly.
I know, it's what I've done, but English is not my native language and I have certain difficulties, however, I am very grateful for all your help.

Code:
<Post-Damage Eval>
if (target.hp<=0)
{
    user.gainHp(1);
    user.addState(X);
}
</Post-Damage Eval>
Here, and all other places, X is the ID of the state you want to add, no leading zeros.
This one works perfectly^^

Code:
<Custom Deselect Effect>
if (this.result.evaded)
    user.gainHp(-1);
</Custom Deselect Effect>


Code:
<Custom Deselect Effect>
if (this.result.evaded)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(-1));
</Custom Deselect Effect>


Code:
<Custom Deselect Effect>
if (this.result.evaded)
{
    user.gainHp(-1);
    target.gainHp(1);
}
</Custom Deselect Effect>
These 3 codes have had no effect :/
I also tried with:
<Custom Deselect Effect> if (target.result().evaded) user.gainHp(-1); </Custom Deselect Effect>
But it still doesn't work.
Maybe I'm not putting the code where it belongs?
I have put the code in Notes, in the States menu.
And then I made said state be granted by a weapon (with the Yanfly Auto Passive States plugin). The character acquires that State (I know, because the icon appears), but he does not damage enemies when Dodge.

Code:
<Post-Damage Eval>
if (target.hp<=0)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(-1));
</Post-Damage Eval>
I changed this code a little, because the damage caused to other enemies was not visible:
<Post-Damage Eval> if (target.hp<=0) $gameTroop.aliveMembers().forEach(enemy => {enemy.gainHp(-2); enemy.startDamagePopup()}); </Post-Damage Eval>
I have also tried to do this same ability, but instead of hitting the rest of the enemies, it hit 1 random enemy alone, but it hasn't worked.
I tried with:
<Post-Damage Eval> if (target.hp<=0) $gameTroop.aliveMembers().forRandom(enemy => {enemy.gainHp(-2); enemy.startDamagePopup()}); </Post-Damage Eval>
But dont't work...

Also, I've seen that when another enemy dies from this effect, they don't disappear from the screen. What I can do?

For dealing damage to yourself, you'd follow the instructions in Yanfly's Skill Core to add an HP Cost to the skill. Then you can change the damage formula to reference a.atk plus/multiplied by some value. And just make the skill speed faster rather than modifying agility.

Or do you mean to grant a buff to those parameters that lasts beyond this one skill's execution? It's not clear.
I think what I was trying to do was not possible. My idea was that when the player chooses a skill, they can (or not) take off 1 HP to increase their attack or agility. But I wanted the moment to choose to be when selecting the ability, not when the ability acts.
However, I have decided to do it another way, although I have encountered another wall...
Skills only have one use (with the Yanfly plugin "Limited Skills Uses").
There are 2 equal skills (Skill 1 and Skill 2, both with <Limit Uses: 1>), however, Skill 2 costs 1 HP.
I would like that by using one, it is no longer possible to use the other.
I have tried putting <Skill 2 Limited Uses: -1> in Notes, but when I use Skill 1, I can continue using Skill 2 (and vice versa).

This doesn't require any plugins, just reference $gameParty.steps() in your damage formula.
Done, thank you very much, it already works great ^^

Code:
<Post-Damage Eval>
$gameTroop.aliveMembers().forEach(enemy => enemy.addState(X));
</Post-Damage Eval>
This works perfectly, thank you^^
But it still doesn't work.
Maybe I'm not putting the code where it belongs?
are you sure that that one doesnt work? there may be no damage popup but the effect should still take place. i can give you a similar one from my project that already works for me (for my setup atleast)
EDIT: i see it now. the originals used "this". Caethyril had already mentioned it, so i assumed you made the correction already. change "this.result" to "target.result()"

I have also tried to do this same ability, but instead of hitting the rest of the enemies, it hit 1 random enemy alone, but it hasn't worked.
forRandom isnt a method. try this
Code:
<Post-Damage Eval>
if (target.hp<=0){
  var enemy = $gameTroop.aliveMembers()[Math.randomInt($gameTroop.aliveMembers().length)];
  enemy.gainHp(-2);
  enemy.startDamagePopup();
}
</Post-Damage Eval>

Also, I've seen that when another enemy dies from this effect, they don't disappear from the screen. What I can do?
Yeah, theres some timings where a battler hitting 0 hp through gainHp doesnt actually kill them.
When you encounter them youll have to add an additional check to see if theyre at 0 hp and use die() on them.

I would like that by using one, it is no longer possible to use the other.
If theyre both one use, try adding this in both of your skills' noteboxes
Code:
<After Eval>
user.setSkillLimitedUse(the other skill's id, 1));
</After Eval>
These 3 codes have had no effect :/
Hm, I'm not sure. My only thought is that by the time Deselect happens the action result has been erased, but I didn't think that was the case.

I have also tried to do this same ability, but instead of hitting the rest of the enemies, it hit 1 random enemy alone, but it hasn't worked.
It's always best to just ask (or actually look it up, if you can) - guessing with code has about a 0% chance of success 😉 @Robro33 already took care of you here.

Also, I've seen that when another enemy dies from this effect, they don't disappear from the screen. What I can do?
I don't think die() will do the trick here, as their HP is already at 0. Try this:
Code:
<Post-Damage Eval> 
if (target.hp<=0)
{
    $gameTroop.aliveMembers().forEach(enemy => 
    {
        enemy.gainHp(-2);
        enemy.startDamagePopup();
        if (enemy.hp<=0)
              enemy.performCollapse()
    }); 
}
</Post-Damage Eval>
are you sure that that one doesnt work? there may be no damage popup but the effect should still take place. i can give you a similar one from my project that already works for me (for my setup atleast)
EDIT: i see it now. the originals used "this". Caethyril had already mentioned it, so i assumed you made the correction already. change "this.result" to "target.result()"


forRandom isnt a method. try this
Code:
<Post-Damage Eval>
if (target.hp<=0){
  var enemy = $gameTroop.aliveMembers()[Math.randomInt($gameTroop.aliveMembers().length)];
  enemy.gainHp(-2);
  enemy.startDamagePopup();
}
</Post-Damage Eval>
Hm, I'm not sure. My only thought is that by the time Deselect happens the action result has been erased, but I didn't think that was the case.
Hello again, now I have managed to get some skills working (finally enemies disappear when they die), however I am still having problems with 4 skills.
The 3 passive Dodge statuses still don't work.
I put screenshots here (sorry, my RPG Maker MV is in Spanish), to see if there is anything wrong.
Spoiler
111.png
Spoiler
222.png
Spoiler
333.png

On the other hand, I have created a skill that when it kills an enemy, it deals 2 damage to a random enemy.
The problem is that that random enemy is sometimes the enemy that has died.
I would like that, if there are 3 enemies (A, B and C) and I kill enemy A with the skill, the special effect would occur only on B or C, but not on A.
Below is the code I created. How can I modify it?
Code:
<Limit Uses: 1>
<Post-Damage Eval>
if (target.hp<=0){
var enemy = $gameTroop.aliveMembers()[Math.randomInt($gameTroop.aliveMembers().length)];
enemy.gainHp(-2);
enemy.startDamagePopup();
if (enemy.hp<=0)
enemy.performCollapse()

}
</Post-Damage Eval>

Again, I must thank you all for helping me so much and for being so patient with me <3
The 3 passive Dodge statuses still don't work.
i usually use (target.result().missed || target.result().evaded) in my states since no matter which happened itd work. I vaguely remember one of my plugins lumping evasion and missing together while eliminating one of the two, but i cant say which one did it or even if thats what actually happens. regardless, try that?

The problem is that that random enemy is sometimes the enemy that has died.
funny enough, i did think that might have been a possibility when i was typing it out since i wasnt sure if the target would be considered dead yet at that time, but i couldnt test it.
try this
Code:
<Post-Damage Eval>
if (target.hp<=0){
  var enemy = $gameTroop.aliveMembers();
  enemy.splice(enemy.indexOf(target), 1);
  enemy = enemy[Math.randomInt(enemy.length)];
 
  if(enemy){
    enemy.gainHp(-2);
    enemy.startDamagePopup();
    if (enemy.hp<=0)
    enemy.performCollapse()
  }
}
</Post-Damage Eval>
And you're sure the actor has the state and is evading? By default, the chance to evade is pretty low, you're giving them some extra bonuses to make sure it happens for your testing?
i usually use (target.result().missed || target.result().evaded) in my states since no matter which happened itd work. regardless, try that?
Nothing... :/
Using this:
Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
    user.gainHp(-1);
</Custom Deselect Effect>
It doesn't work either.

I vaguely remember one of my plugins lumping evasion and missing together while eliminating one of the two, but i cant say which one did it or even if thats what actually happens.
I think the plugin you are referring to is "Hit Accuracy" by Yanfly, but I have tried all the codes turning the plugin on and off and they don't work.

funny enough, i did think that might have been a possibility when i was typing it out since i wasnt sure if the target would be considered dead yet at that time, but i couldnt test it.
try this
Code:
<Post-Damage Eval>
if (target.hp<=0){
  var enemy = $gameTroop.aliveMembers();
  enemy.splice(enemy.indexOf(target), 1);
  enemy = enemy[Math.randomInt(enemy.length)];
 
  if(enemy){
    enemy.gainHp(-2);
    enemy.startDamagePopup();
    if (enemy.hp<=0)
    enemy.performCollapse()
  }
}
</Post-Damage Eval>
Now this ability works perfectly, thank you so much ^^

And you're sure the actor has the state and is evading? By default, the chance to evade is pretty low, you're giving them some extra bonuses to make sure it happens for your testing?
I know the actor has the state, because the state has a gold star icon, and in battle (and menu), the actor shows the icon.
I have given him a +1000% Evasion Rate, so all enemy attacks launched towards the actor miss.
Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
user.gainHp(-1);
</Custom Deselect Effect>
It doesn't work either.
and just making sure: the enemy isnt taking damage at all? or is there just no damage popup? the code doesnt have the line to trigger one and i dont think that deselect produces one without it. did you check their hp before and after the dodge?
and just making sure: the enemy isnt taking damage at all? or is there just no damage popup? the code doesnt have the line to trigger one and i dont think that deselect produces one without it. did you check their hp before and after the dodge?
I have an HP bar on the enemies and the enemies have 1 HP, so they should die after missing all their attacks.
Even if the damage is not displayed, the battle should end after all of your attacks fail.

I've tried putting the code in a clean project, just with the Skill Core plugin and it still doesn't work. I have tried it with Skill Core + Auto Passive States and neither... I have RPG Maker MV v1.6.1 and both plugins are up to date (Skill Core v1.13 and Auto Passive States v1.17). Any ideas? Have you tried it in any of your projects?

EDIT: If necessary, I can take more screenshots or record some video.
I have an HP bar on the enemies and the enemies have 1 HP, so they should die after missing all their attacks.
Even if the damage is not displayed, the battle should end after all of your attacks fail.
for this, i don tthink that the enemy would die if they hit 0 hp. you should need performCollapse() to be called to kill them and make them disappear as a result of the state. Although, you say you have an hp bar so you'd atleast be able to see the hp change happening if it were working.

Have you tried it in any of your projects?
I havent tried what you provided above, but its the same logic my states use. If it helps, this is *exactly* how one of my states' notebox looks like in my project. it works for me and the only relevant plugins for it are autopassives and buffs & states. if your plugins are ordered right it should work for you too. Just remove the parts that arent relevant to you
Code:
<Custom Passive Condition>
condition = (user.isEnemy() ||
user.currentClass().id == 5 ||
user._subclassId == 5) &&
$gameParty.inBattle();
</Custom Passive Condition>

<Custom Deselect Effect>
if ((target.result().missed || target.result().evaded) && this.isDamage() && this.isForOpponent()){
var dmg = target.agi;

if (user.isStateAffected(156)) dmg -= user._spectGuard;
if (dmg>0){
    user.gainHp(-dmg);
    user.startDamagePopup();
}

if (user.hp==0 && !user.isStateResist(1)) user.performCollapse();
}
</Custom Deselect Effect>


EDIT: If necessary, I can take more screenshots or record some video.
maybe share your plugin manager with every plugin in view first?
There must be something else going on in your project.

I made a new test project, put the two states plugins in it, and put on a passive state with 100% evasion and this notetag:
Code:
<Custom Deselect Effect>
if (target.result().evaded)
{
    user.gainHp(-1);
    target.gainHp(1);
    if (user.hp<=0)
        user.performCollapse();
}
</Custom Deselect Effect>

It worked perfectly.
maybe share your plugin manager with every plugin in view first?
There must be something else going on in your project.

I made a new test project, put the two states plugins.
OMG! Reading this, that "two", I suspected that I was missing something.
I added the "Buffs & States Core" plugin (because yes, I didn't have it installed) and when testing it didn't work either, but I deactivated the "Hit Accurcy" plugin and now it works!
After all, the problem was that I was missing a plugin. I'm tremendously stupid.

Using "target.result().missed || target.result().evaded", it works perfectly, even with the Hit Accuracy plugin activated.

I just need to perfect a couple of things:
Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
{
    user.gainHp(-1);
    user.startDamagePopup();
    target.gainHp(1);
    if (user.hp<=0)
        user.performCollapse();
}
</Custom Deselect Effect>
This code does not show the actor's healed HP.

Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
    $gameTroop.aliveMembers().forEach(enemy => enemy.gainHp(-1));
    user.startDamagePopup();
    if (user.hp<=0)
        user.performCollapse();
</Custom Deselect Effect>
In this case there are 2 problems:
1- Only the damage done to the attacking enemy is shown, but the damage in the rest of the enemies is not shown.
2- Enemies do not disappear when they die.
This code does not show the actor's healed HP.
this one is the same adjustment mentioned a few times. if you want a damage popup on something but its not showing, a startDamagePopup() has to be added somewhere. theres one on the user(attacking enemy), but there isnt one on the target (attacked actor).

1- Only the damage done to the attacking enemy is shown, but the damage in the rest of the enemies is not shown.
same point as before, theres no showDamagePopup() thatll play for each enemy. just for the attacker
2- Enemies do not disappear when they die.
the call for performCollapse() is only done on the attacker, but nobody else. that too will have to be changed.

Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
    $gameTroop.aliveMembers().forEach(enemy => {
      enemy.gainHp(-1)
      enemy.startDamagePopup();
      if (enemy.hp<=0)
        enemy.performCollapse();
    });
</Custom Deselect Effect>
this one is the same adjustment mentioned a few times. if you want a damage popup on something but its not showing, a startDamagePopup() has to be added somewhere. theres one on the user(attacking enemy), but there isnt one on the target (attacked actor).
Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
    user.gainHp(-1)
    user.startDamagePopup();
    target.gainHp(1);
    target.startDamagePopup();
    if (user.hp<=0)
        user.performCollapse();
</Custom Deselect Effect>
I have tried this code but it doesn't work 😳

same point as before, theres no showDamagePopup() thatll play for each enemy. just for the attacker

the call for performCollapse() is only done on the attacker, but nobody else. that too will have to be changed.

Code:
<Custom Deselect Effect>
if (target.result().missed || target.result().evaded)
    $gameTroop.aliveMembers().forEach(enemy => {
      enemy.gainHp(-1)
      enemy.startDamagePopup();
      if (enemy.hp<=0)
        enemy.performCollapse();
    });
</Custom Deselect Effect>
This one works perfectly now, thanks^^
I have tried this code but it doesn't work
i see that youre missing braces for your first if statement. If youre using an if and multiple statements follow it, you have to use braces to specify what should be conditional, or else itll just be the next statement. The one that i gave you doesnt need it because the only thing that follows the if is the forEach, which is one statement by itself even though itll do multiple things. But notice how in the forEach i had to use braces because it contains multiple statements in it.
the only thing thatll happen in your state specifically on a dodge is that the attacker loses an hp. the rest happens unconditionally.

But even without the braces, the gainHp and the showDamagePopup on the target should still run. ill assume that by it not working you mean that you still arent getting a damage popup for the actor? does anything else show up like extra misses or is it nothing at all?

Original thread: https://forums.rpgmakerweb.com/threads/creating-more-strange-abilities.163650/