MV Failure (or Miss) message when the damage result is 0

I am developing a game where 0 equals missing an attack. Something like "The target withstood him." I already created the damage formula, everything works perfectly, the 0s appear when they have to appear.
Captura de pantalla 2021-08-09 121955.png


My problem is only "aesthetic", I would like the "failure" message to appear instead (or next to it) as when an attack fails (even though the damage was actually done and was equal to 0).

Captura de pantalla 2021-08-09 121955.png
--->
Captura de pantalla 2021-08-09 122224.png
or...
Captura de pantalla 2021-08-09 121955.jpg


In summary I would like to activate the animation (or text, I don't know what it is) of "failure" at the moment in which a 0 appears as a result of an attack damage.

Here is a list of all the plugins I have:
The plugin I use to show the damage is VE_DamagePopup
Captura de pantalla 2021-08-09 122827.png


I was hoping I could use a script and put it in a .js
Is it possible to do this?
Your images aren't showing.
Your images aren't showing.
Already solved. I don't know what happened. 🙂
Everything is possible, as the entire code for the game is in its JavaScript files (I don't say that to be pedantic, but to express that asking "is this possible" is always going to be answered with yes, the question is really how difficult or even worthwhile it is to do so). From a quick search, I don't see a plugin available that already does this, so you'll need to get or write one.

I'm not immediately familiar with that part of the game engine, but if you haven't gotten help by tonight or tomorrow, I'll take a look for you.
MrTs has a minimum dmg plugin, but there is also a work around,
when it's 0, it would be miss, which I use for the basic attack.

but setting a minimum dmg is always hits, and possible to miss.

Link can be found here: MrTs_MinDmg.
Everything is possible, as the entire code for the game is in its JavaScript files (I don't say that to be pedantic, but to express that asking "is this possible" is always going to be answered with yes, the question is really how difficult or even worthwhile it is to do so). From a quick search, I don't see a plugin available that already does this, so you'll need to get or write one.

I'm not immediately familiar with that part of the game engine, but if you haven't gotten help by tonight or tomorrow, I'll take a look for you.
Well, I suppose so, anything is possible. In any case my question would be if: is it possible to do it in a simple way?

Something like coding that every time:
If "damage value = 0" then "play bug animation".

MrTs has a minimum dmg plugin, but there is also a work around,
when it's 0, it would be miss, which I use for the basic attack.

but setting a minimum dmg is always hits, and possible to miss.

Link can be found here: MrTs_MinDmg.

Thanks, it is interesting and it will surely be useful to me later, but my problem itself is not to create that 0. Within the custom formulas that I use, the 0 is contemplated. My real problem is getting the "Miss" message.

In any case (in the little knowledge of JavaScript that I have) I could think about creating this function based on what you gave me:


(function() {

Game_Action.prototype.makeDamageValue = function(target, critical) {
var value = _Game_Action_makeDamageValue.call(this, target, critical);
return (value = 0 ? "FUNCTION THAT REPRODUCES THE MISS EFFECT" : value);
};
)();


But I am sure that this code is very badly done, it must be missing many things.

Like I say, I am very new to javacript.
I dont target the battle scene, but it is also on the dmg sheet which has MISS
on it, changing that word makes it a different one, but some might know a
way if it's 0, than its misses, but some or most use lunatic code to change
the dmg output 🙂

so you can try to look into those or on the forum, or tips and tricks on yanfly
website for some skills settings, and see if there is something close to what
you need and try to alter that part.

but "(function() { " and last line ")()" is not needed if you overwrite it.
only new functions or better alternate function of overwriting requires it.

but I wish you good luck on your project and the code/plugin you need
for your project 🙂
I dont target the battle scene, but it is also on the dmg sheet which has MISS
...
but I wish you good luck on your project and the code/plugin you need
for your project 🙂

The yanfly thing could be a solution. I will investigate it, thank you very much.

return (value = 0 ? "FUNCTION THAT REPRODUCES THE MISS EFFECT" : value);

In another case, with finishing the "return" I could find it solved. Since I could apply the formula that comes after "return" inside my custom attack formulas.

In other words, if you could find out "FUNCTION THAT REPRODUCES THE MISS EFFECT" then you might get some solution.

So ... What is "FUNCTION THAT REPRODUCES THE MISS EFFECT"? Where I can find it? And how would you write it to work after the "return"?
I cannot answer that, but return dont exactly work in the way you wrote it,
it can return a number or scene, but no idea for formula though, but someone
with much more knowledge can answer that question for the best approach 🙂
In any case (in the little knowledge of JavaScript that I have) I could think about creating this function based on what you gave me:
The biggest problem with that is that, as far as I know, anything that has to do with damage comes after the hit roll has been made. So at that point the state of the attack is a hit, you can't just make it a miss.

What needs to be done is to change the text that is put into the damage popup (the "0") to the word "Miss." If you read and follow code well enough to find that, you're good to go.
The biggest problem with that is that, as far as I know, anything that has to do with damage comes after the hit roll has been made. So at that point the state of the attack is a hit, you can't just make it a miss.

What needs to be done is to change the text that is put into the damage popup (the "0") to the word "Miss." If you read and follow code well enough to find that, you're good to go.

Exactly!

It's just what I originally thought. The problem is that this: "If you read and follow code well enough to find that" I have not managed to do it.

No matter what part I change or place, I always end up putting an error (ironically whenever there is an error in an rpg maker math formula it returns 0, even though this is not important I think).

So he needed to know where I should change ... Any ideas?

Also I discovered that the DamagePopup has a custom "miss", I have been checking all afternoon to try to reference its custom formula in that concept of "0 = miss".

But still no luck.

Here I leave the plugin and a screen amount. Maybe you guys can see something that I can't, if you'd like to check it out.

DamagePopup
Captura de pantalla 2021-08-09 193603.png
In the end I stalled. This is the code that determines when each popup appears; what is highlighted in red are things that I think could help me, but I'm still not sure what form the code would look like.

Sprite_Battler.prototype.setupDamagePopupSprites = function() {
this._damageDelay = 0;
var result = this._battler.result();
if (result.missed || result.evaded) {
this.damagePopupSprite('Miss');

}
if (result.tpAffected) {
this.tpDamagePopup(result);
}
if (result.mpAffected) {
this.mpDamagePopup(result);
}
if (result.hpAffected) {
this.hpDamagePopup(result);

}
this.addStatesPopup(result.addedStates);
this.removeStatesPopup(result.removedStates);
this.addBuffsPopup(result.addedBuffs);
this.addDebuffsPopup(result.addedDebuffs);
this.removeBuffsPopup(result.removedBuffs);
};

I do not know what else to do.

I have tried this:

Sprite_Battler.prototype.setupDamagePopupSprites = function() {
var result = this._battler.result();
if (result.hpAffected = 0) {
this.damagePopupSprite('Miss');
}
};

But it does not work. I even think it rendered the original plugin useless, so I discarded it.

Sure it has several flaws, but I don't know what they are.

I think all of this is trying to "replace" the result, causing the code to fail. Ideally, it should not replace it, just appear next to the result (0) as in the image:

Captura de pantalla 2021-08-09 121955.jpg


But I have no idea how to do something like that. In that case, if I need someone who understands javascript better. 🙁
I think you need something like,

if dmg < 0, result = miss, not equal too 0, but that is a guess otherwise,
I use just always hit, else miss 🙂 so the 0 wont show.

this is my attack formula for now: (which will be changed)

Code:
(a.atk-b.def)>20 ? (a.atk-b.def)-Math.randomInt(19) : ((a.atk-b.def)>0 ? Math.randomInt(a.atk-b.def-1)+1 : ((b.def-a.atk) >= 3 ? 0: 1))

its to complicated to tell what it exactly does, but the 0 dmg wont be showing 🙂
either dmg = 1 else miss.

but while the battle system I going to use, gets an overhaul, so this formula might
not exactly work, in the way I'm going to set it up.

but maybe it can be some of use in your case or how to accomplish on the
function you going to make.
@ShadowDragon actually has a decent solution - cap the minimum damage at 1. There are a few ways to go about that, code-wise, you could use his or Math.max()

Also I discovered that the DamagePopup has a custom "miss", I have been checking all afternoon to try to reference its custom formula in that concept of "0 = miss".
This has nothing to do with what you're trying to do. That customizes what the text looks like when your attack misses, it has nothing to do with making some specific hit result look like a miss.

I have tried this:
Sprite_Battler.prototype.setupDamagePopupSprites = function() {
var result = this._battler.result();
if (result.hpAffected = 0) {
this.damagePopupSprite('Miss');
}
};


But it does not work. I even think it rendered the original plugin useless, so I discarded it.
Yes, because your code syntax is wrong. Saying x = y is an assignment, you forced the hpAffected member variable to be equal to 0. You wanted to evaluate it to see if it's true, if (x == y) with two equal signs. Also, hpAffected does not store a number, it's a boolean, which means it will only be true or false. So...two levels of not correct on that line.

I have not used Victor's popups, but try this. In the same setupDamagePopup function you quoted above, make the first conditional look like this:
Code:
if (result.missed || result.evaded || (result.hpAffected && result.hpDamage==0)) {
      this.damagePopupSprite('Miss');
}

Then, three conditionals below,
Code:
if (result.hpAffected && result.hpDamage>0)

See if that does what you want.
Thank you very much for the help. I managed to crack quite a bit of the code and found out that what I was trying to do was accomplished in more complex ways than I could handle, and it became increasingly difficult. So change the perspective in which you were looking at things.

Customize the "0" conditions elsewhere. In the "Hit" formulas. In other words, instead of trying to generate a "miss" in the damage formula, what I did was modify the "hit" formula and condition it so that in specific circumstances the % value of "Hit" changes to 0% if did not meet the conditions (it could be said that they were the same as the damage formulas), in this way the 0 never appears because during the execution of the "HIT" formula, the result "0" is already expected and the result is never launched. damage formula, resulting in a "miss".

This is the formula I used in Hit:
conditional to overcome <= The conditions ? the result if they are met : the result if they are not met
I do not know one day it will be of use to someone. But there I leave it.

Use the VE_HitFormula plugin to achieve this. Mainly because Extra Parameter Formula the Yanfly (which also changes the HIT formula) gave me too many errors with my basic javacript code; things like a.atk or b.atk behaved strangely, also because unlike Yanfly, VictorEngines allows to place Notetags much simpler in writing and with greater freedom in objects and skills.

I am deeply grateful to those who commented, and this first experience encouraged me to be more active around here and not just "see" how I have been doing the last 5 years. Yes, I was only 5 watching in the shadows 🤣.

I can give this issue as solved.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/failure-or-miss-message-when-the-damage-result-is-0.139422/