Jump to content
Sign in to follow this  
zdowggg

AI respawn and AI vehicle respawn?

Recommended Posts

Hi i was looking through fourms and i cant find an updated way for arma 3 to respawn AI and ai vehicles. I want AI to respawn in vehicles and go to a way point and if they die to do it again

Share this post


Link to post
Share on other sites

untested but try this:

//make a marker called "Attck" it's going to be the marker where ai is going to attack
AttackLocation = getMarkerPos "Attck";

//---Loop forever
while {true} do {

// wat side to count? west east? spawn more AI when all east units dead
   waitUntil {({(side _x) == east} count allUnits) == 0};

//marker east vehocles spawn at
VehicleSpawner = "yourmarker"; 

_grp1 = createGroup east;
_grp1 = [markerPos VehicleSpawner, EAST, ["O_MRAP_02_hmg_F"], [], [], [0.25, 0.25]] call BIS_fnc_spawnGroup;


_wp0 = _grp1 addWaypoint [AttackLocation,0];
_wp0 setWaypointType "SAD";
_wp0 setWaypointFormation "LINE";
_wp0 setWaypointBehaviour "AWARE";
_wp0 setwaypointcombatmode "YELLOW";
_wp0 setWaypointSpeed "NORMAL";


  sleep 5;

}; 

Edited by falconx1

Share this post


Link to post
Share on other sites

i dont understand most of what you just said sounds good but im new to this so could you exsplane step by step please

---------- Post added at 08:24 PM ---------- Previous post was at 08:23 PM ----------

can you tell me the part ware i can make an ai vehicle respawn over and over and ill go from there

Share this post


Link to post
Share on other sites

while {true} do {

//marker vehicles spawn at
VehicleSpawner = "yourmarker"; 

//_grp1 = createGroup east;   //you actually dont need this line of code
_grp1 = [markerPos VehicleSpawner, EAST, ["O_MRAP_02_hmg_F"], [], [], [0.25, 0.25]] call BIS_fnc_spawnGroup;

  sleep 5;

};  

every few seconds a vehicle with crew will spawn at a marker u made inside the editor.

so open the editor and make a marker and name the marker "yourmarker"

and make a file called init.sqf in your mission directory and place the code above

Edited by falconx1

Share this post


Link to post
Share on other sites

Orange text is just comments and not code being executed.

This first line, as it says, creates a variable which is the position of the marker named "Attck".

//make a marker called "Attck" it's going to be the marker where ai is going to attack
AttackLocation = getMarkerPos "Attck";

This line (completed with the } after sleep at the end) means "keep doing this as long as true is true :)

//---Loop forever
while {true} do {

This is what respawns your guys, it's waiting for there to be no more EAST units alive. The script waits here till everyone is dead.

// wat side to count? west east? spawn more AI when all east units dead
   waitUntil {({(side _x) == east} count allUnits) == 0};

Now that everyone is dead we use this line to get the name of a marker where we want the bad guys to spawn on, "yourmarker" in this case.

//marker east vehocles spawn at
VehicleSpawner = "yourmarker"; 

These lines create a group of an Ifrit.

_grp1 = createGroup east;
_grp1 = [markerPos VehicleSpawner, EAST, ["O_MRAP_02_hmg_F"], [], [], [0.25, 0.25]] call BIS_fnc_spawnGroup;

These lines make a waypoint at the marker location we created at the top.

_wp0 = _grp1 addWaypoint [AttackLocation,0];
_wp0 setWaypointType "SAD";
_wp0 setWaypointFormation "LINE";
_wp0 setWaypointBehaviour "AWARE";
_wp0 setwaypointcombatmode "YELLOW";
_wp0 setWaypointSpeed "NORMAL";

This line waits 5 seconds, then checks for everyone to be dead.

  sleep 5;

};

---------- Post added at 04:48 PM ---------- Previous post was at 04:37 PM ----------

You could condense it down to this:

while {true} do {

waitUntil {({(side _x) == east} count allUnits) == 0};
   sleep 5;

grp = [getMarkerPos "heliBase", opfor, ["O_MRAP_02_hmg_F"], [], [], [0.25, 0.25]] call BIS_fnc_spawnGroup;
null = [grp, (getPos player)] call BIS_fnc_taskAttack;
sleep 5;
}; 

Share this post


Link to post
Share on other sites

ok i got the one unit to spawn only problem now is it needs to be a hunter and not an op for vehicle also i want a nother car with it and 2 panthers with it

is there any way if a place a blue for unit on my editor i can just make that unit respawn that way i can give it markers more easy and stuff if not continue with this

---------- Post added at 08:58 PM ---------- Previous post was at 08:58 PM ----------

also if one of the vehicles dies will it respawn or do i have to wait for all of them to die

---------- Post added at 09:04 PM ---------- Previous post was at 08:58 PM ----------

also the vehivle keeps spawning even thos the lastunit isint dead and there spawing in each other witch is causing major destruction

---------- Post added at 09:15 PM ---------- Previous post was at 09:04 PM ----------

gess what im asking is if i place blur for vehicles on the editor is there any way i can make them respawn over and over on my marker that way when i place new units in my editor thel respawn on my marker

Share this post


Link to post
Share on other sites

