Townhall dies timer + a small question

hopy

Active Member
Reaction score
64
One and a half question, shouldn't be to hard.

Reveal every unit.
In my map if your Town Hall gets destroyed you have 5 minutes to build another one or else all your units will get revealed to your opponents.

In order to achieve this I created a trigger that's supposed to create a timer when your Town Hall dies and you have no other town halls.
Trigger:
  • Reveal TH death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
    • Actions
      • Set Unit_Group = (Units owned by (Owner of (Dying unit)) matching (((Unit-type of (Matching unit)) is A town-hall-type unit) Equal to True))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Unit_Group) Greater than or equal to 1
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Countdown Timer - Start TH_Time[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 300.00 seconds
          • Countdown Timer - Create a timer window for (Last started timer) with title Time until you're r...
          • Countdown Timer - Show (Last created timer window) for (Owner of (Triggering unit))
          • Countdown Timer - Change the color of the title for (Last created timer window) to (100.00%, 0.00%, 0.00%) with 0.00% transparency
      • Custom script: call DestroyGroup (udg_Unit_Group)

Now, when my town hall dies nothing happens; no timers start at all. I thought it would be because of the "(((Unit-type of (Matching unit)) is A town-hall-type unit)" part, but I don't quite understand why.

Does anyone else see any reason for this to not work?
(There are a few custom town hall units in my map, but it didn't work when testing it with just a normal castle either, so that shouldn't be the problem I think).

Initially on:
Every trigger has the option for "Initially on", and I've seen people say that you're supposed to turn that off for every repeating trigger or something like that. Now I was wondering: Why? What exactly does this do? When to use it? And what advantages does it have?

+rep for anyone posting something usefull, thank you for helping in advance. :p
 

Necrach

You can change this now in User CP.
Reaction score
62
Strange. You use "Dying unit" sometimes and "Triggering unit" sometimes, but I think Triggering unit should always work with the A unit Dies event. But its definitely not the Timer actions that is wrong.

You might try with some other classification that the Town Hall one. You might want to change which units are town hall types in the Gameplay Constants, but you said you tried with a normal castle, so you are probably right about that not being th problem.

As for your second question, the only thing that does is that the trigger simply doesn't work if turned off! (A running trigger will finish after being turned off, though) Turning off a periodic event might be for not lagging the map, having a lot meaningless triggers running are no good idea.

Crap, I helped you like... nothing at all :S
 

hopy

Active Member
Reaction score
64
Strange. You use "Dying unit" sometimes and "Triggering unit" sometimes.
Yes, this is because I'm usualy to lazy to chance the Triggering Unit to Dying unit and sometimes I'm not. :p
The only thing that does is that the trigger simply doesn't work if turned off! Turning off a periodic event might be for not lagging the map, having a lot meaningless triggers running are no good idea.
Wait... so wouldn't that be basicly the same as a Enabled / Disabled trigger?

Crap, I helped you like... nothing at all :S
Beep Beep! Wrong! :D Being a noob I didn't think about being able to add my custom Town halls to the Gameplay Constants. Now that I've done that I can just add the same Health potions and such to my shops without having to create a new one for every race. xD Yes.. I fail. <,<

This shouldn't effect my reveal timer trigger right? Since it's a classification it scans for it should only look at the TownHall in the classifications in the Object Editor.
 

Necrach

You can change this now in User CP.
Reaction score
62
I still recommend trying another classification than the Town Hall one (Ancients is a classic) or maybe a dummy ability, to detect the town-hall buildings. Because I really see nothing wrong in the trigger. You never know, another method might work better :eek:
 

KJP

New Member
Reaction score
5
i think your problem lies within this line of code

Trigger:
  • Set Unit_Group = (Units owned by (Owner of (Dying unit)) matching (((Unit-type of (Matching unit)) is A town-hall-type unit) Equal to True))


reason being "Matching unit" refers to the pick unit in region action.

I think replacing it with these lines may help.
Trigger:
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Triggering unit) is A town-hall-type unit) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to unitgroup[(Player number of (Owner of (Triggering unit)))]


also i made a slight adjustment to your unit group by making it an array so it will work for all players without overwriting the global.

