Home   Help Search Login Register  

Author Topic: creating a counter-attacking OPFOR enemy in land/sea/air  (Read 1878 times)

0 Members and 1 Guest are viewing this topic.

Offline eggbeast

  • Members
  • *
Hi

I'm editing our version of Evolution
discussion thread:
http://forums.bistudio.com/showthread.php?t=85921&highlight=evo+fix&page=14
link to file:
http://91.192.210.5/gits/Arma/

I have adapted the makesu.sqf which made a su34 in arma.  I have this working for every type of enemt air unit.
I have adapted it now to create a spetnaz assault force that will seek the ambulance or airfield and attack it...

here is the code of makespetz.sqf, called in sinit.sqf
Code: [Select]
//makespetz.sqf - spetnaz assault event - makes truck/ hind / boat borne spetnaz assault that spawns randomly and then seeks the ambulance to destroy Blufor spawnbase

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
sleep 30;
_allobj = [];
_posc = [0,0,0];
_pos2 = [0,0,0];
_pos3 = [0,0,0];
_pos4 = [0,0,0];
_allvecs = [];
_allunitsP = [];
_allunitsA = [];

_allobj = ["mrnd2","mrnd10","mrnd1","mrnd9","mrnd11","mrnd12","mrnd13","mrnd14","mrnd15","mrnd20","mrnd19","mrnd18","mrnd16","mrnd7","mrnd6","mrnd5","mrnd4","mrnd3"];
_max = count _allobj;

_posc =  getmarkerpos (_allobj select (round random (_max - 1)));
_pos2 = [(_posc select 0),(_posc select 1) - 25,(_posc select 2)];
_pos3 = [(_posc select 0),(_posc select 1) - 50,(_posc select 2)];
_pos4 = [(_posc select 0),(_posc select 1) - 75,(_posc select 2)];

_r = (round random 1);
if _r < 1 then
{
_targblue = getmarkerpos ("markerlkwwest");  //ambulance
};
else
{
_targblue = getmarkerpos ("FahneHalo");  //airfield weapons crate
};

//marker shows start location - temporary
_start = createMarkerLocal ["look", _pos4];
_start setMarkerColorLocal "ColorRed";
_start setMarkerShapeLocal "RECTANGLE";
_start setMarkerSizeLocal [50, 50];
_start setMarkerBrushLocal "FDiagonal";

_pilotsp = createGroup (east);
_spetz = createGroup (east);

_dice = (round random 1);

if [(_targblue select 1)] < 4000 then _dice = 2;   //i.e. the ambulance is near to the coast, less than 4000m up in Y direction

if (_dice == 0) then //spetz airborne
{
hint "spetnaz airborne";

_allvecs = ["Mi24_D","Mi24_V","Mi24_P","Mi17_rockets_RU"];
_max = (count _allvecs)-1;
_heli = createVehicle [_allvecs select (round random _max), _posc, [], 500, "FLY"];[_heli] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli1 = createVehicle [_allvecs select (round random _max), _pos2, [], 500, "FLY"];[_heli1] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli1] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli2 = createVehicle [_allvecs select (round random _max), _pos3, [], 500, "FLY"];[_heli2] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli2] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli3 = createVehicle [_allvecs select (round random _max), _pos4, [], 500, "FLY"];[_heli3] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli3] spawn {[_this select 0] call BIS_EVO_idelSVEC};
};

if (_dice == 1) then //spetz land
{
hint "spetnaz land";

_allvecs = ["Kamaz","GAZ_Vodnik_HMG","BTR90","BMP3","GAZ_Vodnik"];
_max = (count _allvecs)-1;
_heli = createVehicle [_allvecs select (round random _max), _posc, [], 0, "NONE"];[_heli] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli1 = createVehicle [_allvecs select (round random _max), _pos2, [], 0, "NONE"];[_heli1] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli1] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli2 = createVehicle [_allvecs select (round random _max), _pos3, [], 0, "NONE"];[_heli2] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli2] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli3 = createVehicle [_allvecs select (round random _max), _pos4, [], 0, "NONE"];[_heli3] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli3] spawn {[_this select 0] call BIS_EVO_idelSVEC};
};

