• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How to round properly

Status
Not open for further replies.
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.
Back
Top