RMMV Damage Formula - ideas and help

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Is there no way to do this within the damage formula?

I have several skills which use common events individually. In order to tidy them up, I thought it would be ideal to use the damage formula to set the variable Skill [variable 5] to the number of the skill [67, for instance], and then call up the common event "Skill" as one of the effects. The common event would contain conditional branches:

If skill = 67, do the stuff for skill 67. If skill = 68, do the stuff for skill 68. etc. That way I would just need to change the number I set the variable to for each individual skill, but they would all draw upon the same common event. I have the skills I want all working properly, as separate common events, I just want to unify them.

However, every way I have tried to set the game variable within the damage formula box has failed. From memory, I have tried [using both square and round brackets]:

v[5] = 67
$gameVariables[5] = 67
$gameVariables.Value[5] = 67
$gameVariables.setValue(5, 67)

If someone can tell me the correct syntax for the damage formula box to set variable 5 to a value of 67, I would be forever grateful. I have trawled through this thread for an hour, trying many different suggestions, and nothing has worked.
If you are using Yanfly DamageCore you can just reach the Id of your skill with
Code:
item.id
And this
$gameVariables.Value[5] = 67
will give you 2 errors 1: the V in value is capitalized and when written correctly it would say invalid left hand side something.

What you thus want is this
Code:
$gameVariables.setValue(5,item.id);
Edit: A quick way to test my example is when you the required plugins installed is selecting your skill and make it do damage without variance and put in this
Code:
<damage formula>
value = item.id;
</damage formula>
You will now deal damage equal to your skill id.
 
Last edited:

LGardner

Veteran
Veteran
Joined
Dec 23, 2018
Messages
36
Reaction score
2
First Language
English
Primarily Uses
RMMV
If you are using Yanfly DamageCore you can just reach the Id of your skill with
Code:
item.id
And this will give you 2 errors 1: the V in value is capitalized and when written correctly it would say invalid left hand side something.

What you thus want is this
Code:
$gameVariables.setValue(5,item.id);
Edit: A quick way to test my example is when you the required plugins installed is selecting your skill and make it do damage without variance and put in this
Code:
<damage formula>
value = item.id;
</damage formula>
You will now deal damage equal to your skill id.
Hi. Many thanks for the reply. I had Yanfly core installed, but not Yanfly Damage Core. Have since installed it. Am still not having any joy I am afraid; I tried the code you suggested in both the damage box:


and the common event itself:


Neither worked. However, in response to your edit, I can confirm that item.id does work in terms of calculating damage -
value = item.id;
returned a hit of approx the skill id each time. But the formula for setting variables [by the way, I wrote last time from memory, but I did use the same capitalisation as standard when actually trying it] didn't work for me. :/

Edit: FOUND THE PROBLEM. Skill's scope was set to none, which worked fine as long as all I needed was the effects, but meant that hp damage formula wasn't taking any effect when I used it. Now I set it to 1 ally, it works as intended. Sorry all, and thanks for the help.
 
Last edited:

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Hi. Many thanks for the reply. I had Yanfly core installed, but not Yanfly Damage Core. Have since installed it. Am still not having any joy I am afraid; I tried the code you suggested in both the damage box:


and the common event itself:


Neither worked. However, in response to your edit, I can confirm that item.id does work in terms of calculating damage -
value = item.id;
returned a hit of approx the skill id each time. But the formula for setting variables [by the way, I wrote last time from memory, but I did use the same capitalisation as standard when actually trying it] didn't work for me. :/

Edit: FOUND THE PROBLEM. Skill's scope was set to none, which worked fine as long as all I needed was the effects, but meant that hp damage formula wasn't taking any effect when I used it. Now I set it to 1 ally, it works as intended. Sorry all, and thanks for the help.
Sorry to you as well the moment you were using scripts in combination with damage formulas I asumed you were allready working with Yanfly plugins and knew what they were capable of.

If you read the description that comes with the plugin or the descriptions of the plugins from Yanfly website and/or his videos you can find out what they are all capable of.

You can just put this in the skills notebox
Code:
<damage formula>
$gameVariables.setValue(5,item.id);
</damage formula>
and insert your script in between.
So if you put the first example of mine in your skill's notebox and remove the script part of your common event it ought to work.
"value" is a variable(used within the damage core plugin) that stores the result of your formula you wrote down, thus by writing "value =50;" makes the skill do 50 damage.

