• 🏆 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] Triggers each time a variable becomes a multiple of 10?

Status
Not open for further replies.
Level 4
Joined
Jul 10, 2013
Messages
60
Hello,

Is there a way to make a recurring type event whenever an variable becomes a multiple of ten? Rather than just spam a huge number of:

[Game] variable becomes equal to 10
[Game] variable becomes equal to 20
[Game] variable becomes equal to 30
ect...

There's nothing under value of real variable that I can figure out that would do this.

Or if its possible to do this as a condition that could also work.
 
Level 4
Joined
Jul 10, 2013
Messages
60
One way is to:
variable becomes greater than 9

Convert the variable to string and check the substring at the second position. If it's 0 it's dividable by 10.

Something like this?
  • (Substring((String(RamstienHunger)), 2, 0)) Equal to 0
I've never used substring before, not sure I'm doing it right.
 
Level 4
Joined
Jul 10, 2013
Messages
60
Replace the 0 with length of string.
Otherwise it's correct.

(Substring((String(RamstienHunger)), 2, 0)) Equal to 0
>>
set tempString = String(RamstienHunger)
(Substring((tempString), 2, Length of TempString)) Equal to 0

  • Ramsitens Hunger
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Not equal to Build Plot
          • (Unit-type of (Triggering unit)) Not equal to Control Point
          • (Killing unit) Equal to Ramstein 0401 <gen>
    • Actions
      • Set RamstienHunger = (RamstienHunger + 1.00)
      • Set TempString = (String(RamstienHunger))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(TempString, 2, (Length of TempString))) Equal to 0
        • Then - Actions
          • Hero - Modify Strength of Ramstein 0401 <gen>: Add 1
        • Else - Actions
So this should work.

However, what if it gets over 100? the 2 in the substring is the location its checking right? Would I just need an OR statement, copy the condition, and change the 2nd conditions 2 to a 3?
 
Level 4
Joined
Jul 10, 2013
Messages
60
modulo 10 will work. You should find it somewhere in the maths function list.

Edit: oh sry.. "X Modulo 10 == 0" must be the condition

Wait, is it really as simple as:

  • (RamstienHunger mod 10) Equal to 0
 
Status
Not open for further replies.
Top