Jump to content
Sign in to follow this  
Lineman

[Solved] Spawning AI with Timed Loop

Recommended Posts

EDIT: Solved. Add waitUntil {triggerActivated StartSpawn};
for "_i" from 1 To 4 do { to the start of the .sqf to limit the number of loops and add sleep 600; to the end, like so:

 

Spoiler

 

if !(isServer) exitWith {};

waitUntil {triggerActivated StartSpawn};
for "_i" from 1 To 4 do {

_spawnPoints = ["EnemySpawn01","EnemySpawn02","EnemySpawn03","EnemySpawn04"];
_unitsInGroup = ["O_Soldier_GL_F","O_Soldier_F","O_Soldier_lite_F","O_Soldier_AR_F","O_Soldier_AAR_F","O_medic_F"];

_spawnMarker = _spawnpoints select (floor random (count _spawnpoints));

_unksSpawnPosition = getMarkerPos _spawnMarker; //[x,y,z]

newGroup = createGroup [east,true];
_newLeader = "O_Soldier_SL_F" createUnit [_unksSpawnPosition,newGroup,"newLeader = this"];
sleep 1;

{
    _newUnit = _x createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
    sleep .4;
}forEach _unitsInGroup;

[newGroup,getPos patrolCentre,50] call BIS_fnc_taskPatrol;
sleep 4;
newGroup setBehaviour "COMBAT";

sleep 600;
};

 

 

Trying to make an AI group spawn at 1 of 4 locations every 10 minutes when Opfor is present. Currently, Opfor enters condition area, a group spawns correctly, but it seems Opfor has to leave and re-enter the area to trigger another spawn. I want the trigger to loop continuously every 10 minutes so long as Opfor remains present.

 

//Trigger
 

Spoiler

 

Activation: Opfor

Activation Type: Present
Repeatable: Yes

Condition: this

On Activation: []execVM "EnemyWest01.sqf";

 

 

//EnemyWest01.sqf
 

Spoiler

 

if !(isServer) exitWith {};

_spawnPoints = ["EnemySpawn01","EnemySpawn02","EnemySpawn03","EnemySpawn04"];
_unitsInGroup = ["O_Soldier_GL_F","O_Soldier_F","O_Soldier_lite_F","O_Soldier_AR_F","O_Soldier_AAR_F","O_medic_F"];

_spawnMarker = _spawnpoints select (floor random (count _spawnpoints));

_unksSpawnPosition = getMarkerPos _spawnMarker; //[x,y,z]

newGroup = createGroup [east,true];
_newLeader = "O_Soldier_SL_F" createUnit [_unksSpawnPosition,newGroup,"newLeader = this"];
sleep 1;

{
    _newUnit = _x createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
    sleep .4;
}forEach _unitsInGroup;

[newGroup,getPos patrolCentre,50] call BIS_fnc_taskPatrol;
sleep 4;
newGroup setBehaviour "COMBAT";

 

 

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  

×