Jump to content
Sign in to follow this  

Spawn Custom Units & SP Respawn

Recommended Posts

Ok, so I don't know how to script this so I'm gonna ask here.

I need full instructions how to use the script :P

1) If player kills 3 civ's, units WITH custom loadouts will spawn on a marker, and their waypoint will be to kill the player

2) In 2 min they despawn; if the player is killed, they will respawn on a marker (NOTE THIS IS SINGLE PLAYER)

If they die normally, I want them to spawn at another marker

How can this be done?

Share this post

Link to post
Share on other sites

Define "player is killed, they will respawn on a marker" and then "if they die normally, spawn on another marker"

What is the distinguishing factors between the two deaths?

But respawn is not possible in single player. This is a decision by BIS that is hard-coded into the engine. The way they do it during the campaign is by saving your progress at different steps throughout the mission.

In the init line of every civilian I would put this code:

_this addEventHandler ["Killed", {player setVariable ["civilianKills",((player getVariable "civilianKills") + 1), false]}];

this can go inside your init.sqf:

[] spawn {
fnc_customGear = {
	//Exported straight from the Arsenal
	removeAllWeapons _this;
	removeAllItems _this;
	removeAllAssignedItems _this;
	removeUniform _this;
	removeVest _this;
	removeBackpack _this;
	removeHeadgear _this;
	removeGoggles _this;

	_this forceAddUniform "U_O_CombatUniform_ocamo";
	_this addItemToUniform "FirstAidKit";
	_this addItemToUniform "10Rnd_93x64_DMR_05_Mag";
	_this addItemToUniform "Chemlight_red";
	_this addVest "V_HarnessO_brn";
	for "_i" from 1 to 6 do {_this addItemToVest "10Rnd_93x64_DMR_05_Mag";};
	for "_i" from 1 to 2 do {_this addItemToVest "16Rnd_9x21_Mag";};
	_this addItemToVest "SmokeShell";
	_this addItemToVest "SmokeShellRed";
	_this addItemToVest "Chemlight_red";
	for "_i" from 1 to 2 do {_this addItemToVest "HandGrenade";};
	_this addHeadgear "H_HelmetO_ocamo";
	_this addWeapon "srifle_DMR_05_KHS_LP_F";
	_this addPrimaryWeaponItem "acc_pointer_IR";
	_this addPrimaryWeaponItem "optic_KHS_blk";
	_this addPrimaryWeaponItem "bipod_02_F_blk";
	_this addWeapon "hgun_Rook40_F";
	_this addWeapon "Binocular";
	_this linkItem "ItemMap";
	_this linkItem "ItemCompass";
	_this linkItem "ItemWatch";
	_this linkItem "ItemRadio";
	_this linkItem "NVGoggles_OPFOR";

fnc_spawnEnemies = {
	_spawnPos = getMarkerPos "enemySpawnPoint";
	_unitsToSpawn = 3;
	_timeToDespawn = 2 * 60; //Two minutes
	_time = 0;
	_group = createGroup east;

	for [{_i = 0}, {_i < _unitsToSpawn}, {_i = _i + 1}] do
		_unit = "B_Soldier_F" createUnit [_spawnPos, _group];
		[_unit] call fnc_customGear;

	_waypoint = _group addWaypoint [position player,0]; 
	_waypoint setWaypointType "DESTROY";
	_waypoint setWaypointBehaviour "COMBAT";
	_waypoint setwaypointcombatmode "RED"; 
	_waypoint setWaypointSpeed "FULL";

	while {_time < _timeToDespawn} do {
		[_group, 0] setWaypointPosition [position player, 0];
		sleep 1;

	{deleteVehicle _x} forEach units group _group;

//At mission start they are in good standing
_goodRating = true;

player setVariable ["civilianKills", 0, false];

//While they remain in good standing with the civs, keep checking
while {_goodRating} do {
	if ((player getVariable "civilianKills") >= 3) then {
		_goodRating = false;
		[] call fnc_spawnEnemies;

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