HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger only fires once, why?

08-01-2008, 07:07 AM#1
Bulletbutter
I need this trigger to fire multiple times but it is only firing once. Can someone tell me why? What do I need to change to make this trigger fire more than once?

Trigger:
Works long way Copy
Collapse Events
Unit - A unit enters P1Upgrade <gen>
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Triggering unit)) Equal to Rifleman
(Number of units in (Units in P1Upgrade <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman))) Equal to 9
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Then - Actions
Unit Group - Pick every unit in (Units in P1Upgrade <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman)) and do (Unit - Kill (Picked unit))
Unit - Remove (Picked unit) from the game
Unit - Create 1 Marine for Player 1 (Red) at (Center of Player 1 USpawn <gen>) facing Default building facing degrees
Unit - Kill (Triggering unit)
Collapse Else - Actions
Game - Display to (All players) the text: WE HAVE A PROBLEM
08-01-2008, 07:12 AM#2
darkwulfv
You're killing the rifleman twice, for one thing. That might be crashing your thread.

(Killing all riflemen). You're also removing a single picked unit, (dunno if that would even work since it's outside of an enum call), "Kill (Triggering Unit)" is not needed since the triggering unit must be a rifleman and you already kill all of them.

Also, why not shift those conditions for the If/Then directly into the conditions section?
08-01-2008, 07:20 AM#3
Bulletbutter
Quote:
You're killing the rifleman twice, for one thing. That might be crashing your thread.
Can you explain how you came to this conclusion? The trigger looks to kill all the riflemen only once.

Quote:
You're also removing a single picked unit, (dunno if that would even work since it's outside of an enum call), "Kill (Triggering Unit)" is not needed since the triggering unit must be a rifleman and you already kill all of them.
That's what my first thoughts were to. But, if I left it out it would actually take 10 riflemen to make the trigger kill them all and it would leave the 10th rifleman alive.

Quote:
Also, why not shift those conditions for the If/Then directly into the conditions section?
Because I don't want to write a trigger for every unit I want to do this to. 10 riflemen change to a marine, 10 marines change to a fel space orc, 10 fel space orcs change to a Hydralisk.....So instead of writing 3 triggers for 10 players I can just write one for one :)
08-01-2008, 07:26 AM#4
darkwulfv
Quote:
Can you explain how you came to this conclusion? The trigger looks to kill all the riflemen only once.
Simple.

Unit type HAS to be a rifleman, right?
So:
The triggering unit (the unit who entered) is now in P1Upgrade, right? So, that would be 9 riflemen, since your trigger checks for 9. Otherwise, it wouldn't work (9 + 1 = 10, no?)

You then pick every unit in P1Upgrade which INCLUDES the triggering unit, because he has to be in P1Upgrade for the trigger to fire. You then kill all the riflemen. And for the record, I really don't think Remove (Picked Unit) works, since it's outside of a Unit-Group loop.

Afterwards, you proceed to kill the triggering unit who already should've been killed because he was in P1Upgrade when all the riflemen were picked and killed.


Make sense?

Another way to put it:

There's 8 riflemen in P1Upgrade. The ninth enters, triggering the actions. So now there are 9 riflemen. You kill all the riflemen in P1Upgrade, which is 9. 9 - 9 = 0.

You then remove the picked unit. Which doesn't work. But if it did somehow, that'd be 0 - 1. -1. You can't have -1 units.

If that doesn't work, you till have 0 units. You then proceed to kill the trigger unit. Which is 0 - 1 = -1.
You can't kill a unit that's already dead. And if you were trying to remove all those riflemen, killing one could cause problems since the "Triggering Unit" would be an empty handle.
08-01-2008, 07:33 AM#5
Bulletbutter
Quote:
Unit type HAS to be a rifleman, right?
yes

Quote:
The triggering unit (the unit who entered) is now in P1Upgrade, right?
No, the triggering unit doesn't get moved. He is supposed to die when 8 other riflemen get to the location.


Quote:
You then pick every unit in P1Upgrade which INCLUDES the triggering unit, because he has to be in P1Upgrade for the trigger to fire.

Afterwards, you proceed to kill the triggering unit who already should've been killed because he was in P1Upgrade when all the riflemen were picked and killed.
For some reason he doesn't die and isn't included. I will triple check it though.Edited because: Yep, in order for the trigger to kill 9 riflemen I need 9+1 to do it.

Quote:
I really don't think Remove (Picked Unit) works, since it's outside of a Unit-Group loop.
I saw a trigger in the forums using that type a few months back and thought it was considered a leak if you picked units and didn't remove them (even though they are killed). Guess I can should remove it if thats not the case.
08-01-2008, 07:39 AM#6
darkwulfv
Quote:
No, the triggering unit doesn't get moved. He is supposed to die when 8 other riflemen get to the location.
What the heck? You make 0 sense. Your trigger fires when a UNIT ENTERS P1Upgrade. It then CHECKS that there are 9 units there, which would have to include the entering unit since he's in that region! Unless my logic fails me, would it not make sense that a unit who triggers a UNIT ENTERS [region] event is IN the region he entered, and thus available for checking?

