ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
469
Reaction score
388
First Language
English
Primarily Uses
RMMV
I think I may not have properly explained what the goal was, but I may have gotten the answer I needed.

If the attack hits, it's supposed to deal damage, then apply a debuff to evasion. However, I didn't think to use a state to lower evasion, which would make doing this a bit easier (unless I'm wrong, but I'm open to learning). I'm gonna try going with applying a state that changes the evasion rate of the affected enemy.
I actually misspoke when I said the state would be added to the target and then the damage would be calculated.

If you check out the flow chart above, you'll see how each step is processed and when. States are added/removed after the damage is done, but must be processed before the actual damage calculation.

The above code:
b.addState(369); 200 + a.mat * 2 - b.mdf * 2
should work, just replace 369 with the ID of your evasion reducing state.
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMMV
I actually misspoke when I said the state would be added to the target and then the damage would be calculated.

If you check out the flow chart above, you'll see how each step is processed and when. States are added/removed after the damage is done, but must be processed before the actual damage calculation.

The above code:
b.addState(369); 200 + a.mat * 2 - b.mdf * 2
should work, just replace 369 with the ID of your evasion reducing state.
Yeah I used the code you provided and it works fine. Is there a way to add to it further, like including a state with a percentage chance to be applied?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,986
Reaction score
4,595
First Language
English
Primarily Uses
RMMZ
Yeah I used the code you provided and it works fine. Is there a way to add to it further, like including a state with a percentage chance to be applied?
If you wanted to do that, you could include a check against a random number. For example say you wanted a 15% chance of applying the state:

JavaScript:
if (Math.randomInt(100) >= 85) b.addState(369); 200 + a.mat * 2 - b.mdf * 2

One thing to note about this method which people tend to not know/forget (and Yanfly wrote an article about it a long time ago) is that if you use Autobattle at all in your game, it's better to do it a different way. The reason being when a battler is determining which of their actions to use, they actually evaluate the damage formula to figure out what's best, meaning in this case that their "test" enemies would end up having the state applied even if that action ends up not being used.
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMMV
If you wanted to do that, you could include a check against a random number. For example say you wanted a 15% chance of applying the state:

JavaScript:
if (Math.randomInt(100) >= 85) b.addState(369); 200 + a.mat * 2 - b.mdf * 2

One thing to note about this method which people tend to not know/forget (and Yanfly wrote an article about it a long time ago) is that if you use Autobattle at all in your game, it's better to do it a different way. The reason being when a battler is determining which of their actions to use, they actually evaluate the damage formula to figure out what's best, meaning in this case that their "test" enemies would end up having the state applied even if that action ends up not being used.
1638713361034.png

What I currently have going is the skill has two effects to it. A chance to stun, and a guaranteed evasion debuff. The stun effect is in the effects part, but I saw no way to apply an evasion debuff there. That's why I originally came here to figure out how to get my skill to apply an evasion debuff if it succeeds. I was curious if it was possible to include both the guaranteed evasion debuff and a chance to stun in the damage formula. As far as auto-battle goes, I don't know if the game I'm going for will include it, since a lot of the game will be based on choices you make throughout it, so not too concerned about that. I'll give that formula a try though, and see how it works.
 

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
469
Reaction score
388
First Language
English
Primarily Uses
RMMV
You should be able to add both through the effects of the skill.
You can also add additional effects through linking a common event to the usage of the skill.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,986
Reaction score
4,595
First Language
English
Primarily Uses
RMMZ

What I currently have going is the skill has two effects to it. A chance to stun, and a guaranteed evasion debuff. The stun effect is in the effects part, but I saw no way to apply an evasion debuff there. That's why I originally came here to figure out how to get my skill to apply an evasion debuff if it succeeds. I was curious if it was possible to include both the guaranteed evasion debuff and a chance to stun in the damage formula. As far as auto-battle goes, I don't know if the game I'm going for will include it, since a lot of the game will be based on choices you make throughout it, so not too concerned about that. I'll give that formula a try though, and see how it works.
Yeah, debuffs only apply to base parameters. You'll have to add a state that inflicts an evasion reduction.
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
37
Reaction score
3
First Language
English
Primarily Uses
RMMV
I appreciate the help guys. I'm still so new to coding and such. It's quite intimidating but I really wanna learn
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
710
Reaction score
302
First Language
English
Primarily Uses
RMMV
If you wanted to do that, you could include a check against a random number. For example say you wanted a 15% chance of applying the state:

JavaScript:
if (Math.randomInt(100) >= 85) b.addState(369); 200 + a.mat * 2 - b.mdf * 2
I think for readability it's better to reverse that conditional:
JavaScript:
if(Math.randomInt(100) < 15) b.addState(369); 200 + a.mat * 2 - b.mdf * 2
 

mkrudesign

Veteran
Veteran
Joined
Jun 11, 2019
Messages
31
Reaction score
2
First Language
English
Primarily Uses
RMMV
Is there a way to set that the minimum amount of damage for a skill as a percent instead of a fixed amount?

For the standard attack skill, the formula I use is: Math.max(a.atk * 4 - b.def * 2,1) So the minimum this skill can do is 1 damage.

The thing is, it gets pretty dumb when enemies who are meant to be intimidating end up hitting for 1 HP if the player becomes over powered. Is there a formula that I can use to make the minimum damage for this skill be, let's say 5% of the target's total health? It would be way easier than having to rebalance the entire game, since mine is open ended.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,599
Reaction score
2,938
First Language
English
Primarily Uses
RMMV
Is there a way to set that the minimum amount of damage for a skill as a percent instead of a fixed amount?
Just replace the "1" with whatever equation you want. So, mathematically, 5% of your target's total health is b.mhp*.05