if (_dice == 2) then //spetz seaborne
{
hint "spetnaz seaborne";

_allvecs = ["RHIB","RHIB2Turret","pbx"];
_max = (count _allvecs)-1;
_heli = createVehicle [_allvecs select (round random _max), _posc, [], 0, "NONE"];[_heli] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli1 = createVehicle [_allvecs select (round random _max), _pos2, [], 0, "NONE"];[_heli1] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli1] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli2 = createVehicle [_allvecs select (round random _max), _pos3, [], 0, "NONE"];[_heli2] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli2] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli3 = createVehicle [_allvecs select (round random _max), _pos4, [], 0, "NONE"];[_heli3] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli3] spawn {[_this select 0] call BIS_EVO_idelSVEC};
};

_allunitsP = ["RU_Soldier_Pilot","RU_Soldier_Officer","RU_Soldier_Crew"];
_max = (count _allunitsP)-1;

_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsDriver _heli;_unit moveInDriver _heli;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsGunner _heli;_unit moveInGunner _heli;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsDriver _heli1;_unit moveInDriver _heli1;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsGunner _heli1;_unit moveInGunner _heli1;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsDriver _heli2;_unit moveInDriver _heli2;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsGunner _heli2;_unit moveInGunner _heli2;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsDriver _heli3;_unit moveInDriver _heli3;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);_unit assignAsGunner _heli3;_unit moveInGunner _heli3;
Sleep 0.2;

/*
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsDriver _heli;_unit moveInDriver _heli;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsGunner _heli;_unit moveInGunner _heli;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsDriver _heli1;_unit moveInDriver _heli1;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsGunner _heli1;_unit moveInGunner _heli1;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsDriver _heli2;_unit moveInDriver _heli2;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsGunner _heli2;_unit moveInGunner _heli2;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsDriver _heli3;_unit moveInDriver _heli3;
Sleep 0.2;
_unit = _pilotsp createUnit [(_allunitsP select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _pilotsp;_unit assignAsGunner _heli3;_unit moveInGunner _heli3;
Sleep 0.2;
*/
_pilotsp setCombatMode "SAFE";
_heli engineon true;
_heli1 engineon true;
_heli2 engineon true;
_heli3 engineon true;

_allunitsA = ["MVD_Soldier_TL","MVD_Soldier_MG","MVD_Soldier","MVD_Soldier_GL","MVD_Soldier_AT","MVD_Soldier_Sniper"];
_max = (count _allunitsA)-1;

_unit = _spetz createUnit [(_allunitsA select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli;_unit moveInCargo _heli;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli;_unit moveInCargo _heli;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _posc, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli;_unit moveInCargo _heli;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli1;_unit moveInCargo _heli1;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli1;_unit moveInCargo _heli1;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos2, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli1;_unit moveInCargo _heli1;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli2;_unit moveInCargo _heli2;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli2;_unit moveInCargo _heli2;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos3, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli2;_unit moveInCargo _heli2;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli3;_unit moveInCargo _heli3;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli3;_unit moveInCargo _heli3;
Sleep 0.2;
_unit = _spetz createUnit [(_allunitsA select (round random _max)), _pos4, [], 0, "NONE"];_unit setSkill 2+(random 3);[_unit] join _spetz;_unit assignAsCargo _heli3;_unit moveInCargo _heli3;
Sleep 0.2;
hint "spetsnaz embarked";

_pilotsp setFormation "LINE";
_pilotsp setSpeedMode "LIMITED";
_pilotsp setBehaviour "SAFE";
_pilotsp setCurrentWaypoint [_pilotsp, _targblue];  //unsure

_wp = _pilotsp addWaypoint [_bluetarg, 10];
_wp2 = _pilotsp addWaypoint [_bluetarg, 20];
[_pilotsp, 2] setWaypointType "CYCLE";

_posl = position (leader _pilotsp);
_posls = position (leader _spetz);

if _posl distance _targblue < 300 then _pilotsp setCombatMode "RED";
if _posls distance _targblue < 300 then _spetz setCombatMode "RED";

{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _pilotsp);
{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _spetz);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_heli1 addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_heli2 addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_heli3 addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];

//sleep 120;
sleep 600.0; //10 mins
if ((count units _pilotsp) == 0 and (count units _spetz) == 0) then
{
hint "spetnaz deleted";
deleteVehicle _heli;
deleteVehicle _heli1;
deleteVehicle _heli2;
deleteVehicle _heli3;
_handle = [_pilotsp] execVM "data\scripts\delete.sqf";
_handle = [_spetz] execVM "data\scripts\delete.sqf";
_loop=1;
};
};

I have used this code in many new side-missions to create enemy units fine, but for some reason the infantry never spawn...

any ideas?

« Last Edit: 23 Nov 2009, 20:33:51 by eggbeast »