• 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.

Remove Events

Status
Not open for further replies.
Level 8
Joined
Dec 9, 2009
Messages
397
I have a trigger that uses
  • Trigger - Add to Trigger01 <gen> the event (Unit - (Picked unit) Acquires a target)
and I added all my units to it, and when a unit spawns, it gets added as well

Problem is, there is no way to remove that event for a unit that dies so I'm leaking...

I thought about during game recreating trigger and destroying the old one,
but GUI has no command for this, is there some custom script I can use to create a trigger during the game?
 
I have a trigger that uses
  • Trigger - Add to Trigger01 <gen> the event (Unit - (Picked unit) Acquires a target)
and I added all my units to it, and when a unit spawns, it gets added as well

Problem is, there is no way to remove that event for a unit that dies so I'm leaking...

I thought about during game recreating trigger and destroying the old one,
but GUI has no command for this, is there some custom script I can use to create a trigger during the game?

You would do something like:
  • Trigger - Destroy Trigger01 <gen>
  • Custom script: set gg_trg_Trigger01 = CreateTrigger()
Then register the events again. And yes, that would be the most efficient method. (in-game destroy and recreation)

gg_ is the prefix of a generated global. The format is gg_TYPE_NAME. For more information, see my mini-tutorial:
http://www.hiveworkshop.com/forums/...ls-278/mini-tutorial-generated-globals-43391/
 
Level 8
Joined
Dec 9, 2009
Messages
397
Because I'd be adding every single unit on the map to the trigger, (ORPG) thats a lot of units. I was thinking of doing it periodically adding a few units to the new trigger.

The Trigger effects for that trigger are quite a lot so instead of triggering a recreate for all the actions I want to split it up. in GUI how would I set something like how Weep's DDS activates?

would it just be

Unit acquires a target
event
set integer = 1
set Attacking = Triggering Unit
set Targeted = Unit being Targeted

When integer = 1
do actions
set integer = 0
the rest
 
Yes, that is essentially how it works. You may want to set the variables to the values before making the integer = 1 though. (so that they can be read in the triggers that have that event) However, DDS uses the unit takes damage event. (instead of unit acquires target, but I assume you were just stating an example so you probably know that already)

Just be careful when you are splitting up the process because one unit might take/deal damage meanwhile you are removing everything periodically. (or whatever method you plan to use)
 
Level 8
Joined
Dec 9, 2009
Messages
397
I get an error when trying to save, it says this line is bad.

  • Custom script: set gg_trg_CS2 = CreateTrigger()
Also, how do i refer to the newly created trigger? do I use jass code and trg_CS2?

example:
  • Trigger - Turn off (trg_CS2)
 
I get an error when trying to save, it says this line is bad.

  • Custom script: set gg_trg_CS2 = CreateTrigger()

What is the name of your trigger? If the name of your trigger is "CS2", then there should be no problem. However, according to this:
Trigger - Turn off (trg_CS2)
It is named "trg_CS2", so the code would be:
  • Custom script: set gg_trg_trg_CS2 = CreateTrigger()
Instead. Basically, it would be "set gg_trg_TriggerName". So if your trigger is named "Test", it would be "gg_trg_Test". If your trigger is named "Pooh", then it would be "gg_trg_Pooh".

Also, how do i refer to the newly created trigger? do I use jass code and trg_CS2?

example:
Trigger - Turn off (trg_CS2)

If you want to, you can always just set a trigger variable so that you can access it with GUI. For example:
  • TestTrig
    • Events
    • Conditions
    • Actions
      • Custom script: call DestroyTrigger(gg_trg_TestTrig)
      • Custom script: set gg_trg_TestTrig = CreateTrigger()
      • Custom script: set udg_MyTriggerVariable = gg_trg_TestTrig
      • Trigger - Turn off (MyTriggerVariable)
That trigger is pointless, but it is just an example. It will destroy "TestTrig", then recreate it. Then it will assign a variable to that trigger and then turn it off.

In the above example, I made a trigger variable named "MyTriggerVariable". In the third line of the actions, it will assign the trigger variable (the format is udg_NameOfTheVariable) to the trigger "TestTrig". That way, you can just access MyTriggerVariable normally in GUI if you want to do anything with it.

Alternatively, you can still use custom script and just do:
  • Custom script: call DisableTrigger(gg_trg_TestTrig)
Which is the same as turning a trigger off.


See post #8
 
Last edited:
Level 8
Joined
Dec 9, 2009
Messages
397
Well, i need to add events to the newly created trigger, and I need to know how to refer back to that trigger

the name I want it to have is CS2
In the GUI add action, it asks which trigger, and only way for me to specify a trigger that doesn't exist already is with the Jass Code, so i figured you add trg_ before the name, but I don't know Jass.

So I need to set the trigger to a variable?

So it's gg_trg_NAME for refering back to it without a variable, and is what I'd type to set it to variable?
 
Sorry I'm a little stupid lol, I wasn't thinking. Once you recreate it, you can actually just use the name of the trigger as you normally would in GUI. So for example
  • CS2
    • Events
    • Conditions
    • Actions
      • Custom script: call DestroyTrigger(gg_trg_CS2)
      • Custom script: set gg_trg_CS2 = CreateTrigger()
      • Trigger - Turn off (CS2)
That would work fine. As long as you have recreated it, you can just refer to the trigger as you normally would in GUI. ;)
 
If you don't have anything named CS2, then that means that you shouldn't use it in that custom script. Change the "CS2" in this line:
  • Custom script: set gg_trg_CS2 = CreateTrigger()
To the name of whatever trigger you are trying to recreate. For example, if your trigger was named "Apples", then it would be:
  • Custom script: set gg_trg_Apples = CreateTrigger()
If your trigger was named "Fix Leak", then it would be:
  • Custom script: set gg_trg_Fix_Leak = CreateTrigger()
If you trigger was named "Abazaba", then it would be:
  • Custom script: set gg_trg_Abazaba = CreateTrigger()
As for the map you sent me, I can't open it because you are using an editor with additional functions for GUI. (either EGUI or WEU or something similar)

If you still don't understand, you can feel free to ask; or better yet, post your trigger and then we can fix it as needed.
 
Level 8
Joined
Dec 9, 2009
Messages
397
So, I have to destroy one with the same name in order to create a new one?

No I don't have one named CS2 because I thought I was making CS2 so I could add stuff to it, then destroy the old one and activate CS2

then 2nd time around create CS1, and Destroy CS2
 
Status
Not open for further replies.
Top