• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Simple Question about integers

Status
Not open for further replies.
Why this code doesn't work:
  • Set SOULS = (SOULS - (SOULS x ((18 - (3 x (Level of Soul Birst for SBirst_caster))) / 100)))
SOULS is an integer. Also when i change this trigger to "souls = souls - 2" it works. So it must be this action, but here is the hole code:
  • SoulBirst
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Birst
    • Actions
      • Set SBirst_caster = (Casting unit)
      • For each (Integer A) from 1 to (5 + (SOULS / 2)), do (Actions)
        • Loop - Actions
          • Set SBirst_point = (Position of SBirst_caster)
          • Unit - Create 1 DummySBirst for (Owner of SBirst_caster) at SBirst_point facing (Facing of SBirst_caster) degrees
          • Unit - Add a (Random real number between 0.01 and 1.20) second Generic expiration timer to (Last created unit)
          • Set SBirst_point = (SBirst_point offset by 800.00 towards (Random real number between ((Facing of SBirst_caster) - 45.00) and ((Facing of SBirst_caster) + 45.00)) degrees)
          • Unit - Order (Last created unit) to Move To SBirst_point
          • Wait 0.01 seconds
      • Set SOULS = (SOULS - (SOULS x ((18 - (3 x (Level of Soul Birst for SBirst_caster))) / 100)))
      • Game - Display to (Player group((Owner of SBirst_caster))) the text: (Remaining Souls: + (String(SOULS)))
      • Custom script: call RemoveLocation (udg_SBirst_point)
 
What isn't working correctly? Are you getting results you don't expect? My guess would be that you are using integer math for real calculations. if you have 3x / 100, it is going to end up rounding for an integer.
 
yeah it simplifies to

set Souls = Souls*(0.82 + 0.03*Level)

wtf

20*(0.82 + 0.03*[4]) = 20*(0.82 + 0.12) = 20*0.94 = 18.8

that's in reals

BUT

Your whole arithmetic operation is done with integers, so EVERY step is rounded. You should do the calculation with reals and convert the result to an integer when it's finished
 
Status
Not open for further replies.
Back
Top