• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

(Difficulty System) Registering An Integer As A Decimal

Status
Not open for further replies.
I have an idea in my head for a difficulty set system and half way through it I realized the game may not accept decimal in Integers.
I do know you can't change an integer to a decimal in the editor, but can it be a decimal in the actual game?
My difficult system essentially works like this:

Player chooses difficulty:

---------------------------------
Difficulty: Integer = #
---------------------------------

Easy: Difficulty - Pick P# = 1
Medium: Difficulty - Pick P# = 2
Hard: Difficulty - Pick # = 3

Difficulty - Pick P1 Initial Value = 0
Difficulty - Pick P2 Initial Value = 0
Difficulty - Pick P3 Initial Value = 0
Difficulty - Pick P4 Initial Value = 0

---------------------------------
After 30 seconds, to set difficulty:
---------------------------------

Set (Difficulty - Set) = ((Difficulty - Pick P1 + (Difficulty - Pick P2 + (Difficulty - Pick P3 + Difficulty - Pick P4))) / Active Players)

Active players is an integer variable I have set to the number of active players currently in the game.

However if, for example, there are 2 players in the game, one chooses hard (3) and one chooses medium (2) that would mean Set (Difficulty - Set) would be 5 / 2 = 2.5.

If the game registers 2.5 as an integer variable, what is going to happen? Will it round up or down?
I can't make a trigger that registers 2.5 as an answer because I literally can't type in 2.5.
If I use "<=" or ">=" then, for example, (>= 1) could mean 2 or 3.
I don't want to finish the code and test it because I fear that all the time coding it will be of waste.

Any help?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Integers are whole numbers only. They are always truncated. Thus 5/2 = 2

Read the mathematic defitinion of integers. Only real difference is that there is a limit based on a 32 bit signed type.

Integers in WC3 behave simlar to 32bit signeds (with two's compliment).
Reals in WC3 behave simlar to 32bit floats (I think).

Reals in WC3 however are rhumored to undergo some integer opperations at large sizes so might experience overflow (usually not possible with floats).

You can represent a decimal using integers via means of fixed point maths to a degree but that is virtual (you need to manually devise logic to convert to decimal).
 
I see.
As long as the game doesn't wig out and not produce a number or set the variable to null I'm okay.
If it is always truncated than I'm alright with that.
In a sense I wish it would round up, seeing as how expert players prefer not to play lower difficulty settings, while lower experienced players wouldn't mind trying a higher difficulty.
Then again, seeing as how it's nazi zombies, the two might be reversed simply for the fact that on a lower difficulty setting you have a possibility of reaching a higher round.
Anyways, thank you. I appreciate the help.
Time to get back to my GUI coding :)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Oh you are refering to SC2... Your PM made me think you were talking about WC3.

Integers in SC2 behave simlar to 32bit signeds (with two's compliment).
Fixed in SC2 behave simlar to a 32bit signed configured to represent a fixed point number.

You may wish to use a fixed point number for this sort of task as you can then perform rounding.
 
Status
Not open for further replies.
Top