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,930
Reaction score
3,130
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
397
Reaction score
365
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 Profile Posts

ScreenShot_8_7_2022_0_23_50.png
Unleash the hype beam...
hjyI4gQ.png


Made an attachment for the HUD that I can control the visibility of with switches. This tracks the current amount of items needed to finish a quest. Once you meet the requisite, it turns into "complete" because I figured it would be a good way to tell the player they're done. Also it stops numbers from going off of the UI.

Tortoise attacks black shoes. Hope everyone is doing well. :)
Banging my head on a wall balancing.
Game Making Every Day #13 :kaosalute:

Forum statistics

Threads
124,313
Messages
1,162,712
Members
163,114
Latest member
pinomedio
Top