Hi everyone! Please help me to solve an issue with a trigger that shows remaining time left for summoned buildings.
As far as I know, there's no way to enable default expiration bar for summoned units if they are marked as buildings (Stats - Is a Building: True). So I figured out that I can show remaining timer with a simple Floating Text in combination with a Countdown Timer. If I have only 1 building — it works. But for my map there can be a total of 8 buildings (based on cooldown and duration of abilities) and I need to show expiration text for every one of them.
So far I made two triggers that work only for the first building, but breaks on others:
So when I build my first building it shows the timer correctly. But on the second and following ones it shows 0 after the first tick of the second trigger or shows nothing at all.
My two questions are:
1. Is there any other way to show remaining time for buildings?
2. What am I doing wrong with the triggers? Apparently the problem is in the first one (since the timer works correctly for the first building), but I can't figure it out.
As far as I know, there's no way to enable default expiration bar for summoned units if they are marked as buildings (Stats - Is a Building: True). So I figured out that I can show remaining timer with a simple Floating Text in combination with a Countdown Timer. If I have only 1 building — it works. But for my map there can be a total of 8 buildings (based on cooldown and duration of abilities) and I need to show expiration text for every one of them.
So far I made two triggers that work only for the first building, but breaks on others:
-
PeonBuild
-

Events
-


Unit - A unit enters (Playable map area)
-
-

Conditions
-


Or - Any (Conditions) are true
-



Conditions
-




(Unit-type of (Triggering unit)) Equal to Watch Tower
-




(Unit-type of (Triggering unit)) Equal to Burrow
-
-
-
-

Actions
-


Set VariableSet tmp_unit = (Triggering unit)
-


Set VariableSet tmp_player = (Owner of tmp_unit)
-


Unit Group - Add (Triggering unit) to UGRP_BuildingsGoup
-


Custom script: set bj_wantDestroyGroup = true
-


Unit Group - Pick every unit in (Units owned by tmp_player of type Peon) and do (Actions)
-



Loop - Actions
-




Set VariableSet tmp_int = (Level of Duration Upgrade for (Picked unit))
-
-
-


Set VariableSet tmp_int = (60 + (20 x tmp_int))
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




(Unit-type of tmp_unit) Equal to Burrow
-
-



Then - Actions
-




Unit - Add a (Real(tmp_int)) second Generic expiration timer to tmp_unit // Burrows made from "Build Tiny Castle" ability, so I need to specify timed life for them
-
-



Else - Actions
-




Animation - Play tmp_unit's stand animation // Towers made from "Serpent Ward" ability, so I need to cancel Building animation
-
-
-


For each (Integer A) from 1 to 8, do (Actions)
-



Loop - Actions
-




If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-





If - Conditions
-






(UNIT_PeonBuilding[(Integer A)] is alive) Equal to False
-
-





Then - Actions
-






Unit - Remove UNIT_PeonBuilding[(Integer A)] from the game // just in case
-






Set VariableSet UNIT_PeonBuilding[(Integer A)] = tmp_unit
-






Countdown Timer - Start TIMER_PeonBuilding[(Integer A)] as a One-shot timer that will expire in (Real(tmp_int)) seconds
-






Floating Text - Create floating text that reads (String(tmp_int)) above UNIT_PeonBuilding[(Integer A)] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
-






Set VariableSet FTXT_BuildingText[(Integer A)] = (Last created floating text)
-






Custom script: exitwhen true
-
-





Else - Actions
-
-
-
-


Trigger - Turn on PeonBuildingTimers <gen>
-
-
-
PeonBuildingTimers
-

Events
-


Time - Every 1.00 seconds of game time
-
-

Conditions
-

Actions
-


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-



If - Conditions
-




(Number of units in UGRP_BuildingsGoup) Equal to 0
-
-



Then - Actions
-




Trigger - Turn off (This trigger)
-




Skip remaining actions
-
-



Else - Actions
-




For each (Integer A) from 1 to 8, do (Actions)
-





Loop - Actions
-






If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-







If - Conditions
-








(UNIT_PeonBuilding[(Integer A)] is alive) Equal to True
-
-







Then - Actions
-








Floating Text - Change text of FTXT_BuildingText[(Integer A)] to (String((Integer((Remaining time for TIMER_PeonBuilding[(Integer A)]))))) using font size 10.00
-
-







Else - Actions
-








Floating Text - Destroy FTXT_BuildingText[(Integer A)]
-








Unit Group - Remove UNIT_PeonBuilding[(Integer A)] from UGRP_BuildingsGoup.
-
-
-
-
-
-
-
-
So when I build my first building it shows the timer correctly. But on the second and following ones it shows 0 after the first tick of the second trigger or shows nothing at all.
My two questions are:
1. Is there any other way to show remaining time for buildings?
2. What am I doing wrong with the triggers? Apparently the problem is in the first one (since the timer works correctly for the first building), but I can't figure it out.
Last edited:
