MV How to use the Unused portion of Damage.png spritesheet

Hey all,

To be clear, I mean this spritesheet:

1755728675538.png


The red box is the area I'm interested in. I'm not currently using a plugin to change the damage pop-ups (Yanfly doesn't have one and the one I tried caused conflicts, as I recall) so I simply chose to edit the spritesheet to change colors/font (not pictured).

How do I call this area? Or maybe just point me to where/how the "Miss" function works so I can try to figure it out. My idea is to have text pop up that says something like "No Effect" if an attack deals 0 damage (or 0 MP damage).
How do I call this area? Or maybe just point me to where/how the "Miss" function works so I can try to figure it out. My idea is to have text pop up that says something like "No Effect" if an attack deals 0 damage (or 0 MP damage).
you can start by looking for Sprite_Damage.prototype.createMiss within sprites.js and seeing where its called. the process should be the same, but you would have to make a slight adjustment to what portion of the sheet to use to make the plugin for your new popup
you can start by looking for Sprite_Damage.prototype.createMiss within sprites.js and seeing where its called. the process should be the same, but you would have to make a slight adjustment to what portion of the sheet to use to make the plugin for your new popup

So I've been fiddling with this by making a new plugin. It looks like this:

JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    var result = target.result();
    if (result.missed || result.evaded) {
        this.createMiss();
    } else if (result.hpAffected && result.hpDamage !== 0) {
        this.createDigits(0, result.hpDamage);
    } else if (target.isAlive() && result.mpDamage !== 0) {
        this.createDigits(2, result.mpDamage);
    } else if (result.hpDamage === 0 && target.isAlive() && result.mpDamage === 0) {
        this.createNofx();
    }
    if (result.critical) {
        this.setupCriticalEffect();
    }
};

Sprite_Damage.prototype.createMiss = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(0, 4 * h, 4 * w, h);
    sprite.dy = 0;
};   
    
Sprite_Damage.prototype.createNofx = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(4 * w, 4 * h, 4 * w, h);
    sprite.dy = 0;
};

Now I have a few problems. First, when my "Nofx" function is triggered, it never stops:
1755732315704.png


The "ABCD" is just placeholder so I can figure out if I'm calling the right part of the spritesheet.

The other problem is that Nofx seems to trigger on any attack. Thankfully, it doesn't trigger on an attack that has no damage component, so that's nice.

So I don't understand the conditions in the original apparently. But also I think there's an issue with how MP damage is recognized. Since this target has no MP to begin with, I'm not sure if dealing "0 MP damage" makes sense to the game.

Spoiler: How to call from the spritesheet
For those interested, I did figure out the way to call parts of the spritesheet. It's in the sprite.setFrame part.

The first thing to understand is that the spritesheet is being divided horizontally by 10 and vertically by 5. So if I say "4th position" that would mean 3 since 0 is in the first position.

The first variable is the horizontal starting point. By putting "4 * w" it starts at the 4th position.

The next variable is the height which should not be changed if using the last row of the normal spritesheet.

The third variable is the length of what you are showing. "4 * w" means it is 4 digits long. Since I changed the word "miss" to "parry" I will likely change this to "5 * w" since it is 5 letters long.

I don't know what the last variable does lol
Now I have a few problems. First, when my "Nofx" function is triggered, it never stops
try adding a result.isHit() in your condition. iirc many damage popups are created in battle, but most dont actually gain a sprite to display and not all of them are done as a result of being targeted by an action. that and also I think popups for actors are still made in front view even though theyre not displayed.
The other problem is that Nofx seems to trigger on any attack.
when exactly do you want it to play? so far with that youve shown it seems to be on any skill that fails to either do hp or mp damage but should? is there more to it?
you could probably be stricter with the condition and add in result.hpAffected

I don't know what the last variable does lol
its x position, y position, width, and height in that order. normally height wouldnt be anything other than the digit height since everything is a uniform height, but if you wanted to completely redo the damage sheet and specific popups could be bigger, then there you go
Test stuff in a minimal environment first, i.e. disable all other plugins that aren't strictly necessary for the new one to function.
  • If it works under those conditions, then you can gradually re-enable plugins to try to discover possible conflicts. (Note that a conflict can occur between more than 2 plugins; also, sometimes a plugin conflict can be fixed simply by changing the load order.)

  • If not, then at least you know that you're looking for a solution in the core scripts.
try adding a result.isHit() in your condition.

This has given me a lot more success. It now looks like this:

JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    var result = target.result();
    if (result.missed || result.evaded) {
        this.createMiss();
    } else if (result.hpAffected && result.isHit()) {
        this.createDigits(0, result.hpDamage);
    } else if (target.isAlive() && result.mpDamage !== 0) {
        this.createDigits(2, result.mpDamage);
    } else if (result.hpDamage === 0 && target.isAlive() && result.mpDamage === 0 && result.isHit()) {
        this.createNofx();
    }
    if (result.critical) {
        this.setupCriticalEffect();
    }
};

