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,583
Reaction score
2,926
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
361
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


New Boss Attacks for Soul Hero Adventure:
1,Aim and shoot
2,Boulders falling frenzy
3,Throwing Fireballs
4,Chasing Magical Traps
5,Lasers attack of 360-degree
Pokemon AI Logic: "Enemy is weak to Fire, I better use Rain Dance to make fire type moves less effective. I should just always cast Rain Dance first no matter what, even though it's a niche move that I'm not set up to exploit."
After a little test with the parallax mapping, found it lags like a cat on a leash. Instead of the original idea to parallax map the entirety of the ship, I guess I'll settle for editing the tilesets. Probably should have done that first. :kaosigh:
So I kinda came back and learned how to mod other RPG Maker games so... Hello everyone!
Captura-de-pantalla-475.png
Version 1.0.1 done! Now finally free time... oh
Capture.PNG

Forum statistics

Threads
123,283
Messages
1,155,485
Members
161,685
Latest member
wrmybr
Top