Battle Formula Help

Darccloud92

Villager
Member
Joined
Jun 26, 2015
Messages
7
Reaction score
0
Primarily Uses
Hello I'm currently learning how to customize battle formulas for skills. I've looked at several tutorials to make some more interesting skills, but I'm having trouble trying to correctly make a particular skill. At it's core, the skill I am working on is supposed to deal damage to the target then heal the user. Ultimately what I'd like to have it do is deal both physical and magical damage and heals the user for the magic damage dealt. Here is the first formula I tried, however it does not work like it should, it does far to much damage. I think it is adding the users HP to the damage dealt.


a.atk * 4 - b.def * 2; x=a.mat *2.5 - b.mdf; a.hp +=(a.hp+x)


when written this way the formula has the same problem


r = (a.atk + a.mat) - (b.def +b.mdf); a.hp +=(a.hp+r)


When I do this instead, just dealing damage based on magical attack and healing for the damage dealt I also get ridiculously high damage. Both heal the user like they are supposed to at least


a.hp += (a.hp + (a.mat - b.mdf))


Any help with what I'm doing wrong or the correct way to actually right this formula would be stellar to know, ty in advance!
 

Victor Sant

Veteran
Veteran
Joined
Mar 17, 2012
Messages
1,694
Reaction score
1,452
First Language
Portuguese
Primarily Uses
the last value must always be numeric, it will be the damage dealt. On your case, the last value is  a.hp + r, so basically the damage is being equal the actor's HP + the damage.


So if you want to do something after the damage is calculated, you must return the damage value again at the end.


for example:


dmg = damage_formula; do_something_else; dmg


The last part in green is essential for the maker to get the correct value.


Your formula should be something like


dmg = (a.atk + a.mat) - (b.def +b.mdf); a.hp += dmg; dmg


if you want the healing to be based only on the magic damage, you would need to store both the magic and physcal damage separatedely and return both at the end.


something like


dmg = a.atk - b.def; mag = a.mat - b.mdf; a.hp += mag; dmg + mag


Also you're doing something wrong on your formula:


a.hp +=(a.hp+r)


this will not add the damage to the user's hp, it will add the user's own HP + the damage.


So if the user has 1000 HP and deals 500 damage, he will heal 1500 hp. 
 
Last edited by a moderator:

Darccloud92

Villager
Member
Joined
Jun 26, 2015
Messages
7
Reaction score
0
Primarily Uses
Ah thank you so much! I should have realized if I could store data in variables I could store the damage results. That's weird about having to return to the damage at the end, great to know. And thanks for the correction on properly updating the amount of health they were gaining, I just figured updating it would be like updating a variable in ruby.


So I just tested the formulas and the didn't work for me but I think i figured out why. It didn't like me adding equations when defining dmg and mag. Is there a way I can put equations in there without causing the error?


Edit again* I played around with the syntax and ending up getting this to work, I guess I just cant multiply their defense? I tried multiplying their defenses in variables but that didn't seem to work either


 dmg = a.atk * 1.5 - b.def; mag = a.mat * 3 - b.mdf; a.hp += (mag*3); dmg + mag
 
Last edited by a moderator:

Raikiri91

Villager
Member
Joined
Aug 30, 2014
Messages
23
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I am using this formula for my attack skill:
if a.atk * 4 - b.def * 100 < 0; b.atk + a.atk ;end;
and I am getting a LOT of misses in battle. I don't fully comprehend damage formulas.
I have only param HIT on my actors/enemies/classes/gear and all set to 100% Could that be a reason for error, or is it something with my formula?

oh I am also using yanfly battle engine, enemy hp, extra params, auto battle, and visual battlers. all on default.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top