Sprite_Damage.prototype.createMiss = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(0, 4 * h, 4 * w, h);
    sprite.dy = 0;
};   
    
Sprite_Damage.prototype.createNofx = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(4 * w, 4 * h, 4 * w, h);
    sprite.dy = 0;
};

The new problem is that when numbers pop up they fly up and off the screen...

Test stuff in a minimal environment first, i.e. disable all other plugins that aren't strictly necessary for the new one to function.

...which was so baffling I had to try this. I had no reason to think there was a plugin conflict, but I guess so. The code I have above works perfectly in a blank project.

After some trial and error it turns out to be Yanfly's Battle Engine Core. There's a whole section covering this function in there. Needless to say, it would be quite unrealistic to remove such a plugin this late into development over a simple QoL feature.

Trying to work with this seems to be a bit of a tangled web. He has this new chunk in there: this._result = target.shiftDamagePopup(); which seems to point to this:

JavaScript:
Game_Battler.prototype.shiftDamagePopup = function() {
    if (!this._damagePopup) this.clearDamagePopup();
    return this._damagePopup.shift();
};

This kind of code just looks circular to me and I never understand what it's doing.
Just passing by but have you tried inserting "this._result = target.shiftDamagePopup();" in the beginning of Sprite_Damage.prototype.setup in your plugin (iow account for the overwrite Yamfly made in YEP_BattleEngineCore.js)?

Also maybe edit thread title to match the actual question...
Just throwing this out there, have you tried SRD's pop-up customizer?
Yeah what @Canned_Dinosaur said, don't overwrite the stuff that Yanfly already overwrote. Also, since it creates digits for 0 (hpAffected is set to true) shouldn't you also add a check to the line (EDIT: condition) where it creates digits for hp damage that result.hpDamage !== 0
Just passing by but have you tried inserting "this._result = target.shiftDamagePopup();" in the beginning of Sprite_Damage.prototype.setup in your plugin (iow account for the overwrite Yamfly made in YEP_BattleEngineCore.js)?

When I overwrite the yanfly overwrite, it just seems to break the plugin and it returns to default functionality. I believe there are safeties like that in Yanfly's stuff...

JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    this._result = target.shiftDamagePopup();
    var result = this._result;
    if (result.missed || result.evaded) {
        this.createMiss();
    } else if (result.hpAffected && result.hpDamage !== 0) {
        this.createDigits(0, result.hpDamage);
    } else if (target.isAlive() && result.mpDamage !== 0) {
        this.createDigits(2, result.mpDamage);
    } else if (result.hpDamage == 0 && target.isAlive() && result.mpDamage == 0 && result.isHit()) {
        this.createNofx();
    }
    if (result.critical) {
        this.setupCriticalEffect();
    }
};

Also maybe edit thread title to match the actual question...
Uhhh, I'll try?
Just throwing this out there, have you tried SRD's pop-up customizer?
I'm pretty sure this is the one I tried that had issues. IIRC, it broke DoT's/HoT's and maybe some other Yanfly tricky stuff.
Yeah what @Canned_Dinosaur said, don't overwrite the stuff that Yanfly already overwrote. Also, since it creates digits for 0 (hpAffected is set to true) shouldn't you also add a check to the line (EDIT: condition) where it creates digits for hp damage that result.hpDamage !== 0
It sounds like you're saying to do the opposite of what Canned said? Just having hpAffected for that line is just how it is by default. I can add a more specific condition (shown above) but that doesn't seem to make a difference here.

I thought I found another line of code to look at in Yanfly's stuff last night but now I can't find it, agh!
No I mean I tested it yesterday and it seemed to work for me (unless I misunderstood something). I have Yanfly stuff and with this it showed "no effect" when I made an attack deal 0 damage. Under Yanfly plugins, a plugin with:


Sprite_Damage.prototype.setup = function(target) {
this._result = target.shiftDamagePopup();
var result = this._result;
if (result.missed || result.evaded) {
this.createMiss();
} else if (result.hpAffected && result.hpDamage !== 0) {
this.createDigits(0, result.hpDamage);
} else if (target.isAlive() && result.mpDamage !== 0) {
this.createDigits(2, result.mpDamage);
} else if (result.hpDamage === 0 && target.isAlive() && result.mpDamage === 0 && result.isHit()) {
this.createNofx();
}
if (result.critical) {
this.setupCriticalEffect();
}
};


