RMMV Damage Formula - ideas and help

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,483
Reaction score
1,371
First Language
English
Primarily Uses
RMMV
I had a feeling it might be failing at the enemy level check, hence the console log test. While enemies don't have levels by default, but you can still use that tag to make the comparison as though they did:

Code:
a.level > (+b.enemy().meta.Level || 1) ? b.hp : 0
Try that. No plugin even required for it to work, either. However, <Level: x> is case sensitive, so <level: x> or <LEVEL: x> won't work.

Also, if enemies try to use this skill against actors, it will fail. Here's a version that is completely usable by both actors and enemies alike:

Code:
(a.isActor() ? a.level : (+a.enemy().meta.Level || 1)) > (b.isActor() ? b.level : (+b.enemy().meta.Level || 1)) ? b.hp : 0
 

Kagemaru

Veteran
Veteran
Joined
Dec 11, 2017
Messages
35
Reaction score
3
First Language
French
Primarily Uses
RMMV
For the <Level: x> notetag, no worries, I know its case sensitive.

Only one actor uses that spell right now but I might give it to special bosses later in the game, so Im gonna use the second formula.

I tried using the spell on a group of 2 enemies and the first test went well. Both enemies have 100HP and the spell dealt 100 points of damage to both of them.
The second test didnt go well though. When I used the spell, enemy A received 100 damage and died but enemy B received only 50 damage. I used the spell a second time, and the spell only dealt 25 damage. On the third turn, it also dealt 25 damage, which finally killed enemy B.
I battled the same enemies several times after that but the spell dealt 100 points of damage to both enemies every time. I wonder what happened during the second test?

Finally, Im not good with formulas, so could you please tell me what that last formula does?
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
115
Reaction score
65
First Language
French
Primarily Uses
RMMV
Here's a breakdown of the line:

If X is greater than Y, deals the target's current HP as damage. Otherwise, it's 0. Now to determine X and Y.

