RMMV Damage Formula - ideas and help

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,888
Reaction score
521
First Language
English
Primarily Uses
N/A
So you can add a state, while simutaniously removing states all to the actor in the same formula? Excellent!

Certain types of state effects just opened up. Like states that only go away when the actor uses an attacking skill while those attacking skills add states to the user and enemies through the effect part. While not going away when they use a support skill
 

jjleroy

I love bananas
Veteran
Joined
Aug 5, 2017
Messages
184
Reaction score
34
First Language
German, English
Primarily Uses
RMMV
Is there a way to save the Evasion Rate of an actor in a variable?

I tried $gameActors.actor(1).xparam(1)
and actor.eva

but neither of them worked...
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
395
Reaction score
217
First Language
English
Primarily Uses
RMMV
If you're trying to set a game variable using the damage formula you'll need to use something like this

Code:
$gameVariables.setValue(id, $gameActors.actor(1).eva)
Where id is the variable's ID.
 

jjleroy

I love bananas
Veteran
Joined
Aug 5, 2017
Messages
184
Reaction score
34
First Language
German, English
Primarily Uses
RMMV
If you're trying to set a game variable using the damage formula you'll need to use something like this

Code:
$gameVariables.setValue(id, $gameActors.actor(1).eva)
Where id is the variable's ID.
Thank you very much!

So I would like to create a state which halfs the hit rate of all incoming attacks.

I was wondering if I could just half the Hit Rate formula (for ALL actors&enemies) for a brief amount of time whenever the actor is attacked.
Then after damage is done, reset Hit Rate formula to normal one.

Is it ok to do it this way, or do you see some kind of error in my solution?!
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
395
Reaction score
217
First Language
English
Primarily Uses
RMMV
The logic seems fine but I think the execution would be difficult without using a plugin. Do you have something that will allow you to modify an actions hitrate? I suspect you might be able to do this with Yanfly's buffs states core.

If not you could try saving the below as a plugin and adding it to your plugin manager. On the line that starts "var div = ", replace "stateId" with the state's id.

Code:
    jjleroy_Game_Action_itemHit = Game_Action.prototype.itemHit;
    Game_Action.prototype.itemHit = function(target) {
        var div = target.isStateAffected(stateId) ? 2 : 1;
        return jjleroy_Game_Action_itemHit.call(this, target) / div;
    };
 

jjleroy

I love bananas
Veteran
Joined
Aug 5, 2017
Messages
184
Reaction score
34
First Language
German, English
Primarily Uses
RMMV
Thank you @Silva !

Is there a way to define in the damage formula whether or not a target
result().isHit() ?
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
395
Reaction score
217
First Language
English
Primarily Uses
RMMV
Not by default. The damage formula will only evaluate if target.result().isHit() returns true, at which point it's too late for any changes to matter.

If you're looking to make changes to the way hits are calculated I would definitely recommend using a plugin so that you can change the result before the damage formula is reached.
 

TMS

Guy with Mask
Veteran
Joined
Apr 17, 2012
Messages
308
Reaction score
57
First Language
English
Primarily Uses
N/A
So I'm thinking for the first time about damage formulas I might want to use. I've noticed people in this thread talking about Math.randomInt(x). Is there a place in MV's Help documentation (or anywhere else) that describes stuff like that?

Edit:
I have a few other questions.

The first one I'm not really sure how to word, but I'm thinking of having attacks in my game that hit multiple times. Not in the sense that the attack repeats itself; rather it calculates several damage values according to a given formula and then adds them together, whereas usually (with an attack that only hits once) only one damage value is calculated for the total. Would a multi-hit attack like what I'm describing just be a case of using a lot of parentheses to make a really long formula?

A somewhat related question is whether there's a way to get a random number that's between two numbers other than 0. What do I do if, say, I want an attack to hit between 2 and 4 times (inclusive)?
 
Last edited:

D.L. Yomegami

Sanely Insane
Veteran
Joined
Jan 22, 2017
Messages
179
Reaction score
234
First Language
English
Primarily Uses
RMMZ
For your first question, this ought to be of some use.

For your third question: it's mostly a simple matter of taking your desired minimum value and adding Math.randomInt() to it. A rough exact formula would look something like this:

Min + Math.randomInt((Max - min) + 1)

Where Min is your desired minimum value and Max is your desired maximum value. Some examples:
Min = 2, Max = 4: 2 + Math.randomInt(3)
Min = 3, Max = 7: 3 + Math.randomInt(5)
Min = 10, Max = 13: 10 + Math.randomInt(4)

I'm not entirely sure what you're asking for your second question, but to me it sounds like you want something like Formula1 + Formula2 = Final Damage Value that produces 1 Damage Popup. In that case, it really is as simple as putting the two formulas in parentheses and then adding them together. If that's not what you're looking for, then I'm not sure how to answer that, unfortunately.

Now for my own question.