Sprite_Damage.prototype.createNofx = function() {
var w = this.digitWidth();
var h = this.digitHeight();
var sprite = this.createChildSprite();
sprite.setFrame(4 * w, 4 * h, 4 * w, h);
sprite.dy = 0;
};


EDIT: And unless I'm again misunderstanding something, I don't get how that one line wouldn't make a difference? Like if by default it shows "0" and you want it to show "no effect", then of course you have to make it not show the "0", if you have a row of if else if statements?
Oh, dangit. Sounds like the hunt begins to find another plugin overwriting then. Might be an obfuscated one. Agh!

I tested an empty project but I didn't test an empty project with just Yanfly battle engine core :headshake:
EDIT: And unless I'm again misunderstanding something, I don't get how that one line wouldn't make a difference? Like if by default it shows "0" and you want it to show "no effect", then of course you have to make it not show the "0", if you have a row of if else if statements?
When you deal 0 MP damage there is no pop-up. I'm fine with HP damage showing zero, although I think that's impossible in my game since all damage reduction is multiplicative and never totals 100% (and never risks rounding down to 0... I think).

I do have an alternative idea. Using yanfly's action sequence to check the damage result and play a failure animation if 0. I think that's possible? But not sure how it works if the attack is an "all enemies." It wouldn't be too terrible to go this route since I have so few MP damaging skills.
No I mean I tested it yesterday and it seemed to work for me (unless I misunderstood something). I have Yanfly stuff and with this it showed "no effect" when I made an attack deal 0 damage. Under Yanfly plugins, a plugin with:
I should have tested this for myself to understand what "Yanfly stuff" is. I went on a witchhunt to find any other plugin that messes with the Sprite_Damage function. Kept coming back to Battle Engine Core.

So I turned plugins on and off one by one in an empty project... it's gotta be battle engine core lol

If I don't have it turned on, this works fine:

JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    var result = target.result();
    etc

Which makes sense because that's how it looks in rpg_sprites.js. If I turn on Battle Engine, the sprites start to slide upward off the screen as described. So, I tried this one:

JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    this._result = target.shiftDamagePopup();
    var result = this._result;
    etc

This makes it stop working altogether and just does default functions, making me think some Yanfly catchall is disabling the plugin or something.

Again, there's this bit of code in the battle core. But I tried going so far as to comment it out and it still causes var result = target.result(); to make popup's scroll off the screen.

JavaScript:
Game_Battler.prototype.shiftDamagePopup = function() {
    if (!this._damagePopup) this.clearDamagePopup();
    return this._damagePopup.shift();
};

The last pieces of code I see in battle engine core are these:

JavaScript:
Game_Battler.prototype.startDamagePopup = function() {
    var result = this.result();
    if (result.missed || result.evaded) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.hpAffected) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.mpDamage !== 0) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      this._damagePopup.push(copyResult);
    }
};

and

JavaScript:
Sprite_Battler.prototype.setupDamagePopup = function() {
    if (this._battler.isDamagePopupRequested()) {
      if (this._battler.isSpriteVisible()) {
        var sprite = new Sprite_Damage();
        sprite.x = this.x + this.damageOffsetX();
        sprite.y = this.y + this.damageOffsetY();
        sprite.setup(this._battler);
        this.pushDamageSprite(sprite);
        BattleManager._spriteset.addChild(sprite);
        this._battler.clearResult();
      }
    } else {
      this._battler.clearDamagePopup();
    }
};

But I don't know. Something is causing it to shift the popup endlessly but I don't know JS enough to make heads or tails of this.
Something is causing it to shift the popup endlessly
the term shift here has nothing to do with movement. yanfly's battle engine turns the _damage popup property into an array because it allows for multihits and battlers having multiple popups. shifting within an array refers grabbing and removing the first element

So I turned plugins on and off one by one in an empty project... it's gotta be battle engine core lol
ive tried the version of setup shown in post 10 and the rest from post 6 in a project with the battle engine core and it looks fine. is your battle engine core version 1.51 and are you sure youve made no direct alterations to it or any core js file?

This makes it stop working altogether and just does default functions, making me think some Yanfly catchall is disabling the plugin or something.
are you sure there wasnt an error there when you did it? a syntax error or some other error within the file that gets caught on compile would invalidate thee entire plugin.
Well now I'm really confused. Two people are sure it works. I think at this point there's just something missing here.

What are you using for the "Nofx" part? Here's what my damage.png looks like:

1756404609309.png


So when I use an MP damage attack but it deals 0 damage on hit, I should be seeing something from the placeholder "ABCDEF" section.

is your battle engine core version 1.51 and are you sure youve made no direct alterations to it or any core js file?
It turns out both my battle engine core and yanfly core were a version behind. Nevertheless, this empty project has both redownloaded from itch at the most recent versions and still no luck.

