Enemy Equipment Durability

Hi. I'm making a game in which everyone is wearing armour that needs to be broken through before any damage can be caused.

I have it set up using YEP_X_ItemDurability for the actors. They have armour and DEF set up so that it causes the damage to be 0, but after it is hit a number of times it breaks, and then the damage takes effect.

However, for the sake of game play, and having fun smashing the enemies stuff just like they smash yours, I also need this durability aspect to happen to the enemies.

The function would be:

You need to hit each individual enemy a number of times, causing 0 DMG, before a message comes up that says "enemy 1's armour breaks", and then the enemy's DEF will be lowered X amount, and this would result in the DMG being raised.

Ideally, it would be stackable, too. So you would continue to break off bits of armour with each attack, and then their DEF would get even lower after a certain amount of more attacks.

And it needs to be individual for each enemy. So that would mean using a variable that counts all hits and lowers all DEF wouldn't work. It needs to be like 'slime 1 has been hit 3 times, therefore slime 1 is affected by DEF lowered'

Perhaps the solution is creating invisible states that stack, but I can't figure out which ones they would be.

Thanks.
I don't see why you'd need more than one state. You'll need Yanfly's Buffs & States Core.

Create a Turn 0 troop event that gives every enemy a state. In that state you put these notetags:
Code:
<Custom Apply Effect>
user.armor = 10;
</Custom Apply Effect>

<Custom React Effect>
if (target.armor > 5)
{
    value = 0;
    if (--target.armor == 5)
        SceneManager._scene._logWindow.addText(target.name() + "'s armor breaks!");
}
else
{
    value = Math.round(value * .75);
    if (--target.armor == 0)
    {
        SceneManager._scene._logWindow.addText(target.name() + "'s armor is destroyed!");
        target.removeState(stateId);
    }
}
</Custom React Effect>

That makes the enemy start with 10 armor points. They take no damage from the first five hits, after which the armor breaks. Then they start taking 75% of the attack's damage until five more hits destroys the armor and they take full damage.

Modify the numbers however you feel appropriate.
Hmmm... It didn't work.

I put it in exactly as you say, the state is applied to the enemies, but...

They still receive full damage, and the 'armor breaks' message never appears.

Sorry.
Do you
- have the required plugin installed?
- have it in the correct place in your plugin manager according to the list on the Yanfly Engine Plugins Web site?
- save your project and start a new game, not load a save?

If you can verify all of that, press F8 during the game, go to the Console tab, see if there are any errors.
Yeah, I did all that. Still nothing.

So, I created a new project and stuck the code in to test it out and it does work there, so it must be something I've done with my other plugins that are making it not work. I'll have to poke around and see what might be affecting it. But thank you thank you thank you! Looks perfect!!

Also... I was also wondering what the code would be to add a 'smash' sound affect when the armor breaks? If it's not too much trouble to ask.
Also... I was also wondering what the code would be to add a 'smash' sound affect when the armor breaks? If it's not too much trouble to ask.
stick this before the message line
Code:
AudioManager.playSe({name:"Sound", pan:0, pitch:100, volume:100});
just replace Sound with the smash sound effect's filename without the extension. keep the quotations
Edit: forgot the function takes an object. changed it accordingly

Original thread: https://forums.rpgmakerweb.com/threads/enemy-equipment-durability.164748/