• 🏆 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!

Least Common Multiple v1.1

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
One of the simplest "system" spells that helps you find the least common multiple of up to 10 numbers. Since i use control timer (only one trigger that runs on 0.01 sec that dictates when otherwise triggers with there own timers will do, since having more timers is very laggy), thus i need a least common multiple for all the timers i use. This system makes it much easier. That is the reason i created this system, you can use it for what ever you wish.
And the Tutorial:
  • How to use LCM
    • Events
    • Conditions
    • Actions
      • -------- Set the inputs, always start with 0, maximum inputs are 10(9 because it's starting from 0), you can stop midway any time --------
      • -------- If you type 0 but after type a number that isn't 0, you will receive an ingame error message --------
      • Set Function_LCM_Input[0] = 1
      • Set Function_LCM_Input[1] = 2
      • Set Function_LCM_Input[2] = 4
      • Set Function_LCM_Input[3] = 8
      • Set Function_LCM_Input[4] = 16
      • Set Function_LCM_Input[5] = 32
      • Set Function_LCM_Input[6] = 64
      • Set Function_LCM_Input[7] = 128
      • Set Function_LCM_Input[8] = 256
      • Set Function_LCM_Input[9] = 512
      • -------- Then "Run" the LCM Run --------
      • Trigger - Run Least Common Multiple Run <gen> (ignoring conditions)
      • -------- Then Set your value to "Result" --------
      • Set Test = Function_LCM_Result
      • -------- Tutorial completed! --------
The whole System:
  • Least Common Multiple Run
    • Events
    • Conditions
    • Actions
      • Set Function_LCM_0 = False
      • Set Function_LCM_InputNumbers = -1
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Function_LCM_Input[(Integer A)] Not equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Function_LCM_0 Equal to False
                • Then - Actions
                  • Set Function_LCM_InputNumbers = (Function_LCM_InputNumbers + 1)
                • Else - Actions
                  • Set Function_LCM_Failed = True
            • Else - Actions
              • Set Function_LCM_0 = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Function_LCM_Failed Equal to False
        • Then - Actions
          • Set Function_LCM_DividingBy = 2
          • Set Function_LCM_Result = 1
          • Trigger - Run Least Common Multiple Calculation <gen> (ignoring conditions)
        • Else - Actions
          • For each (Integer A) from 0 to 9, do (Actions)
            • Loop - Actions
              • Set Function_LCM_Input[(Integer A)] = 0
          • Game - Display to (All players) the text: The world editor do...
  • Least Common Multiple Calculation
    • Events
    • Conditions
    • Actions
      • Set Function_LCM_IsItDevided = False
      • For each (Integer A) from 0 to Function_LCM_InputNumbers, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Function_LCM_Input[(Integer A)] mod Function_LCM_DividingBy) Equal to 0
            • Then - Actions
              • Set Function_LCM_IsItDevided = True
              • Set Function_LCM_Input[(Integer A)] = (Function_LCM_Input[(Integer A)] / Function_LCM_DividingBy)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Function_LCM_IsItDevided Equal to True
        • Then - Actions
          • Set Function_LCM_Result = (Function_LCM_Result x Function_LCM_DividingBy)
          • Trigger - Run (This trigger) (ignoring conditions)
        • Else - Actions
          • Set Function_LCM_IsItDevided = True
          • For each (Integer A) from 0 to Function_LCM_InputNumbers, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Function_LCM_Input[(Integer A)] Greater than 1
                • Then - Actions
                  • Set Function_LCM_DividingBy = (Function_LCM_DividingBy + 1)
                  • Set Function_LCM_IsItDevided = False
                  • Trigger - Run (This trigger) (ignoring conditions)
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Function_LCM_IsItFinished Equal to True
        • Then - Actions
          • For each (Integer A) from 0 to Function_LCM_InputNumbers, do (Actions)
            • Loop - Actions
              • Set Function_LCM_Input[(Integer A)] = 0
        • Else - Actions
Update:
v1.1 Minor changes and added triggers

Keywords:
Least Common Multiple, LCM
Contents

LCM (Map)

Reviews
11:42, 27th May 2016 Tank-Commander: Hasn't been updated to use a dynamic number of inputs in the last two weeks - set to needs fix

Moderator

M

Moderator

11:42, 27th May 2016
Tank-Commander: Hasn't been updated to use a dynamic number of inputs in the last two weeks - set to needs fix
 
Heyho, could you make the amount dynamic? Like not making it static to 10.

Well i use it :D, as i already made it why not upload it to hive
Not that I would not believe your post, but I would be curious to see an implementation of this system in wc3.
Would you be so kind to show your example where you used it? I fail to imagine something atm.
 
Level 3
Joined
May 7, 2016
Messages
38
Heyho, could you make the amount dynamic? Like not making it static to 10.
I was never needed more than 5 but i'l see what i can do(currently busy)
Not that I would not believe your post, but I would be curious to see an implementation of this system in wc3.
Would you be so kind to show your example where you used it? I fail to imagine something atm.
  • Initialization
  • Set Function_LCM_Inputs[0] = 10
  • Set Function_LCM_Inputs[1] = (Integer((C_US_TUS_CD[1] x 100.00)))
  • Set Function_LCM_Inputs[2] = (Integer((C_US_TUS_CD[2] x 100.00)))
  • Set Function_LCM_Inputs[3] = (Integer((C_US_TR_ColorTimer x 100.00)))
  • Set Function_LCM_Inputs[4] = (Integer((C_US_TR_RotationTime x 100.00)))
  • Trigger - Add Least Common Multiple Run <gen> to the trigger queue (Ignoring conditions)
  • Set C_T_T_MaxValue = (Function_LCM_Output - 1)
  • Timer
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • T_T_Timer Less than C_T_T_MaxValue
        • Then - Actions
          • Set T_T_Timer = (T_T_Timer + 1)
        • Else - Actions
          • Set T_T_Timer = 0
      • Trigger - Run Camera Force <gen> (ignoring conditions)
      • Trigger - Run Tower Range Effects <gen> (ignoring conditions)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (T_T_Timer mod 10) Equal to 0
        • Then - Actions
          • Trigger - Run Rapid Regen <gen> (ignoring conditions)
          • Trigger - Run Heal Unit Aid <gen> (ignoring conditions)
          • Trigger - Run Special Unit Heal <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer(((Real(T_T_Timer)) mod (C_US_TUS_CD[1] x 100.00)))) Equal to 0
        • Then - Actions
          • Trigger - Run Tank1 Unit Shield <gen> (ignoring conditions)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer(((Real(T_T_Timer)) mod (C_US_TUS_CD[2] x 100.00)))) Equal to 0
        • Then - Actions
          • Trigger - Run Tank2 Unit Shield <gen> (ignoring conditions)
        • Else - Actions
I use this system for most of my maps
Edit:
Since i'm on gui i'm stuck with the "for loop", so should i just set the limit as same as the int limit and order a stop if it encounters a 0?
Edit:
Hmm or should i try and make one?
... I'l update it soon
 
Last edited:
Top