RMMV Damage Formula - ideas and help

SavageWolf09

Villager
Member
Joined
Jan 24, 2015
Messages
20
Reaction score
5
First Language
English
Primarily Uses
You are welcome, solving puzzles is fun and i get to see a new perspective on skills.
Did you manage to get the skill working? The one with which you wanted to select the weapons attack?
Kinda just put it together and haven't tested it.
No, I looked at the formula and while I could make out parts. The formula as a whole was beyond me. However the above formula did what i need. but instead of a weapons atk I used variables to create a set of stats like strength and dexterity
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
No, I looked at the formula and while I could make out parts. The formula as a whole was beyond me. However the above formula did what i need. but instead of a weapons atk I used variables to create a set of stats like strength and dexterity
Ah well no worries i can explain "a.isActor" is a built in function that returns true if the user of the skill is an actor (an actor is the players character(s)or allie)and so we can use it in our "if statement".

a.actorId is a builtin function that returns the ID of the actor so long the user actually is an actor.
We give our own declared variable "x" the value that a.actorId returns.

"value" is an variable used by Yanfly's damage core plugin and will contain the damage formula.
The code is listed between"<damage formula></damage formula>" so that the plugin knows that there is code there in between.

You seem to understand "Math.randomInt()".


"$gameActors.actor(x).equips()[0].params[2]"And now this. Do you know how to enter the debug console? If you change "x" to 1 for example and enter this there,
the game will check in the list of actors in the game "$gameActors"
with actor id 1 "$gameActors.actor(1)"
and check his list of equips and selects the first equip"$gameActors.equips()[0]"
a piece of equipment can have 8 different stat bonuses from where number 3 is the one for attack but arrays count from 0 thus we use 2"$gameActors.equips()[0].params[2]".

equips is a function that returns an array thats why "()" these are needed.
You can break the entirety of it up at the "."like i did above and use it in the debug console (and in the damage formule as long Yanfly damage core plugin is used)

Hope it helped, and just ask if you don't get something or if something wasn't clear to you.
 

Sednaiur

Villager
Member
Joined
Jul 7, 2018
Messages
26
Reaction score
8
First Language
German
Primarily Uses
RMMV
I was thinking about a simple and easy to use, yet nicely expandable damage formula to better balance the damage progression in my RPG while giving a lot of options to raise damage by different means.
In my RPG you do not gain ATK or MAT through your levels, but only by equipment (like in FF6). Yet I wanted every level to matter in any damage formula needed, but not in a rough way like a.atk + a.level - b.def *2 since I am not in favor of such simple straight formulas.
I could only find things like a.atk * 3 - b.def *2 or a.atk * a.atk and stuff, so I came up with this idea to fix that problem:

The damage formula is as simple as this:
Code:
500 * a.atk * 0.02 * a.level * 0.02
I first give a skill it's own parameter to be modified (that simple "500" there) and take this role off from the ATK, which now serves as a multiplier itself instead of being the rough number. And by also using the level of the user I can more finetune the formula, so the above formula would do 20 damage when done by a character with 10 levels and 10 atk. I think this is really useful if I want the levels of my characters matter without being too weightful early on or too useless later on.

But, of course, this could be improved by implementing actual variables into that formula, so I will actually be able to raise that 500-number by a variable, which brings me to my question:

How do I add a variable to any damage formula?
Let's say I have a variable with the ID 0005 called "base damage raiser" and I want to put that after the 500 in the formula. How to do so?

I use most of YanFly's plugins, in case it helps.
 

Sednaiur

Villager
Member
Joined
Jul 7, 2018
Messages
26
Reaction score
8
First Language
German
Primarily Uses
RMMV
@Boonty
Thank you very much. You were fully right.
Now I can go one step further into detail with my formulas. :)
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
Hi wanted to thank everyone for their help with my D&D style Damage Formula and decided to upload it here.

if (b.def <= (Math.randomInt(20) + 1 + a.atk + Math.floor(v[1]-10)/2)) Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0

if (b.def <= (Math.randomInt(20)+ 1 + a.atk + Math.floor(v[1]-10)/2)) This is the attack roll that decides if you hit or miss


if (b.def <= (Math.randomInt(20) + 1 is the dice roll that results in a number from 1 to 20. Then you add your overall atk as the Proficiency bonus. Then Math.floor(v[1]-10)/2)) as the part that determines your ability score. With this part you will have to create a variable to act as the six basic skill.

I recommend using yanfly's actor variables just to keep track of them in game.

Math.randomInt(4) + 1 + Math.floor(v[1]-10)/2; else 0 is the damage roll

Math.randomInt(4) + 1 is the basic dice roll. Just repe lace the 4 with the type of dice roll you want. 4 for a d4 dice 6 for d6 etc.

