HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger Math problem. Help!

11-30-2004, 02:10 PM#1
Rith
I am making a map for Warcraft III. I want to make a point system, to show which player is the strongest at the moment. From a scale 0-100%. 0 means that you are defeated and got no money left. 100% Means you are victorious and got all the money in the game.
You can score 25% on 4 attributes, Units, Hero Levels, Buildings and Gold. 25+25+25+25=100.

Every 2 minutes the scoreboard will update with the following trigger;
Change value in scoreboard 1 for Player 1 into ( (Number of units owned by Player 1 / Total units in map) + (Number of buildings owned by Player 1 / Total buildings in map) + (Gold owned by Player 1 / Total Gold) + ((Level of Hero 1 owned by Player 1 + Level of Hero 2 owned by player 1) / Combined Levels of all Heros in map) x 25

But the problem is, that Warcraft III can't remember numbers beneath 1 (0,999 etc.) and since all (Something owned by Player X / Something in entire map) gets beneath 0 it won't update the scoreboard, well – it will, but it will always stay 0. Since 0 + 0 + 0 + 0 x 25 is 0..

Any suggestions?
11-30-2004, 02:37 PM#2
aaero
I'm not sure of the formatting, but you'll need to use the function

Conversion - Convert Integer to Real

The first portion will be

Real((Number of units owned by Player 1 / Total units in map) + ...) x 25

or

Real(Number of units owned by play 1) / Real(Total Units in map) + ... ) x 25

or in the worst case

Real(Number of units owned by play 1) / Real(Total Units in map)) + ... ) x 25

When you find which of those works, apply it to the other 4 calculations.

It has to do with how Warcraft (and most programming languages) do their math. When you are dealing with integers, you're going to lose everything after the decimal point (this is called truncating - it doesn't round off, it just drops everything afte the decimal point). By changing the data type to Real using the Conversion function, it will no long truncate automatically.
11-30-2004, 02:47 PM#3
Rith
I believe a scoreboard uses Integer.. not Real.

Edit; Okay, I got it working with variables now. Thanks a lot ^^