The reason the script in the comon event isn't working is because item.id is (I believe an temporary and/or local) Object that is created by the plugin at skill selection.
When "<damage formula></damage formula>" is found, by a function of the plugin, in the notebox of your selected skill and it will then read what is written.
It's also in that point in time that you can thus access the data of the object "item".

However this is thus far my understanding of Yanfly's plugins I have not really looked into the code of the plugin itself so i might not be entirly correct.
Long story short use item.id only within Yanfly's plugins.

In case you don't understand some of the things I was talking about, go to w3schools and to the javascript section IMO it's a good website that teaches you the basics of code.
You will however have to understand it yourself as in how to make use of it.

And in case you are going to experiment with some lets say more advanced scripts do note the script box can only hold about ten lines and if you would lets say press enter to have the code on line 10 move to line eleven .... well the result is an empty line 10 it has happend to me sadly.
Thus I recommend when possible to code/test your larger scripts in the debug console and when finished save your script somewhere else and jam your code together on fewer lines bofore cramming it in your script box.

I really have been typing way to much late at night......
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,990
First Language
Tagalog
Primarily Uses
FOUND THE PROBLEM. Skill's scope was set to none, which worked fine as long as all I needed was the effects, but meant that hp damage formula wasn't taking any effect when I used it. Now I set it to 1 ally, it works as intended. Sorry all, and thanks for the help.
Yup that is right, to explain this:

The damage evaluation function is actually called by the Target object (not the user). So since the scope is none, there is no Target object, meaning there is also no object that will call the damage evaluation function, so its never evaluated.

@jetboost - no need for Yanfly's plugin and a custom <damage formula> notetag for the set variable part because the damage formula can already run JS codes by default. So basically, he can just insert the $gameVariables.setValue() call inside the skill's actual damage formula box.

Also item.id is accessible in the damage formula box even without any plugin because item is actually passed as a parameter of the function that evals the damage formula box. Plus since you're doing it on the formula box, its better to just write the skill id number itself.. and ofc, if you're using a common event, item.id will not exist.
 
Last edited:

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Yup that is right, to explain this:

The damage evaluation function is actually called by the Target object (not the user). So since the scope is none, there is no Target object, meaning there is also no object that will call the damage evaluation function, so its never evaluated.

@jetboost - no need for Yanfly's plugin and a custom <damage formula> notetag for the set variable part because the damage formula can already run JS codes by default. So basically, he can just insert the $gameVariables.setValue() call inside the skill's actual damage formula box.

Also item.id is accessible in the damage formula box even without any plugin because item is actually passed as a parameter of the function that evals the damage formula box. Plus since you're doing it on the formula box, its better to just write the skill id number itself..
Thank you for the correction I didn't know that.


Plus since you're doing it on the formula box, its better to just write the skill id number itself.
(I think)I understand it. By doing so the program has less work to do.

However in my case I use it for my "skill mastery/lvl" system I have set up for my skills and I will thus need the skill id quite a bit more thus I store the value of item.id in a variable and use that.
Quite sad that a few weeks later after having created it Yanfly released a plugin that does allmost the same:|.

Because of the way I set up various things for my skills and the various systems that I have set up that can influence the skills I will need to use quite a bit of code thus I actually allmost never use the damage formule box cause it just isn't convenient for writing a large amount of code inside of it, the notebox even has a scroll bar :D.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,990
First Language
Tagalog
Primarily Uses
Yeah, different cases different uses. Indeed for a JS system that will be used by different skills, using item.id (if possible) is better so that the skill wont need to supply its id to the system via other methods (on the other poster's case, via setting a game variable's value to the id). As you said and explained though, if he uses item.id in the common event, it will not work.

Quite sad that a few weeks later after having created it Yanfly released a plugin that does allmost the same
Dont be sad, you learned something and now you have a system that you made on your own and didnt need to rely on somebody elses work. Be happy :)
 
Last edited:

Manjini

