After you destroy a certain building you win. Like for example, after you destroy the one pylon on the map you win but that pylon spawns like 4 minutes after the march started.
Take advantage of unit references. Bind the death event to a unit reference. Update the unit reference to the pylon when the pylon does exist.
Periodically poll if a pylon matching the description of your special pylon does exist, if not "win" the players. Trigger is initially off and only turned on after the pylon does exist.
Dynamically create a trigger and event when creating the pylon. Requires some galaxy script knowledge as GUI lacks interfaces for the required actions.
First, create a variable of type unit to store the pylon. ( Pylon var)
Second, create a trigger that after an amount of time (4 minutes in your case) it will create the pylon and after creating it you save the pylon in the variable. ( Pylon Spawn)
Lastly, create another trigger that will check if any unit died. Which unit? You will specify this under the conditions (in your case the Pylon ). If it's destroyed then you end the game in victory/defeat for whichever player you pick. (Pylon Win)
Lastly, create another trigger that will check if any unit died. Which unit? You will specify this under the conditions (in your case the Pylon ). If it's destroyed then you end the game in victory/defeat for whichever player you pick. (Pylon Win)
Why check when every unit dies when you can just check when your specific unit dies?
If using this approach make sure the trigger is initially off. Turn it on when the pylon is created. This prevents it from firing unnecessarily before it can ever be true.
Do not do that actually, since all events are instanced at the preloading of the game that would actually be any unit (or no unit, depending on settings) since the variable is most likely instanced as no unit. You would need to use it in the condition like earlier, or dynamically add it later on.
I am confused. No where in the pics does it specify "pylon" so how does the editor know it is that particular building?
When you store it in the variable, you specify that specific pylon. You could have 20 other pylons in the editor all scattered randomly throughout the map, but if the one that is saved in the variable dies then it will end the game in victory.
The key here is the variable. This variable saves the last created unit which in this case it's the pylon created after 4 minutes and if this specific building dies then you win.
Do not do that actually, since all events are instanced at the preloading of the game that would actually be any unit (or no unit, depending on settings) since the variable is most likely instanced as no unit. You would need to use it in the condition like earlier, or dynamically add it later on.
Was the case for Warcraft III. Is not with StarCraft II. They added unitref type for this very problem.
// Unit events // - Use a null unit for "any unit" events // - When a unitref within an event refers to a variable with a null value, by default this is also // treated as "any unit". However, if UnitEventSetNullVariableInvalid is set to true, then null // variable refs within events are treated as "no unit" instead, meaning that the event will never // fire. //
//-------------------------------------------------------------------------------------------------- // Unit Reference // - A unitref may refer to a unit explicitly or through a unit variable //-------------------------------------------------------------------------------------------------- native unitref UnitRefFromUnit (unit u); native unitref UnitRefFromVariable (string v);
native unit UnitRefToUnit (unitref r);
If you refer to a unit via a variable it should automatically change the event to whatever the unit the unit variable is set to. joemart06 implantation is probably the most efficient, especially if you turn off the trigger until the variable is assigned to the pylon. Well this assumes GUI does the correct thing as uses UnitRefFromVariable with the variable name in that case and not UnitRefFromUnit of the unit variable.
After you destroy a certain building you win. Like for example, after you destroy the one pylon on the map you win but that pylon spawns like 4 minutes after the march started.
There are a few ways...
First, create a variable of type unit to store the pylon. ( Pylon var)
Second, create a trigger that after an amount of time (4 minutes in your case) it will create the pylon and after creating it you save the pylon in the variable. ( Pylon Spawn)
Lastly, create another trigger that will check if any unit died. Which unit? You will specify this under the conditions (in your case the Pylon ). If it's destroyed then you end the game in victory/defeat for whichever player you pick. (Pylon Win)
I just forgot I could place the variable in the event. There.
I am confused. No where in the pics does it specify "pylon" so how does the editor know it is that particular building?
Do not do that actually, since all events are instanced at the preloading of the game that would actually be any unit (or no unit, depending on settings) since the variable is most likely instanced as no unit. You would need to use it in the condition like earlier, or dynamically add it later on.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
To polish it a little bit, I can turn off the trigger and activate it after I assign the pylon to the Pylon Var variable.
The key here is the variable. This variable saves the last created unit which in this case it's the pylon created after 4 minutes and if this specific building dies then you win.
Was the case for Warcraft III. Is not with StarCraft II. They added unitref type for this very problem.
// Unit events
// - Use a null unit for "any unit" events
// - When a unitref within an event refers to a variable with a null value, by default this is also
// treated as "any unit". However, if UnitEventSetNullVariableInvalid is set to true, then null
// variable refs within events are treated as "no unit" instead, meaning that the event will never
// fire.
//
native void TriggerAddEventUnitDied (trigger t, unitref u);
// Unit Reference
// - A unitref may refer to a unit explicitly or through a unit variable
//--------------------------------------------------------------------------------------------------
native unitref UnitRefFromUnit (unit u);
native unitref UnitRefFromVariable (string v);