Floor or Ceiling Function?

Edward

New Member
Reaction score
2
Hello,
I'm looking for a Floor or Ceiling Function for triggers. For instance, I need a condition to fire if the unit's life is greater than 75%.

The only way to achieve this is to go to Integer - Max Unit Life x Integer(3/4). However the Max life x 0.75 is not always an integer, thus the trigger stops! The easy fix would be to have a Floor function which would round down to the nearest integer.

Current Life > Floor[Max Life x (3/4)]

Having a Floor or Ceiling Function would be useful in A LOT of other situations as well.
 

hgkjfhfdsj

Active Member
Reaction score
55
unit life is in real
and multiply by 0.75 instead as a real. integers can only be whole numbers and always truncates.
 

Edward

New Member
Reaction score
2
All right I changed the comparison to real. However, if I do need a floor or ceiling function at another time, does it exist? Does it even exist in JASS?

EDIT:
Nice work btw, here is the trigger you fixed again!
Trigger:
  • Horde Spike 1
    • Events
      • Unit - A unit enters Spike Horde 1 <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A flying unit) Equal to False
          • ((Triggering unit) is A Hero) Equal to False
          • (Life of (Triggering unit)) Greater than ((Max life of (Triggering unit)) x 0.75)
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Triggering unit)) Equal to Player 1 (Red)
              • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
              • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
              • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
              • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
              • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
    • Actions
      • Unit - Set life of (Triggering unit) to 75.00%
 

hgkjfhfdsj

Active Member
Reaction score
55
well for a floor you can convert to integer..
ceiling.. not sure if theres a function for it..
 

Edward

New Member
Reaction score
2
If Floor is "Convert to Integer"

then Ceiling is:

"Arithmetic: (Convert to Integer) + 1"
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
If Floor is "Convert to Integer"

then Ceiling is:

"Arithmetic: (Convert to Integer) + 1"

thats not true, if your real value is 18.00 you would get 18.00 + 1 = 19.
to see whether a real variable a would round down if converted to an integer do check "Int(a) != a" if this returns true you know you have to add 1 to the integer value.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top