Jump to content
Sign in to follow this  
Thamu

AI respawn on specific area

Recommended Posts

Hello all! I'm creating a training mission,and I have a small problem. On map Chernarus, I created enemy infantry and vehicles on there,so people can practice some shooting with helos and airplanes. BUT! When everything is destroyed (infantry and vehicle) they dont spawn back! I'm using this script to respawn enemy vehicle: http://forums.bistudio.com/showthread.php?t=76445&highlight=Vehicle+Respawn

and using a marker to respawn infantry (like wiki is teaching), but this is not working. I already used the search button, but I found nothing about that. There is a possibility of Infantry on a certain city spawn only on there? Thanks.

Share this post


Link to post
Share on other sites

Edit: tested and modified into one single script for both infantery and vehiclegroups.

place this in the init of the leader of all the infantery or vehicle groups you want to respawn.

you need to change "spawnmarker" to a markername you have placed in editor for that side or type unit, you can use same or several markers, it does not matter.

also change "patrolmarker" to a marker you have placed on map wich will be their patrol area, (they will go here after respawn).

_null = [this,"spawnmarker","patrolmarker"] execVM "respawn.sqf";

// save this as [b]respawn.sqf[/b]
_grp = (group (_this select 0));
_spawn = _this select 1;
_here = _this select 2;

waituntil {!isnil "bis_fnc_init"};
_side = side _grp;
_vehicles = [];
_units = [];
{
_veh = vehicle _x;
if (!(_veh isKindOf "Man")) then {
	if (!(_veh in _vehicles)) then {
		_vehicles = _vehicles + [_veh];
	};
} else {
	_units = _units + [(typeOf _veh)];
};
} foreach units _grp;
_types = [];
if ((count _units) != 0) then {_types = _units};
{_types = _types + [(typeOf _x)]} foreach _vehicles;

while {true} do {
[b]// here we wait until all in group is dead.[/b]
waitUntil {sleep 1; ({alive _x} count units _grp) == 0};

[b]// here we spawn the group using BIS_fnc_spawnGroup.[/b]
_grp = [getMarkerPos "spawnmarker", _side, _types] call BIS_fnc_spawnGroup;

[b]// here we use the function BIS_fnc_taskPatrol to create a dynamic patrol around the "patrolmarker" area. the patrol will be random within 500 of the marker, change 500 to whatever desired.[/b]
_null = [_grp, getMarkerPos _here, 500] call BIS_fnc_taskPatrol;
};

Note: do not start units in Cargo of a vehicle, they will not be added.

Edited by Demonized

Share this post


Link to post
Share on other sites

Thx for your help again. I will test this.

EDIT: So,I tested:

I killed the entire squad,but they dont respawn.

When the entire squad dies,it enters on "while" again,but nothing happens.

Edited by Thamu

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  

×