I'm trying to design a damage formula with a sort of "soft cap" on both maximum and minimum damage values. Basically, whenever the damage approaches some kind of maximum value (like 9999 or half the target's maximum HP) or minimum value (like 10 or a third of the attacker's offensive parameter), the damage kind of levels out. For example, if the "soft cap" is 9999 while the final damage would otherwise be twice that, it'd instead be something like 10,100 or even still below 9999. Likewise for minimum damage: if the "soft cap" on minimum damage is a third of the attacker's offensive parameter, I don't want any damage to be drastically below that. All this while the damage in between the two "soft caps" is more or less normal for whatever formula I decide to use (I normally use something like a.atk * (256 - b.def) / 256 or a.atk * 100 / (100 + b.def)).

I'm completely at a loss at what kind of math I'd need to do to achieve this effect. It feels like the exact curves I want look similar to a square root formula (for max "soft cap") or exponent formula (for min "soft cap"), yet whenever I play around with such formulas in a graphing calculator I simply cannot get the curves to look the way I want them to. Would anyone have a better idea of what formula I would want for something like this?

I'm aware I could achieve something similar via the Math.max/Math.min or clamp functions, but that's not quite what I want. Those are a hard stop that cause the damage to turn into a flat line at the maximum and minimum values (variance notwithstanding); I'm looking for something that'd be more of a curve at the "caps."
 
  • Like
Reactions: TMS

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
2,994
First Language
Tagalog
Primarily Uses
RMVXA
@Yomegami - You'd either want to use maybe if statements or the Min/Max method. If those are pretty "hard" caps for you, you can always add a bit of random integers to vary the resulting values, or add a percentage of the actual over damage.

If you want it for all skills though, you might want to actually write a plugin that handles it just so you wont need to do it for every skill in your game.
 

Kirbs

Crimson Claw
Member
Joined
Feb 4, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm sorta new to the forums and I don't know how to make a thread but anyways.

I was trying to make some skills.
I'm not sure how to make attack called "Experience Attack (I may Change this name XD)"

"This attack deals more damage if the user has a higher level than the target, if its will deal +250% bonus damage! otherwise it deals Mid Physchial damage."

Its kind of like Yanfly's "Enemy Level" Video where there's a move called "Challenger" And "Overpower".

also I was also trying to make a attack that was the same as that one but it does more damage if the target has a higher level.


I Really think this is going to be a complexed one...
Ex: [Users Level is 13 >Targets Level is at 5 = Deals +250% Bonus DMG + The Skills damage]
If uses incorrectly [Users Level is 12 <Targets Level is at 15 = The Skills Damage]

The other one Where if you're Level is lower it works:
Ex: [Users Level is 3 <Targets Level is at 5 = Deals +250% Bonus DMG + The Skills damage]
If uses incorrectly [Users Level is 22 >Targets Level is at 15 = The Skills Damage]
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,485
Reaction score
4,952
First Language
English
Primarily Uses
RMVXA
@Kirbs To post a new thread, just go to the forum you want to post in, and look on the right hand side (somewhat near the top) for the button that says 'Post New Thread'.

However, for this particular issue, it is something that can be done with a damage formula, so you've posted in the right place :)
 

udime123

Director of Fate
Veteran
Joined
Mar 29, 2018
Messages
92
Reaction score
14
First Language
English
Primarily Uses
RMMV
@Kirbs I don't actually use Enemy Level plugins, but I'm certain Yanfly would include information as to how to draw up enemy Levels as a variable. Assuming tbat were the case, you'd probably write it up like "a.currentExp() / b.currentExp()", since (to my knowledge), there's no call for Actor Levels. If you want it to be a flat rate, that would only require an if/then statement in the Note section, which might actually be easier.

[If a.LV>b.LV, a.atk * 2.5 - b.def; else, a.atk * 1 - b.def]

Something like that, assuming you can get a variable for the level.

This is kinda a sloppy fix, but if you can't figure out any other way to pull the user's level, you could set every encounter to set a Global Variable to the Actor's level on the first turn.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,474
Reaction score
1,366
First Language
English
Primarily Uses
RMMV
Enemies don't have levels by default, and one of the yanfly plugins (not sure which) seems to add levels to enemies based on the average party level, which would make something like what you're trying to do pretty useless and easy to exploit. If you really want to make something like this work, you'll have to take matters into your own hands with something like this:
  1. In each enemy's note box, add the note tag <Level: x> where "x" is the desired level for that enemy. So <Level: 5> to set an enemy to level 5 for the purposes of what you're trying to do. This tag is case sensitive, so use <Level: x> not <level: x> or <LEVEL: x>
  2. In the formula box of your skill: (a.level > (+b.enemy().meta.Level || 1) ? 3.5 : 1) * a.atk - b.def
  3. Note that the multiplier I used is 3.5 instead of 2.5 since you implied that you wanted 250% bonus damage added to the normal damage rather than a 250% modifier applied to the normal damage. Change it to 2.5 if the latter is actually what you meant.
  4. Change the a.atk - b.def portion to whatever you want your formula to be, so: (a.level > (+b.enemy().meta.Level || 1) ? 3.5 : 1) * a.atk * 4 - b.def * 2 ...or whatever
  5. Enemies without a <Level: x> tag will be treated as level 1.
  6. This formula is meant to be used by actors against enemies. If an enemy tries to use it, the whole thing will probably explode
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,636
Reaction score
417
First Language
Portuguese
Primarily Uses
RMMV
@Aesica it does it by default, but you can also set it in a range. Most enemy level plugins let you do so. Yanfly is just the better known one because... well, yanfly.
Also for most of them you just need to do "a.level" for both sides.

@Kirbs I'd like to help you, but I don't get what you are trying to do, honestly... Tell me if I am wrong: if the user's level is lower, deal as much damage as a normal attack, but if higher deals normal damage plus 2.5 times normal damage?
P.S.: (seems a bit overpowered to me, but ok if so... but can I suggest using the value of the difference for the bonus instead of just a set value? like one level difference add 25% but two add 50% and so on or something like that)
 

Kirbs

Crimson Claw
Member
Joined
Feb 4, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
Enemies don't have levels by default, and one of the yanfly plugins (not sure which) seems to add levels to enemies based on the average party level, which would make something like what you're trying to do pretty useless and easy to exploit. If you really want to make something like this work, you'll have to take matters into your own hands with something like this:
  1. In each enemy's note box, add the note tag <Level: x> where "x" is the desired level for that enemy. So <Level: 5> to set an enemy to level 5 for the purposes of what you're trying to do. This tag is case sensitive, so use <Level: x> not <level: x> or <LEVEL: x>
  2. In the formula box of your skill: (a.level > (+b.enemy().meta.Level || 1) ? 3.5 : 1) * a.atk - b.def
  3. Note that the multiplier I used is 3.5 instead of 2.5 since you implied that you wanted 250% bonus damage added to the normal damage rather than a 250% modifier applied to the normal damage. Change it to 2.5 if the latter is actually what you meant.
  4. Change the a.atk - b.def portion to whatever you want your formula to be, so: (a.level > (+b.enemy().meta.Level || 1) ? 3.5 : 1) * a.atk * 4 - b.def * 2 ...or whatever
  5. Enemies without a <Level: x> tag will be treated as level 1.
  6. This formula is meant to be used by actors against enemies. If an enemy tries to use it, the whole thing will probably explode
Thank you! This seems very helpful!
I’ll try it later when I have the chance to!
Btw I was using the “Enemy Level” Plugin
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,474
Reaction score
1,366
First Language
English
Primarily Uses
RMMV
@Aesica it does it by default, but you can also set it in a range. Most enemy level plugins let you do so. Yanfly is just the better known one because... well, yanfly.
Also for most of them you just need to do "a.level" for both sides.
If you're using a plugin to set specific levels, then yeah you'd want to replace the (+b.enemy().meta.Level || 1) mess with just b.level, but without any plugins, enemies don't have a level parameter, so that's a way to add some sort of level functionality via note tags without adding or tinkering with plugins.
 

Kirbs

Crimson Claw
Member
Joined
Feb 4, 2019
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMMV
If you're using a plugin to set specific levels, then yeah you'd want to replace the (+b.enemy().meta.Level || 1) mess with just b.level, but without any plugins, enemies don't have a level parameter, so that's a way to add some sort of level functionality via note tags without adding or tinkering with plugins.
SO the formula is set up like: (a.level > b.level) ? 2.5 : 1) * a.atk - b.def
and the other move is like: (a.level < b.level) ? 2.5 : 1) * a.atk - b.def
 

