MV [SOLVED] A state that deals damage only when using skills

Hi everyone,

I'm having an issue with a custom notetag in the YEP Buffs and States Core Plugin for RPG Maker MV. My goal is to have a state that damages the target only when he selects a skill, but I don't know how to do it, because when I select a command like guard, for example, the target still gets hit by the damage. Here is my code:

JavaScript:
<State: 16>
<Custom Action End Effect>
if (target.isActor() || target.isEnemy()) {
    var dmg = Math.floor(target.mhp * 0.1);
    target.gainHp(-dmg);
    target.startDamagePopup();
    target.clearResult();
    
    // Play animation
    target.startAnimation(53);

    // Add battle log message
    BattleManager.addText(target.name() + " suffers from its wounds.");

    if (target.hp <= 0) {
        target.performCollapse();
    }
}
</Custom Action End Effect>

the guard command uses a state called "guard" (ID2) that triggers a skill named "rest" (Skill ID2), so damage should occur only when a skill is used (what I believe to be the standard for RPG maker when you start a new project).
you need to clarify what you want because youre using terms differently than how the engine uses them and havent defined them. everything in the skills section of the database is a skill. Guard and Attack are the first two skills there. Any action that a battler takes that isnt a skill is an item.

are you trying to make the state ignore your guard and attack skills, or is "skill" classification of skills that you use?
Sorry, let me try to clarify. First, let try to say what I want to do.

I'm creating a bleeding state. So instead of doing damage over time, I want it to deals damage every time the target performs a skill, and only a skill. I kind of accomplished that, but if I select the guard command or items on the battle menu, the actor receives damage from the state, and I don't want that.

are you trying to make the state ignore your guard and attack skills, or is "skill" classification of skills that you use?
I'm using my battle menu like this (but is temporary):

Skills
Guard
Item

Only the skills inside the command skills will activate the bleeding state damage. Guard and Item, will not.
Only the skills inside the command skills will activate the bleeding state damage. Guard and Item, will not.
so all skills are applicable except Guard then?

Code:
<Custom Action End Effect>
var action = user.currentAction()
if (action && action.isSkill() && !action.isGuard()) {
    var dmg = Math.floor(target.mhp * 0.1);
    target.gainHp(-dmg);
    target.startDamagePopup();
    target.clearResult();
    
    // Play animation
    target.startAnimation(53);

    // Add battle log message
    BattleManager.addText(target.name() + " suffers from its wounds.");

    if (target.hp <= 0) {
        target.performCollapse();
    }
}
</Custom Action End Effect>
IsSkill() checks if the action is a skill (as opposed to an item) and isGuard() checks if the skill is the actor's guard skill - the same as the one that shows up on the actor command window
Nothing is working now :/ damage is not being dealt when selecting a skill, guard or item
did you save your project before testing it and use a new game file instead of loading one?

i tested it myself before posting it and just tried it again to be sure. it works just fine for me
Yes, I just tried that. For some reason is not working for me. I tested in a new game file also and had the same result. 🙁
can you provide a screenshot of your plugin manager and a screenshot of your state as it is inside the database?
Sure!

Screenshot 2025-02-17 230833.png


Screenshot 2025-02-17 231155.png
Bump
i kinda forgot this thread was going on. my bad 😍

usually when a screenshot of the plugin manager is asked for, you need to take however many is needed to show the entire list. from the portion youve shown the yanfly plugins are in the correct order, so ill trust that that isnt an issue further down.

try this then. im assuming the action is being cleared by then. its not the case im used to seeing. the action should be defined at action start, so we'll save it in order to look at it later.
Code:
<Custom Action Start Effect>
user._curAction = user.currentAction()
</Custom Action Start Effect>

<Custom Action End Effect>
if (user._curAction){
    var action = user._curAction;
    if (action && action.isSkill() && !action.isGuard()) {
        var dmg = Math.floor(target.mhp * 0.1);
        target.gainHp(-dmg);
        target.startDamagePopup();
        target.clearResult();
      
        // Play animation
        target.startAnimation(53);
  
        // Add battle log message
        BattleManager.addText(target.name() + " suffers from its wounds.");
  
        if (target.hp <= 0) {
            target.performCollapse();
        }
    }
}
delete user._curAction;
</Custom Action End Effect>
Nice! It works perfectly! Thank you @Robro33 :kiss:

I believe that this thread can be closed then!
This thread is closed due to being marked as solved. Report the next one so we can find it easily. If you need this thread reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-a-state-that-deals-damage-only-when-using-skills.175523/