You've got all the code you need right there. If you wanted blufor instead of opfor and a hunter instead of an ifrit there's only a few things you need to change in the code. I've broken it down line by line so it should be pretty easy to tell what to change, give it shot. :)

Share this post


Link to post
Share on other sites

ok but whats the code for a blue for unit to spawn i need one with a hunter and a panther

---------- Post added at 04:34 AM ---------- Previous post was at 03:55 AM ----------

ok i got a better idia since i already have a base with epty vehicles that respawn how do i make a blue for rifel man take a random vehicle and respawn and do it again that should be alot more easy

Share this post


Link to post
Share on other sites

Please can someone help - I just cant get my head round respawning vehicles.

I am using the code below to spawn a Gorgon, driver and gunner which then proceed to patrol round their waypoints. The $64,000 question is what would I need to add to this to make the vehicle respan afer it has been destroyed

if (!isServer) exitWith {};

	_con2GRP2 = createGroup EAST;  

	_con2 = createVehicle ["O_APC_Wheeled_02_rcws_F", getMarkerPos "c1a", [],0,"NONE"];
	_con2  setDir 280;

	_VarName = "con2"; 
	_con2 SetVehicleVarName _VarName; 
           call compile format["%1 = _con2", _VarName]; 
           clearMagazineCargoGlobal  _con2;
           clearWeaponCargoGlobal _con2;

           _con2pilot = _con2GRP2 createunit ["O_soldierU_AR_F", [0,0,1], [], 0, "CAN_COLLIDE"];
           _VarName = "con2pilot2"; 
           _con2pilot SetVehicleVarName _VarName; 
           call compile format["%1 = _con2pilot", _VarName];

          _con2pilot moveInDriver _con2; 
	_con2pilot setCombatMode "BLUE";
	_con2pilot setBehaviour "SAFE";
           _con2pilot allowDamage true;
           _con2pilot setCaptive false;
	sleep 3.0;

           _con2gunner = _con2GRP2 createunit ["O_soldierU_AR_F", [0,0,1], [], 0, "CAN_COLLIDE"];
          	_VarName = "tp10";
	_con2gunner SetVehicleVarName _VarName;
           call compile format["%1 = _con2gunner", _VarName];
	_con2gunner moveInTurret [_con2, [0]];
	_con2gunner setCombatMode "RED";
	_con2gunner setBehaviour "SAFE";

 		_con2 lock true;



_waypoint0 = _con2GRP2 addwaypoint[getmarkerpos "c1b",0];
_waypoint0 setwaypointtype "move"; 
_waypoint0 setWaypointTimeout [0, 0, 0];
_waypoint0 setWaypointSpeed "LIMITED";
_waypoint0 setWaypointBehaviour "SAFE";
_waypoint0 setWaypointFormation "LINE";
_waypoint0 setWaypointCombatMode "RED";
_waypoint0 setWaypointCompletionRadius 0;

sleep 0.1;

_waypoint1 = _con2GRP2 addwaypoint[getmarkerpos "c1c",0];
_waypoint1 setwaypointtype "move"; 
_waypoint1 setWaypointTimeout [300, 360, 420];
_waypoint1 setWaypointSpeed "LIMITED";
_waypoint1 setWaypointCompletionRadius 0;

sleep 0.1;


_waypoint2 = _con2GRP2 addwaypoint[getmarkerpos "c1d",0];
_waypoint2 setwaypointtype "Move"; 
_waypoint2 setWaypointTimeout [0, 0, 0];
_waypoint2 setWaypointSpeed "LIMITED";
_waypoint2 setWaypointCompletionRadius 0;

sleep 0.1;

_waypoint3 = _con2GRP2 addwaypoint[getmarkerpos "c1d",0];
_waypoint3 setwaypointtype "move"; 
_waypoint3 setWaypointTimeout [0, 0, 0];
_waypoint3 setWaypointSpeed "NORMAL";
_waypoint3 setWaypointBehaviour "SAFE";
_waypoint3 setWaypointCompletionRadius 0;


sleep 0.1;

_waypoint4 = _con2GRP2 addwaypoint[getmarkerpos "c1e",0];
_waypoint4 setwaypointtype "move"; 
_waypoint4 setWaypointTimeout [0, 0, 0];
_waypoint4 setWaypointSpeed "NORMAL";
_waypoint4 setWaypointBehaviour "SAFE";
_waypoint4 setWaypointCompletionRadius 0;

sleep 0.1;
_waypoint5 = _con2GRP2 addwaypoint[getmarkerpos "c1f",0];
_waypoint5 setwaypointtype "move"; 
_waypoint5 setWaypointTimeout [0, 0, 0];
_waypoint5 setWaypointCompletionRadius 0;

sleep 0.1;

_waypoint6 = _con2GRP2 addwaypoint[getmarkerpos "c1a",0];
_waypoint6 setwaypointtype "cycle"; 
_waypoint6 setWaypointTimeout [0, 0, 0];
_waypoint6 setWaypointSpeed "NORMAL";
_waypoint6 setWaypointCompletionRadius 0;

if (true) exitWith {};        

Will be forever in your debt if someone can help with this - I am sure the answer is somewhere in the forums but I cant find it

Thanks in advance

Oh forget to mention this will be running on a dedi server

Edited by Doodle
Cos im forgetful

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  

×