Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I have good guys and bad guys - with TK skins and BAF skins (and different weapons and skill levels). They all shoot zombies. This is how I hacked it together (and it can be imporoved, but I was trying to just go for basic function testing).
Add this line to your init.sqf under factions:
Then, you can either modify your add_unit_server to accept a bandit/hero parameter to change the center, or just (like I did for testing) duplicate it.
*Deleted code from quote to save space*
Now, call them from your chernarus mission init.sqf the same way, and choose if you want to spawn a bandit or soldier.
Code:_aispawn = [[4780.92,2500.74,0.001],20,1,5] execVM "units\add_unit_server.sqf";//Balota _aispawn = [[4703.12,2525.5,0.001],20,1,5] execVM "units\add_unit_server_Bandit.sqf";//Balota
_aispawn = [[4185.1543,3678.1938,0.001],5000,20,4] execVM "units\add_unit_server_bandit.sqf";//Bandit spawn Pancho
_aispawn = [[2334.2578,8068.2959,0.001],50,8,15] execVM "units\add_unit_server_bandit.sqf";//Bandit spawn Villa Oscura
private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
_aiunit = objNull;
_aiGroup = createGroup resistance;
_aispawnpos =_this select 0;
_wpradius = _this select 1;
_wpnum = _this select 2;
_numunits = _this select 3;
_xpos = _aispawnpos select 0;
_ypos = _aispawnpos select 1;
diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3",_aispawnpos,_wpradius,_wpnum];
for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do {
_unitpos = [_xpos+x,_ypos+x,0];
_rndLOut=floor(random 30);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["DMR","20Rnd_762x51_DMR"]};
case 1: {["G36K_camo","30Rnd_556x45_Stanag"]};
case 2: {["m16a4_acg","30Rnd_556x45_Stanag"]};
case 3: {["M4A1_HWS_GL_CAMO","30Rnd_556x45_Stanag"]};
default: {["M4A1","30Rnd_556x45_Stanag"]};
};
//Generate what the sidearm and ammo will be
_rndLOut=floor(random 3);
_aiside=
switch (_rndLOut) do
{
case 0: {["M9","15Rnd_9x19_M9"]};
case 1: {["M9 Silenced","15Rnd_9x19_M9SD"]};
case 2: {["glock17_EP1","17Rnd_9x19_glock17"]};
};
//Generate what the equipment will be - it's likely to be a map, but maybe.... :)
_rndLOut=floor(random 30);
_aiequipspawn=
switch (_rndLOut) do
{
case 0: {["Binocular_Vector"]};
case 1: {["ItemGPS"]};
case 2: {["ItemCompass"]};
case 3: {["NVGoggles"]};
case 4: {["Binocular"]};
default: {["ItemMap"]};
};
"BAF_Soldier_L_DDPM" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
diag_log format ["AIUNIT: Creating BAF_Soldier_L_DDPM by %1 at %2. Result:%3 | Loadout:%4 / Num:%5",player,_unitpos,_aiunit,_ailoadout,_rndLOut];
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit setCombatMode "RED";
_aiunit setBehaviour "COMBAT";
//clear default weapons / ammo
removeAllWeapons _aiunit;
//add random selection
_aiwep = _ailoadout select 0;
_aiammo = _ailoadout select 1;
_aiunit addweapon _aiwep;
_aiunit addMagazine _aiammo;
// Add sidearm and mags
_aiunit addweapon _aisidearm;
_aiunit addMagazine _aisidearmammo;
// add gear
_aiunit addWeapon _aigear;
//_aiunit addMagazine _aigear;
//set skills
_aiunit setSkill ["aimingAccuracy",0.9];
_aiunit setSkill ["aimingShake",0.9];
_aiunit setSkill ["aimingSpeed",0.9];
_aiunit setSkill ["endurance",1];
_aiunit setSkill ["spotDistance",0.9];
_aiunit setSkill ["spotTime",0.9];
_aiunit setSkill ["courage",0.9];
_aiunit setSkill ["reloadSpeed",0.9];
_aiunit setSkill ["commanding",1];
_aiunit setSkill ["general",1];
//sleep 0.5;
} ;
//infinite ammo
_aiunit addEventHandler ["Fired", {(_this select 0) setvehicleammo 1}];
//generate waypoints
for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
_wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
_wp = _aiGroup addWaypoint [_wppos, _wpradius];
_wp setWaypointType "MOVE";
};
_wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
_wp setWaypointType "CYCLE";
diag_log format ["AIUNIT: Last Waypoint %1 at %2",_wp,_wppos];
private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
_aiunit = objNull;
_aiGroup = createGroup EAST;
_aispawnpos =_this select 0;
_wpradius = _this select 1;
_wpnum = _this select 2;
_numunits = _this select 3;
_xpos = _aispawnpos select 0;
_ypos = _aispawnpos select 1;
diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3",_aispawnpos,_wpradius,_wpnum];
for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do {
_unitpos = [_xpos+x,_ypos+x,0];
_rndLOut=floor(random 50);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["huntingrifle","5x_22_LR_17_HMR"]};
case 1: {["Sa58V_RCO_EP1","30Rnd_762x39_AK47"]};
case 2: {["SVD_Camo","10Rnd_762x54_SVD"]};
case 3: {["Sa58V_CCO_EP1","30Rnd_762x39_AK47"]};
default: {["AK_47","30Rnd_762x39_AK47"]};
};
//Generate what the sidearm and ammo will be
_rndLOut=floor(random 3);
_aiside=
switch (_rndLOut) do
{
case 0: {["M1911","7Rnd_45ACP_1911"]};
case 1: {["revolver_EP1","6Rnd_45ACP"]};
case 2: {["Makarov","8Rnd_9x18_Makarov"]};
};
//Generate what the equipment will be - it's likely to be a map, but maybe.... :)
_rndLOut=floor(random 50);
_aiequipspawn=
switch (_rndLOut) do
{
case 0: {["Binocular_Vector"]};
case 1: {["ItemGPS"]};
case 2: {["ItemCompass"]};
case 3: {["NVGoggles"]};
case 4: {["Binocular"]};
default: {["ItemMap"]};
};
"TK_INS_Soldier_EP1" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
diag_log format ["AIUNIT: Creating TK_INS_Soldier_EP1 by %1 at %2. Result:%3 | Loadout:%4 / Num:%5",player,_unitpos,_aiunit,_ailoadout,_rndLOut];
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit setCombatMode "RED";
_aiunit setBehaviour "COMBAT";
//clear default weapons / ammo
removeAllWeapons _aiunit;
//add random selection
_aiwep = _ailoadout select 0;
_aiammo = _ailoadout select 1;
_aiunit addweapon _aiwep;
_aiunit addMagazine _aiammo;
// Add sidearm and mags
_aiunit addweapon _aisidearm;
_aiunit addMagazine _aisidearmammo;
// add gear
_aiunit addWeapon _aigear;
//_aiunit addMagazine _aigear;
//set skills
_aiunit setSkill ["aimingAccuracy",0.9];
_aiunit setSkill ["aimingShake",0.9];
_aiunit setSkill ["aimingSpeed",0.8];
_aiunit setSkill ["endurance",1];
_aiunit setSkill ["spotDistance",0.8];
_aiunit setSkill ["spotTime",0.7];
_aiunit setSkill ["courage",0.9];
_aiunit setSkill ["reloadSpeed",0.9];
_aiunit setSkill ["commanding",1];
_aiunit setSkill ["general",1];
//sleep 0.5;
} ;
_aiunit addEventHandler ["Fired", {(_this select 0) setvehicleammo 1}];
//generate waypoints
for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
_wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
_wp = _aiGroup addWaypoint [_wppos, _wpradius];
_wp setWaypointType "MOVE";
};
_wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
_wp setWaypointType "CYCLE";
diag_log format ["AIUNIT: Last Waypoint %1 at %2",_wp,_wppos];
_aiunit addEventHandler ["Fired", {(_this select 0) setvehicleammo 1}];
case 0: {["Binocular","G36K_camo","30Rnd_556x45_G36","DZ_CivilBackpack_EP1"]};
case 1: {["NVGoggles","BAF_L85A2_RIS_Holo","30Rnd_556x45_Stanag","DZ_CivilBackpack_EP1"]};
case 2: {["ItemGPS","Mk_48_DZ","100Rnd_762x51_M240","DZ_CivilBackpack_EP1"]};
case 3: {["Binocular_Vector","BAF_AS50_scoped","10Rnd_127x99_m107","DZ_CivilBackpack_EP1"]};
default {["ItemMap"]};
TuBz, i'm stuck on top of a building.. lol.. I landed here with a heli the other day, and now my heli's gone and im stuck.. Help me out ;DYou can spawn them with what ever you want but from experience..all that will happen is the players will discover the AI are well equiped and kill them all for the loot they carry
up to you!
Placing a 'cycle' waypoint directly over the first 'move' waypoint should get them looping..I have been using this for awhile now, and did not notice it initially. But I keep getting the AI troops next to a wall, sitting there.
I thought at first this was just a timer thing between waypoints, but I sat watching them from a distance for about 30 minutes and they all seem to just be stuck.
So I restarted the server and watched. It seems that after they finish their waypoints, they just stop. They do not move anymore unless they see a target, at which point they will go after it (until they lose interest) and then return to the wall, stop and stay there.
Is there a way to make the waypoints cycle? I currently have 10 waypoints set in a 75m radius. I notice them stop 9 or 10 times before they get to the wall, then they sit at the wall. So I'm thinking that they are completing the defined number of waypoints and just stopping there.
Not with the current code, it picks the first item as the weapon and the second as the ammo. Though there are some good additions on this thread, one for infinite ammo and am sure there are some tweaks for changing the equipment.Hey guys would this work
Everything else is just working great, i love it!Code:case 0: {["Binocular","G36K_camo","30Rnd_556x45_G36","DZ_CivilBackpack_EP1"]}; case 1: {["NVGoggles","BAF_L85A2_RIS_Holo","30Rnd_556x45_Stanag","DZ_CivilBackpack_EP1"]}; case 2: {["ItemGPS","Mk_48_DZ","100Rnd_762x51_M240","DZ_CivilBackpack_EP1"]}; case 3: {["Binocular_Vector","BAF_AS50_scoped","10Rnd_127x99_m107","DZ_CivilBackpack_EP1"]}; default {["ItemMap"]};
The problem seems to be that the AI Units are created by the server whereas the zeds are created by the client and as such 'can't see' each other.i saw a post earlier that say's that works, my AI guys don't seem to be running out of ammo, i just can't get the zeds to react to their shots.......lol
Let us know when you want to re-spawn and we will attack with a fleet of Apache'sTuBz, i'm stuck on top of a building.. lol.. I landed here with a heli the other day, and now my heli's gone and im stuck.. Help me out ;D