• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Strange Income numbers

Status
Not open for further replies.
Level 3
Joined
Dec 2, 2006
Messages
32
Hello, I've been making a map for a week or so and this is the income trigger I have been using:
  • Income
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Income = ((Income x 115) / 100)
      • Player Group - Pick every player in (All players) and do (Player - Add Income to (Picked player) Current gold)
      • Game - Display to (All players) the text: (You get + ((|cffffcc00 + ((String(Income)) + |r)) + gold from income.))
It works fine and after circa 90 incomes the amounts looked like this:
Income 92: 15527250
Income 93:17856337
Income 94: 20534787
Income 95: -19334667
Income 96: 20952878
Income 97:-18853863
Income 98: 21267730
Income 99: -18491783
Income 100: -21265550
Income 101: 18494290
Income 102: 21268433
Income 103: -18490975
Income 104: -21264621
Income 105: 18495358

The increment of the income is 15% so why does it become negative?

Anyway, I've changed it now because the amounts aren't supposed to go so ridiculously high.
 
Last edited:
Level 6
Joined
Feb 2, 2005
Messages
205
i think it is because cant calculate big number very well. why dont you do it like this:

  • Income
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set Increase = 1.15
      • Set Income = (Income x Increase)
      • Player Group - Pick every player in (All players) and do (Player - Add Income to (Picked player) Current gold)
      • Game - Display to (All players) the text: (You get + ((|cffffcc00 + ((String(Income)) + |r)) + gold from income.))
Increase should be a real value
 
Level 3
Joined
Dec 2, 2006
Messages
32
The Income is an integer value and the increase a real. Integer values can't be multiplied with real values. Atleast not in this scenario. I've changed the income to real but I always get lots of extra numbers i.e. 133.506. How can I approximate (is that how you say it? My English vocabulary isn't that good.) this number to a whole number?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The reason the error occured in the firstplace was you exceeded the maximum size of a 32 bit variable by multiplying by 115 before dividing and thus it errored and changed the sign bit and then preformed the division.

One way to work around this would be to use a form of scientific notation (ofcourse losing accuracy after a certian number). For this you basically have a real as your number and then multiply that by 10 and use and integer for the power of that 10. However you already solved it and thus this method is pointless unless you want to work with insainly high numbers.
 
Status
Not open for further replies.
Top