Yanfly's Battle Core - Damage Formula Syntax

kurt91

Veteran
Veteran
Joined
Dec 28, 2015
Messages
39
Reaction score
20
First Language
English
Primarily Uses
I made a damage formula that works just fine in the spreadsheet program I used to test it. It was very complex, though, so I downloaded and installed Yanfly's Damage Core to help make it a bit more manageable, since my project already uses all of the prerequisite plugins. I followed the instructions on how to set everything up, but my damage formula no longer works. When I set it up in RPG Maker MV, I ended up with my test player and test enemy doing zero damage every turn. I even tanked the enemy's attack up to 20, with my player's defense set to 2, and it still deals zero damage. The only thing that I can think of is that I made a mistake putting the damage formula in. Could somebody help look it over? Here's what I have...


<damage formula>


b.arm=(b.def-b.paramBase(3));


arm.var=(Math.randomInt(-b.arm,b.arm)*.10);


aluk.var=(Math.randomInt(0,a.luk)*.01);


bluk.var=(Math.randomInt(0,b.luk)*.01);


value=(a.atk + (.2 * a.agi) + aluk.var) / (b.def + b.arm + arm.var + bluk.var);


</damage formula>
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
<damage formula>


b.arm=(b.def-b.paramBase(3));


arm.var=(Math.randomInt(-b.arm,b.arm)*.10);


aluk.var=(Math.randomInt(0,a.luk)*.01);


bluk.var=(Math.randomInt(0,b.luk)*.01);


value=(a.atk + (.2 * a.agi) + aluk.var) / (b.def + b.arm + arm.var + bluk.var);


</damage formula>


I just woke up, so I can be mistaken, but what are those vars (b.arm, arm.var, aluk.var, bluk.var)?


Should those be variables you created inside that tag for the formula?


If you, you have to put a


var


in front of them or they won't work.


Something like this:


var bArm=(b.def-b.paramBase(3));

var arm=(Math.randomInt(-bArm,bArm)*.10);

var aLuk=(Math.randomInt(0,aLuk)*.01);

var bLuk=(Math.randomInt(0,bLuk)*.01);


only the value dosn't need that.
 

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
try this.

Code:
<damage formula>
b.cusPar = {};
b.cusPar.arm=(b.def - (b.paramBase(3)));
b.cusPar.armV=(Math.randomInt((b.cusPar.arm * -1),b.cusPar.arm) * 0.10);
b.cusPar.aluk=(Math.randomInt(0, a.luk) * 0.01);
b.cusPar.bluk=(Math.randomInt(0, b.luk) * 0.01);
value = (a.atk + (0.2 * a.agi) + b.cusPar.aluk) / (b.def + b.cusPar.arm + b.cusPar.armV + b.cusPar.bluk);
console.log(value);
</damage formula>
 
Last edited by a moderator:

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
what do you mean by 



b.paramBase(3)


what plugin do you use? for me paramBase return to undefined.


That shouldn't happen with or without plugins.


It could only occure when you don't have a target.


paramBase is a function of rmmv itself.


Every actor and enemy has it
 
Last edited by a moderator:

kurt91

Veteran
Veteran
Joined
Dec 28, 2015
Messages
39
Reaction score
20
First Language
English
Primarily Uses
I just woke up, so I can be mistaken, but what are those vars (b.arm, arm.var, aluk.var, bluk.var)?


Should those be variables you created inside that tag for the formula?


If you, you have to put a



var


in front of them or they won't work.


Something like this:



var bArm=(b.def-b.paramBase(3));

var arm=(Math.randomInt(-bArm,bArm)*.10);

var aLuk=(Math.randomInt(0,aLuk)*.01);

var bLuk=(Math.randomInt(0,bLuk)*.01);


only the value dosn't need that.
I noticed some other people using "var" like that, so I tried it as well, with no change whatsoever.


However, I did notice something that you did that worked! You removed the period from all of my variable names, changing things like "b.arm" into "bArm". I tried that, and it worked perfectly. It seems that you can't use periods in variable names for some reason, which kind of sucks because I was hoping to keep my variables in the same format as the built-in ones. Oh well, as long as it works...

try this.



<damage formula>
b.cusPar = {};
b.cusPar.arm=(b.def - (b.paramBase(3)));
b.cusPar.armV=(Math.randomInt((b.cusPar.arm * -1),b.cusPar.arm) * 0.10);
b.cusPar.aluk=(Math.randomInt(0, a.luk) * 0.01);
b.cusPar.bluk=(Math.randomInt(0, b.luk) * 0.01);
value = (a.atk + (0.2 * a.agi) + b.cusPar.aluk) / (b.def + b.cusPar.arm + b.cusPar.armV + b.cusPar.bluk);
console.log(value);
</damage formula>



I noticed that you did things differently. You managed to get periods working in your variable names. Why did that work? I mean, that first variable looks as though it made a difference. What does "b.cusPar = {};" mean?
 

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
I noticed that you did things differently. You managed to get periods working in your variable names. Why did that work? I mean, that first variable looks as though it made a difference. What does "b.cusPar = {};" mean?
I just assign an object to b.cusPar.


Your mistake is you need to assign an object to them, like

Code:
var arm = {};
//Then you can add whatever to arm like:
arm.whatever = 0;
arm.anything = true;
arm.everything = 'Hello Earth!';
 
Last edited by a moderator:

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
However, I did notice something that you did that worked! You removed the period from all of my variable names, changing things like "b.arm" into "bArm". I tried that, and it worked perfectly. It seems that you can't use periods in variable names for some reason, which kind of sucks because I was hoping to keep my variables in the same format as the built-in ones. Oh well, as long as it works...


yeah, right. You can't use periods for variable names 'cause they have a specific "role".


I'll try to explain it a bit.


What you see in the built-in formulas and variables is a bit different.


When you see


b.def


for example, the "b" stands for an object.


in this case for the target. The def is a property of this object.


So to access the def property you have to specify from which object you want it.


That's what the period is there for.


That's also what izyees does with the arm object.


The whatever, anything, and everything are properties/variables of that object
 
Last edited by a moderator:

kurt91

Veteran
Veteran
Joined
Dec 28, 2015
Messages
39
Reaction score
20
First Language
English
Primarily Uses
Okay, I think I get it. So, hypothetically speaking since I've already got my stuff working now, is there a way that I could add a "b.arm" or "a.wpn" to my project so they work like you'd expect as though they were always part of the system?


Sorry if I seem a bit stupid at this. I haven't done anything in Java since I took a class on it back in high school. I would have kept going at it, but the school decided it wasn't worth teaching anymore. Most of my programming knowledge is through a couple minor scripting languages and a basic grasp of Game Maker's GML.
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top