Edit: a better idea might be to use the following triggers so you dont need to setting and destroying the unit group variable.
Trigger:
  • Construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (unitgroup[(Player number of (Owner of (Triggering unit)))] is empty) Equal to True
        • Then - Actions
          • Countdown Timer - Pause timer[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
      • Unit Group - Add (Constructed structure) to unitgroup[(Player number of (Owner of (Triggering unit)))]

and replace the quoted line from your original post to
Trigger:
  • Unit Group - Remove (Triggering unit) from unitgroup[(Player number of (Owner of (Triggering unit)))]
 

hopy

Active Member
Reaction score
64
i think your problem lies within this line of code
Trigger:
  • Set Unit_Group = (Units owned by (Owner of (Dying unit)) matching (((Unit-type of (Matching unit)) is A town-hall-type unit) Equal to True))

reason being "Matching unit" refers to the pick unit in region action.
I think replacing it with these lines may help.
Trigger:
  • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Triggering unit) is A town-hall-type unit) Equal to True)) and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to unitgroup[(Player number of (Owner of (Triggering unit)))]
Well in the Trigger editor it says: "Matching Unit: Use this to refer to the unit being considered for 'Units matching conditions' functions", so I think that matching unit should be correct. I will test this in a moment though.
Trigger:
  • Construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (unitgroup[(Player number of (Owner of (Triggering unit)))] is empty) Equal to True
        • Then - Actions
          • Countdown Timer - Pause timer[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
      • Unit Group - Add (Constructed structure) to unitgroup[(Player number of (Owner of (Triggering unit)))]
Not sure what you're trying to do there. All this would do is Pause the timer that's if the player creates a Townhall and didn't have any yet and add that town hall to a variable. Not quite what the trigger was supposed to do; it should start a timer if a town hall dies and the player doesn't have any others.
 

KJP

New Member
Reaction score
5
I probably didnt come across as clear as i thought, but ill post the triggers i worked on earlier today to see if i can clear it up a bit.

Trigger:
  • set up player unit groups
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Unit_group[1] = P1
      • Set Unit_group[2] = P2
      • Set Unit_group[3] = P3
      • Set Unit_group[4] = P4
      • Set Unit_group[5] = P5
      • Set Unit_group[6] = P6
      • Set Unit_group[7] = P7
      • Set Unit_group[8] = P8
      • Set Unit_group[9] = P9
      • Set Unit_group[10] = P10
      • Set Unit_group[11] = P11
      • Set Unit_group[12] = P12
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A town-hall-type unit) Equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to Unit_group[(Player number of (Picked player))]
                • Else - Actions
          • Game - Display to (All players) the text: ((units in unit group belonging to player + (String((Player number of (Picked player))))) + ( is + (String((Number of units in Unit_group[(Player number of (Picked player))])))))


this picks all the starting units and adds them to a master unit group array pointing to the individual unit groups for each player and is additional to what i suggested in my last post, which in full is

Trigger:
  • Reveal TH death
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
    • Actions
      • Game - Display to (All players) the text: (unit count of unit group pre removal = + (String((Number of units in Unit_group[(Player number of (Owner of (Triggering unit)))]))))
      • Unit Group - Remove (Triggering unit) from Unit_group[(Player number of (Triggering player))]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Unit_group[(Player number of (Triggering player))]) Greater than or equal to 1
        • Then - Actions
        • Else - Actions
          • Countdown Timer - Start TH_Time[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 300.00 seconds
          • Countdown Timer - Create a timer window for (Last started timer) with title Time until you&#039;re r...
          • Countdown Timer - Show (Last created timer window) for (Owner of (Triggering unit))
          • Countdown Timer - Change the color of the title for (Last created timer window) to (100.00%, 0.00%, 0.00%) with 0.00% transparency
      • Game - Display to (All players) the text: (unit count of unit group post removal = + (String((Number of units in Unit_group[(Player number of (Triggering player))]))))

and finally the last trigger (for construction purposes of new townhalls) to stop(well pause the timer which just resets by the way)
Trigger:
  • Finish construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • ((Constructed structure) is A town-hall-type unit) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Unit_group[(Player number of (Triggering player))]) Equal to 0
          • (Elapsed time for TH_Time[(Player number of (Triggering player))]) Less than or equal to 299.00
        • Then - Actions
          • Countdown Timer - Pause TH_Time[(Player number of (Triggering player))]
          • Countdown Timer - Hide (Last created timer window)
        • Else - Actions
      • Unit Group - Add (Constructed structure) to Unit_group[(Player number of (Owner of (Constructed structure)))]


the triggers works although i keep getting the timer windows for other players showing up with no timer when an enemy base is destroyed.

finally if the player is defeated it would make sense to destroy the corrisponding unitgroup then
 

hopy

Active Member
Reaction score
64
Ah, now I understand. Alright, I will try that. Will make those in a minute with a few small changes and I'll edit this post if it doesn't work. Thanks
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top