After playing on a server where I stumbled across some AI troops roaming the server I thought I would add them to my server. So far reports back have been good, apparently is quite surprising to find random bands of troops roaming the server.
This script will spawn groups of AI NPCs, set random waypoints, tool them up with a random selection of weapon & ammo and then send them on their way, attacking zeds as they go.
This mission script allows you to specify the following:
init.sqf (in your mission folder)
This is creating 6 groups of troops (one per each line). The array infront of the execVM command consists of the following (in order):
You can call this same command as many times as you feel is necessary, a new 'AI group' is generated each time, keeping them as separate groups..
The main code: <Mission Folder>\units\add_unit_server.sqf
Finally there is a bit of code from Xyberviri's dayZ Factions thread that handles the opposition / friendliness of the units, this is what gets the units attacking zeds: <Mission Folder>\Dayz_Factions\init.sqf
Battleye: In some cases you might get booted for a script restriction #8, try updating line #10 addWaypoint of your scripts.txt to this
Also, edit lines #114 addWeapon and #118 addMagazine. Add:
to the end of both lines. I haven't tested this but I would think that you will only get these errors if trying to run from the client. The server should be running the commands..
The attached .pbo has the basic files required (have used the mission init.sqf from the latest Reality build) and come from the normal dayz_1.chernaurs.pbo in MPMission folder. The only lines added are: the one to initiate the Dayz_Factions init and the 6 lines to create the 6 groups..
There are ways of enhancing the AI of the troops, this uses ARMA2 AI troops. I haven't yet added anything more and am experimenting with taking leadership of the troops so they actually help you..
I look forward to your feedback.. PM me if you are really stuck, after reading through the thread for any clues as how to resolve your issue..
This script will spawn groups of AI NPCs, set random waypoints, tool them up with a random selection of weapon & ammo and then send them on their way, attacking zeds as they go.
This mission script allows you to specify the following:
- Centre point where troops spawn
- Radius of waypoint creation (how far troops can travel)
- Number of waypoints
- Number of troops created.
init.sqf (in your mission folder)
Code:
if (isServer) then {
_dayzFactions = [] execVM "Dayz_Factions\init.sqf";
//diag_log format["Dayz Factions executed: %1",_dayzFactions];
//Array to pass to .sqf: [[<worldspace>],radius of waypoints (in metres),number of waypoints,number of ai units]
_aispawn = [[6689.49,2623.59,0],160,8,4] execVM "units\add_unit_server.sqf";//Chernogorsk
_aispawn = [[7622.51,7912.7,0],5000,20,6] execVM "units\add_unit_server.sqf";//Chernaurs (Whole map)
_aispawn = [[7625.51,7915.7,0],5000,20,6] execVM "units\add_unit_server.sqf";//Chernaurs (Whole map)
_aispawn = [[4598.66,10197.7,0],650,12,4] execVM "units\add_unit_server.sqf";//NW Airfield
_aispawn = [[10447.5,2246.96,0],180,3,3] execVM "units\add_unit_server.sqf";//Electrozavodsk
_aispawn = [[13253.3,6406.53,0],180,4,3] execVM "units\add_unit_server.sqf";//Solnichniy
};
This is creating 6 groups of troops (one per each line). The array infront of the execVM command consists of the following (in order):
- [<worldspace>] (Array of X,Y,Z worldspace coordinates where troops start)
- Radius (in metres) that the waypoints are randomly created within. These are the points that the troops run between)
- The number of waypoints (Generally create more for a larger radius)
- Number of AI units to create
Code:
_aispawn = [[6689.49,2623.59,0],160,6,4] execVM "units\add_unit_server.sqf";
You can call this same command as many times as you feel is necessary, a new 'AI group' is generated each time, keeping them as separate groups..
The main code: <Mission Folder>\units\add_unit_server.sqf
Code:
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 3);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["AK_47_M","30Rnd_762x39_AK47"]};
case 1: {["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD"]};
case 2: {["Remington870_lamp","8Rnd_B_Beneli_74Slug"]};
};
"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;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
_aiunit addMagazine _aiammo;
//set skills
_aiunit setSkill ["aimingAccuracy",1];
_aiunit setSkill ["aimingShake",1];
_aiunit setSkill ["aimingSpeed",1];
_aiunit setSkill ["endurance",1];
_aiunit setSkill ["spotDistance",1];
_aiunit setSkill ["spotTime",1];
_aiunit setSkill ["courage",1];
_aiunit setSkill ["reloadSpeed",1];
_aiunit setSkill ["commanding",1];
_aiunit setSkill ["general",1];
//sleep 0.5;
} ;
//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];
Finally there is a bit of code from Xyberviri's dayZ Factions thread that handles the opposition / friendliness of the units, this is what gets the units attacking zeds: <Mission Folder>\Dayz_Factions\init.sqf
Code:
waitUntil{initialized};
//0Day
createCenter east;
createCenter resistance;
//Survivors
WEST setFriend [RESISTANCE,1];
WEST setFriend [EAST,0];
//Bandits
EAST setFriend [RESISTANCE,0];
EAST setFriend [WEST,0];
//AI Units
RESISTANCE setFriend [WEST,1];
RESISTANCE setFriend [EAST,0];
RESISTANCE setFriend [CIVILIAN,0];//AI Units attack zeds
//CIVILIAN setFriend [RESISTANCE,0];//Testing Zeds attack AI units, doesn't seem to help..
Battleye: In some cases you might get booted for a script restriction #8, try updating line #10 addWaypoint of your scripts.txt to this
Code:
5 addWaypoint !"\"addWaypoint\"," !"units\add_unit_server.sqf"
Also, edit lines #114 addWeapon and #118 addMagazine. Add:
Code:
!"units\add_unit_server.sqf"
The attached .pbo has the basic files required (have used the mission init.sqf from the latest Reality build) and come from the normal dayz_1.chernaurs.pbo in MPMission folder. The only lines added are: the one to initiate the Dayz_Factions init and the 6 lines to create the 6 groups..
There are ways of enhancing the AI of the troops, this uses ARMA2 AI troops. I haven't yet added anything more and am experimenting with taking leadership of the troops so they actually help you..
>> There is a lot of good content in this thread provided by others. As there are so many pages I have tried to highlight the main points here <<
>> Additional Tweaks THIS POST<<
>> Sycosis has put together a tutorial HERE<<
>> A List of un-banned soldier skins HERE (Not Tested)<<
>> Setting Sides and Different Loadouts HERE <<
>> A List of Towns and their worldspace coordinates HERE <<
>> Taking Control of AI Groups HERE <<
>> Orcthrasher touches on the subject of vehicles HERE <<
>> Some Hero / Bandit Stuff here (Not Tested) Also Infinite Ammo HERE <<
(There is a lot in this thread, if you have any posts you think should be mentioned or a relevant AI Troop thread elsewhere, let me know and I will add it in here)
I look forward to your feedback.. PM me if you are really stuck, after reading through the thread for any clues as how to resolve your issue..