- Joined
- Jul 29, 2010
- Messages
- 15
I need help with a trigger to destroy a town hall if one is already constructed by the same player. I've tried alot of different triggers to do this, but I can't seem to figure it out.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Trigger

Events


Unit - A unit Begins construction

Conditions


(Unit-type of (Constructing structure)) Equal to Town Hall

Actions


Custom script: set bj_wantDestroyGroup = true


Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)



Loop - Actions




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





If - Conditions






(Owner of (Picked unit)) Equal to (Owner of (Constructing structure))






(Picked unit) Not equal to (Constructing structure)






(Unit-type of (Picked unit)) Equal to Town Hall





Then - Actions






Unit - Kill (Constructing structure)





Else - Actions
Townhall

Events


Unit - A unit Begins construction

Conditions


((Unit-type of (Constructing structure)) is A town-hall-type unit) Equal to (==) True

Actions


Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Constructing structure))) and do (Actions)



Loop - Actions




Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Number of units in (Units in (Playable map area) matching (((Picked unit) is A town-hall-type unit) Equal to (==) True))) Greater than (>) 1





Then - Actions






Unit - Kill (Constructing structure)






Game - Display to (Player group((Owner of (Constructing structure)))) the text: You already have a ...





Else - Actions






Do nothing
Hm, I'll work on it. One sec.
EDIT: I could just make a little system for you and attach the map if you'd prefer?
There you go
Please be sure to read the note that I left.
Townhall Death

Events


Unit - A unit Dies

Conditions


((Dying unit) is A town-hall-type unit) Equal to (==) True

Actions


Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Dying unit))) and do (Actions)



Loop - Actions




Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






Townhalls[(Player number of (Owner of (Dying unit)))] Less than or equal to (<=) 0





Then - Actions






Game - Display to (All players) the text: You have lost!






Unit - Kill (Picked unit)






Game - Defeat (Owner of (Dying unit)) with the message: Defeat!





Else - Actions






Set Townhalls[(Player number of (Owner of (Dying unit)))] = 0
Townhall Death

Events


Unit - A unit Dies

Conditions


((Dying unit) is A town-hall-type unit) Equal to (==) True

Actions


Unit Group - Pick every unit in (Units in (Playable map area) owned by (Owner of (Dying unit))) and do (Actions)



Loop - Actions




Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






((Picked unit) is A Hero) Equal to (==) False






Townhalls[(Player number of (Owner of (Dying unit)))] Less than or equal to (<=) 0





Then - Actions






Unit - Kill (Picked unit)





Else - Actions






Set Townhalls[(Player number of (Owner of (Dying unit)))] = 0
Custom script: set bj_wantDestroyGroup = true