Detect unit has upgraded

Level 12
Joined
Nov 13, 2010
Messages
276
will you can do like this
  • upgreade
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Castle
        • Then - Actions
        • Else - Actions
or
  • upgreade 2
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Castle
        • Then - Actions
        • Else - Actions
it depahps on what you need it for
 
Level 9
Joined
Mar 15, 2020
Messages
85
Well there is group of dummy units, these invisible dummy units are called mechanical gears or parts... I am not using gold because gold and lumber are ammunition for my map. After the unit upgrades it Subtract the Group of Dummy units, sadly I only find more frustration than solution.
 
Level 12
Joined
Nov 13, 2010
Messages
276
(Constructed structure) not (Constructing structure) if still not work try out Triggering unit

  • Event:
    • Unit - A unit Finishes construction
  • Condition:
    • (Unit-type of (Constructed structure)) Equal to Auto Turret
  • Action:
    • Unit - Remove (Random unit from MechanicalParts[1]) from the game
 
Level 12
Joined
Nov 13, 2010
Messages
276
lets us try with a debug messages to see what happens
  • Events
    • Unit - A unit Finishes construction
  • Action
    • Game - Display to (All players) the message: (Unit-type of (Triggering unit))
If nothing shows up when you upgrade a turret to Auto Turret, then the event is NOT firing, that confirms the upgrade doesn’t trigger it.

If it does show Auto Turret then your original trigger should be working.

after this test If it doesn’t fire we can switch tactics
________________________________________________
the new tactics is that we will detect When Auto Turret Appears
Create a Unit Group variable called AutoTurretTracker and initialize it empty
  • Events
    • Time - Every 0.50 seconds of game time
    • Conditions
      • (Number of units in AutoTurretTracker) < (Number of units of type Auto Turret owned by Player 1)
  • Action
    • Unit Group - Pick every unit of type Auto Turret owned by Player 1 and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Picked unit is in AutoTurretTracker) Equal to False
          • Then - Actions
            • Unit - Add Picked unit to AutoTurretTracker
            • Unit - Remove (Random unit from MechanicalParts[1]) from the game
          • Else - Actions
            • Do nothing
 
Last edited:
Level 9
Joined
Mar 15, 2020
Messages
85
I found solution, basically the Unit is a Concrete Hub and it doesnt really do anything, Since the Unit only has upgrade why not just use reference the Unit is Ordered and use if then statement, by using If Ordered unit is equal to the type of unit that has been upgraded then the action will execute as it was desired. I hope anyone in the future is helped by this method. Another Thing to Note Use a Wait Action at least 0.01 in order for it to be executed, anyway Thanks for help. and I also dont know why Wait works and if doesnt have wait it doesnt work which can be stupid but all in all It did what it was intended to do.
 
Last edited:
Level 14
Joined
Jan 10, 2023
Messages
247
...and I also dont know why Wait works and if doesnt have wait it doesnt work which can be stupid but all in all It did what it was intended to do.
I would guess that's because a unit doesn't do something when it is ordered to do it, it does it after it has been ordered to do it.

So you order it to upgrade, at that moment it is doing nothing - so its 'current order' is null, or 'stop'.
0.01 seconds (or maybe only 0.00 seconds) later, it will actually start doing the order and its order will be the name of the upgraded unit.

Just a theory, an educated theory.

Nice solution btw.
 
Level 9
Joined
Mar 15, 2020
Messages
85
Lastly I forgot to mention this, this is important... The first condition should be the ordered unit equal to scout tower, then put wait action, next is if then else statement, Ordered Unit equals to Guard Tower, below your condition is your action. If you referred the Ordered unit equals to The Guard Tower alone the action ofc would loop because the Guard tower is the one being ordered now, not the scout tower sorry for late information.
 
Top