If the user is an actor, X is their level. Otherwise, take the level of the enemy, if it doesn't have a specific level (which wouldn't return a number) we'll say it's 1 (that's what the || 1 is for).
Same process to determine Y, but this time we're getting the target's level.

So here's what the line means: if the user's level is greater than the target's, deals the target's current HP as damage. Otherwise, it's 0.
It's a formula that does what you wanted, but properly handles how enemy levels are processed.

Now for the reason why Enemy B survived this skill despite taking damage, it could be that it has a resistance greater than 0 to the element / type (physical, magic) of the skill. To solve this, try making your skill a certain hit and making it non-elemental. Just remove any reason why it would be able to reduce damage taken. Are you still having this issue?
 

Kagemaru

Veteran
Veteran
Joined
Dec 11, 2017
Messages
35
Reaction score
3
First Language
French
Primarily Uses
RMMV
Oooh! That was really easy to understand! Thanks! :D

For the problem that I mentioned last time, is it possible that it happened because the enemy guarded? When I was testing that time, I left my room for a few seconds. Im using the... active time battle system, I think its called? The enemy must have guarded without me noticing. Ill test it later tonight to be sure, but if thats really what caused the problem, I wont be able to use the formula that Aesica provided... T.T
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,483
Reaction score
1,371
First Language
English
Primarily Uses
RMMV
Oh yeah, if this skill can be resisted/reduced in any way, it's not going to kill the target. If you want to ensure the enemy dies every time, there's a bit more to add OR you could just replace b.hp with some huge number like 9999.

If you use yanfly's action sequences, it's possible to make it look a lot cleaner--no "0" popup on failure and a clean dispatch with no damage popups when it works, no guard/reductions to worry about, etc.
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
115
Reaction score
65
First Language
French
Primarily Uses
RMMV
Or you could do b.addState(1) or whatever is the add state script in MZ, it would only care about one resistance and that'd be the resistance to the death / KO state.

Or b.die() but apparently that skips certain steps? I didn't really understand which ones, though. That's what I've done on an Execution skill in my game, and it worked as planned even with a condition.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,483
Reaction score
1,371
First Language
English
Primarily Uses
RMMV
Basically, die() is a cleanup function invoked as a result of adding state 1 to the target, not as a way to add state 1 to the target. When invoked directly from the console:


As you can see, the enemy is still there. You can't collapse it away via x.performCollapse() and checking its states reveals it doesn't have the death state or anything. The fact that it works when done via the formula box is something of a fluke, because the fact that the damage formula attempts to inflict damage is what probably fills in the missing pieces, allowing the enemy to die off properly.

I guess what I'm saying is that you probably can use die() in the formula, but it's bad practice and will behave horribly if used anywhere else. Better to stick with addState(1);
 

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
115
Reaction score
65
First Language
French
Primarily Uses
RMMV
I'll make sure to remember that for any other instakill I put in my game. Thanks for the clarification.
 

Kagemaru

Veteran
Veteran
Joined
Dec 11, 2017
Messages
35
Reaction score
3
First Language
French
Primarily Uses
RMMV
@Aesica Thanks a lot for telling me about that! Ive never used the action sequence functions, but Ill give it a try.

@CHKNRAVE I did try adding b.addState(1) to the formula before asking for help here but I havent tried it since then. Ill go give that a try too.
 

Black Pagan

Veteran
Veteran
Joined
Feb 21, 2017
Messages
337
Reaction score
257
First Language
English
Primarily Uses
RMMV
Guys, Can someone help me with this Damage Formula ? I'm trying to use Default Normal Attack to have such a Condition :

"If Player has Weapon Y equipped, Then Normal attacks Life-steal X% Life from Enemy, Else Default Damage Formula calculations happen".
 
Last edited:

Trogdor101

Villager
Member
Joined
Sep 18, 2020
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMZ
if you ask me, a simple damage system with the least amount of variance in damage amount is the best for strategic game play. When your players press the button they should be able to reasonably be able to predict how much damage it will do to the opponent. For this reason I propose the following:
1. a.attack - b.defense + x for bladed weapons where x is their base damage
2. a.attack + x for blunt weapons, note x should be less than bladed weapons, this is to represent their armor piercing nature while making sure they are not always a better option against any enemy
3. a.attack - b.defense or a.attack for unarmed combat

you may also want to try
3. 2*a.attack - b.attack if you want to make defense scale slower than attack, but I suggest keeping them in tandum with one another

this all of course goes for magic as well
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,483
Reaction score
1,371
First Language
English
Primarily Uses
RMMV
Guys, Can someone help me with this Damage Formula ? I'm trying to use Default Normal Attack to have such a Condition :

"If Player has Weapon Y equipped, Then Normal attacks Life-steal X% Life from Enemy, Else Default Damage Formula calculations happen".
The easiest way to do this is just use one of the many plugins capable of replacing the basic attack command. You can put a note tag on the desired weapon that will replace basic attack with a skill that does exactly what you're trying to do easily enough.
 

TheDrifter

Veteran
Veteran
Joined
Apr 18, 2012
Messages
119
Reaction score
5
First Language
English
Primarily Uses
Hi,
I'd like to create a skill that restores TP based on how hurt the user is.

For example,
If the user has 1/100 HP, the skill restores 50 TP.
If the user has 50/100 HP, the skill restores 25 TP.
If the user has 100/100 HP, the skill restores 0 TP.

Here is the formula I have so far:
Code:
b.gainTp(Math.ceil(50 - (a.hp / a.mhp * 50)))
So far, the skill seems to work in a brand new project with no plugins, except it shows the user being dealt 0 HP damage (while also restoring the correct amount of TP).

If I use Yanfly's Damage Core 1.08 plugin, this skill makes the game crash.

Any tips / pointers on what I'm doing wrong and how to fix it?
Thanks!

EDIT:
I sort of figured it out.
Make it an HP Restore skill with the following formula instead:
Code:
b.gainTp(Math.ceil(50 - (a.hp / a.mhp * 50))); 0
Only problem is, it still shows the user being dealt 0 HP damage. Not sure how to hide that and only show the amount of TP gained.

Does anyone know how?
 
Last edited:

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
115
Reaction score
65
First Language
French
Primarily Uses
RMMV
Hi,
I'd like to create a skill that restores TP based on how hurt the user is.

For example,
If the user has 1/100 HP, the skill restores 50 TP.
If the user has 50/100 HP, the skill restores 25 TP.
If the user has 100/100 HP, the skill restores 0 TP.

Here is the formula I have so far:
Code:
b.gainTp(Math.ceil(50 - (a.hp / a.mhp * 50)))
So far, the skill seems to work in a brand new project with no plugins, except it shows the user being dealt 0 HP damage (while also restoring the correct amount of TP).

If I use Yanfly's Damage Core 1.08 plugin, this skill makes the game crash.

Any tips / pointers on what I'm doing wrong and how to fix it?
Thanks!

EDIT:
I sort of figured it out.
Make it an HP Restore skill with the following formula instead:
Code:
b.gainTp(Math.ceil(50 - (a.hp / a.mhp * 50))); 0
Only problem is, it still shows the user being dealt 0 HP damage. Not sure how to hide that and only show the amount of TP gained.

Does anyone know how?
The damage / recovery formula is always expecting a final value, which is why you get 0 damage / recovery at the end.

Instead, using the Buffs and States Core, you could create a state whose custom apply effect does the TP manipulation. The skill would then have no damage / recovery formula so you won't get a 0, and it just applies the state which does the job.
 

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

Latest Threads

Latest Profile Posts

We are truly intellectuals.
Without using violence without weapons
Our group has as many as 1.3 million people and more than 1 hundred thousand talks.
We gathered in an hour, more than 4.5 Half a hundred thousand



I got a Sword.
I got an Axe.
I got two Swords.
Nothing to see here, just walking with my dog.
I haven’t worked on my game in a while. Tomorrow might be the day.
*squeals* :kaoblush:


I've been experimenting with improved memory management again, which allowed me to include items to increase player path length. These are both 44 grid spaces long, and stable. :LZSexcite:
I FINALLY DID IT! 5 years making my very first game and I just officially released it on STEAM..... OMG..... I can say I finished a game! The feelings!!!!!

Forum statistics

Threads
104,463
Messages
1,006,474
Members
135,971
Latest member
Akasheee
Top