Dummy
Member
Joined
Jan 6, 2019
Messages
25
Reaction score
22
First Language
German
Primarily Uses
RMMV
Hello! Could somebody help me to figure out a nice damage formula similar to Ragnarok Online just with higher damage outputs and obviously no agility, dextery etc.? Let's say you are level 10 and the enemy is level 1 and you have like 20 defense, the enemy still could hit you for maybe 1 or 2 damage but not 0 and not 100. I want a high tolerance in attack * defense ratio. So that killing a monster one level below would not be one hit (Unless you have special gear which gives high amount of attack or something) but we are talking about raw values here. Like no extra armor or weapons added. I want defense to be meaningful but also high damage numbers. My level cap is 60 at the moment to keep the balancing a little on the easier side. I managed to do fun battles in the higher levels, but my issue really is the lower end. For example I kill level 1 monsters being level 1 and then level up, I would one shot the level 1 enemies by just being one level higher.
(I am using yanflys plugins: baseparamcontrol, classbaseparam, enemy levels, damage core and armor scaling if that helps).
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,990
First Language
Tagalog
Primarily Uses
If you want defense to work more, you just need to set your damage formula to use defense more...

Like, the original DF is

a.atk*4 - b.def*2

So you can make it like

a.atk*4 - b.def*4

or you can make def work as % reduction like

(a.atk*4)*(1.00-def/100.0)

