RMMZ If a character is in your party, when enemies attack they will lose HP.

Mechazard

Warper
Member
Joined
May 25, 2022
Messages
2
Reaction score
1
First Language
Fr
Primarily Uses
RMMZ
Hi everyone !

I'm searching for a script as described in the title.

I explain ;
One of my character is a Ninja and he's using makibishis
(little iron stars ninjas drop on the floor to slow down enemies "irl")
So I would like to reproduce this in RPGmaker MZ ;

when an enemy attacks the party with the ninja in, he will lose -5% HP
exepted if this enemy can fly
;

so I would like to add this malus only on certain kind of enemies.

I installed the VisuStella's plugin (amazing btw) but it's working for states and not for passiv skill who can reduce enemies life.

I also tried to work with conditionnal branch but maybe didn't see the right things .

Anyway here I am now looking for a script or for someone who could help how to do.

(I saw nothing on google btw maybe I didn't search well but I'm not english so maybe there are some subtilities with keywords I may don't know)

Thx for your answers ! Hope it will be helpful for someone internet else too !
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,525
Reaction score
2,888
First Language
English
Primarily Uses
RMMV
I installed the VisuStella's plugin (amazing btw) but it's working for states and not for passiv skill who can reduce enemies life.
I would do this with states.

There are different ways you could do it, putting a passive state on the entire party that triggers when they're the target of an attack (in which case I would also make "flying" a passive state that you put on specific enemies to bypass the code).

Or you could put a turn 0 event into each of your troops that checks for the party member to know this skill and then apply a state to each of the enemies that you decide should have it, and it triggers code to hurt them after they make attacks.

Either way you'll need some JavaScript in there. You could check out Yanfly's Tip and Trick for Thornmail which might be a helpful start.
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
394
Reaction score
360
First Language
English
Primarily Uses
RMMZ
This should do what you are asking for. (Caveat: it's late here and I haven't thoroughly tested).

JavaScript:
const Mechazard_executeHpDamage = Game_Action.prototype.executeHpDamage;
Game_Action.prototype.executeHpDamage = function(target, value) {
    Mechazard_executeHpDamage.call(this, target, value);
    if (BattleManager._subject.isEnemy() && target.isActor() && $gameParty.hasNinja()) {
        const enemy = BattleManager._subject;
        if (!enemy.isFlying()) {
            const damage = Math.max(1, Math.round(enemy.mhp * 0.05));
            enemy.gainHp(-damage);
            enemy.startDamagePopup();
        }
    }
}
Game_Party.prototype.hasNinja = function() {
    const ninjaClassId = 3; // change 3 to your ninja class ID
    for (const actor of this.battleMembers()) {
        if (actor._classId === ninjaClassId) return true;
    }
}
Game_Enemy.prototype.isFlying = function() {
    return this.enemy().meta.Flying;
}

Add the <Flying> notetag to your flying enemies.

Might need some more details. For example, if you are using the front-view battle system you'd probably want to add a battle log window message to indicate that the effect triggered.
 

Mechazard

Warper
Member
Joined
May 25, 2022
Messages
2
Reaction score
1
First Language
Fr
Primarily Uses
RMMZ
Woaw I wasn't expected for that clean code that fast lmao this is perfect thank you very much !!
 

Latest Threads

Latest Posts

Latest Profile Posts

The main game of my trilo/saga 50%OFF on Steam..... its now or never more
I swap between Ace and MZ so I can stay fresh but - what do you mean you can use subfolders in the plugin's folder for easier organization!?
Did some new music again, praise be. To the next song!
Watch Studio Blue play Numina by starlit in our latest RPG Maker Games Critique stream starting NOW!

Forum statistics

Threads
123,139
Messages
1,154,248
Members
161,474
Latest member
nugogo555
Top