• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Decimals in Variables

Status
Not open for further replies.
Level 3
Joined
Jul 27, 2008
Messages
35
Hi everyone.

I'm having trouble in a little map I'm working on.

Right now I have a trigger that makes it so whenever an "ancient" classified unit dies, the hero gets stats based on the level of the unit.

The equation basically goes something along the lines of "add (10 x (level of dying unit)) x StatMultiplier str/agi/int"

It works for the most part, but I'm having trouble with the StatMultiplier variable. I can't seem to set it to a decimal number.

I want it to be 1.5, but I can only get it to be 2 or 1.

Also, if I try to set the variable to 3/2, it just sets it to one.

Is there anyway I can set the variable to a number with a decimal?

Also, I am sorry if this is in the wrong section. I'm not sure if variables are triggers or not. I would improve the post, but it isn't easy on this damn cottage dial-up.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's what you can do:

Calculate the stat bonus and save it to a real.
Convert the bonus to an integer. It will get rounded down.
Subtract the value of the integer from the real.
Give the bonus to your unit.

Now your stat bonus is something like 0,54 for example.

Next time you kill an ancient, save the bonus to the same real, use Real_Number = Real_Number + bonus.
Convert it again to an integer, and do the subtraction.

That way none of your bonus gets wasted.
 
Level 3
Joined
Jul 27, 2008
Messages
35
Yay I'm back home :D

Anyways, I had to read over Maker's post a few times to understand it (and I'm the guy who gets everything :eek:), but I decided it was a good idea to use it in my map because there is a large chance the base stat bonus could change to an odd number (so large that I made it its own variable :thumbs_up:).

I was able to implement it and it worked perfectly! :cool:

Thanks for the help guys.
 
Status
Not open for further replies.
Top