This will make it such that each point of defense gives 1% damage reduction
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
For example I kill level 1 monsters being level 1 and then level up, I would one shot the level 1 enemies by just being one level higher.
I use the same plugins except armor scaling.
I had the same issue going from lvl 1 to lvl 2 and ballancing to the point I have made an gigantic spreadsheet that calculates the damage done and recieved so I could keep an eye on the vallues and test skills faster at various levels against various levels.
(Can't really share it with you though it is to personalized for my project so its useless to you.)
I suggest you create something similar based on your situation if it's really neccesary.

Anyway the way I solved this issue is by making my game start at lvl 2.
Create a tutorial fight balance it to lvl 1 and have it give you enough EXP to lvl up.
This is how I solved my issue.
 

Manjini

Dummy
Member
Joined
Jan 6, 2019
Messages
25
Reaction score
22
First Language
German
Primarily Uses
RMMV
I guess I have to use excel or google spreadsheet as well. Since altering the atk + def formula with default values is not accurate in addition with the enemy levels (How much atk, def etc. the enemy itself will gain per level in my game).
I like your workaround jetboost, but I cannot admit defeat just yet! I want it sorted out with a nice smooth curve!
Anyways thanks for the replies.
 

SANTERSAKH

Villager
Member
Joined
Mar 21, 2019
Messages
14
Reaction score
1
First Language
Russian
Primarily Uses
RMMV
Hello everyone!
How to set formula like this: when attacker's final ATK is less than target's DEF, minimum damage will not be 0 but be random number between 1 and 1/20 of attacker's ATK?
Or just tell how to remove 0 damage (at least 1)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,670
Reaction score
2,990
First Language
Tagalog
Primarily Uses
You can probably use a plugin to avoid 0 damage after all calculations are done...

Or in your damage formula

Math.max(1,actual formula)

This way, if the damage will be less than 1, it will be 1 instead.

So like

Math.max(1,atk*4-b.def*2)

Take note though that doing this in the damage formula box means that it can still be changed via the other factors that are incorporated after the formula calculation, like element rates and pdr/mdr. But as long as you dont have a 0% element rate or pdr/mdr then you wont get 0 damage after this.
 

SANTERSAKH

Villager
Member
Joined
Mar 21, 2019
Messages
14
Reaction score
1
First Language
Russian
Primarily Uses
RMMV
You can probably use a plugin to avoid 0 damage after all calculations are done...

Or in your damage formula

Math.max(1,actual formula)

This way, if the damage will be less than 1, it will be 1 instead.

So like

Math.max(1,atk*4-b.def*2)

Take note though that doing this in the damage formula box means that it can still be changed via the other factors that are incorporated after the formula calculation, like element rates and pdr/mdr. But as long as you dont have a 0% element rate or pdr/mdr then you wont get 0 damage after this.
Thanks! That is what I need!
Back to my request, will this work fine?

Math.max(1,Math.randomInt(a.atk/20),a.atk * 3 - b.def * 2)
 

Silva

Scoobityboo
Veteran
Joined
Nov 5, 2018
Messages
361
Reaction score
185
First Language
English
Primarily Uses
RMMV
Thanks! That is what I need!
Back to my request, will this work fine?

Math.max(1,Math.randomInt(a.atk/20),a.atk * 3 - b.def * 2)
This will work. It will make the damage the highest of all the values separated by a comma. I noted in your previous post though that you wanted to use the random number between 1 and atk/20 only when a.atk < b.def (or maybe a.atk * 3 < b.def * 2, your word choice confused me a little). To do this you can use the ternary operator "?" like so:

Code:
a.atk < b.def ? Math.randomInt(a.atk/20) : a.atk * 3 - b.def * 2
You can combine this with Math.max as well to make sure the formula's output is always 1 like so:

Code:
Math.max(1, a.atk < b.def ? Math.randomInt(a.atk/20) : a.atk * 3 - b.def * 2)
 

SANTERSAKH

Villager
Member
Joined
Mar 21, 2019
Messages
14
Reaction score
1
First Language
Russian
Primarily Uses
RMMV
I noted in your previous post though that you wanted to use the random number between 1 and atk/20 only when a.atk < b.def (or maybe a.atk * 3 < b.def * 2, your word choice confused me a little).
This is an example. I will fit this formula for not-overpowered minimum damage.
 

Catog

Professional Internal Screamer
Veteran
Joined
Feb 9, 2016
Messages
53
Reaction score
13
First Language
English
Primarily Uses
RMMV
Okay, this is sending me stir-crazy, I swear.

I have a skill called Shatter which, if the target is already inflicted with Petrify, should inflict Death. Even if that isn't the case, I want it to inflict damage. But no matter what, I can't seem to get this to work.

I've tried two main formulas:
if (!b.isStateAffected(35)) b.addState(1); a.mat * 4 - b.def * 1
and
if (b.isStateAffected(35)) {b.addState(1); dmg = 0;} else {(a.atk * 4) - (b.def * 1); }
The latter is if I can't get it to work with damage, and therefore it'll either inflict Death or damage.
But no matter how much I try, I can't get it to work.

I have Yanfly's Buff/States Core, so if someone has a solution there, even, that can work.
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Okay, this is sending me stir-crazy, I swear.

I have a skill called Shatter which, if the target is already inflicted with Petrify, should inflict Death. Even if that isn't the case, I want it to inflict damage. But no matter what, I can't seem to get this to work.

I've tried two main formulas:

and


The latter is if I can't get it to work with damage, and therefore it'll either inflict Death or damage.
But no matter how much I try, I can't get it to work.

I have Yanfly's Buff/States Core, so if someone has a solution there, even, that can work.
Have you set your skill up to do (hp)damage?
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Yeah, definitely been set for HP Damage through the whole process.
Was reading it from my mobile just before now that I take a better look at your question it seems I missunderstood you.
I think you want this
Code:
if (b.isStateAffected(35)){ b.addState(1);} a.mat * 4 - b.def * 1
You had an "!" before b and you missed these "{ }" in your first example
 

Catog

Professional Internal Screamer
Veteran
Joined
Feb 9, 2016
Messages
53
Reaction score
13
First Language
English
Primarily Uses
RMMV
Was reading it from my mobile just before now that I take a better look at your question it seems I missunderstood you.
I think you want this
Code:
if (b.isStateAffected(35)){ b.addState(1);} a.mat * 4 - b.def * 1
You had an "!" before b and you missed these "{ }" in your first example
Hmm... I gave it a go, and while it did do the damage, it didn't add the Death state :/
 

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

Latest Threads

Latest Profile Posts

I picked up For The King in a Humble Bundle sale, and one mechanic that stuck out to me was a physical change to the world map when finishing a side quest. That got me thinking about special map-effect rewards for certain side quests in my game.
Stream will be live shortly with some Witcher 3! Feel free to drop by!
This forum is a great source of procrastination for me.
Today I read "The mouth speaks what the heart is full of." Simple, and reminds me I have a ton of work to do.
Why are cats so darn cute when their tongues are sticking out? If I did that, it wouldn't have the same effect.

Forum statistics

Threads
94,399
Messages
920,665
Members
124,193
Latest member
Oirammm18
Top