Jump to content
Sign in to follow this  
Thingamajig

AI Respawning

Recommended Posts

Hi all.

I'm using this nice little script here to get empty vehicles to respawn:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//*****************************************************

//**

//** ArmA Script File

//**

//**     vrs_AI_general.sqf

//**

//*****************************************************

//**  Version 1.0 beta

//BEGIN vrs_AI_general.sqf

//Script by norrin March 2007

//Based upon KaRRiLLioN's original vrs.sqf script heavily modified for use with playable and non-playable AI units

//Contact me at norrins_nook@iprimus.com.au

//IMPORTANT: ADD A GAMELOGIC NAMED Server

//to the mission to prevent multispawn

//to run this script place the following code in the init line of the vehicle:

// v = [this, "vehicle name", x, y] execVM "vrs_AI_general.sqf"

//where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay

//Note: the vehicle name must be in quotation marks eg. if vehicle name Hmm1 it must appear in the init line as "Hmm1"

private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this select 0;

_name_vcl = _this select 1;

_vclemptydelay = _this select 2;

_respawndelay = _this select 3;

_dir = Getdir _vcl;

_pos = Getpos _vcl;

_type = typeOf _vcl;

_run = TRUE;

sleep 5;

for [{}, {_run}, {_run}] do

{

while {_vcl distance _pos < 5 && canMove _vcl} do

  {

sleep 1;

  };

while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do  

  {

_wait = Time + _vclemptydelay;

sleep 1;

};

while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do

{

sleep 1;

};

while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do

{

sleep 1;

};

_delay = Time + _respawndelay;

while {!canMove _vcl && Time < _delay} do

  {

sleep 1;

  };

if (count crew _vcl < 1) then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setVehicleVarName _name_vcl;

  player groupchat format ["%1", VehicleVarName _vcl];

        _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  sleep 2;

  };

if ({damage _x} forEach crew _vcl >= 1)then

  {

  deleteVehicle _vcl;

        _vcl = _type createVehicle _pos;

  _vcl setVehicleVarName _name_vcl;

  player groupchat format ["%1", VehicleVarName _vcl];

        _vcl setdir _dir;

        sleep 1;

        _vcl setvelocity [0,0,0];

        _vcl setpos _pos;

        sleep 1;

        _vcl setvelocity [0,0,0];

  sleep 1;

  };

sleep 2;

i also tried the above script on AI units (people) and it works. but for some reason when the AI respawn, they do not move. even though they have waypoints set to go to.

Anyone know how i can get them to continue thier cycle of waypoints after they have respawned?

Thanks in advance.

Share this post


Link to post
Share on other sites

what i do is write a script telling the ai to move to a position

with the domove command and at the respawn point have a trigger that goes of every 30 sec if there is anyone in the trigger list nil = [thislist] execVM "move.sqf";

and that will keep them going all day..

there is an example of how i do this  

http://www.flashpoint1985.com/cgi-bin....ekiller

Michael

Share this post


Link to post
Share on other sites
what i do is write a script telling the ai to move to a position

with the domove command and at the respawn point have a trigger that goes of every 30 sec if there is anyone in the trigger list nil = [thislist] execVM "move.sqf";

and that will keep them going all day..

there is an example of how i do this  

http://www.flashpoint1985.com/cgi-bin....ekiller

Michael

Thanks alot ^.^

Could you, or anyone :P, also solve another problem i have?.

I'm placing empty civilian vehicles in all the towns for a CTI game. but i noticed that after ive destroyed so many empty civilian vehicles, friendly A.I engage me!.

I thought they would ignore me destroying these vehicles as they are empty...is there a way to do this?.

Thanks again.

Share this post


Link to post
Share on other sites

Not sure if this is suitable, but I did a script called AIGroupRespawn.sqf to respawn entire groups of AI when group is dead, not just individual AI - both infantry and vehicles.

This ensures the group stays together and resumes their waypoints. It has multiple respawn points, etc.

See last post of this Respawn dead AI topic. The script has probably since been updated in the mission Op. Silent Lamb. Let us know if you want the update.

Share this post


Link to post
Share on other sites
Not sure if this is suitable, but I did a script called AIGroupRespawn.sqf to respawn entire groups of AI when group is dead, not just individual AI - both infantry and vehicles.

This ensures the group stays together and resumes their waypoints. It has multiple respawn points, etc.

See last post of this Respawn dead AI topic. The script has probably since been updated in the mission Op. Silent Lamb. Let us know if you want the update.

thanks.

I did come across these posts before. but it appears the links in them are still dead.

Got any fresh ones?.

Share this post


Link to post
Share on other sites

Here's the most recent version: AIGroupRespawn.sqf. Have a browse. Easy to use.

(There might be a flaw with it (or it could have been something else), where the AI stop spawning or moving (or something), since the appearance of AI often stops or dwindles down after about 3 hours of game play in a mission which probably has about 200 AI.

The groups are being re-used but perhaps I'm reaching some sort of ArmA limit, like unit numbering or whatever. Never worked it out yet.

It may not affect you if your mission time or AI count is shorter/lower than that combination.

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  

×