Quote:
Yep, in order for the trigger to kill 9 riflemen I need 9+1 to do it.
Then something must be wrong with how you're doing it, because either A) This makes no sense or B) You aren't explaining how this works, so I'm telling you things that have no value as to how the trigger is SUPPOSED to work.

Quote:
I saw a trigger in the forums using that type a few months back and thought it was considered a leak if you picked units and didn't remove them (even though they are killed). Guess I can should remove it if thats not the case.
Uhhh... No. And you "method" wouldn't work anyways. It would be trying to remove a "null" unit, since "Picked Unit" would return null outside of a group loop.
08-01-2008, 07:47 AM#7
Bulletbutter
I can't explain why its doing what its doing. Maybe I can explain what I want the trigger to do.

if 9 units enter p1upgrade
if all of those 9 units are riflemen
kill all riflemen
create 1 marine at Player 1 USpawn
Then I want to repeat if for as many times as I need.

The trigger that I used above is copy/pasted so there are no typo's. What actually happens is this.

I bring 9 riflemen to p1upgrade (nothing happens)
I bring 1 more riflemen to p1upgrade (9 riflemen die and the 10th is left there and the marine is created at Player 1 USpawn)
And to top it off, it only works once.
08-01-2008, 10:21 AM#8
Pytho
There is a bug, that sometimes the unit which triggers the "Unit-Enters Region" Event isn't really inside the region:
http://www.wc3campaigns.net/showthread.php?t=61918

And as darkwulfvsaid: The Remove Picked Unit-thing doesn't work outside a pick every unit-loop, just replace Kill Picked Unit with Remove Picked Unit.
Trigger:
Then - Actions
Unit Group - Pick every unit in (Units in P1Upgrade <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman)) and do (Unit - Remove (Picked unit) from the game)
Unit - Create 1 Marine for Player 1 (Red) at (Center of Player 1 USpawn <gen>) facing Default building facing degrees
08-01-2008, 04:19 PM#9
crayz
Quote:
Originally Posted by Bulletbutter
I saw a trigger in the forums using that type a few months back and thought it was considered a leak if you picked units and didn't remove them (even though they are killed). Guess I can should remove it if thats not the case.

I think you just have to remove all the units from the unit group to prevent leaks, you don't have to remove that unit from the game.
08-01-2008, 04:27 PM#10
Bulletbutter
Ok, the remove unit fixed the issue with it only firing once. I still have the other problem.

Trigger:
Works long way Copy
Collapse Events
Unit - A unit enters P1Upgrade <gen>
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Triggering unit)) Equal to Rifleman
(Number of units in (Units in P1Upgrade <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman))) Equal to 9
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Then - Actions
Unit Group - Pick every unit in (Units in P1Upgrade <gen> matching ((Unit-type of (Matching unit)) Equal to Rifleman)) and do (Unit - Remove (Picked unit) from the game)
Unit - Create 1 Marine for Player 1 (Red) at (Center of Player 1 USpawn <gen>) facing Default building facing degrees
Unit - Kill (Triggering unit)
Collapse Else - Actions
Game - Display to (All players) the text: WE HAVE A PROBLEM
When Unit- Kill (Triggering Unit) is disabled I actually need 9+1 for the trigger to fire everytime. When I enable Unit - Kill (triggering unit) I need 9+1 for the first time only. After the first time it works like it should. If I replace Unit - Kill (Triggering Unit) with Unit - Remove (triggering unit) I need 9+1 everytime.

It's ok if I want 9 riflemen to die that I can just set the trigger to check for 8 (since the trigger appears to be meeting all the conditions and THEN waiting for the event). My next question is, will it have a negative effect on my map? I will be using several different -If (All Conditions are True) then do (Then Actions) else do (Else Actions)- for this trigger and all 8 players will be able to do it and they will need to be doing it quite frequently.
08-01-2008, 04:31 PM#11
Bulletbutter
Quote:
Originally Posted by crayz
I think you just have to remove all the units from the unit group to prevent leaks, you don't have to remove that unit from the game.
You are right, but first I have to put them in a temp unit group. I was under the impression that when you used unit group - pick ever unit that it automatically placed the picked units in a temp group (kinda like a hidden variable) but thats not the case.

I think I am just going to try to set them all in a temp group then destroy the group. This may be the reason why the triggering unit doesn't get picked. Using Unit Group - Pick every unit does in fact cause leaks if you do not set them to a unit group.