is something wrong with this formula

Nhum

Warper
Member
Joined
Nov 20, 2015
Messages
2
Reaction score
0
First Language
Thai
what i want is "if A have state 407 then add state 408 to A then damage formula if not damage formula
..but it won't work plz help

a.state?(407)? a.add_state(408); a.mhp / 4 : a.mhp / 4
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
a.add_state(408) if a.state?(407); return a.mhp / 4.0;

swap the IF, make the 4 a float.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
The problem with your formula is that you did not use any parenthesis at all. With them you would have not experienced the issue at all. That said, you can do it even shorter if you get rid of the return statement, which is not necessary in ruby and is also considered bad practice when you only have to return a single value:
Code:
a.add_state(408) if a.state?(407); a.mhp / 4;
make the 4 a float
VX Ace does not automatically convert float into integers. This will result in damage being a float. Not only does it look ugly, it might also create issues when checking battlers' HP when using "==".
An integer division here is perfectly fine, if you want to be more accurate, round the result, like this:
Code:
r = a.mhp / 4.0; a.add_state(409) if a.state?(407); r.round
However, I would rather not add the round part. I doubt a single digit is going to have a huge impact on the game-play.
 

Nhum

Warper
Member
Joined
Nov 20, 2015
Messages
2
Reaction score
0
First Language
Thai
thank you all of work for the help
the formula work now
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,254
Reaction score
1,254
First Language
Spanish
Primarily Uses
RMVXA
if you don't divide between floats, Ace might round the number down, returning 0.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
VX Ace does not automatically convert float into integers. This will result in damage being a float.
The damage is already in float, probably not in the damage formula if you didn't do it, but when counting to element rate and physical/magical damage rate, the final damage number is in float, so there is nothing wrong changing the damage formula into a float number. It will be returned back to an integer when executing damage.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
round the number down, returning 0
That only happens if the numerator is smaller than the denominator, which is unlikely going to happen since the denominator is 4 and mhp will likely be higher than that, no matter what (and the designer is going to set a fixed value for that in the classes/enemies database tab).

@TheoAllen you are indeed correct, there is a call to the to_i method in the call to make_damage after evaluating the formula. However, to_i only cuts decimal digits, while round rounds the number up or down. If you let the engine do it you might have a X.75 transform into X rather than (X + 1). Of course, whether or not this is necessary depends on how the OP wants to use the skill, but overall, I have to admit that using a float will not create any issue as the final damage is converted into an integer. Thank you for pointing that out, I honestly missed that to_i completely.
 

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

Latest Threads

Latest Profile Posts

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.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,446
Members
137,820
Latest member
georg09byron
Top