BaronVampson

Veteran
Veteran
Joined
Jul 7, 2018
Messages
48
Reaction score
2
First Language
English
Primarily Uses
RMMV
I edited this post because I think I identified the route of the problem. Mods please delete this post thank you.
 
Last edited:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,636
Reaction score
417
First Language
Portuguese
Primarily Uses
RMMV
@BaronVampson I'd really think it would be better if you had just edited the post and added the solution instead. After all, like you had a problem but found the solution, others could have the same problem and see in your post and seen your solution faster.

I guess i may be too late, but... well, just an idea for next time.
 

Users Who Are Viewing This Thread (Users: 2, Guests: 3)

Latest Threads

Latest Posts

Latest Profile Posts

A video game has a brand attached to it.
No offence meant, but it is disadvantageous to use the default RM graphics due to the fact that they can correlate your game strongly to other RM games and whatever associations a user has with those unrelated games.
Exhaustion sickness hitting me again near deadline whyyyy (sobs)
thats it, i 've had it, I will NOT promote my game as a "retro RPG" when its done, i have in the past but it is literally the first thing on every rpg maker game description to the point that you'd think the sales pitch came with the RTP. I refuse to use that angle.
My memory is embellishing the quality of NES era game assets :/ .... I need to stop comparing my work to somthing that was groundbreaking decades ago. Especially since its not as good as I seem to keep remembering it to be.
I finally found something that pleased me to organize my tasks. :)

Forum statistics

Threads
103,199
Messages
997,989
Members
134,680
Latest member
Avliass
Top