(SOLVED) Erosion system (like Dofus)

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
Edit :
This is solved, @Magnus0808 made the plugin for me, please credit him if you are using it!


Hello everyone, I have searched all over the web for a specific plugin I can not find so I end up here!

Is it possible to create an "Erosion" system like the game Dofus with plugin or events in an RPGMaker MV game?

So, how does it work and why it is useful?
In RPG sometimes when only one character on your party is alive and this character main specialty is healing (and is better at healing itself than dealing damages) and the enemy have the same setup, the battle can be never-ending and the player only have the choice to give up (and be infuriated).

In the game Dofus, there is an Erosion system that prevents that.
Absolutely all players and all enemies have a base 10% Erosion (also called Natural Erosion).

That mean let's say the enemy A have a total of 1000 HP.
The player attack him with 200 damages.

In a game without the Erosion system, the enemy would have 800 HP remaining (with 1000 HP maximum)
But with the Erosion system, the enemy now have 800 HP (the same) but maximal HP is now 980. (He lost 10% maximum HP of 200 damages).
This works like a buff but it infinite and Maximum HP can only be recovered when battle ends.

It means that as long as there is damage inflicted, the battler will eventually end!

This kind of system is also useful again enemy that can heal themselves with a % of their max HP, reducing Max HP of the enemy will also reduce the heal they can do!

Now, what about Erosion spells?
In the game Dofus, there is also some spells that inflicts a buff on enemies that can add up more Erosion.
For example a spell that add 20% Erosion for 3 turns.
It mean now the enemy will have 30% Erosion on him (10% natural + 20% from the spell) making the fight shorter even if the player should not have come to the area and have not enough attack power.

Can we do something more advanced than Dofus?
In this game, there is no way to recover lost maximum HP until the fight is over but it actually might be a good idea to give the player a spell than can remove all or a a small portion of lost Max HP.

If a plugin is made, what would be the best option?
If a plugin is made, I think it would be super cool to be able to change the "Natural Erosion" in the plugin parameters.
(It can be from 0, so there is No Erosion to 100% so that every damage taken can not be healed)

