Here's what I'm trying to do. I've created a number of beacons at different enemy positions. The player (player 1) simply has to capture each location. That means at least one of the player's units are there and no enemy units (Player 10) are near (within a distance of 10).
This is the trigger I've come up with, but I'm wondering if there's a better/more efficient way to handle it.
Events
Timer -Every 1.0 seconds of Game Time
Local Variables
Conditions
Actions
Unit Group -Pick each unit in (Beacon (Terran Large) units in (Entire map) owned by player 1 matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
General -If (Conditions) then do (Actions) else do (Actions)
If
(Number of Living units in (Any units in (Region((Position of (Picked unit)), 3.0)) owned by player 1 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) >= 1
(Number of Living units in (Any units in (Region((Position of (Picked unit)), 10.0)) owned by player 10 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) == 0
Then
Unit -Kill (Picked unit)
------- This is also where I would set the objective to completed.
Else
If I did what you suggest, I would need a copy of the trigger for each beacon, right? This is what I'm trying to avoid. The map I'm currently working on has 4 beacons. Later in the campaign there might be maps with 6 or 8. I'd like to have a generic beacon-handling trigger I can just put in any map, without having to modify it every time or make several copies just because there are several beacons.
I was also wondering about the performance of the "Units in region matching condition" function. I couldn't find any reference for how it works behind the scenes. If there are, say, a few thousand units on the whole map, does it have to check every one of them to see if they're within 10 of the beacon?
You can still use only 1 trigger, because you can use 4 events (1 for each beacon) and it'll trigger whichever beacon is approached/exited. Then just make everything else in the trigger reference the region approached/exited to pick the correct beacon.
I would edit my previous answer to instead use pre-set circle regions on the terrain editor: One with a radius of 3 for the capturing unit and one with a radius of 10 for checking if an enemy is near the beacon (both regions centered on the beacon).
You can also make a custom action for killing the beacons, since that's repeated, as shown in the attached snapshots.
In regards to your 2nd question, I'm pretty sure it just queries the particular region, then checks only those units contained in that region to see if they match the conditions. So it shouldn't be too much of a hit on performance, especially since you wouldn't be using a periodic event anymore, so it'd only query the region whenever a unit entered.
It still looks like I would have to go in and modify the trigger for each different map I put it in. I'm going to keep using my current trigger, but I'll definitely try this if there are performance issues down the road.
Thanks!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Here's what I'm trying to do. I've created a number of beacons at different enemy positions. The player (player 1) simply has to capture each location. That means at least one of the player's units are there and no enemy units (Player 10) are near (within a distance of 10).
This is the trigger I've come up with, but I'm wondering if there's a better/more efficient way to handle it.
In reply to jchardin64:
I think that setup looks fine. If you didn't want to use periodic you could use something like this:
*Just not sure if your player 10 unit dies (instead of exiting the range of the beacon point) if the Leave trigger will fire.
Thank you for the reply.
If I did what you suggest, I would need a copy of the trigger for each beacon, right? This is what I'm trying to avoid. The map I'm currently working on has 4 beacons. Later in the campaign there might be maps with 6 or 8. I'd like to have a generic beacon-handling trigger I can just put in any map, without having to modify it every time or make several copies just because there are several beacons.
I was also wondering about the performance of the "Units in region matching condition" function. I couldn't find any reference for how it works behind the scenes. If there are, say, a few thousand units on the whole map, does it have to check every one of them to see if they're within 10 of the beacon?
You can still use only 1 trigger, because you can use 4 events (1 for each beacon) and it'll trigger whichever beacon is approached/exited. Then just make everything else in the trigger reference the region approached/exited to pick the correct beacon.
I would edit my previous answer to instead use pre-set circle regions on the terrain editor: One with a radius of 3 for the capturing unit and one with a radius of 10 for checking if an enemy is near the beacon (both regions centered on the beacon).
You can also make a custom action for killing the beacons, since that's repeated, as shown in the attached snapshots.
In regards to your 2nd question, I'm pretty sure it just queries the particular region, then checks only those units contained in that region to see if they match the conditions. So it shouldn't be too much of a hit on performance, especially since you wouldn't be using a periodic event anymore, so it'd only query the region whenever a unit entered.
I see.
It still looks like I would have to go in and modify the trigger for each different map I put it in. I'm going to keep using my current trigger, but I'll definitely try this if there are performance issues down the road.
Thanks!