Floor Damage

● ARCHIVED · READ-ONLY
Started by Jeremiah Eastman 3 posts View original ↗
  1. Hey there gang I have been trying to figure something out and I think I am on the right path but have not yet been able to achieve what I am after. So I thought I would run it by the community and see if anyone had any ideas here that might help me. Basically what I am after is a easy way to stop floor damage on the non battle party group members, in other word the ones not shown walking behind you when on the map.

    I have achieved this through a big complex, there are a lot of recruits in my game, parallel process. I believe I can edit the rpg_objects.js however to accomplish this without the need for the big parallel. What I am trying to change is,

    Game_Actor.prototype.performMapDamage = function() {
    if (!$gameParty.inBattle()) {
    $gameScreen.startFlashForDamage();
    }
    };


    I have been trying to change that line to something like this,

    Game_Actor.prototype.performMapDamage = function() {
    if (!$gameParty.inBattle && .isbattleMember()) {
    $gameScreen.startFlashForDamage();
    }
    };

    I have tried many different ways to alter the code but haven't had any luck yet. If anyone has any suggestion I would love to hear them I may be on the wrong path completely though but hope not.:smile: Thanks much for taking a look.

    Edit:
    Side note I also tried with Yanflys passive states but couldn't get it to recognize any form of .battleMembers.
  2. As you can see, performMapDamage only "performs" the visual effects. The function you're looking for is actually executeFloorDamage:
    Code:
    Game_Actor.prototype.executeFloorDamage = function() {
        var damage = Math.floor(this.basicFloorDamage() * this.fdr);
        damage = Math.min(damage, this.maxFloorDamage());
        this.gainHp(-damage);
        if (damage > 0) {
            this.performMapDamage();
        }
    };
    It's better to avoid editing the base code directly. Plugins can override base functions and can be turned on or off at will. You can also tell the code to "remember" the original function, which can then be invoked in a new context; this is called aliasing and is much better in terms of compatibility.

    Here's an example of how you could alias the map damage function to restrict floor damage to battle participants (just save it as a .js file and import as you would with any other plugin):
    Code:
    _Game_Actor_executeFloorDamage = Game_Actor.prototype.executeFloorDamage;
    Game_Actor.prototype.executeFloorDamage = function() {
        if (this.isBattleMember()) _Game_Actor_executeFloorDamage.call(this);
    };
    What does this do? The first line creates the alias: it remembers the old version of this function so we can refer to it later. Then we replace the function with our own version, which says "run the old version of this function only if this actor takes part in battle".
  3. Freaking amazing! Thank you so much for setting me straight on this, and it will clear up some messy parallel processes which I have been wanting to fix for a long time now.:smile: I realized last night that I was probably trying to affect the wrong line of code and the one you pointed to was likely the right one but had no idea how to alter that portion correctly. This is a big one for my, I am going to add you in the special thanks section of my games credits.:smile: Also big thanks for the explainer, I am trying to learn this stuff while I make my game rather than before and more and more I see I am doing this backwards hehe.