Trigger help - Unit auto spawn

Status
Not open for further replies.
Level 1
Joined
Mar 21, 2011
Messages
3
Howdy!

Im new to the editor and have tried different triggers to get the effect I want without any success. What I want is a trigger that when a player enters a region with his unit, a marine will spawn every 2sec at the players starting location as long as the player is within the region bound's.

So far Iv come up with:

Events
* Unit - Any Unit Enters "Marine" <- Marine is the Region name

Local Variables

Conditions

Actions
* Unit - Create 1 Marine for player (Triggering player) at (Start location of player (Triggering player)) using default facing (No Options)



So, how do I loop this every 2 seconds as long as the triggering players unit is within the region?


Thanks in advance.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
You have 1 trigger to handle spawning (all units), 1 trigger to handle the region entery and 1 to handle the exit.

When a player enters the region, you add the spawn unit type to a spawn list and store that he is currently in the region and that it has been added to the list.
When a unit leaves the region you remove the spawn from the list and store that he is not currently in the region.

The spawn system loops through all spawns he should be getting for all players and creates them at the start location.

This however has the problem of units dieing in the region causing a leak bug. To fix, you need to also keep track of units in spawn regions and every time one of them dies you have to check if units still exist in the spawn region.
 
Level 5
Joined
Jul 10, 2010
Messages
124
you need 2 triggers, 1 boolean variable, and 1 action definition


trigger 1
event-unit enters region
condition-owner of triggering unit = player 1
action-if booleanvariable = false then do actions:
-set booleanvariable = true
-run actiondefinition

trigger 2
event-unit leaves region
condition-owner of triggering unit = player 1
- number of units in region owned by triggering player less than 1
action-set booleanvariable = false

action definition
loop while booleanvariable = true
create 1 marine for player 1 in spawnregion
wait 2.0 game seconds
 
Status
Not open for further replies.
Top