The other question is: how are you testing this? I just made an attack that deals "1 - b.def" damage as MP damage. I'm attacking a bat enemy who has 100 mmp and 1 def.
So when I use an MP damage attack but it deals 0 damage on hit, I should be seeing something from the placeholder "ABCDEF" section.
ah, that'd do it. apologies for the gaslighting session. i didnt realize you were checking out mp damage popups and i only looked at hp. I cant check rn but just reading though what you shared i assume theres no popup on mp damage then?
take a look at startDamagePopup. it only makes an mp popup if the mp damage isnt 0. theres no mpAffected property you can use (without making it at least) to tell if the skill called gainMp and failed to do damage. your adjustments would have to start there
I'll just note that I haven't really followed this and earlier I just quickly tested it for hp damage. When replying I wasn't aware that you wanted it for mp damage. So I'm not claiming that it works for that (sorry if that caused confusion).

I quickly peeked at Yanfly Battle Core and there's a startDamagePopup function that only seems to do something if mpDamage !== 0, so I guess you'd have to do something with that and maybe other stuff too, but I don't have motivation to try anything at the moment.
take a look at startDamagePopup. it only makes an mp popup if the mp damage isnt 0. theres no mpAffected property you can use (without making it at least) to tell if the skill called gainMp and failed to do damage. your adjustments would have to start there

Alright, I found a thing and here's what I added:

JavaScript:
Game_Battler.prototype.startDamagePopup = function() {
    var result = this.result();
    if (result.missed || result.evaded) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.hpAffected) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.mpDamage > 0) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      this._damagePopup.push(copyResult);
    }
    if (result.mpDamage == 0 && result.hpAffected == 0 && result.isHit()) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }  
};

So far this seems to work, although this is dangerous because the purpose of this function is confusing to me so not sure if I'm breaking something, heh. Basically I added the last if condition so that it would recognize the mpdamage = 0 scenario.

I'll do more testing later, but I may have it now!

EDIT:
Further testing has found a new problem: skills that don't do any kind of damage at all.

How do I distinguish between an attack that tried to do damage and ended up doing 0, and an attack that never could have dealt damage to begin with?
How do I distinguish between an attack that tried to do damage and ended up doing 0, and an attack that never could have dealt damage to begin with?
thats what the hpAffected property for results is for. skills that affect hp call gainHp on the battler regardless of value, and having used that function at all makes that property true in the target's result.
so if the property is true but the hp damage is 0, then the conclusion would be that something tried to change the hp of the battler and failed to do so. If the property is false, then the skill never tried to touch their hp
@Robro33 Does that property consider MP damage, though? It seems like it doesn't. And I don't think mpAffected exists? I have used the condition "isMpEffect()" in a state before, but it doesn't seem to work in a plugin. I guess that's only a Yanfly notetag thing, or I'm getting the syntax wrong somehow.

Anyway, here's how far I've gotten. I've tried to make the conditions more precise so that it's checking whether I'm doing + or - damage, 0 damage, or miss/evade. But for some reason what I have is doing nothing for the Nofx part, but everything else works:

Spoiler: This is getting long
JavaScript:
Sprite_Damage.prototype.setup = function(target) {
    this._result = target.shiftDamagePopup();
    var result = this._result;
    if (result.missed || result.evaded) {
        this.createMiss();
    } else if (result.hpDamage !== 0 && result.isHit()) {
        this.createDigits(0, result.hpDamage);
    } else if (target.isAlive() && result.mpDamage !== 0) {
        this.createDigits(2, result.mpDamage);
    } else if (result.hpAffected && result.hpDamage == 0 && target.isAlive() && result.mpDamage == 0 && result.isHit()) {
        this.createNofx();
    }
    if (result.critical) {
        this.setupCriticalEffect();
    }
};

Sprite_Damage.prototype.createMiss = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(0, 4 * h, 4 * w, h);
    sprite.dy = 0;
};   
    
Sprite_Damage.prototype.createNofx = function() {
    var w = this.digitWidth();
    var h = this.digitHeight();
    var sprite = this.createChildSprite();
    sprite.setFrame(4 * w, 4 * h, 4 * w, h);
    sprite.dy = 0;
};


Game_Battler.prototype.startDamagePopup = function() {
    var result = this.result();
    if (result.missed || result.evaded) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.hpDamage !== 0) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }
    if (result.mpDamage !== 0) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.hpAffected = false;
      this._damagePopup.push(copyResult);
    }
    if (result.hpAffected && result.mpDamage == 0 && result.hpDamage == 0 && result.isHit()) {
      var copyResult = JsonEx.makeDeepCopy(result);
      copyResult.mpDamage = 0;
      this._damagePopup.push(copyResult);
    }   
};

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-the-unused-portion-of-damage-png-spritesheet.179677/