Default Attack Formula - No damage reduction

Pumamori

Veteran
Veteran
Joined
Oct 29, 2012
Messages
109
Reaction score
21
First Language
German
Primarily Uses
RMMV
Alright, so I hope the title isn't too confusing. Anyways, I really enjoy the formula function that allowes me to create my own damage formulas, and it works most of the time just fine, but sometimes, I feel like either I did something wrong, or the maker interprets my formula the wrong way, anyway, to the problem.

I'm using a resistance-based system in my game, similar to the MMORPG Dofus. Just to explain it real quick, it reduces the amount of damage taken by a percentage, equal to the defense stat of said attack type.

So I did a little thinking, and came up with the following: a.atk - b.def / 100 * a.atk

In theory, this does exactly what it should do, I tried it with some example values, like: "67 - 50 / 100 * 67 = 33,5"

My first thought was, that it might have done it in the wrong order, so I put some brackets here and there: a.atk - ((b.def / 100) * a.atk) , however, this still doesn't work. The result is always, that it does the exact same amount of damage, without reducing any of it, except it hits 100 Resistance, where it does no damage as intended. 

Example of what I mean:
Actor attacks with an attack stat of 20, enemy has a physical resistance of 50%. The output should be, without variance, 10, however, it comes out as 20. 

Actor attacks with an attack stat of 20, enemy has a physical resistance of 100%. No damage is done, as intended.

I checked some threads for formula suggestions and problems, but I didn't find one that tackled a problem similar to this one, excuse me if one already exists!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
all values in the system are integers by default - that means that everything after the decimal point is dropped by default.


You either need to force float, or sort the formulas to have divisions done last.


Example:


Mathematically. (b.def/100)*a.atk is the same as a.atk * (b.def/100) or even a.atk * b.def / 100


However, the integer reduction forces two different results in the case of a.atk=67 and b.def=50


1) b.def/100 is 50/100 is 0.5 - is zero after integer reduction. Zero multiplied by a.atk remains zero


2) a.atk * b.def is 67 * 50 is 3350. 3350 / 100 is 33.5 - is 33 after integer reduction, much more like the 50%-reduction of 67 that you expected.
 

Pumamori

Veteran
Veteran
Joined
Oct 29, 2012
Messages
109
Reaction score
21
First Language
German
Primarily Uses
RMMV
Works like a charm! Thank you very much! 
 

Pumamori

Veteran
Veteran
Joined
Oct 29, 2012
Messages
109
Reaction score
21
First Language
German
Primarily Uses
RMMV
Thanks for reopening!

Alright, so we still have the "solution" formula. "a.atk - (a.atk * b.def / 100)"

And it seems to work just fine on lower levels, but after I tried a testbattle against an enemy with 0 defense (=> No damage reduction, flat out the a.atk), with the attacker being a level 80 actor with about 200 attack, the damage output was 70.

200 - (200 * 0 / 100)
200 - 0 = ...70?

I'm sorry for consistently asking questions, but I want to give this project my all, and mistakes like that ruin quite the point in leveling up after a while, eh? :) 
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Did you remember to zero the variance?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Alright, so we still have the "solution" formula. "a.atk - (a.atk * b.def / 100)"
Please give a screenshot of the skill with that damage formula.
There are several other points that can affect damage (like the variance mentioned above), and in the formula itself - sometimes even a space more or missing can change the way ruby interprets a formula...
 

Pumamori

Veteran
Veteran
Joined
Oct 29, 2012
Messages
109
Reaction score
21
First Language
German
Primarily Uses
RMMV
Alright, I realised what the problem is. Nothing of the things mentioned above though, it was not the variance (it works as intended, and 15% from 200 should still not be at 70), and also no error with the formula.

It seems like, I can't playtest with a higher level, than I set the limit to in the first place.

Say, my actor 1 is only able to level up to 35 in the regular game for example, where the atk stat is at ~70. 

In the playtest, I try to use him with a level of 99, where his atk stat would be at ~200.

The damage I'm getting out is the same from 35 onward, so I suppose that's the explanation. Thanks for the quick help tho! :) 
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top