• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to round properly

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
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