A ceiling option for Erosion (on Dofus, the ceiling is at 50%, so even if the player is under a +70% Erosion Buff (with the 10% natural, it would mean 80% total, the player Erosion can not go above 50%). I can be changed on plugin parameters from 0 to 100.

A notetag on Actors and Enemy that can modify the Base Erosion the unit takes.
A notetag in Armors, States and Weapons that can Increase or Decrease the erosion.
A notetag in Spells that inflicts or heals a flat or a % Max HP of Ally/Enemy Erosion.

Thank you for reading me until the end!
 

Attachments

Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
This sounds interesting, though I may not have time to take it on.

You would need to indicate what plugins you are using for battle or anything else that might access Max HP, and whether this should affect those as well.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Is the erosion permanent after battle, or do the actors recover their max HP to the normal amount after a battle is over?
 

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
@Shaz I'm using Lecode's battle system but it should not be incompatible... I guess!

@Aloe Guvner Nope :
  • When the battle is finished, they keep their health percentage, which makes actually makes them gain HP because erosion is undone. Example. a character that has 1000 max HP and finishes a fight with 200/800 HP left will go back to 250/1000 hp.

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
If they finish a fight with 200/800, how do they get back to 250HP afterwards?

Please provide a link to the plugin. Whoever writes this for you can make sure they're not incompatible. That's better than "guessing" that they won't be.
 

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
@Shaz Because if you end the fight with 200/800 HP (while your max is 1000HP because you have been eroded) that means that you have 25% HP left, when the battle is over you recover your HP max (1000) but you stay at 25% of your HP (so that way you "recover" 50HP).
It might be difficult to explain, it is possible to check it out by playing the game Dofus (first area is completely free and you can test it)
I recommend using the character "iop" since he does have a spell that increase enemy erosion from the level 1 and is easy to play!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
So in addition to MaxHP going back to what it was at the end of the battle, HP also has to change, according to the %? Simple enough.

Bump this thread on Saturday morning if nobody picks up your request and I might be able to take a shot at it over the weekend. But please add a link to your battle plugin.
 

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
@Shaz Bump
I have not found any way to do this with states!
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
I am currently writting this plugin for you. I almost have a version finished I just need to add the notetags for skills/spells. When you mention they should be able to deal flat or % of max HP erosion should this amount count towards the max erosion for that attack or should it be dealt with separately?

I also have not tested for comparability with the plugin you have mentioned yet.
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
797
Reaction score
350
First Language
English
Primarily Uses
N/A
I am currently writting this plugin for you. I almost have a version finished I just need to add the notetags for skills/spells. When you mention they should be able to deal flat or % of max HP erosion should this amount count towards the max erosion for that attack or should it be dealt with separately?

I also have not tested for comparability with the plugin you have mentioned yet.
LoL
I was working on this too.
I'll leave it to you tho.
You do good work.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Maybe if people want to fill a request, they should say so. This one currently has (at least) 3 people working on it, because nobody knew someone else was doing it.
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
797
Reaction score
350
First Language
English
Primarily Uses
N/A
I did see that you were giving it a go, but didn't see any confirmation after the "Saturday Bump". But really what's the harm in more than 1 coder working on a request?
It'd be different if it was a commissioned request, but we're just doing it to do it, yes?
 

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
@Everyone You are awesome :ehappy:

@Magnus0808 That is actually a good question, I have not thought about it.
What are the pros and cons?

I think the most natural would be this case :
Enemy have 1000 HP
Actor deals a 100 HP attack with 10% base (default) and this skill have a flat 50 HP erosion.

(100 *10% = 10) + 50 -> It would become 60 HP eroded.
Enemy have now 900/940 HP

What do you think?
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
Code:
//=============================================================================
// MRP_ErosionSystem.js
//=============================================================================

/*:
 * @plugindesc ErosionSystem
 * @author Magnus0808
 *
 * @help This plugin brings an erosion system to your game!
 * There are 3 parameters to this plugin. The natural erosion rate
 * which is the base erosion rate for all attacks. You can then also
 * specify the maximum and minimum.
 *
 * E.g. with an erotion rate on 10% then if you deal 100dmg to a target with
 * 1000hp, then the target will have 900hp left like normal. However, the targets
 * maximum hp will decrease by 10 to 890hp.
 *
 * You can also make weapons, armor and statuses affect the erosion rate by using
 * the note tag <procentErosion:x.xxx> where x.xx is the number the
 * erosion rate should be increased with.
 * e.g. if you have a shield with the tag <procentErosion:-0.05> then
 * you will only be affected by an erosion rate of 5% instead of 10%
 * (assuming the Natural Erosion Rate is 10%)
 *
 * You can also add the tag to skills which will have the same effect for that
 * attack. Furthermore, you can use the note tag <flatErosion:xxxx> to inflect
 * erosion directly to the max hp with a skill!
 * E.g. if you have a skill called Bite with the note tag <flatErosion:100>
 * then everytime you use this skill the target will lose 100 maximum hp for
 * the battle. It should be noted that this does not count towards the maximum
 * erosion rate, and can therefore potentionally deal an even highr amount of
 * erosion.
 *
 * @param Natural Erosion Rate
 * @type Number
 * @decimals 3
 * @desc This is the base erosion rate in %. 1 = 100%
 * @default 0.100
 *
 * @param Max Erosion Rate
 * @type Number
 * @decimals 3
 * @desc This is the min erosion rate in %.
 * 1 = 100%
 * @default 0.500
 *
 * @param Min Erosion Rate
 * @type Number
 * @decimals 3
 * @desc This is the max erosion in %. This should always be lower than max erosion. 1 = 100%
 * @default 0.000
 *
 * @param Negative HP Regen Erosion
 * @type Boolean
 * @desc If true then negative HP regeneration deals erosion.
 * E.g. Poison (only if the total HP regen is negative)
 * @default true
 *
 * @param Can Die From Erosion
 * @type Boolean
 * @desc If true then it is possible to die from erosion! This happens if
 * when you take erosion dmg it makes your max hp become lower than 1!
 * @default false
 */
 
(function() {
    
    ErosionSystem = {};
    ErosionSystem.Parameters = PluginManager.parameters('MRP_ErosionSystem');
    ErosionSystem.baseErosion = Number(ErosionSystem.Parameters['Natural Erosion Rate']);
    ErosionSystem.maxErosion = Number(ErosionSystem.Parameters['Max Erosion Rate']);
    ErosionSystem.minErosion = Number(ErosionSystem.Parameters['Min Erosion Rate']);
    ErosionSystem.negativeRegenErosion = (String(ErosionSystem.Parameters['Negative HP Regen Erosion']) == 'true');
    ErosionSystem.dieErosion = (String(ErosionSystem.Parameters['Can Die From Erosion']) == 'true');
    
    // Changes to Game_Battler
    var old_init = Game_Battler.prototype.initMembers;
    Game_Battler.prototype.initMembers = function() {
        old_init.call(this);
        this._erosionDamaged = 0;
    };
    
    
    Game_Battler.prototype.getBaseErosionRate = function() {
        var battler;
        var baseErosion = 0;
        if(this.isEnemy()){
            battler = this.enemy();
        }else {
            battler = this.actor();
        }
        if(battler){
            if(battler.meta.baseErosion){
                baseErosion += Number(battler.meta.baseErosion);
            }else{
                baseErosion += ErosionSystem.baseErosion;
            }
            if(battler.meta.procentErosion){
                baseErosion += Number(battler.meta.procentErosion)
            }
        } else {
            baseErosion += ErosionSystem.baseErosion;
        }
        return baseErosion;
    }
    
    Game_Battler.prototype.getErosionRate = function() {
        var erosionRate = this.getBaseErosionRate();
        // Handle States
        let states = this.states();
        for(var i = 0; i < states.length; i++){
            let state = states[i];
            if(state.meta.procentErosion){
                erosionRate += Number(state.meta.procentErosion);
            }
        }
        return erosionRate;
    }
    
    Game_Battler.prototype.removeErosion = function() {
        var procentHealth = this._hp/this.mhp;
        this._paramPlus[0] += this._erosionDamaged;
        this._erosionDamaged = 0;
        this._hp =  Math.floor(procentHealth * this.paramBase(0));       
    }

    Game_Battler.prototype.applyErosion = function(value, action) {
        var erosionRate = this.getErosionRate();
        var flatErosion = 0;
        
        if(this._leTbsDirectionalDmg) value += Math.floor(value * this._leTbsDirectionalDmg); // Compatible with LeTBS directional dmg
        
        // Handle Skills
        if(action){
            var dataClass = action._item._dataClass;
            if(dataClass == 'skill'){
                var skill = $dataSkills[action._item._itemId];
                if(skill.meta.procentErosion){
                    erosionRate += Number(skill.meta.procentErosion);
                }
                if(skill.meta.flatErosion){
                    flatErosion += Number(skill.meta.flatErosion);
                }
            }
        }
        
        this.applyProcentErosion(value, erosionRate);
        this.applyFlatErosion(flatErosion);
    }
    
    Game_Battler.prototype.applyProcentErosion = function(value, erosionRate){
        if(erosionRate < ErosionSystem.minErosion) erosionRate = ErosionSystem.minErosion;
        if(erosionRate > ErosionSystem.maxErosion) erosionRate = ErosionSystem.maxErosion;
        var erosionDmg = value * erosionRate;
        this.applyFlatErosion(erosionDmg);
    }
    
    Game_Battler.prototype.applyFlatErosion = function(value){
        if(this._erosionDamaged + value <= 0){ // The flat erosion removes all erosion
            this._paramPlus[0] += this._erosionDamaged;
            this._erosionDamaged = 0;
        } else {
            this._erosionDamaged += value;
            this._paramPlus[0] -= value;
        }
        if(this._hp > this.mhp) this._hp = this.mhp;
        if(ErosionSystem.dieErosion && (this.paramBase(0) + this._paramPlus[0]) <= 0){
            this.die();
        }
    }
    
    Game_Battler.prototype.regenerateHp = function() {
        var value = Math.floor(this.mhp * this.hrg);
        value = Math.max(value, -this.maxSlipDamage());
        if (value !== 0) {
            this.gainHp(value);
        }
        if(ErosionSystem.negativeRegenErosion && value < 0){ // takes dmg
            this.applyErosion(Math.abs(value), null);
        }
    };
    
    
    // Changes to Actor
    Game_Actor.prototype.getErosionRate = function() {
        var erosionRate = Game_Battler.prototype.getErosionRate.call(this);
        var actor = this.actor();
        if(actor){
            var equips = actor.equips;
            for(var i = 0; i < equips.length; i++){
                var equipment;
                if (i == 0){ // is Weapon
                    equipment = $dataWeapons[equips[i]];
                } else { // is armor
                    equipment = $dataArmors[equips[i]];
                }
                
                if(equipment){
                    if(equipment.meta.procentErosion){
                        erosionRate += Number(equipment.meta.procentErosion);
                    }
                }
            }
        }
        return erosionRate;
    }
    
    // Handles calling the erosion
    Game_Action.prototype.apply = function(target) {
        var result = target.result();
        this.subject().clearResult();
        result.clear();
        result.used = this.testApply(target);
        result.missed = (result.used && Math.random() >= this.itemHit(target));
        result.evaded = (!result.missed && Math.random() < this.itemEva(target));
        result.physical = this.isPhysical();
        result.drain = this.isDrain();
        if (result.i****()) {
            if (this.item().damage.type > 0) {
                result.critical = (Math.random() < this.itemCri(target));
                var value = this.makeDamageValue(target, result.critical);
                this.executeDamage(target, value);
                target.applyErosion(value, this);
            } else {
                target.applyErosion(0, this);
            }
            this.item().effects.forEach(function(effect) {
                this.applyItemEffect(target, effect);
            }, this);
            this.applyItemUserEffect(target);
        }
    };
    
    // Handles removing erosion after battle
    BattleManager.endBattle = function(result) {
        this._phase = 'battleEnd';
        if (this._eventCallback) {
            this._eventCallback(result);
        }
        if (result === 0) {
            $gameSystem.onBattleWin();
        } else if (this._escaped) {
            $gameSystem.onBattleEscape();
        }
        $gameParty.removeErosion();
    };
    
    Game_Party.prototype.removeErosion = function() {
        var actors = this.allMembers();
        for(var i = 0; i < actors.length; i++){
            actors[i].removeErosion();
        }
    };
    
})();
Hi, I went with the approach you found most natural.
Here is the first version of the plugin. It might still have some bugs, and I still haven't checked for any compatibility with the plugin you mentioned yet. It does not contain every feature I have in mind yet either, however I am about to go to bed for today as it is almost 6AM here, and I thought you might want to check out its current state.
 

Attachments

Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
what's the harm in more than 1 coder working on a request?
that we only have a limited amount of time, and we could have all been working on different requests :)

I'm glad you got it done. Sooner than I would have.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top