(85 100) = 0 ? Simple math not working?

Post » Mon Feb 17, 2014 1:14 am

debug.messagebox(attacker.getfactionrank(aadpH2HSkill)) ;-- this returns 85
debug.messagebox(attacker.getfactionrank(aadpH2HSkill) / 100) ;-- THIS RETURNS 0 ...ZERO!??
HUH? what am I missing here?
I tried this next:
int Num = attacker.getfactionrank(aadpH2HSkill)
debug.messagebox(Num) ;-- returns 85
debug.messagebox(Num / 100) ;-- this still returns ZERO!
User avatar
Nikki Morse
 
Posts: 3494
Joined: Fri Aug 25, 2006 12:08 pm

Post » Sun Feb 16, 2014 4:13 pm

Had the same issues, try this...

debug.messagebox(Num) / 100
User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Mon Feb 17, 2014 1:55 am

That was it!

Thank you so very much, I thought I was going crazy.

...and now I hate you. :tongue:

Now I have to go thru ALL my scripts ( OMG ) and double check that this is not in any of my other math formulas.

I do not think it is because I would have caught this by now if I did this, but now I have to read EVERY line just to be sure. :mellow:

User avatar
Lauren Dale
 
Posts: 3491
Joined: Tue Jul 04, 2006 8:57 am

Post » Mon Feb 17, 2014 12:38 am

Yeah, math drove me crazy as well in a miriad of scripts, specially the CK Wiki tells you otherwise.

User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Sun Feb 16, 2014 1:56 pm

Strange how some like this will work: massmod = AttackerWeapon.GetWeight() / steelSwordW

and this: attacker.GetActorValue("Sneak")/100

Both are working fine, but not the one that is "get faction rank".

Well, once again thank you, I would have been banging my head on a wall all night if you had not answered that so quickly.

User avatar
Lil Miss
 
Posts: 3373
Joined: Thu Nov 23, 2006 12:57 pm

Post » Sun Feb 16, 2014 6:32 pm

This look like the integer arithmetic problem someone just asked about all over again. There's no mystery. If you divide two integers you get an integer back, even if you want to use it as a float later.

GetWeight() returns a floating point number GetFactionRank() doesn't.

debug.messagebox(attacker.getfactionrank(aadpH2HSkill) / 100.0) ; putting the decimal point in 100.0 will give you a decimal answer.

If both numbers are in integer variables (or integer values returned by a function) use the "as float" operation on one of them.

float avg = (sum as float) / count
float avg = sum / (count as float)
User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Mon Feb 17, 2014 3:29 am

interesting, that does make sense (in a programming "think" way) , but then why is this one working correctly:

attacker.GetActorValue("Sneak")/100

GetActorValue("Sneak") is an Int ...er...right?

User avatar
Stacyia
 
Posts: 3361
Joined: Mon Jul 24, 2006 12:48 am

Post » Sun Feb 16, 2014 7:33 pm

Actor Values are floats (well some of them are at least). Health, Magicka, and Stamina definitely are. I think skills use the fractional part to report progress toward leveling. Some others never have a fractional value, but the function always returns a float.
User avatar
Robert DeLarosa
 
Posts: 3415
Joined: Tue Sep 04, 2007 3:43 pm


Return to V - Skyrim