Jump to content
Sign in to follow this  
Flingotravels

Spawning AI using trigger

Recommended Posts

I'm creating a zombie-based mission, and I would like to create the effect of an omnipresence of undead around the map. How can I spawn a group using a trigger?

Share this post


Link to post
Share on other sites

The problem with createUnit is that the unit must join an existing group upon its creation, otherwise it's simply not created. You don't want to use a trigger for this, it would get messy. With a script, you can use the same script for all units easily by having the units call the script from their init-lines and passing a reference to themselves as the parameter like:

this exec "myscript.sqs"

Now the script has a reference to the particular unit in its _this variable. Then you can do something like

@player distance _this < 600

{_x createUnit [getpos _this, group _this]} forEach ["SoldierEB", "SoldierEB", "SoldierEB", "SoldierELAW","SoldierEMG","SoldierEMedic"]

With this example you could cover a large area with lone officers all of which would spawn a group when the player gets closer than 600m.

There's also some ready scripting solutions for covering large areas with enemies, such as DAC.

Share this post


Link to post
Share on other sites

Interesting script!

How would one go about setting up a maximum number of group respawns? Let's say you didn't want to exceed 5 respawns--what would it look like?

Or, better yet, just to add some more uncertainty, how would the entire script look if there was a randomly generated number of respawns assigned to a group, say, no more than 5 and no less than 1?

Share this post


Link to post
Share on other sites

Add on the beginning of the script a variable like

_spwn = _this select 0

and on the end of the script

_spwn = _spwn - 1

? _spwn == 0 : exit

To call a script

[5] exec "myscript.sqs"

The number means a number of spawns. If you need a bit of randomizing just add a prefix random infront of number (ain't quite sure if this will work thou, test it and you'll see).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×