Try spacing the terms of the formula out more; place a space between every single operand (except consecutive parentheses) and see if that helps.
Why is this formula giving me Null damage?
RPG Maker VXAce SupportI'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.
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.
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!).
lol math seems to be causing problems in this topic...
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)
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)
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.
Not less rigid than you thought. You just thought wrong 😉
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.
If memory serves right, it's considered a float otherwise.
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.
(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.
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.
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.
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.
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.
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?
Did you change any other scripts or anything else in the database?
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.
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.
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 ... 😉
But if it works ... 😉
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.
I shall leave the thread open for a bit in case your fears about it ceasing to work materialize.
Does the problem come back if you remove the parenthesis?
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.
At least Shaz will be relieved that the parentheses made no difference; she was sceptical about them.
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?
http://nrich.maths.org/5947 explains it better than I can.
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.
Original thread: https://forums.rpgmakerweb.com/threads/why-is-this-formula-giving-me-null-damage.34041/