Why is this formula giving me Null damage?

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Try spacing the terms of the formula out more; place a space between every single operand (except consecutive parentheses) and see if that helps.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I'd like to see a screenshot of the skill as well, or at least copy and paste the formula from there to here rather than retyping it - I'm with Andar - need to know that it doesn't have a typo in the formula box but appears correctly here.

The other thing you can do is start adding debug points to each of those aliased/overwritten methods to print the formula before evaluating, and the result after evaluating, to see which one, if any, is messing it up.
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
Only thing I can think of is maybe one of the scripts you're using is rounding off integers, although that wouldn't explain the null pops.

You can't add 58 to -96 and get -154.  It would be -38.
Buh... wh... how...

You DO realize I added 96 to 58 there, and subtracted the resulting 154 from the 240, right?

Because that wasn't a -96 + 58, it was a 96 + 58. Subtractions come after additions.

On another note, it seems Tsukihime got the original formula working correctly, so perhaps the arithmetic order of operations is somewhat less... rigid than I thought, as it were.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Buh... wh... how...

You DO realize I added 96 to 58 there, and subtracted the resulting 154 from the 240, right?

Because that wasn't a -96 + 58, it was a 96 + 58. Subtractions come after additions.

On another note, it seems Tsukihime got the original formula working correctly, so perhaps the arithmetic order of operations is somewhat less... rigid than I thought, as it were.
Actually, addition and subtraction are left to right at the same time, at least in PEDMAS (which most computers and computer programs use). Though, surprisingly, the order of operations is not taught as a standard nationwide, so different countries/cultures have different assumptions on what to use (something I learned after teaching math for 10 years myself!).
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
lol math seems to be causing problems in this topic...

Buh... wh... how...

You DO realize I added 96 to 58 there, and subtracted the resulting 154 from the 240, right?

Because that wasn't a -96 + 58, it was a 96 + 58. Subtractions come after additions.
I'm assuming you're referring to this

240 - 96 + 58=240 - 154 = 86240 - 96 + 58 is not the same as 240 - (96 + 58)It's 240 + (-96 +58)

Regardless of country of origin I highly doubt any school would allow you to break the negative sign from a number and treat them separately.

-96 == -(96) == -1*96, but -96 + 20 != -(96 + 20) because -1*(96 + 20) equals (-96 - 20)
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Subtractions come after additions.
Not in THIS universe ;)


Things in brackets first, exponentials, then multiplication and division working from left to right, then addition and subtraction working from left to right.

On another note, it seems Tsukihime got the original formula working correctly, so perhaps the arithmetic order of operations is somewhat less... rigid than I thought, as it were
Not less rigid than you thought. You just thought wrong ;)
 
Last edited by a moderator:

Lowell

The Walking Atelier
Veteran
Joined
Apr 21, 2012
Messages
292
Reaction score
69
First Language
English
Primarily Uses
Pretty sure you have to add .to_i to the formula that has the HP a.hp values in it.

If memory serves right, it's considered a float otherwise.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
It is with immense joy that I can report that putting a parenthesis around the opening part of the formula seems to solve the problem.  Here is a copy/paste of the formula

(a.atk*4 - b.def * 2) + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp).

During the battle the character with this skill took a hit.  On the next turn the damage went up.  So all seems to be working as I intended.

You have no idea how much of a relief this is to me.

Thanks to all of you for your input.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I am pretty certain that putting parentheses around the opening part of the formula made no difference at all. You must have missed all that talk above about the order of mathematical operations.


This:


a.atk*4 - b.def*2 + ((a.atk*4 - b.def*2) * (a.mhp - a.hp)/a.mhp)


does exactly the same thing as this:


(a.atk*4 - b.def * 2) + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp)


You have either changed something else in your formula (extra spaces are always nice, and can sometimes make a difference), or it's just coincidence that it appeared to work on another attempt (or it really WAS working initially but something else was adjusting it). Do you have a variance? It won't surprise me if you come back to this and say it's not working after all.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I keep variance low, so it's only 8%, which isn't enough to make the difference between 200+ damage and Null.

I had run the test some 20+ times before posting here, and it gave null every time.  If something else was adjusting it, I have no idea what.  
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Did you run 20 tests after getting it to work and get a decent amount of damage every time?


Did you change any other scripts or anything else in the database?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
It's nearly 20 tests, and yes, decent damage each time.  The character starts the battle with just over 50% of HP.  If he gets hit on the first round his damage goes up on his next turn.  When his HP fell to just 8, the damage he dealt was huge, so that all seems to function as intended.

EDIT

Hit the post button too soon.

For your other question, nothing else changed.  I'm always very slow to re-configure scripts because I'm not very confident that I know what I'm doing.  the reason for emphasizing 'changed' is that indeed I altered nothing within scripts or database.  What I did do, though, was remove an unused script which was in my script list, but which I had decided not to use.  It was Vlue's CRI Effects script.  This script only mods critical hits via note tags, and the skill I've been posting about doesn't use that script.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Interesting. I can only imagine that you did something else to make it work, because I don't believe it's possible to get a different result by JUST adding the brackets.


But if it works ... ;)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Exactly - if it works, who am I to turn my nose up at it?  

I shall leave the thread open for a bit in case your fears about it ceasing to work materialize.
 

Espon

Lazy Creator
Veteran
Joined
Mar 20, 2012
Messages
1,810
Reaction score
192
First Language
Gibberish
Primarily Uses
RMMV
Does the problem come back if you remove the parenthesis?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Oh dear, no it doesn't.  It looks like it must have had something to do with the script that I removed after all.

At least Shaz will be relieved that the parentheses made no difference; she was sceptical about them.
 

Warpmind

Twisted Genius
Veteran
Joined
Mar 13, 2012
Messages
936
Reaction score
578
First Language
Norwegian
Primarily Uses
lol math seems to be causing problems in this topic...

I'm assuming you're referring to this

240 - 96 + 58=240 - 154 = 86240 - 96 + 58 is not the same as 240 - (96 + 58)It's 240 + (-96 +58)

Regardless of country of origin I highly doubt any school would allow you to break the negative sign from a number and treat them separately.

-96 == -(96) == -1*96, but -96 + 20 != -(96 + 20) because -1*(96 + 20) equals (-96 - 20)
Of course I was never taught it was alright to break a negative sign from a number and treat them separately - but in this case, as the formula was set up, there were no negative numbers. There was a subtraction, which is not the same thing. The 96 is a positive number (b.def*2), which is subtracted from another positive number.

While you should get the same result from adding a negative number and subtracting a positive number, the difference between the two is quite immense. :)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Of course I was never taught it was alright to break a negative sign from a number and treat them separately - but in this case, as the formula was set up, there were no negative numbers. There was a subtraction, which is not the same thing. The 96 is a positive number (b.def*2), which is subtracted from another positive number.


While you should get the same result from adding a negative number and subtracting a positive number, the difference between the two is quite immense. :)
Subtraction is by definition adding a negative number.


a - a = 0


a + (-a) = 0


What is the difference?
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Actually, by the official definition in math books, a - a is a + (-a). That is the way it is set up in algebra theory and accepted worldwide, so that is the official math definition.
 

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

Latest Threads

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