Math.floor(v[1]-10)/2 this is you ability score again.

else 0 just reduces all damage to 0 if your attack roll doesn't beat out your opponents. As I couldn't figure out how to do a miss.
Are you making a separate skill for each weapon, or do you know a way to get the weapon to provide the damage calculation? I'm trying to do the D&D thing too, and I'd really like to be able to put the damage calculation into the weapons themselves. (I'm going to use a plugin to mess with Hit and Eva to determine hits and misses.) The Yanfly Damage Core looked promising with it's ability to set damage in a note, but it seems that the notes only work in Skills or Items, when I need it to work in the note of a Weapon. (Still new to the software and my brain hasn't gotten used to thinking of "weapon" and "item" as two fundamentally different categories of objects.)
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Are you making a separate skill for each weapon, or do you know a way to get the weapon to provide the damage calculation? I'm trying to do the D&D thing too, and I'd really like to be able to put the damage calculation into the weapons themselves. (I'm going to use a plugin to mess with Hit and Eva to determine hits and misses.) The Yanfly Damage Core looked promising with it's ability to set damage in a note, but it seems that the notes only work in Skills or Items, when I need it to work in the note of a Weapon. (Still new to the software and my brain hasn't gotten used to thinking of "weapon" and "item" as two fundamentally different categories of objects.)
Every weapon? or every weapon type?
You can have a common event check in every battle what/which weapon(type) you have and then create your damage calculation for every weapon(type) and store it into variable X.
Have your skill use variable X as in
Code:
<damage formula>
value = $gameVariables.value(X);
<\damage formula>
It should work but it is a lot of work to do so I have made something similar but even added a bit more complexity to it really it will take up quite some time (well most of the time spend was figuring out how i could get it to work and testing).
Notes*
Your damage formula becomes bigger + your common event if other actors beside actor 1 will use the same skills.
It also becomes bigger if enemies are able to use the same skills.
 

UnknownQED

Villager
Member
Joined
Jan 15, 2019
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hi! I'm trying to write a skill that will kill an enemy when they use it (but deal a lot of damage to the player). In my attack formula I have:
a.hp -= 1000; <damage formula for attack>
(We can assume that the enemy has less than 1000 hp). They use the attack, but don't die. What am I doing wrong?

As a note, I also tried:
a.setState(1)
and after all the enemies used the ability I won the battle, but the enemy image persisted (I wasn't able to test if the enemy could still be targeted), which is obviously not great behavior.
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Hi! I'm trying to write a skill that will kill an enemy when they use it (but deal a lot of damage to the player). In my attack formula I have:
a.hp -= 1000; <damage formula for attack>
(We can assume that the enemy has less than 1000 hp). They use the attack, but don't die. What am I doing wrong?

As a note, I also tried:
a.setState(1)
and after all the enemies used the ability I won the battle, but the enemy image persisted (I wasn't able to test if the enemy could still be targeted), which is obviously not great behavior.
"a.hp -=1000" you are trying to assign a value to a.hp if i'm correct.

I think you should create a second skill "suicide", target self, value a.hp and have your skill have the effect of "force action" skill "suicide".

Should do the trick.
 

UnknownQED

Villager
Member
Joined
Jan 15, 2019
Messages
10
Reaction score
1
First Language
English
Primarily Uses
RMMV
This may be dumb, but where is "force action" on the skill effects tab?
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
This may be dumb, but where is "force action" on the skill effects tab?
No it isn't I kinda forgot you have to use an common event as the effect and within that common event you can select force action.
But it isn't exactly intuative to use and may not be fully to your liking either.....
I knew it was possible to do but force action is only useable in very specific situations.
So you may want to use the script variant
Code:
$gameTroop.members()[index].forceAction(skillId, targetIndex)
But then we are delving into teritory I also haven't explored yet as I don't know how you can use it in combination with Yanfly's plugins and don't know how you properly select the enemy who has to suicide in case of multiple enemies.

Maybe someone else can help you further.

oh wait i remember something, with Yanfly's skill core plugin you can define custom costs for skills.
Using that you could have your skill use the users entire hp as cost might be the bettter solution.
 
Last edited:

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
Every weapon? or every weapon type?
I'll need it for every type, but I'll need to adjust some weapons in particular to let them do, say an extra X amount of fire damage on top of what the category normally does.

You can have a common event check in every battle what/which weapon(type) you have and then create your damage calculation for every weapon(type) and store it into variable X.
Have your skill use variable X as in
Code:
<damage formula>
value = $gameVariables.value(X);
<\damage formula>
It should work but it is a lot of work to do so I have made something similar but even added a bit more complexity to it really it will take up quite some time (well most of the time spend was figuring out how i could get it to work and testing).
Notes*
Your damage formula becomes bigger + your common event if other actors beside actor 1 will use the same skills.
It also becomes bigger if enemies are able to use the same skills.
Yeah, I figure Common Events are likely a fallback if something easier won't get the job down. I figured out how to get basically what I'm going for by using YEP Weapon Unleash, assigning each weapon a corresponding skill with that damage formula, and giving a 100% chance of that weapon unleashing that skill when used. While with my current level of experience (little) I think it would take me a while to figure out how to get the common event to work right, but I'm not sure which is the better option in the long run. Thoughts?
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
I'll need it for every type, but I'll need to adjust some weapons in particular to let them do, say an extra X amount of fire damage on top of what the category normally does.



Yeah, I figure Common Events are likely a fallback if something easier won't get the job down. I figured out how to get basically what I'm going for by using YEP Weapon Unleash, assigning each weapon a corresponding skill with that damage formula, and giving a 100% chance of that weapon unleashing that skill when used. While with my current level of experience (little) I think it would take me a while to figure out how to get the common event to work right, but I'm not sure which is the better option in the long run. Thoughts?
My thoughts.
I didn't know about that plugin, it seems to be able to do what you want as well.
If it is able to do all you want i'd say you just stick to that plugin but try to think ahead what other skills you want to make for your different weapon types and what kind of damage/effects they should have.

What i can see my method with common events has only this advantages:
1: Reuseability for other skills as every skill will keep using variable X.
2: Less skills needed as they all make use of the same attack skill.
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
My thoughts.
I didn't know about that plugin, it seems to be able to do what you want as well.
If it is able to do all you want i'd say you just stick to that plugin but try to think ahead what other skills you want to make for your different weapon types and what kind of damage/effects they should have.

What i can see my method with common events has only this advantages:
1: Reuseability for other skills as every skill will keep using variable X.
2: Less skills needed as they all make use of the same attack skill.
I think your idea of using common events is a better method. I was thinking it through and realized that if I have each weapon be a skill, then it would be difficult (impossible?) to use different weapons with the same skill (where a skill adds something to the basic weapon attack, for instance)--which is something I will need to do with some characters.

The thought I'm having about how I might be able to implement it would just be to make a "Weapon Damage" common event that checks which weapon the actor is using, does the damage formula, and then outputs it to a variable. I could probably even just insert the variable into the normal damage formula form and not even need to call on Damage Core (at least for this particular feature). Since there are really only a few different basic damage configuration for weapons, it wouldn't be terribly long--many weapons would share the same damage formula.

The downsides that immediately occur to me are that I'll have to have the common event check the equipment every turn, since the actors will be able to switch in battle, I'll have to find some way to reset the variable after it is used (or otherwise make sure it doesn't get used again until it's run again), I'll have to add to the event every time I make a new weapon (which won't be terribly often), and unless I'm missing it, I can't find any event option that will check which equipment is being used by the actor--running the common event doesn't seem to transfer the info on who the actor is or what weapon they're attacking with. That last one means I'll probably have to figure out how to do it with JavaScript (which I don't know how to use).
 
Joined
Apr 26, 2017
Messages
2
Reaction score
1
First Language
english
Primarily Uses
RMMV
If it isn't too much trouble to ask, I am making a weapon in my game where the damage output is directly proportional to the entire party's HP total. I am wondering how I would call that value in a damage formula (I am using a different skill than the default attack for this particular weapon). If anyone has advice I would be very appreciative.
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
If it isn't too much trouble to ask, I am making a weapon in my game where the damage output is directly proportional to the entire party's HP total. I am wondering how I would call that value in a damage formula (I am using a different skill than the default attack for this particular weapon). If anyone has advice I would be very appreciative.
You will have to use damagecore plugin of Yanfly and you could use the same steps of using it as above by putting the value you want in a variable by means of a common event or you could write it the damage formala itself.
Code:
<damage formula>
value= 0;
for(i=0; i < $gameParty._actors.length; i++)
{value +=gameActors.actor($gameParty._actors[i]).hp;}
</damage formula>
This should do it I believe.
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
I think your idea of using common events is a better method. I was thinking it through and realized that if I have each weapon be a skill, then it would be difficult (impossible?) to use different weapons with the same skill (where a skill adds something to the basic weapon attack, for instance)--which is something I will need to do with some characters.

The thought I'm having about how I might be able to implement it would just be to make a "Weapon Damage" common event that checks which weapon the actor is using, does the damage formula, and then outputs it to a variable. I could probably even just insert the variable into the normal damage formula form and not even need to call on Damage Core (at least for this particular feature). Since there are really only a few different basic damage configuration for weapons, it wouldn't be terribly long--many weapons would share the same damage formula.

The downsides that immediately occur to me are that I'll have to have the common event check the equipment every turn, since the actors will be able to switch in battle, I'll have to find some way to reset the variable after it is used (or otherwise make sure it doesn't get used again until it's run again), I'll have to add to the event every time I make a new weapon (which won't be terribly often), and unless I'm missing it, I can't find any event option that will check which equipment is being used by the actor--running the common event doesn't seem to transfer the info on who the actor is or what weapon they're attacking with. That last one means I'll probably have to figure out how to do it with JavaScript (which I don't know how to use).
Yes you are right i will show you a bit how i have it set up.
This is how I make the checks (Conditional branch- script)
Code:
$gameActors.actor(1).isWtypeEquipped(1)
Every actor has a different variable they use. (like I said having more actors makes it bigger)
And this is how my attack skill looks like
Code:
<damage formula>

if( a.isActor()  && a.actorId() === 1){value = v[46] * (v[20] / 100) - b.def * 3 * (v[40] / 100) ;}
 else if( a.isActor()  && a.actorId() === 2){value = v[66] * (v[41] / 100) - b.def * 3 * (v[39] / 100);}
 else if( a.isActor()  && a.actorId() === 3){value = v[86] * (v[42] / 100) - b.def * 3 * (v[38] / 100) ;}
 else if( a.isActor()  && a.actorId() === 4){value = v[106] * (v[43] / 100) - b.def * 3 * (v[37] / 100);}
 else if( a.isEnemy()){value = a.atk * 6 - b.def * 3 ;}


</damage formula>
Like i said I made it a bit more complex every actor has 2 variables they use in their attack and I use even more to calculate the base value every variable used in the formula has and I have also asigned a variable for each enemy's defense(sadly I have just realised that I need to rewrite the code/common event for the skills that use it as i have made an mistake in it )
This should help you advance a bit smoother i think.
 
Joined
Apr 26, 2017
Messages
2
Reaction score
1
First Language
english
Primarily Uses
RMMV
You will have to use damagecore plugin of Yanfly and you could use the same steps of using it as above by putting the value you want in a variable by means of a common event or you could write it the damage formala itself.
Code:
<damage formula>
value= 0;
for(i=0; i < $gameParty._actors.length; i++)
{value +=gameActors.actor($gameParty._actors[i]).hp;}
</damage formula>
This should do it I believe.
Thank you this was very helpful!
 

Dethroner

Villager
Member
Joined
Jun 21, 2016
Messages
12
Reaction score
3
First Language
Rus
Primarily Uses
RMMV
Hello!
I want to make a battle system like in the game Eiyuu * Senki.

Outline of little battle:
--------
Hero
--------
HP 520
ATK 8
DEF 6
--------
Enemy
--------
HP 280
ATK 5
DEF 3


1st option: Hero attacks Enemy with full HP. Result about 190 damage (Enemy left with 90 HP)
2nd option: Enemy attacks Hero with full HP. Result 65 damage (Hero left with 455 HP)

So, I need to make an attack formula, where the damage is dependent on HP with the influence of ATK and DEF.

Can you help please? Thanks in advance!
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Hello!
I want to make a battle system like in the game Eiyuu * Senki.

Outline of little battle:
--------
Hero
--------
HP 520
ATK 8
DEF 6
--------
Enemy
--------
HP 280
ATK 5
DEF 3


1st option: Hero attacks Enemy with full HP. Result about 190 damage (Enemy left with 90 HP)
2nd option: Enemy attacks Hero with full HP. Result 65 damage (Hero left with 455 HP)

So, I need to make an attack formula, where the damage is dependent on HP with the influence of ATK and DEF.

Can you help please? Thanks in advance!
Dependant on the hero's HP?
If so
Code:
<damage formula>
value = (($gameActors.actor(your hero id).hp / $gameActors.actor(your hero id).mhp))*($gameActors.actor(your hero id).atk*25);
<\damage formula>
In your example if your hero is at full health this would do 200 damage he takes 65 damage bringing his health to 455
455/520*100 = 0,875 * (8*25) =175
 

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

Latest Threads

Latest Posts

Latest Profile Posts

The more I think about it, the weirdest part of going to work post-virus will probably be getting used to seeing my coworkers' mouths again. :LZYshock:
I think one of my weirdest realizations is that my speed of game development would probably be about the same if I *didn't* work a full-time manual labor job.
Quick question, what's the best way to capture-er, I mean RECRUIT playtesters? Should I make a project thread and use that?
Node Graph out of Date. Rebuilding...
Does anyone know of any good Discord groups for art or biology discussion, that sort of thing?

Forum statistics

Threads
98,056
Messages
948,945
Members
129,333
Latest member
rootcf
Top