Spawn something in front of the player

For the spawning, I went with the approach of “spawn stuff in front!” so you can place a trigger with this in it’s onAct:

nul = [(thislist select 0), 8] execVM "spawnResponse.sqf";

Which calls this script:

	if (isServer) then {

	// How many enemies in each group.
	_sourcePoint = _this select 0;
	_enemyCount = _this select 1;
	// Get a random position within 300-600m and in a 90 degree arc in front of the player's vehicle/player.
	_randDir = getDir vehicle _sourcePoint - 45;
	_randDir = _randDir + random(90);
	_randDist = (random 100) + 200;
	_enemyLoc =	[(getPos vehicle _sourcePoint select 0) + (_randDist * sin(_randDir)), (getPos vehicle _sourcePoint select 1) + (_randDist * cos(_randDir)), 0];
	// Spawn the first group and have them attack.
	grp = [_enemyLoc, east, _enemyCount] call BIS_fnc_spawnGroup; 
	null = [grp,(getPos vehicle _sourcePoint)] call BIS_fnc_taskAttack; 
	grp reveal _sourcePoint;

That’ll spawn 8 (or whatever number) of east units 300-600m in front of the unit that set off the trigger.

Comments are closed.