Thus, Math.max(a.atk*4-b.def*2, b.mph*.05)
 

ScorchedGround

Blizzards most disappointed fan (More than ever)
Veteran
Joined
Apr 12, 2020
Messages
754
Reaction score
1,137
First Language
German
Primarily Uses
RMMV
Is there a formula that I can use to make the minimum damage for this skill be, let's say 5% of the target's total health?

You basically just do the exact thing as before, but replace the "1" with the minimum damage you wish for.

e.g.
Math.max(a.atk * 4 - b.def * 2, b.mhp*0.05)

Now, if you asked me, I wouldn't use a % amount because that could get wonky at some points, but rather a flat amount of the attackers stats.
Something like:
Math.max(a.atk * 4 - b.def * 2, a.atk * 0.5)

Edit: Ninja'd
 

mkrudesign

Veteran
Veteran
Joined
Jun 11, 2019
Messages
31
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thank you! I wasn't sure if it was that easy!
 

mkrudesign

Veteran
Veteran
Joined
Jun 11, 2019
Messages
31
Reaction score
2
First Language
English
Primarily Uses
RMMV
You basically just do the exact thing as before, but replace the "1" with the minimum damage you wish for.

e.g.
Math.max(a.atk * 4 - b.def * 2, b.mhp*0.05)

Now, if you asked me, I wouldn't use a % amount because that could get wonky at some points, but rather a flat amount of the attackers stats.
Something like:
Math.max(a.atk * 4 - b.def * 2, a.atk * 0.5)

Edit: Ninja'd
Could you explain the downside to using a % amount? You mentioned things could get wonky. Is there something I'm missing here?
 

Quack

Villager
Member
Joined
Dec 13, 2015
Messages
21
Reaction score
8
Primarily Uses
Could you explain the downside to using a % amount? You mentioned things could get wonky. Is there something I'm missing here?
I don't think he was objecting to using a percentage amount, but that it was a percentage of the target's hp.
Sometimes bosses have very high hp so you could potentially end up in a situation where 5% of the target is actually more than the normal attack value before being reduced by target's defense.
If you just want to prevent attack value from getting too low, it might be better to set your "minimum" damage value to a percentage of the normal attack value before it is reduced by defense rather than a percentage of the target's hp.
JavaScript:
Math.max(a.ath * 4 - b.def, a.atk * 4 * 0.05)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,599
Reaction score
2,938
First Language
English
Primarily Uses
RMMV
I don't think he was objecting to using a percentage amount, but that it was a percentage of the target's hp.
Sometimes bosses have very high hp so you could potentially end up in a situation where 5% of the target is actually more than the normal attack value
I don't know what ScorchedGround's objection was, but the original post for this formula did indicate it's for an enemy skill, so killing bosses too quickly wouldn't be a concern :wink:
 

Nox_Aeternae

Villager
Member
Joined
Feb 14, 2022
Messages
9
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hey! So, I wanted to write a spell that does a percentage of MaxHP as damage both to the enemy and the caster. My initial formula was this:

a.mhp* 20 / 100 && a.gainHp(0 - a.mhp* 20 / 100)

and it didn't work. The part after the "&&" worked but the part before didn't.

So, I thought that maybe the problem was with the "&&" symbol and changed my formula to

a.mhp* 20 / 100 ; a.gainHp(0 - a.mhp* 20 / 100)

and the result was the same. The caster would take damage but the enemy would take 0.

I've tried a bunch of things but what ended up working was to reverse the order:

a.gainHp(0 - a.mhp* 20 / 100) ; a.mhp* 20 / 100

The above formula worked just as I wanted, but as it stands I'm not sure why it worked while the previous ones didn't. And because of that I don't feel like I've actually learned anything. If anyone could explain the reasoning behind it, I'd be grateful!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,356
Reaction score
9,728
First Language
German
Primarily Uses
RMMV
the eval for the damage formula expects a number as a result, and that number will always be the last one processed. in your first variants the number was calculated first, but never used anywhere.

it works the other way around because the number first calculated there is used in the gainhp function instead of just being ignored, while the second calculation is taken as the result of the eval and used by the engine itself.
 

Nox_Aeternae

Villager
Member
Joined
Feb 14, 2022
Messages
9
Reaction score
2
First Language
English
Primarily Uses
RMMV
@Andar, Thanks a lot! That makes perfect sense now. So, the calculation for the damage the ability deals has to always be last.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,986
Reaction score
4,595
First Language
English
Primarily Uses
RMMZ
@Andar, Thanks a lot! That makes perfect sense now. So, the calculation for the damage the ability deals has to always be last.
To expand on what Andar said, when you used && in your first formula, you actually turned it into a *boolean condition*.

a.mhp* 20 / 100 && a.gainHp(0 - a.mhp* 20 / 100)

This would evaluate to *true* if both sides are truthy, and *false* if either side is falsy.

Because a.hp * 20 / 100 just returns itself, that always returns truthy. But the gainHp function doesn't return a value, so it will never evaluate to a truthy value in a condition.

Therefore, your formula was evaluating to *false*, but booleans aren't numbers so it was unable to deal any damage using it.
 

Latest Threads

Latest Profile Posts

Played and finished Mad Father, one of the older RPGmaker horror games out there. That was one mad, MAD father
Hi, I am new here, exciting! Emmm where to change my head portrait?
I now have an idea of how to approach my IGMC entry for this year's theme, as well as a working title (TBA). Given the limited time I can spare, I'm going with a game design that doesn't require a battle system. Something that could be expanded if I want to make it a longer game, but can probably be played through within 2 hours (the goal for now), at least on a speed run.
很好,我喜欢你的游戏独特的用户界面

Forum statistics

Threads
123,372
Messages
1,156,134
Members
161,821
Latest member
haze_dj
Top