Jump to content
Sign in to follow this  
RomanLord

Help Spawning AI repeteadly

Recommended Posts

Hello all

I'm using the following script to spawn enemy AI infantry, then passing them to UPSMON script for patrolling an area.

The script works fine, called by a trigger.

the problem is that it works only ONCE.

If I call it again, there are no AI spawning also if UPSMON script debug shows me that is creating new istances and new waypoints, but no AI are created.

I want to call it different times based on advancing of my squad. Instead of putting 100 eney AI on the island at the same time, I will spawn them only when my group is in the area, then delete the old ones...

Where I'm wrong?

if (!isServer) exitWith {};

_infTypes = ["MOL_Rifleman","MOL_Rifleman","MOL_Soldier_MG","MOL_Medic"];

_infType = count _infTypes;




_numOfGrps = ceil(random 4);
for "_i" from 1 to _numOfGrps do
{

_grp = createGroup East; 
_numInGrp = ceil(random 6);
for "_i" from 1 to _numInGrp do
{
_infTypes select ceil(random _infType) createUnit [(getMarkerPos "areanew"), _grp, "",0.4,"PRIVATE"];
sleep 1;
};
"MOL_Officer" createUnit [(getMarkerPos "areanew"), _grp, "nul=[this,'areanew','nofollow','nowait'] execVM 'scripts\upsmon.sqf'",0.4,"SERGEANT"];

sleep 1;

_unit = leader _grp;
_unit setFormation "VEE";
_unit setBehaviour "CARELESS";
sleep 1;

{
_x allowFleeing 0;
_x setskill ["aimingAccuracy",0.4];
_x setskill ["aimingShake",0.4];
_x setskill ["aimingSpeed",0.4];
_x setskill ["Endurance",1];
_x setskill ["spotDistance",0.4];
_x setskill ["spotTime",0.4];
_x setskill ["courage",1];
_x setskill ["reloadSpeed",0.4];
_x setskill ["commanding",0.4];
_x setskill ["general",0.4];
_x allowFleeing 0;
} forEach units _grp;


};

Share this post


Link to post
Share on other sites

Couldn't you call it with multiple triggers?

Edit: I would also assume you would have to pre place and use the script from armaholic something in line with "Spawn and Move to way points", which will allow you to spawn multiple waves defined by: How many units you want, how much time between each wave.

Edited by Skelt

Share this post


Link to post
Share on other sites

This will do what your looking for, just found it. Same thing I was looking for. You can place a group of AI in the editor, and tell it how many times to resapawn, and at what interval, in seconds.

Best Spawn AI on trigger Script I have found. If not please PM me!! :) I'm always up for improvements.

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  

×