• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Destroy a town hall if one is already present

Status
Not open for further replies.
Level 2
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.
 
Level 11
Joined
Jun 20, 2009
Messages
880
This should do it:

  • 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
 
Level 2
Joined
Jul 29, 2010
Messages
15
That's not exactly what I was lookin' for :<

I'm trying to make a map with a Curse of Time style to it, and I meant Town Hall as in the major building that creates builders. The reason I'm looking for this trigger is because I don't want everyone having the ability to use every race's builders.

Thanks for the help though, +Rep :p
 
Level 3
Joined
Jan 26, 2008
Messages
38
Judging by your comment, I think this is what you wanted:

  • 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
You could always add an action that adds the cost of the town hall back to the player.
You can't really do this without killing the worker unit too unless you add variables. You could change the event to fire when the worker FINISHES construction, then destroying the structure. But that'd make a huge waste of time.
 
Level 3
Joined
Jan 26, 2008
Messages
38
There you go :)
Please be sure to read the note that I left.
 

Attachments

  • TownHallTest.w3x
    16.7 KB · Views: 40
Level 3
Joined
Jan 26, 2008
Messages
38
Sure, I'll just add the trigger here.

  • 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
Replace the current one I gave you with this one. You can just add in the new actions. EDITED
 
Level 2
Joined
Jul 29, 2010
Messages
15
Well I mean every unit owned by the player owning the Town Hall EXCEPT the Hero, not defeat the player

EDIT: Well I don't want them to be defeated because it's an RPG. Though I could make it so they have to ressurect somewhere else, just not defeat them.
 
Level 3
Joined
Jan 26, 2008
Messages
38
Ohhhh. Sorry, I hadn't read your reply. Sure here you go:

  • 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
 
Status
Not open for further replies.
Top