Author: Big_Wilk
Author Website: https://www.youtube.com/channel/UCTACxBY48txEvFOPm6eJONw

Short description: Looking a a couple of ways you may wish to spawn in waves of AI.
Date: 2016-04-25 12:37
Submitted by: big_wilk


Comments: (0)
Rating:



 

SPAWNING WAVES / DEFEND MISSION

by
Big_Wilk

Description

Hi,
I was asked to make a few scripts for this section. These examples will spawn units / vehicles around a player that will then move towards the players position. In MP games you will want to replace anywhere it says "PLAYER" with a position / object that will be known / understood by the server. In the editor you may runs these script via the debug console, in a trigger, or by pasting them into a .sqf file.

Check out a video I made on the subject for more information about implementing these ideas: https://www.youtube.com/watch?v=33cWZPP9qdo&feature=youtu.be

Example 1: Spawns a circle of empty cars around the player ever 1 degrees (360 cars total):
for '_i' from 0 to 359 do {
_spawnPos = [player, 200, _i] call BIS_fnc_relPos;
_veh = "C_Offroad_01_F" createVehicle _spawnPos ;
};
This basic example shows you how bis_fnc_relPos works, read more here: https://community.bistudio.com/wiki/BIS_fnc_relPos

Example 2: Spawns a helicopter random around the player.
for '_i' from 0 to 1 do {
 _spawnPos = [player, 500, (RANDOM 360)] call BIS_fnc_relPos;
 _spawnedVehicleArray = [_spawnPoS, 180, "B_Heli_Transport_01_F", EAST] call bis_fnc_spawnvehicle;
 _heli = _spawnedVehicleArray select 0;
 _heliCrewsGroup = _spawnedVehicleArray select 2;
 _heli doMove (position PLAYER);
 waitUntil {!alive _heli};
};
Every time the previous helicopter has been destroyed a new helicopter is spawned, change the highest number in line 1 to increase the number of waves you need.

Example 3: Works much the same as example 2 but spawns groups of troops instead.
for '_i' from 0 to 9 do {
  _spawnPos = [player, 300, (RANDOM 360)] call BIS_fnc_relPos;
  _spawnPos = [_spawnPos, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;
  _grp = [_spawnPos, EAST, 10] call BIS_fnc_spawnGroup;
  _wp = _grp addWaypoint [position player, 0];
  sleep 5;
};
Ive used BIS_fnc_findSafePos to search around the area BIS_fnc_relPos has created to find a location that is safe for troops to be spawned (not inside a rock or in the sea for example).

Have fun defending your mega 3DEN bases from these waves! These examples are intended for you to build upon but try not to go nuts with the number of units / vehicles you are spawning in to preserve your servers fps if making a mission for an MP / Coop game.



Tags: No tags