• 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.

How to round properly

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
I'm working on something that adds +1 to a integer variable every 10 hero levels however after level 10 it just adds +1 anyways, anyone know how to detect every 10 numbers then add +1? Since the numbers go past 10,000 I can't do if checks to see if hero level is 10,20,30,etc.
Use the power of the modulus operator!

Level mod 10 == 0

Every 10 levels it will be true, just what you want. I forget if this was a SC2 or WC3 problem but you might need to loop for each level gained in case the hero gains more than 1 level instantly (large exp source) as otherwise you will potentially miss out levels that meet the condition.
 
Status
Not open for further replies.
Top