Jump to content
Sign in to follow this  
Darkhalo288

Creating waves of ai

Recommended Posts

How would i go about creating an ai spawn point and having it spawn a certain enemy unit or group from there every X min to a certain location, i know how to do way points and all just not the constant spawns of ai. Also how can i create a spawn point that activates after a certain time, for example say after 10min game the spawn point then sends waves of ai to the target location every X min also?

---------- Post added at 07:44 PM ---------- Previous post was at 07:27 PM ----------

.....

Share this post


Link to post
Share on other sites

Create a script

Name it: "spawn.sqf"

Airborne = [getmarkerPos "start", side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup;

sleep 1;

wp1 = Airborne addwaypoint [position player, 0];
wp1 setwaypointtype "SAD";
wp1 setWaypointSpeed "FULL";

sleep 60;

[] execVM "spawn.sqf";

create a marker name it start

create a trigger

condition

local player

On Act

nul=[] execVM "spawn.sqf";

change the "sleep 60" to whatever time you want.

You might want to add an {deletevehicle _x} for eachunits Airborne in after the time is up otherwise you will be overwhelmed with bad guys, I guess it depends on the mission you are making.

Also to answer your question about starting the spawn at a certain time you could have the trigger do a timeout of 600,600,600 (10min) before it starts spawning.

This should get you started in the right direction.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Shamelessly promoting my own script: Editor based AI spawn by trigger

Support delayed activation (by trigger, just set the value to true when ready), zero need for messing with markers and it even got a built in wave mode for respawning the same group at intervals a certain amount of times.

Sidenote to cobra4v320: How does that work with new groups? If you just keep creating the group and assigning it to the same global variable, doesnt this mean you loose track of the group ID for the previous spawn and become unable to delete old groups, to the point of eventually not being able to create new groups?

I know my script above does the same mistake, damn I need to focus and upload the new version :(

Share this post


Link to post
Share on other sites

@Murklor

The script I posted works fine, every 60 seconds it spawns in another group. If its waves he wants, its waves he gets. The information posted was a start, Im not going to write the script for him. :j: However you are probably right about the variable name, I will test when I get home.

Share this post


Link to post
Share on other sites
@Murklor

The script I posted works fine, every 60 seconds it spawns in another group. If its waves he wants, its waves he gets. The information posted was a start, Im not going to write the script for him. :j: However you are probably right about the variable name, I will test when I get home.

I never said it wouldnt work ;)

I just think your script will work 143 times (assuming the player is part of a group) and then cant create any more groups.

My solution has been to call this simple sqf for respawning units:

_group = _this select 0;
_unitsGroup = units _group; 

while { ({alive _x} count _unitsGroup) > 0 } do {
//hint format ["Units alive: %1", {alive _x} count _unitsGroup]; 
sleep 5;
};

deleteGroup _group;

That way you automatically clean the group when its dead and can create multiple groups without worry... Well unless you create a ton of units at the same time lol.

I dont really know if it works as it should, my testing is so uber :rolleyes:

Or I'm a retard and Arma 2 already does this automatically for dead groups... But I dont think so, as you can create groups with no units in them (obviously).

Share this post


Link to post
Share on other sites
Create a script

Name it: "spawn.sqf"

Airborne = [getmarkerPos "start", side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup;

sleep 1;

wp1 = Airborne addwaypoint [position player, 0];
wp1 setwaypointtype "SAD";
wp1 setWaypointSpeed "FULL";

sleep 60;

[] execVM "spawn.sqf";

create a marker name it start

create a trigger

condition

local player

On Act

nul=[] execVM "spawn.sqf";

change the "sleep 60" to whatever time you want.

You might want to add an {deletevehicle _x} for eachunits Airborne in after the time is up otherwise you will be overwhelmed with bad guys, I guess it depends on the mission you are making.

Also to answer your question about starting the spawn at a certain time you could have the trigger do a timeout of 600,600,600 (10min) before it starts spawning.

This should get you started in the right direction.

Ok i've done everything you've said and nothing happens at all, is there something else i need to add?

Share this post


Link to post
Share on other sites
Ok i've done everything you've said and nothing happens at all, is there something else i need to add?

You'll need to place a functions module in your mission, just place it is all nothing else needed.

Share this post


Link to post
Share on other sites
Create a script

Name it: "spawn.sqf"

Airborne = [getmarkerPos "start", side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup;

sleep 1;

wp1 = Airborne addwaypoint [position player, 0];
wp1 setwaypointtype "SAD";
wp1 setWaypointSpeed "FULL";

sleep 60;

[] execVM "spawn.sqf";

create a marker name it start

create a trigger

condition

local player

On Act

nul=[] execVM "spawn.sqf";

change the "sleep 60" to whatever time you want.

You might want to add an {deletevehicle _x} for eachunits Airborne in after the time is up otherwise you will be overwhelmed with bad guys, I guess it depends on the mission you are making.

Also to answer your question about starting the spawn at a certain time you could have the trigger do a timeout of 600,600,600 (10min) before it starts spawning.

This should get you started in the right direction.

How could i give it a multiple spawn points or a radius to spawn randomly on?

---------- Post added at 20:09 ---------- Previous post was at 19:48 ----------

Airborne = [getmarkerPos "start", side opfor, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_GUE" >> "Infantry" >> "TK_GUE_Group")] call BIS_fnc_spawnGroup;

also that is my script line but it does not work any ideas why? i want to spawn takistani militiamen

Share this post


Link to post
Share on other sites
You'll need to place a functions module in your mission, just place it is all nothing else needed.

It's still dont work for me.

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  

×