1
0
This commit is contained in:
2022-04-21 16:15:41 +03:00
commit 9d4fc88901
601 changed files with 66252 additions and 0 deletions
.gitignore24_napf.bat24_napf.cfg
@DayZ_Epoch_Server
HiveExt.dll
addons
dayz_server.pbo
dayz_server
$PREFIX$
AdminTools
DZAI
SHK_pos
compile
init
DZAI_version.txtdzai_config.sqfdzai_functions.sqfdzai_initserver.sqf
world_classname_configs
world_spawn_configs
#readme - directory guide and custom spawn info.txt
custom_markers
custom_spawns
spawn_areas
spawn_markers
world_caribou.sqfworld_chernarus.sqfworld_cmr_ovaron.sqfworld_dayzunleashed.sqfworld_fallujah.sqfworld_fdf_isle1_a.sqfworld_isladuala.sqfworld_lingor.sqfworld_mbg_celle2.sqfworld_namalsk.sqfworld_napf.sqfworld_oring.sqfworld_panthera2.sqfworld_sara.sqfworld_sauerland.sqfworld_smd_sahrani_a2.sqfworld_takistan.sqfworld_tavi.sqfworld_tavi_old.sqfworld_trinity.sqfworld_utes.sqfworld_zargabad.sqf
scripts
spawn_functions
DZMS
WAI
bankTraders
compile
config.cpp
eventHandlers
init
modules
system
traders
BattlEye
DatabaseMySql.dllDatabasePostgre.dllEATadminLogger.dllEATbaseExporter.dllHiveExt.ini
Keys
MPMissions/DayZ_Epoch_24.Napf
ActionMenu
CfgServerTraderZSC
Stats
dayz_code
description.extdialog.hppinit.sqf
logistic
mission.sqm
rlnt
rules.sqf
scripts
spawn
stringtable.xml
Users/server
epoch.sql

@ -0,0 +1,377 @@
private ["_startDist","_PorM","_PorM2","_msgcrash","_msgdrop","_mission","_position","_difficulty","_name","_missionType","_showMarker","_enableMines","_completionType","_msgstart","_msgwin","_msglose","_mines"];
_mission = _this select 0;
_position = _this select 1;
_difficulty = _this select 2;
_name = _this select 3;
_missionType = _this select 4;
_showMarker = _this select 5;
_enableMines = _this select 6;
_completionType = _this select 7;
_airClass = _this select 8;
_vehclass = _this select 9;
_msgstart = (_this select 10) select 0;
_msgcrash = (_this select 10) select 1;
_msgdrop = (_this select 10) select 2;
_msgwin = (_this select 10) select 3;
_msglose = (_this select 10) select 4;
if(wai_debug_mode) then {diag_log format["WAI: Starting Mission number %1",_mission];};
if(wai_enable_minefield && _enableMines) then {
_mines = [_position,50,75,100] call minefield;
wai_mission_data select _mission set [2, _mines];
};
_color = call {
if(_difficulty == "Easy") exitWith {"ColorGreen"};
if(_difficulty == "Medium") exitWith {"ColorYellow"};
if(_difficulty == "Hard") exitWith {"ColorRed"};
if(_difficulty == "Extreme") exitWith {"ColorBlack"};
};
_name = call {
if(_missionType == "MainHero") exitWith {"Bandit " + _name;};
if(_missionType == "MainBandit") exitWith {"Hero " + _name;};
};
_startDist = 10000; // increase this to delay the time it takes for the plane to arrive at the mission
_PorM = if (random 1 > .5) then {"+"} else {"-"};
_PorM2 = if (random 1 > .5) then {"+"} else {"-"};
_startPos = call compile format ["[(%1 select 0) %2 %4,(%1 select 1) %3 %4, 300]",_position,_PorM,_PorM2,_startDist];
[_difficulty,_msgstart] call wai_server_message;
WAI_MarkerReady = true;
[_position,_mission,_name,_completionType,_color,_showMarker,_airClass,_vehclass,_msgcrash,_msgdrop,_msgwin,_msglose,_enableMines,_missionType,_difficulty,_startPos] spawn {
private ["_loot","_vehMark","_return","_parachute","_vehPos","_vehicle","_aigroup","_speed","_dir","_wp","_msgcrash","_msgdrop","_dropzone","_plane","_pilot","_left","_leftTime","_claimTime","_acArray","_claimed","_acTime","_acdot","_acMarker","_timeStamp","_unitGroups","_playerArray","_enableMines","_aiVehicles","_aiVehArray","_baseclean","_msgwin","_msglose","_bomb","_position","_timeout","_player_near","_complete","_starttime","_timeout_time","_max_ai","_killpercent","_mission","_missionType","_airemain","_text","_name","_completionType","_marker","_dot","_color","_showMarker","_startPos"];
_position = _this select 0;
_mission = _this select 1;
_name = _this select 2;
_completionType = _this select 3;
_color = _this select 4;
_showMarker = _this select 5;
_airClass = _this select 6;
_vehclass = _this select 7;
_msgcrash = _this select 8;
_msgdrop = _this select 9;
_msgwin = _this select 10;
_msglose = _this select 11;
_enableMines = _this select 12;
_missionType = _this select 13;
_difficulty = _this select 14;
_startPos = _this select 15;
_timeout = false;
_player_near = false;
_complete = false;
_starttime = diag_tickTime;
_timeout_time = (random((wai_mission_timeout select 1) - (wai_mission_timeout select 0)) + (wai_mission_timeout select 0)) * 60;
_max_ai = (wai_mission_data select _mission) select 0;
_unitGroups = (wai_mission_data select _mission) select 1;
_mines = (wai_mission_data select _mission) select 2;
_aiVehicles = (wai_mission_data select _mission) select 4;
_vehicles = (wai_mission_data select _mission) select 5;
_killpercent = _max_ai - (_max_ai * (wai_kill_percent / 100));
_loot = if (_missionType == "MainHero") then {Loot_VehicleDrop select 0;} else {Loot_VehicleDrop select 1;};
_playerArray = [];
_timeStamp = diag_tickTime;
_closestPlayer = objNull;
_acArray = [];
_claimed = false;
_acTime = diag_tickTime;
_claimTime = 0;
_left = false;
_leftTime = 0;
_vehDropped = false;
_onGround = false;
_crashed = false;
_dropzone = "HeliHEmpty" createVehicle [0,0,0];
_dropzone setPos _position;
_plane = _airClass createVehicle _startPos;
_dir = [_plane, _dropzone] call BIS_fnc_relativeDirTo;
_plane setDir _dir;
_plane setPos _startPos;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_plane];
_plane engineOn true;
_speed = 150;
_plane setVelocity [(sin _dir*_speed),(cos _dir*_speed),0];
_plane flyInHeight 200;
_aigroup = createGroup civilian;
_pilot = _aigroup createUnit ["SurvivorW2_DZ",_startPos,[],0,"FORM"];
[_pilot] joinSilent _aigroup;
_pilot setSkill 1;
_pilot setCombatMode "BLUE";
_pilot moveInDriver _plane;
_pilot assignAsDriver _plane;
_aigroup setSpeedMode "LIMITED";
_wp = _aigroup addWaypoint [_position, 0];
_wp setWaypointType "MOVE";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointCompletionRadius 50;
_t1 = 0;
_dropTime = 0;
while {!_timeout && !_complete} do {
if (!alive _plane && {!_vehDropped}) exitWith {
[_difficulty,_msgcrash] call wai_server_message;
_crashed = true;
_timeout = true;
};
if ((_plane distance _position < 230) && {!_vehDropped}) then {
uiSleep 1; // This gets the drop near the center of the mission
_planePos = [_plane] call FNC_GetPos;
uiSleep 1; // need to do this otherwise the C130 blows up
_parachute = createVehicle ["ParachuteMediumEast", _planePos, [], 0, "FLY"];
_parachute setPos _planePos;
_vehicle = [_vehclass,_planePos,_mission] call custom_publish;
_vehicle attachTo [_parachute, [0, 0, 1]];
_t1 = diag_tickTime;
[_difficulty,_msgdrop] call wai_server_message;
_return = _aigroup addWaypoint [_startPos, 0];
_return setWaypointType "MOVE";
_return setWaypointBehaviour "CARELESS";
[_plane,_position,_aigroup] spawn wai_clean_aircraft;
_vehDropped = true;
};
if (_vehDropped && {!_onGround}) then {
_dropTime = diag_tickTime - _t1; // used to override if stuck in a tree or on top of a building
if (((([_parachute] call FNC_GetPos) select 2) < 6) || {_dropTime > 55}) then {
detach _vehicle;
deleteVehicle _parachute;
_vehPos = [_vehicle] call FNC_GetPos;
//_vehPos set [2,0];
//_position = _vehPos;
_onGround = true;
};
};
if (count _mines > 0) then {
{
if((isPlayer _x) && (vehicle _x != _x) && (vehicle _x distance _position < 275) && !(_x in _playerArray)) then {
_x call wai_minefield_warning;
_playerArray set [count _playerArray, _x];
};
if((isPlayer _x) && (vehicle _x != _x) && (vehicle _x distance _position < 75) && (alive _x) && ((([vehicle _x] call FNC_GetPos) select 2) < 1)) then {
_bomb = "Bo_GBU12_lgb" createVehicle ([vehicle _x] call FNC_GetPos);
uiSleep 3;
deleteVehicle _bomb;
};
} count playableUnits;
};
if ((diag_tickTime - _timeStamp) > 180 && (count _aiVehicles) > 0) then {
{
if (_x isKindOf "StaticWeapon") then {
(gunner _x) action ["getout",_x];
};
} forEach _aiVehicles;
_timeStamp = diag_tickTime;
};
if (use_wai_autoclaim && _showMarker) then {
#include "\z\addons\dayz_server\WAI\compile\auto_claim.sqf"
};
if (count _aiVehicles > 0) then {
_aiVehicles call wai_monitor_ai_vehicles;
};
if (_showMarker) then {
if (ai_show_count) then {
_aiCount = (wai_mission_data select _mission) select 0;
_text = format["%1 (%2 A.I.)",_name,_aiCount];
} else {
_text = _name;
};
_marker = createMarker [_missionType + str(_mission), _position];
_marker setMarkerColor _color;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerBrush "Solid";
_marker setMarkerSize [300,300];
_dot = createMarker [_missionType + str(_mission) + "dot", _position];
_dot setMarkerColor "ColorBlack";
_dot setMarkerType "mil_dot";
_dot setMarkerText _text;
if (_onGround) then {
_vehMark = createMarker [_missionType + str(_mission) + "vehicle", _vehPos];
_vehMark setMarkerColor "ColorBlack";
_vehMark setMarkerType "mil_dot";
_vehMark setMarkerText _vehclass;
};
if (use_wai_autoclaim) then {
_acMarker = createMarker [_missionType + str(_mission) + "auto", _position];
_acMarker setMarkerShape "ELLIPSE";
_acMarker setMarkerBrush "Border";
_acMarker setMarkerColor "ColorRed";
_acMarker setMarkerSize [ac_alert_distance,ac_alert_distance];
if (_claimed) then {
_acdot = createMarker [_missionType + str(_mission) + "autodot", [(_position select 0) + 100, (_position select 1) + 100]];
_acdot setMarkerColor "ColorBlack";
_acdot setMarkerType "mil_objective";
if (_left) then {
_acdot setMarkerText format["%1 Claim Timeout [%2]",(_acArray select 1),_leftTime];
} else {
_acdot setMarkerText format["Claimed by %1",(name _closestPlayer)];
};
};
};
uiSleep 1;
deleteMarker _marker;
deleteMarker _dot;
if (!isNil "_acMarker") then {deleteMarker _acMarker;};
if (!isNil "_acdot") then {deleteMarker _acdot;};
if (!isNil "_vehMark") then {deleteMarker _vehMark;};
} else {
uiSleep 1;
};
_player_near = [_position,wai_timeout_distance] call isNearPlayer;
if (diag_tickTime - _starttime >= _timeout_time && !_player_near) then {
_timeout = true;
} else {
if (_player_near) then {_starttime = diag_tickTime;};
};
if (_onGround) then {
_complete = [_mission,_completionType,_killpercent,_vehPos] call wai_completion_check;
};
};
if (_complete) then {
[_vehicle,_mission,[[_vehicle]]] call wai_generate_vehicle_key;
_vehicle setVehicleLock "unlocked";
[_vehicle,_vehclass,2] call load_ammo;
[_vehicle,_loot] call dynamic_crate;
if (count _mines > 0) then {
_mines call wai_fnc_remove;
};
[_difficulty,_msgwin] call wai_server_message;
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
diag_log format["WAI: [Mission: %1]: Ended at %2",_name,_position];
if (wai_clean_mission_time > 0) then {
private ["_finish_time","_cleaned","_playernear"];
_finish_time = diag_tickTime;
_cleaned = false;
while {!_cleaned} do {
uiSleep 3;
if (count _aiVehicles > 0) then {
_aiVehicles call wai_monitor_ai_vehicles;
};
if (diag_tickTime - _finish_time >= 60*wai_clean_mission_time) then {
if (count _aiVehicles > 0) then {
_aiVehicles call wai_fnc_remove;
};
_mission call wai_remove_ai;
if (count _vehicles > 0) then {
[_mission,_vehicles] call wai_remove_vehicles;
};
deleteVehicle _dropzone;
uiSleep 5;
{
if (count units _x == 0) then {
deleteGroup _x;
};
} forEach _unitGroups;
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
_cleaned = true;
};
};
};
};
if (_timeout) then {
if (alive _plane) then {
[_plane,_position,_aigroup] spawn wai_clean_aircraft;
};
if (count _mines > 0) then {
_mines call wai_fnc_remove;
};
if (count _aiVehicles > 0) then {
_aiVehicles call wai_fnc_remove;
};
_mission call wai_remove_ai;
if (count _vehicles > 0) then {
[_mission,_vehicles] call wai_remove_vehicles;
};
deleteVehicle _dropzone;
if (!_crashed) then {
[_difficulty,_msglose] call wai_server_message;
};
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
uiSleep 5;
{
if (count units _x == 0) then {
deleteGroup _x;
};
} forEach _unitGroups;
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
diag_log format["WAI: [Mission: %1]: Timed out at %2",_name,_position];
};
};

@ -0,0 +1,82 @@
if (!_claimed) then {
// Find the closest player and send an alert
if (isNull _closestPlayer) then {
_closestPlayer = _position call wai_isClosest; // Find the closest player
[_closestPlayer,_name,"Start"] call wai_AutoClaimAlert; // Send alert
_claimTime = diag_tickTime; // Set the time variable for countdown
};
// After the delay time, check player's location and either claim or not claim
if ((diag_tickTime - _claimTime) > ac_delay_time) then {
if ((_closestPlayer distance _position) > ac_alert_distance || {!alive _closestPlayer}) then {
[_closestPlayer,_name,"Stop"] call wai_AutoClaimAlert; // Send alert to player who is closest
_closestPlayer = objNull; // Set to default
_acArray = []; // Set to default
} else {
_claimed = true;
[_closestPlayer,_name,"Claimed"] call wai_AutoClaimAlert; // Send alert to all players
diag_log text format ["WAI Auto Claim: mission %1 has been claimed by %2",_name,(name _closestPlayer)];
_acArray = [getplayerUID _closestPlayer, name _closestPlayer]; // Add player UID and name to array
};
};
};
if (_claimed) then {
// Used in the marker when a player has left the mission area
_leftTime = round (ac_timeout - (diag_tickTime - _claimTime));
// If the player dies at the mission, change marker to countdown and set player variable to null
if ((!alive _closestPlayer) && !_left) then {
_closestPlayer = objNull; // Set the variable to null to prevent null player errors
_claimTime = diag_tickTime; // Set the time for countdown
_left = true; // Changes the marker to countdown
};
// Check to see if the dead player has returned to the mission
if (isNull _closestPlayer) then {
_closestPlayer = [_position,_acArray] call wai_checkReturningPlayer;
};
// Notify the player that he/she is outside the mission area
if (!(isNull _closestPlayer) && ((_closestPlayer distance _position) > ac_alert_distance) && !_left) then {
[_closestPlayer,_name,"Return"] call wai_AutoClaimAlert;
_claimTime = diag_tickTime; // Set the time for the countdown
_left = true; // Set the mission marker to countdown
};
// If the player returns to the mission before the clock runs out then change the marker
if (!(isNull _closestPlayer) && ((_closestPlayer distance _position) < ac_alert_distance) && _left) then {
[_closestPlayer,_name,"Reclaim"] call wai_AutoClaimAlert;
_left = false; // Change the mission marker back to claim
};
// Warn other players in mission area
{
if(!(_x in (units group _closestPlayer)) && ((_x distance _position) < ac_alert_distance )) then {
//warn
RemoteMessage = ["rollingMessages", format["You are in %1's mission. Ask %1 for permission!",_acArray select 1] ];
(owner _x) publicVariableClient "RemoteMessage";
};
} forEach playableUnits;
// If the player lets the clock run out, then set the mission to unclaimed and set the variables to default
// Player left the server
if ((isNull _closestPlayer) && ((diag_tickTime - _claimTime) > ac_timeout)) then {
[_acArray ,_name,"Unclaim"] call wai_AutoClaimAlert; // Send alert to all players
_claimed = false;
_left = false;
_acArray = [];
} else {
// Player is alive but did not return to the mission
if (((diag_tickTime - _claimTime) > ac_timeout) && ((_closestPlayer distance _position) > ac_alert_distance)) then {
[_closestPlayer,_name,"Unclaim"] call wai_AutoClaimAlert; // Send alert to all players
_closestPlayer = objNull;
_claimed = false;
_left = false;
_acArray = [];
};
};
};

@ -0,0 +1,159 @@
private ["_unit","_ailist","_hit","_count","_vehpos","_max_distance","_vehicle","_position_fixed","_position","_dir","_class","_dam","_damage","_hitpoints","_selection","_fuel","_key","_inventory"];
_count = count _this;
_class = _this select 0;
_position = _this select 1;
_mission = _this select 2;
_max_distance = 17;
_position_fixed = false;
_dir = floor(round(random 360));
if (typeName _class == "ARRAY") then {
_class = _class call BIS_fnc_selectRandom;
};
if (_count > 3) then {
_position_fixed = _this select 3;
};
if (_count > 4) then {
_dir = _this select 4;
};
if (!_position_fixed) then {
_vehpos = [0,0,0];
while {count _vehpos > 2} do {
_vehpos = [_position,12,_max_distance,10,0,0.7,0] call BIS_fnc_findSafePos; // Works better
//_vehpos = _position findEmptyPosition[20,_max_distance,_class];
_max_distance = (_max_distance + 10);
};
} else {
_vehpos = _position;
};
_vehicle = _class createVehicle _vehpos;
_vehicle setDir _dir;
_vehicle setPos _vehpos;
_vehicle setVectorUp surfaceNormal position _vehicle;
_vehicle setVariable ["ObjectID","1",true];
_vehicle setVariable ["CharacterID","1",true]; // Set character ID to non-zero number so players see the red "Vehicle Locked" message
_vehicle setVariable ["mission" + dayz_serverKey,_mission, false];
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
_vehicle setVehicleLock "locked";
((wai_mission_data select _mission) select 5) set [count ((wai_mission_data select _mission) select 5), _vehicle];
if (wai_debug_mode) then {diag_log format["WAI: Spawned %1 at %2",_class,_vehpos];};
if (getNumber(configFile >> "CfgVehicles" >> _class >> "isBicycle") != 1) then {
_hitpoints = _vehicle call vehicle_getHitpoints;
{
_dam = (random((wai_vehicle_damage select 1) - (wai_vehicle_damage select 0)) + (wai_vehicle_damage select 0)) / 100;
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
if ((_selection in dayZ_explosiveParts) && _dam > 0.8) then {
_dam = 0.8
};
_isglass = ["glass", _selection] call fnc_inString;
if(!_isglass && _dam > 0.1) then {
_strH = "hit_" + (_selection);
_vehicle setHit[_selection,_dam];
_vehicle setVariable [_strH,_dam,true];
if (wai_debug_mode) then {diag_log format["WAI: Calculated damage for %1 is %2",_selection,_dam];};
};
} count _hitpoints;
_fuel = (random((wai_mission_fuel select 1) - (wai_mission_fuel select 0)) + (wai_mission_fuel select 0)) / 100;
_vehicle setFuel _fuel;
if (wai_debug_mode) then {diag_log format["WAI: Added %1 percent fuel to vehicle",_fuel];};
};
if (wai_godmode_vehicles) then {
_vehicle addEventHandler ["HandleDamage",{0}];
} else {
_vehicle addEventHandler ["HandleDamage",{_this call fnc_veh_handleDam}];
};
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_vehicle];
if (wai_keep_vehicles) then {
_vehicle addEventHandler ["GetIn", {
_vehicle = _this select 0;
_unit = _this select 2;
_vehicle setVariable ["mission" + dayz_serverKey,nil];
if !(isPlayer _unit) exitWith {};
if (wai_debug_mode) then {diag_log "PUBLISH: Attempt " + str(_vehicle);};
_class = typeOf _vehicle;
_characterID = _vehicle getVariable ["CharacterID", "0"];
_worldspace = [getDir _vehicle, getPosATL _vehicle];
_hitpoints = _vehicle call vehicle_getHitpoints;
_damage = damage _vehicle;
_fuel = fuel _vehicle;
_uid = _worldspace call dayz_objectUID2;
_array = [];
{
_hit = ([_vehicle,_x] call object_getHit) select 0; //Update for 1.0.7
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
if (wai_debug_mode) then {diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit];};
} count _hitpoints;
_inventory = [getWeaponCargo _vehicle, getMagazineCargo _vehicle, getBackpackCargo _vehicle];
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance,_class,_damage,_characterID,_worldspace,_inventory,_array,_fuel,_uid];
_key call server_hiveWrite;
_key = format["CHILD:388:%1:",_uid];
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (wai_debug_mode) then {diag_log "HIVE: WRITE: "+ (str _key);};
if (_outcome != "PASS") then {
deleteVehicle _vehicle;
diag_log "CUSTOM: failed to get id for : " + (str _uid);
} else {
_oid = _result select 1;
_vehicle setVariable ["ObjectID", _oid, true];
if (wai_debug_mode) then {diag_log "CUSTOM: Selected " + (str _oid);};
_vehicle setVariable ["lastUpdate",diag_tickTime];
_vehicle call fnc_veh_ResetEH;
PVDZE_veh_Init = _vehicle;
publicVariable "PVDZE_veh_Init";
diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid));
if (wai_vehicle_message) then {
[nil,(_this select 2),"loc",rTitleText,"This vehicle is saved to the database.","PLAIN",5] call RE;
};
};
}];
} else {
_vehicle addEventHandler ["GetIn", {
_vehicle = _this select 0;
if (wai_vehicle_message) then {
[nil,(_this select 2),"loc",rTitleText,"WARNING: This vehicle will be deleted at restart!","PLAIN",5] call RE;
};
if (_vehicle getVariable ["claimed",nil] == "yes") exitWith {};
_vehicle setVariable ["mission" + dayz_serverKey,nil];
_vehicle setVariable ["claimed","yes",false];
_vehicle removeAllEventHandlers "HandleDamage";
_vehicle addEventHandler ["HandleDamage",{_this call fnc_veh_handleDam}];
}];
};
_vehicle

@ -0,0 +1,171 @@
private ["_multiArrItem","_multiArrWep","_loot","_vehicles","_complete","_marker","_ammo","_tool","_crate","_weapon","_item","_backpack","_num_tools","_num_items","_num_backpacks","_num_weapons","_weapons_array","_tool_array","_item_array","_backpack_array","_num_pistols","_pistols_array","_pistol","_pistolammo"];
_crate = _this select 0;
_loot = _this select 1;
if ((count _this) > 2) then {
_complete = _this select 2;
};
_multiArrItem = false;
_multiArrWep = false;
if !(isNil "_complete") then {
if (typeOf _crate in (crates_large + crates_medium + crates_small)) then {
if (wai_crates_smoke && sunOrMoon == 1) then {
_marker = "smokeShellPurple" createVehicle getPosATL _crate;
_marker setPosATL (getPosATL _crate);
_marker attachTo [_crate,[0,0,0]];
};
if (wai_crates_flares && sunOrMoon != 1) then {
_marker = "RoadFlare" createVehicle getPosATL _crate;
_marker setPosATL (getPosATL _crate);
_marker attachTo [_crate, [0,0,0]];
PVDZ_obj_RoadFlare = [_marker,0];
publicVariable "PVDZ_obj_RoadFlare";
};
};
};
if(typeName (_loot select 0) == "ARRAY") then {
_num_weapons = (_loot select 0) select 0;
_weapons_array = (_loot select 0) select 1;
} else {
_num_weapons = _loot select 0;
_weapons_array = ai_wep_random;
_multiArrWep = true;
};
if(typeName (_loot select 1) == "ARRAY") then {
_num_tools = (_loot select 1) select 0;
_tool_array = (_loot select 1) select 1;
} else {
_num_tools = _loot select 1;
_tool_array = crate_tools;
};
if(typeName (_loot select 2) == "ARRAY") then {
_num_items = (_loot select 2) select 0;
_item_array = (_loot select 2) select 1;
} else {
_num_items = _loot select 2;
_item_array = crate_items_random;
_multiArrItem = true;
};
if(typeName (_loot select 3) == "ARRAY") then {
_num_pistols = (_loot select 3) select 0;
_pistols_array = (_loot select 3) select 1;
} else {
_num_pistols = _loot select 3;
if (WAI_Overpoch) then {
_pistols_array = ai_wep_owpistol;
} else {
_pistols_array = ai_wep_pistol;
};
};
if(typeName (_loot select 4) == "ARRAY") then {
_num_backpacks = (_loot select 4) select 0;
_backpack_array = (_loot select 4) select 1;
} else {
_num_backpacks = _loot select 4;
_backpack_array = crate_backpacks_all;
};
if(_num_weapons > 0) then {
if (_multiArrWep) then {
for "_i" from 1 to _num_weapons do {
_weapons_array = ai_wep_random select (floor (random (count ai_wep_random)));
_weapon = _weapons_array select (floor (random (count _weapons_array)));
_ammo = _weapon call find_suitable_ammunition;
_crate addWeaponCargoGlobal [_weapon,1];
_crate addMagazineCargoGlobal [_ammo, (round(random((wai_num_mags select 1) - (wai_num_mags select 0))) + (wai_num_mags select 0))];
};
} else {
for "_i" from 1 to _num_weapons do {
_weapon = _weapons_array select (floor (random (count _weapons_array)));
_ammo = _weapon call find_suitable_ammunition;
_crate addWeaponCargoGlobal [_weapon,1];
_crate addMagazineCargoGlobal [_ammo, (round(random((wai_num_mags select 1) - (wai_num_mags select 0))) + (wai_num_mags select 0))];
};
};
};
if(_num_tools > 0) then {
for "_i" from 1 to _num_tools do {
_tool = _tool_array select (floor (random (count _tool_array)));
if(typeName (_tool) == "ARRAY") then {
_crate addWeaponCargoGlobal [_tool select 0,_tool select 1];
} else {
_crate addWeaponCargoGlobal [_tool,1];
};
};
};
if(_num_items > 0) then {
if (_multiArrItem) then {
for "_i" from 1 to _num_items do {
_item_array = crate_items_random select (floor (random (count crate_items_random)));
_item = _item_array select (floor (random (count _item_array)));
if(typeName (_item) == "ARRAY") then {
_crate addMagazineCargoGlobal [_item select 0,_item select 1];
} else {
_crate addMagazineCargoGlobal [_item,1];
};
};
} else {
for "_i" from 1 to _num_items do {
_item = _item_array select (floor (random (count _item_array)));
if(typeName (_item) == "ARRAY") then {
_crate addMagazineCargoGlobal [_item select 0,_item select 1];
} else {
_crate addMagazineCargoGlobal [_item,1];
};
};
};
};
if(_num_pistols > 0) then {
for "_i" from 1 to _num_pistols do {
_pistol = _pistols_array select (floor (random (count _pistols_array)));
_pistolammo = _pistol call find_suitable_ammunition;
_crate addWeaponCargoGlobal [_pistol,1];
_crate addMagazineCargoGlobal [_pistolammo, (round(random((wai_num_mags select 1) - (wai_num_mags select 0))) + (wai_num_mags select 0))];
};
};
if(_num_backpacks > 0) then {
for "_i" from 1 to _num_backpacks do {
_backpack = _backpack_array select (floor (random (count _backpack_array)));
if(typeName (_backpack) == "ARRAY") then {
_crate addBackpackCargoGlobal [_backpack select 0,_backpack select 1];
} else {
_crate addBackpackCargoGlobal [_backpack,1];
};
};
};
if (wai_high_value_chance > 0) then {
if(random 100 < wai_high_value_chance) then {
_item = crate_items_high_value select (floor (random (count crate_items_high_value)));
_crate addMagazineCargoGlobal [_item,1];
};
};
if(wai_debug_mode) then {
diag_log format["WAI: Spawning in a dynamic crate with %1 guns, %2 tools, %3 items and %4 pistols and %5 backpacks",_num_weapons,_num_tools,_num_items,_num_pistols,_num_backpacks];
};

@ -0,0 +1,119 @@
private ["_i","_traders","_safepos","_validspot","_position","_color","_markers"];
if (wai_use_blacklist) then {
_safepos = [getMarkerPos "center",150,((getMarkerSize "center") select 1),(_this select 0),0,0.4,0,wai_blacklist];
} else {
_safepos = [getMarkerPos "center",150,((getMarkerSize "center") select 1),(_this select 0),0,0.4,0];
};
_i = 0;
_validspot = false;
while {!_validspot} do {
_i = _i + 1;
_position = if (!wai_user_spawnpoints) then {_safepos call BIS_fnc_findSafePos} else {WAI_StaticSpawnPoints call BIS_fnc_selectRandom};
_validspot = true;
// if the count of the selected position is more than two BIS_fnc_findSafePos failed
if (!wai_user_spawnpoints) then {
if ((count _position) > 2) then {
_validspot = false;
_color = "ColorBlue";
};
};
if (wai_avoid_samespot) then {
{
if ((_position distance _x) < 200) then {
_validspot = false;
_color = "ColorBlue";
};
} forEach wai_markedPos;
};
// If DZMS installed, include the markers
_markers = if (!isNil "DZMSMarkers") then {DZMSMarkers + wai_mission_markers} else {wai_mission_markers};
if (_validspot && {wai_avoid_missions != 0}) then {
{
if (getMarkerColor _x != "" && (_position distance (getMarkerPos _x) < wai_avoid_missions)) exitWith {
if (wai_debug_mode) then {diag_log format ["WAI: Invalid Position (Marker: %1)",_x];};
_validspot = false;
_color = "ColorBlue";
};
} count _markers;
};
if (_validspot && {wai_avoid_safezones != 0}) then {
{
_szPos = _x select 0;
if (_position distance _szPos < wai_avoid_safezones) exitWith {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (SafeZone)";};
_color = "ColorBrown";
_validspot = false;
};
} forEach DZE_SafeZonePosArray;
};
if (_validspot && {wai_avoid_water != 0}) then {
if ([_position,wai_avoid_water] call isNearWater) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (Water)";};
_color = "ColorBlue";
_validspot = false;
};
};
if (_validspot && {wai_avoid_town != 0}) then {
if ([_position,wai_avoid_town] call isNearTown) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (Town)";};
_color = "ColorGreen";
_validspot = false;
};
};
if (_validspot && {wai_avoid_road != 0}) then {
if ([_position,wai_avoid_road] call isNearRoad) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (Road)";};
_color = "ColorGrey";
_validspot = false;
};
};
if (_validspot && {wai_avoid_players != 0}) then {
if ([_position,wai_avoid_players] call isNearPlayer) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (player)";};
_color = "ColorPink";
_validspot = false;
};
};
if (_validspot && {wai_avoid_plots != 0}) then {
if (count (_position nearEntities ["Plastic_Pole_EP1_DZ", wai_avoid_plots]) > 0) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (plot)";};
_color = "ColorBlack";
_validspot = false;
};
};
if (!_validspot) then {
if (wai_debug_mode) then {
_marker = createMarkerLocal ["spotMarker" + (str _i),[_position select 0,_position select 1]];
_marker setMarkerShapeLocal "ICON";
_marker setMarkerTypeLocal "DOT";
_marker setMarkerColorLocal _color;
_marker setMarkerSizeLocal [1.0, 1.0];
_marker setMarkerTextLocal "fail";
};
};
if (_validspot) then {
if (wai_debug_mode) then {diag_log format ["Loop complete, valid position %1 in %2 attempts.",_position,_i];};
};
};
if (wai_avoid_samespot) then {
wai_markedPos set [count wai_markedPos, _position];
};
_position set [2, 0];
_position

@ -0,0 +1,287 @@
find_suitable_ammunition = {
private["_weapon","_result","_ammoArray"];
_result = false;
_weapon = _this;
_ammoArray = getArray (configFile >> "cfgWeapons" >> _weapon >> "magazines");
if (count _ammoArray > 0) then {_result = _ammoArray select 0;};
if (typeName _result == "BOOL") then {diag_log format["WAI: Cannot find magazine for weapon - %1.",_weapon];};
_result
};
wai_spawnCrate = {
private ["_pos","_crate","_mission","_offset","_type","_loot","_position","_crates"];
_crates = _this select 0;
_pos = _this select 1;
if (count _this > 2) then {
_mission = _this select 2;
};
{
_loot = _x select 0;
_type = _x select 1;
_offset = _x select 2;
_position = [(_pos select 0) + (_offset select 0), (_pos select 1) + (_offset select 1), 0];
if (count _offset > 2) then {
_position set [2, (_offset select 2)];
};
if (typeName _type == "ARRAY") then {
_type = _type call BIS_fnc_selectRandom;
};
_crate = _type createVehicle [0,0,0];
if (count _x > 3) then {
_crate setDir (_x select 3);
};
if (surfaceIsWater _position) then {
_crate setPosASL _position;
} else {
_crate setPos _position;
};
_crate setVariable ["permaLoot",true];
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
_crate addEventHandler ["HandleDamage", {0}];
_crate enableSimulation false;
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 3) set [count ((wai_mission_data select _mission) select 3), [_crate,_loot]];
} else {
(wai_static_data select 3) set [count (wai_static_data select 3), [_crate,_loot]];
};
} count _crates;
};
wai_server_message = {
private ["_color","_params","_type"];
_type = _this select 0;
_message = _this select 1;
call {
if (wai_mission_announce == "Radio") exitWith {
RemoteMessage = ["radio",_message];
};
if (wai_mission_announce == "DynamicText") exitWith {
_color = call {
if(_type == "Easy") exitWith {"#00cc00"};
if(_type == "Medium") exitWith {"#ffff66"};
if(_type == "Hard") exitWith {"#990000"};
if(_type == "Extreme") exitWith {"#33334d"};
};
_params = ["0.40","#FFFFFF","0.60",_color,0,-.35,10,0.5];
RemoteMessage = ["dynamic_text", ["STR_CL_MISSION_ANNOUNCE",_message],_params];
};
if (wai_mission_announce == "titleText") exitWith {
RemoteMessage = ["titleText",_message];
};
};
publicVariable "RemoteMessage";
};
wai_minefield_warning = {
private ["_owner","_params"];
_owner = (owner _this);
_params = ["0","#FFFFFF","0.50","#ff3300",0,.3,10,0.5];
RemoteMessage = ["dynamic_text",["","STR_CL_MINEFIELD_WARNING"],_params];
(_owner) publicVariableClient "RemoteMessage";
};
wai_AutoClaimAlert = {
private ["_unit","_owner","_mission","_type","_message","_name"];
_unit = _this select 0;
_mission = _this select 1;
_type = _this select 2;
if (typeName _unit == "ARRAY") then {
_name = _unit select 1;
} else {
_owner = owner _unit;
_name = name _unit;
};
_message = call {
if (_type == "Start") exitWith {["STR_CL_AUTOCLAIM_ANNOUNCE",_mission,ac_delay_time];};
if (_type == "Stop") exitWith {["STR_CL_AUTOCLAIM_NOCLAIM",_mission];};
if (_type == "Return") exitWith {["STR_CL_AUTOCLAIM_RETURN",ac_timeout];};
if (_type == "Reclaim") exitWith {"STR_CL_AUTOCLAIM_RECLAIM";};
if (_type == "Claimed") exitWith {["STR_CL_AUTOCLAIM_CLAIM",_name,_mission];};
if (_type == "Unclaim") exitWith {["STR_CL_AUTOCLAIM_ABANDON",_name,_mission];};
};
if (_type == "Claimed" || _type == "Unclaim") exitWith {
RemoteMessage = ["IWAC",_message];
publicVariable "RemoteMessage";
};
RemoteMessage = ["IWAC",_message];
(_owner) publicVariableClient "RemoteMessage";
};
wai_monitor_ai_vehicles = {
private "_vehicle";
{
_vehicle = _x;
if (alive _vehicle && ({alive _x} count crew _vehicle > 0)) then {
_vehicle setVehicleAmmo 1;
_vehicle setFuel 1;
} else {
_vehicle setDamage 1;
};
} count _this;
};
wai_fnc_remove = {
{
deleteVehicle _x;
} count _this;
};
wai_remove_vehicles = {
private ["_mission","_vehicles"];
_mission = _this select 0;
_vehicles = _this select 1;
{
if (_x getVariable ["mission" + dayz_serverKey, nil] == _mission) then {
deleteVehicle _x;
};
} count _vehicles;
};
wai_remove_ai = {
{
if (_x getVariable ["mission" + dayz_serverKey, nil] == _this) then {
deleteVehicle _x;
};
} count allUnits;
};
wai_generate_vehicle_key = {
private ["_isKeyOK","_crates","_keyColor","_keyNumber","_vehicle","_crate","_keySelected","_mission","_unit","_ailist","_characterID"];
_vehicle = _this select 0;
_mission = _this select 1;
_crates = _this select 2;
if (wai_vehicle_keys == "NoVehicleKey") exitWith {
_vehicle setVariable ["CharacterID","0",true];
_vehicle setVehicleLock "unlocked";
};
_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom;
_keyNumber = (ceil(random 2500)) + 1;
_keySelected = format["ItemKey%1%2",_keyColor,_keyNumber];
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
_characterID = str(getNumber(configFile >> "CfgWeapons" >> _keySelected >> "keyid"));
if !(_isKeyOK) exitWith {
_vehicle setVariable ["CharacterID","0",true];
_vehicle setVehicleLock "unlocked";
diag_log format["WAI: Failed to generate a key for vehicle %1 at mission %2",_vehicle,_mission];
};
_vehicle setVariable ["CharacterID",_characterID,true];
if (wai_vehicle_keys == "KeyinVehicle") exitWith {
_vehicle addWeaponCargoGlobal [_keySelected,1];
_vehicle setVehicleLock "unlocked";
};
if (wai_vehicle_keys == "KeyinCrate") exitWith {
_crate = (_crates select 0) select 0;
_crate addWeaponCargoGlobal [_keySelected, 1];
};
if (wai_vehicle_keys == "KeyonAI") exitWith {
_ailist = [];
{
if ((_x getVariable ["mission" + dayz_serverKey,nil] == _mission) && (_x getVariable ["bodyName",nil] == "mission_ai") && !(_x getVariable ["noKey", false])) then {
_ailist set [count _ailist, _x];
};
} count allDead;
_unit = _ailist call BIS_fnc_selectRandom;
_unit addWeapon _keySelected;
if(wai_debug_mode) then {
diag_log format["There are %1 Dead AI for mission %2 vehicle key",_ailist,_mission];
diag_log format["Key added to %1 for vehicle %2",_unit,_vehicle];
};
};
};
wai_completion_check = {
private ["_completionType","_complete","_position","_mission","_killpercent","_objectivetarget"];
_mission = _this select 0;
_completionType = _this select 1;
_killpercent = _this select 2;
_position = _this select 3;
_complete = false;
call
{
if (_completionType select 0 == "crate") exitWith {
if(wai_kill_percent == 0) then {
_complete = [_position,20] call isNearPlayer;
} else {
if(((wai_mission_data select _mission) select 0) <= _killpercent) then {
_complete = [_position,20] call isNearPlayer;
};
};
};
if (_completionType select 0 == "kill") exitWith {
if(((wai_mission_data select _mission) select 0) == 0) then {
_complete = true;
};
};
if (_completionType select 0 == "assassinate") exitWith {
_objectivetarget = _completionType select 1;
{
if !(alive _x) exitWith {_complete = true;};
} count units _objectivetarget;
};
/* no missions are using this function at the moment
if (_completionType == "resource") exitWith {
_node = _completionType select 1;
_resource = _node getVariable ["Resource", 0];
if (_resource == 0) then {
if ([_position,80] call isNearPlayer) then {
_complete = true;
} else {
_timeout = true;
};
};
}; */
};
_complete
};
wai_clean_aircraft = {
private ["_veh","_position","_group"];
_veh = _this select 0;
_position = _this select 1;
_group = _this select 2;
uiSleep 60;
deleteVehicle _veh;
while {(count (wayPoints _group)) > 0} do {
deleteWaypoint ((wayPoints _group) select 0);
};
{
deleteVehicle _x;
} count (units _group);
uiSleep 5;
deleteGroup _group;
if(wai_debug_mode) then {diag_log "WAI: Aircraft Cleaned";};
};

@ -0,0 +1,36 @@
private ["_wp","_skill","_mission","_wp_rad","_wp","_pos_x","_pos_y","_pos_z","_unitGroup","_position"];
_unitGroup = _this select 0;
_position = _this select 1;
_pos_x = _position select 0;
_pos_y = _position select 1;
_pos_z = _position select 2;
_wp_rad = 0;
if(count _this > 2) then {
_skill = _this select 2;
_wp_rad = call {
if (_skill == "easy") exitWith {20;};
if (_skill == "medium") exitWith {40;};
if (_skill == "hard") exitWith {80;};
if (_skill == "extreme") exitWith {120;};
if (_skill == "random") exitWith {random(100);};
};
};
// AI is on a building so limit the movement
if (_pos_z > 1) then {
_wp_rad = 0;
};
{
_wp = _unitGroup addWaypoint [_x,10];
_wp setWaypointType "MOVE";
} count [[_pos_x,(_pos_y+_wp_rad),0],[(_pos_x+_wp_rad),_pos_y,0],[_pos_x,(_pos_y-_wp_rad),0],[(_pos_x-_wp_rad),_pos_y,0]];
_wp = _unitGroup addWaypoint [[_pos_x,_pos_y,0],_wp_rad];
_wp setWaypointType "CYCLE";

@ -0,0 +1,395 @@
private ["_rocket","_unarmed","_launcher","_starttodrop","_timebtwdrops","_flyinheight","_distance","_heliStartDir","_start_position","_diag_distance","_rndnum","_mission_data","_pos_x","_pos_y","_ainum","_missionrunning","_aitype","_helipos1","_geartools","_gearmagazines","_cleanheli","_drop","_helipos","_gunner2","_gunner","_player_present","_skillarray","_aicskill","_aiskin","_aigear","_wp","_helipatrol","_gear","_skin","_backpack","_mags","_gun","_triggerdis","_startingpos","_aiweapon","_mission","_heli_class","_aipack","_helicopter","_unitGroup","_pilot","_skill","_paranumber","_position","_wp1"];
if (!wai_enable_paradrops) exitWith {};
_position = _this select 0;
_pos_x = _position select 0;
_pos_y = _position select 1;
_triggerdis = _this select 1;
_heli_class = _this select 2;
_heliStartDir = _this select 3;
_distance = _this select 4;
_flyinheight = _this select 5;
_timebtwdrops = _this select 6;
_starttodrop = _this select 7;
_paranumber = _this select 8;
_skill = _this select 9;
_gun = _this select 10;
_mags = _this select 11;
_backpack = _this select 12;
_skin = _this select 13;
_gear = _this select 14;
_aitype = _this select 15;
_helipatrol = _this select 16;
_aipack = "";
_player_present = false;
if (count _this > 17) then {
_mission = _this select 17;
} else {
_mission = nil;
};
if (typeName _gun == "ARRAY") then {
_launcher = _gun select 1;
_gun = _gun select 0;
};
_aiweapon = [];
_aigear = [];
_aiskin = "";
_aicskill = [];
_skillarray = ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
_unarmed = false;
if(wai_debug_mode) then {diag_log "WAI: Paradrop waiting for player";};
// Wait until a player is within the trigger distance
while {!_player_present} do {
_player_present = [[_pos_x,_pos_y,0],_triggerdis] call isNearPlayer;
uiSleep 5;
};
_aiskin = call {
if (_skin == "random") exitWith {ai_all_skin select (floor (random (count ai_all_skin)));};
if (_skin == "hero") exitWith {ai_hero_skin select (floor (random (count ai_hero_skin)));};
if (_skin == "bandit") exitWith {ai_bandit_skin select (floor (random (count ai_bandit_skin)));};
if (_skin == "special") exitWith {ai_special_skin select (floor (random (count ai_special_skin)));};
_skin;
};
if(typeName _aiskin == "ARRAY") then {
_aiskin = _aiskin select (floor (random (count _aiskin)));
};
if(!isNil "_mission") then {
_missionrunning = (typeName (wai_mission_data select _mission) == "ARRAY");
} else {
_missionrunning = true;
};
if(!_missionrunning) exitWith {if (wai_debug_mode) then {diag_log format["WAI: Mission at %1 already ended, aborting para drop",_position];};};
if(wai_debug_mode) then {diag_log format ["WAI: Spawning a %1 with %2 units to be para dropped at %3",_heli_class,_paranumber,_position];};
if(_aitype == "Hero") then {
_unitGroup = createGroup RESISTANCE;
} else {
_unitGroup = createGroup EAST;
};
_pilot = _unitGroup createUnit [_aiskin,[0,0,0],[],1,"NONE"];
[_pilot] joinSilent _unitGroup;
// This random number is used to start the helicopter a random distance from the mission
_rndnum = (random ((_distance select 1) - (_distance select 0)) + (_distance select 0));
call
{
if (_heliStartDir == "North") exitWith {_helicopter = createVehicle [_heli_class,[(_position select 0),(_position select 1) + _rndnum,100],[],0,"FLY"];};
if (_heliStartDir == "South") exitWith {_helicopter = createVehicle [_heli_class,[(_position select 0),(_position select 1) - _rndnum,100],[],0,"FLY"];};
if (_heliStartDir == "East") exitWith {_helicopter = createVehicle [_heli_class,[(_position select 0) + _rndnum,(_position select 1),100],[],0,"FLY"];};
if (_heliStartDir == "West") exitWith {_helicopter = createVehicle [_heli_class,[(_position select 0) - _rndnum,(_position select 1),100],[],0,"FLY"];};
};
_start_position = position _helicopter;
if (wai_debug_mode) then {
_diag_distance = _helicopter distance _position;
diag_log format["WAI: the Paratrooper Drop has started %1 from the mission",_diag_distance];
};
//_helicopter setFuel 1;
_helicopter engineOn true;
//_helicopter setVehicleAmmo 1;
_helicopter flyInHeight _flyinheight;
_helicopter addEventHandler ["GetOut",{(_this select 0) setFuel 0;(_this select 0) setDamage 1;}];
_pilot assignAsDriver _helicopter;
_pilot moveInDriver _helicopter;
_gunner = _unitGroup createUnit [_aiskin,[0,0,0],[],1,"NONE"];
_gunner assignAsGunner _helicopter;
_gunner moveInTurret [_helicopter,[0]];
[_gunner] joinSilent _unitGroup;
_gunner2 = _unitGroup createUnit [_aiskin,[0,0,0],[],1,"NONE"];
_gunner2 assignAsGunner _helicopter;
_gunner2 moveInTurret [_helicopter,[1]];
[_gunner2] joinSilent _unitGroup;
call {
if (_aitype == "Hero") exitWith {{ _x setVariable ["Hero",true]; _x setVariable ["humanity", ai_add_humanity]; } count [_pilot, _gunner, _gunner2];};
if (_aitype == "Bandit") exitWith {{ _x setVariable ["Bandit",true]; _x setVariable ["humanity", ai_remove_humanity]; } count [_pilot, _gunner, _gunner2];};
if (_aitype == "Special") exitWith {{ _x setVariable ["Special",true]; _x setVariable ["humanity", ai_special_humanity]; } count [_pilot, _gunner, _gunner2];};
};
{
_pilot setSkill [_x,1]
} count _skillarray;
{
_gunner setSkill [_x,0.7];
_gunner2 setSkill [_x,0.7];
} count _skillarray;
{
_x addWeapon "Makarov_DZ";
_x addMagazine "8Rnd_9x18_Makarov";
_x addMagazine "8Rnd_9x18_Makarov";
} count (units _unitgroup);
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_helicopter];
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _unitGroup];
((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _helicopter];
} else {
(wai_static_data select 1) set [count (wai_static_data select 1), _unitGroup];
(wai_static_data select 2) set [count (wai_static_data select 2), _helicopter];
};
_unitGroup allowFleeing 0;
_unitGroup setBehaviour "CARELESS";
_unitGroup setSpeedMode "FULL";
if(_aitype == "Hero") then {
_unitGroup setCombatMode ai_hero_combatmode;
_unitGroup setBehaviour ai_hero_behaviour;
} else {
_unitGroup setCombatMode ai_bandit_combatmode;
_unitGroup setBehaviour ai_bandit_behaviour;
};
// Add waypoints to the chopper group.
_wp = _unitGroup addWaypoint [[(_position select 0), (_position select 1)], 0];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 100;
_drop = true;
//_helipos = getPos _helicopter;
while {(alive _helicopter) && (_drop)} do {
private ["_magazine","_weapon","_weapon","_chute","_para","_pgroup"];
uiSleep 1;
_helipos = getPos _helicopter;
if (_helipos distance [(_position select 0),(_position select 1),100] <= _starttodrop) then {
if(_aitype == "Hero") then {
_pgroup = createGroup RESISTANCE;
} else {
_pgroup = createGroup EAST;
};
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _pgroup];
} else {
(wai_static_data select 1) set [count (wai_static_data select 1), _pgroup];
};
for "_x" from 1 to _paranumber do {
_helipos = getPos _helicopter;
call {
if(typeName(_gun) == "SCALAR") then {
if(_gun == 0) exitWith {_aiweapon = ai_wep_random select (floor (random (count ai_wep_random)));};
if(_gun == 1) exitWith {_aiweapon = ai_wep_machine;};
if(_gun == 2) exitWith {_aiweapon = ai_wep_sniper;};
} else {
if(_gun == "random") exitWith {_aiweapon = ai_wep_random select (floor (random (count ai_wep_random)));};
if(_gun == "unarmed") exitWith {_unarmed = true;};
_aiweapon = _gun;
};
};
if (!_unarmed) then {
_weapon = if (typeName (_aiweapon) == "ARRAY") then {_aiweapon select (floor (random (count _aiweapon)))} else {_aiweapon};
if !(isClass (configFile >> "CfgWeapons" >> _weapon)) then {
diag_log text format ["WAI Error: Weapon classname (%1) is not valid!",_weapon];
_weapon = "M16A2_DZ"; // Replace with known good classname.
};
_magazine = _weapon call find_suitable_ammunition;
};
_aigear = call {
if (typeName(_gear) == "SCALAR") then {
if(_gear == 0) exitWith {ai_gear0;};
if(_gear == 1) exitWith {ai_gear1;};
if(_gear == 2) exitWith {ai_gear2;};
if(_gear == 3) exitWith {ai_gear3;};
if(_gear == 4) exitWith {ai_gear4;};
} else {
if(_gear == "random") exitWith {ai_gear_random select (floor (random (count ai_gear_random)));};
};
};
_gearmagazines = _aigear select 0;
_geartools = _aigear select 1;
call {
if(_backpack == "random") exitWith {_aipack = ai_packs select (floor (random (count ai_packs)));};
if(_backpack == "none") exitWith {};
_aipack = _backpack;
};
_aiskin = call {
if (_skin == "random") exitWith {ai_all_skin select (floor (random (count ai_all_skin)));};
if (_skin == "hero") exitWith {ai_hero_skin select (floor (random (count ai_hero_skin)));};
if (_skin == "bandit") exitWith {ai_bandit_skin select (floor (random (count ai_bandit_skin)));};
if (_skin == "special") exitWith {ai_special_skin select (floor (random (count ai_special_skin)));};
_skin;
};
//if(typeName _aiskin == "ARRAY") then {
//_aiskin = _aiskin select (floor (random (count _aiskin)));
//};
_para = _pgroup createUnit [_aiskin,[0,0,0],[],1,"FORM"];
_para enableAI "TARGET";
_para enableAI "AUTOTARGET";
_para enableAI "MOVE";
_para enableAI "ANIM";
_para enableAI "FSM";
removeAllWeapons _para;
removeAllItems _para;
_para addWeapon _weapon;
for "_i" from 1 to _mags do {
_para addMagazine _magazine;
};
if(_backpack != "none") then {
_para addBackpack _aipack;
};
{
_para addMagazine _x
} count _gearmagazines;
{
_para addWeapon _x
} count _geartools;
if (sunOrMoon != 1) then {
_para addWeapon "NVGoggles";
};
_aicskill = call {
if(_skill == "easy") exitWith {ai_skill_easy;};
if(_skill == "medium") exitWith {ai_skill_medium;};
if(_skill == "hard") exitWith {ai_skill_hard;};
if(_skill == "extreme") exitWith {ai_skill_extreme;};
if(_skill == "random") exitWith {ai_skill_random select (floor (random (count ai_skill_random)));};
ai_skill_random select (floor (random (count ai_skill_random)));
};
{
_para setSkill [(_x select 0),(_x select 1)]
} count _aicskill;
_para addEventHandler ["Killed",{[_this select 0, _this select 1] call on_kill;}];
_chute = createVehicle ["ParachuteWest", [(_helipos select 0), (_helipos select 1), (_helipos select 2)], [], 0, "NONE"];
_para moveInDriver _chute;
[_para] joinSilent _pgroup;
// Adjusting this number changes the spread of the AI para drops
uiSleep _timebtwdrops;
if(!isNil "_mission") then {
_mission_data = (wai_mission_data select _mission);
if (typeName _mission_data == "ARRAY") then {
_ainum = _mission_data select 0;
wai_mission_data select _mission set [0, (_ainum + 1)];
_para setVariable ["mission" + dayz_serverKey, _mission, false];
};
} else {
wai_static_data set [0, ((wai_static_data select 0) + 1)];
};
};
if (!isNil "_launcher" && wai_use_launchers) then {
call {
if (_launcher == "Random") exitWith { _launcher = (ai_launchers_AT + ai_launchers_AA) call BIS_fnc_selectRandom; };
if (_launcher == "at") exitWith {_launcher = ai_wep_launchers_AT select (floor (random (count ai_wep_launchers_AT)));};
if (_launcher == "aa") exitWith {_launcher = ai_wep_launchers_AA select (floor (random (count ai_wep_launchers_AA)));};
};
_rocket = _launcher call find_suitable_ammunition;
_para addMagazine _rocket;
_para addMagazine _rocket;
_para addWeapon _launcher;
};
call {
if (_aitype == "Hero") exitWith {{_x setVariable ["Hero",true,false]; _x setVariable ["humanity", ai_remove_humanity];} count (units _pgroup);};
if (_aitype == "Bandit") exitWith {{_x setVariable ["Bandit",true,false]; _x setVariable ["humanity", ai_add_humanity];} count (units _pgroup);};
if (_aitype == "Special") exitWith {{_x setVariable ["Special",true,false]; _x setVariable ["humanity", ai_special_humanity];} count (units _pgroup);};
};
_drop = false;
_pgroup selectLeader ((units _pgroup) select 0);
if(wai_debug_mode) then {diag_log format ["WAI: Spawned in %1 ai units for paradrop",_paranumber];};
[_pgroup,_position,_skill] call group_waypoints;
if(_aitype == "Hero") then {
_pgroup setCombatMode ai_hero_combatmode;
_pgroup setBehaviour ai_hero_behaviour;
} else {
_pgroup setCombatMode ai_bandit_combatmode;
_pgroup setBehaviour ai_bandit_behaviour;
};
};
};
if (_helipatrol) then {
_wp1 = _unitGroup addWaypoint [[(_position select 0),(_position select 1)], 100];
_wp1 setWaypointType "SAD";
_wp1 setWaypointCompletionRadius 150;
_unitGroup setBehaviour "AWARE";
_unitGroup setSpeedMode "FULL";
{
_x addEventHandler ["Killed",{[_this select 0, _this select 1] call on_kill;}];
} forEach (units _unitgroup);
} else {
{
_x doMove [(_start_position select 0), (_start_position select 1), 100]
} count (units _unitGroup);
_unitGroup setBehaviour "CARELESS";
_unitGroup setSpeedMode "FULL";
_cleanheli = true;
while {_cleanheli} do {
uiSleep 5;
_helipos1 = getPos _helicopter;
if ((_helipos1 distance [(_start_position select 0),(_start_position select 1),100] <= 2000) || (!alive _helicopter)) then {
deleteVehicle _helicopter;
{
deleteVehicle _x;
} count (units _unitgroup);
deleteGroup _unitGroup;
if(wai_debug_mode) then { diag_log "WAI: Paradrop helicopter cleaned"; };
_cleanheli = false;
};
};
};

@ -0,0 +1,140 @@
private ["_start_position","_diag_distance","_rndnum","_mission","_aitype","_aiskin","_skin","_aicskill","_wpnum","_radius","_gunner2","_gunner","_skillarray","_startingpos","_heli_class","_startPos","_helicopter","_unitGroup","_pilot","_skill","_position","_wp"];
_position = _this select 0;
_radius = _this select 1;
_wpnum = _this select 2;
_heli_class = _this select 3;
_skill = _this select 4;
_skin = _this select 5;
_aitype = _this select 6;
if (count _this > 7) then {
_mission = _this select 7;
} else {
_mission = nil;
};
_skillarray = ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
call {
if(_skill == "easy") exitWith { _aicskill = ai_skill_easy; };
if(_skill == "medium") exitWith { _aicskill = ai_skill_medium; };
if(_skill == "hard") exitWith { _aicskill = ai_skill_hard; };
if(_skill == "extreme") exitWith { _aicskill = ai_skill_extreme; };
if(_skill == "random") exitWith { _aicskill = ai_skill_random call BIS_fnc_selectRandom; };
_aicskill = ai_skill_random call BIS_fnc_selectRandom;
};
call {
if (_skin == "random") exitWith { _aiskin = ai_all_skin call BIS_fnc_selectRandom; };
if (_skin == "hero") exitWith { _aiskin = ai_hero_skin call BIS_fnc_selectRandom; };
if (_skin == "bandit") exitWith { _aiskin = ai_bandit_skin call BIS_fnc_selectRandom; };
if (_skin == "special") exitWith { _aiskin = ai_special_skin call BIS_fnc_selectRandom; };
_aiskin = _skin;
};
if(typeName _aiskin == "ARRAY") then {
_aiskin = _aiskin call BIS_fnc_selectRandom;
};
if(_aitype == "Hero") then {
_unitGroup = createGroup RESISTANCE;
} else {
_unitGroup = createGroup EAST;
};
_pilot = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
[_pilot] joinSilent _unitGroup;
// This random number is used to start the helicopter from 3000 to 4000 meters from the mission.
_rndnum = 3000 + round (random 1000);
_helicopter = createVehicle [_heli_class,[(_position select 0) + _rndnum,(_position select 1),100],[],0,"FLY"];
_diag_distance = _helicopter distance _position;
if (wai_debug_mode) then {
diag_log format["WAI: the Heli Patrol has started %1 from the mission",_diag_distance];
};
_helicopter setFuel 1;
_helicopter engineOn true;
_helicopter setVehicleAmmo 1;
_helicopter flyInHeight 150;
_helicopter lock true;
_helicopter addEventHandler ["GetOut",{(_this select 0) setFuel 0;(_this select 0) setDamage 1;}];
_pilot assignAsDriver _helicopter;
_pilot moveInDriver _helicopter;
_gunner = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
_gunner assignAsGunner _helicopter;
_gunner moveInTurret [_helicopter,[0]];
[_gunner] joinSilent _unitGroup;
_gunner2 = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
_gunner2 assignAsGunner _helicopter;
_gunner2 moveInTurret [_helicopter,[1]];
[_gunner2] joinSilent _unitGroup;
call {
if (_aitype == "Hero") exitWith {{ _x setVariable ["Hero",true,false]; _x setVariable ["humanity", ai_remove_humanity];} count [_pilot, _gunner, _gunner2]; };
if (_aitype == "Bandit") exitWith {{ _x setVariable ["Bandit",true,false]; _x setVariable ["humanity", ai_add_humanity];} count [_pilot, _gunner, _gunner2]; };
if (_aitype == "Special") exitWith {{ _x setVariable ["Special",true,false]; _x setVariable ["humanity", ai_special_humanity];} count [_pilot, _gunner, _gunner2]; };
};
{
_pilot setSkill [_x,1];
} count _skillarray;
{
_gunner setSkill [(_x select 0),(_x select 1)];
_gunner2 setSkill [(_x select 0),(_x select 1)];
} count _aicskill;
{
_x addWeapon "Makarov_DZ";
_x addMagazine "8Rnd_9x18_Makarov";
_x addMagazine "8Rnd_9x18_Makarov";
} count (units _unitgroup);
{
_x addEventHandler ["Killed",{[_this select 0, _this select 1] call on_kill;}];
} forEach (units _unitgroup);
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_helicopter];
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _unitGroup];
((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _helicopter];
} else {
(wai_static_data select 1) set [count (wai_static_data select 1), _unitGroup];
(wai_static_data select 2) set [count (wai_static_data select 2), _helicopter];
};
_unitGroup allowFleeing 0;
_unitGroup setBehaviour "AWARE";
_unitGroup setSpeedMode "FULL";
if(_aitype == "Hero") then {
_unitGroup setCombatMode ai_hero_combatmode;
_unitGroup setBehaviour ai_hero_behaviour;
} else {
_unitGroup setCombatMode ai_bandit_combatmode;
_unitGroup setBehaviour ai_bandit_behaviour;
};
if(_wpnum > 0) then {
for "_i" from 1 to _wpnum do {
_wp = _unitGroup addWaypoint [[(_position select 0),(_position select 1),0],_radius];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 200;
};
};
_wp = _unitGroup addWaypoint [[(_position select 0),(_position select 1),0],100];
_wp setWaypointType "CYCLE";
_wp setWaypointCompletionRadius 200;
_unitGroup

@ -0,0 +1,103 @@
private["_vehicle","_type","_inGear"];
#define GEAR(mag) if !(isNil "_inGear") then {_vehicle addMagazineCargoGlobal [mag,_inGear];};
#define TURRET(mag,num) _vehicle addMagazineTurret [mag,[num]];
_vehicle = _this select 0;
_type = _this select 1;
if (count _this > 2) then {
_inGear = _this select 2;
};
call {
if(_type == "Mi17_DZE") exitWith {
TURRET("100Rnd_762x54_PK",0)
TURRET("100Rnd_762x54_PK",1)
GEAR("100Rnd_762x54_PK")
};
if(_type == "UH1Y_DZE") exitWith {
TURRET("2000Rnd_762x51_M134",0)
TURRET("2000Rnd_762x51_M134",1)
GEAR("2000Rnd_762x51_M134")
};
if(_type == "UH1H_DZE") exitWith {
TURRET("100Rnd_762x51_M240",0)
TURRET("100Rnd_762x51_M240",1)
GEAR("100Rnd_762x51_M240")
};
if(_type == "CH_47F_EP1_DZE") exitWith {
TURRET("2000Rnd_762x51_M134",0)
TURRET("2000Rnd_762x51_M134",1)
TURRET("100Rnd_762x51_M240",2)
GEAR("2000Rnd_762x51_M134")
};
if(_type == "UH60M_EP1_DZE") exitWith {
TURRET("2000Rnd_762x51_M134",0)
TURRET("2000Rnd_762x51_M134",1)
GEAR("2000Rnd_762x51_M134")
};
if(_type == "HMMWV_M998A2_SOV_DES_EP1_DZE") exitWith {
TURRET("48Rnd_40mm_MK19",0)
TURRET("100Rnd_762x51_M240",1)
GEAR("48Rnd_40mm_MK19")
};
if(_type == "LandRover_Special_CZ_EP1_DZE") exitWith {
TURRET("29Rnd_30mm_AGS30",0)
TURRET("100Rnd_762x54_PK",1)
GEAR("29Rnd_30mm_AGS30")
};
if(_type == "GAZ_Vodnik_DZE") exitWith {
TURRET("100Rnd_762x54_PK",0)
TURRET("100Rnd_762x54_PK",1)
GEAR("100Rnd_762x54_PK")
};
if(_type == "HMMWV_M1151_M2_CZ_DES_EP1_DZE") exitWith {
TURRET("100Rnd_127x99_M2",0)
GEAR("100Rnd_127x99_M2")
};
if(_type == "LandRover_MG_TK_EP1_DZE") exitWith {
TURRET("100Rnd_127x99_M2",0)
GEAR("100Rnd_127x99_M2")
};
if(_type == "UAZ_MG_TK_EP1_DZE") exitWith {
TURRET("150Rnd_127x107_DSHKM",0)
GEAR("150Rnd_127x107_DSHKM")
};
if(_type == "ArmoredSUV_PMC_DZE") exitWith {
TURRET("2000Rnd_762x51_M134",0)
GEAR("2000Rnd_762x51_M134")
};
if(_type == "Offroad_DSHKM_Gue_DZE") exitWith {
TURRET("150Rnd_127x107_DSHKM",0)
GEAR("150Rnd_127x107_DSHKM")
};
if(_type == "Pickup_PK_TK_GUE_EP1_DZE") exitWith {
TURRET("100Rnd_762x54_PK",0)
GEAR("100Rnd_762x54_PK")
};
if(_type == "Pickup_PK_GUE_DZE") exitWith {
TURRET("100Rnd_762x54_PK",0)
GEAR("100Rnd_762x54_PK")
};
if(_type == "Pickup_PK_INS_DZE") exitWith {
TURRET("100Rnd_762x54_PK",0)
GEAR("100Rnd_762x54_PK")
};
};

@ -0,0 +1,16 @@
private["_area_max","_area_min","_position","_num_mines","_mines"];
_position = _this select 0;
_area_min = _this select 1;
_area_max = _this select 2;
_num_mines = _this select 3;
_mines = [];
for "_x" from 1 to _num_mines do {
_mine_pos = [_position,_area_min,_area_max,10,0,2000,0] call BIS_fnc_findSafePos;
_mine = createVehicle ["Mine", _mine_pos, [], 0, "CAN_COLLIDE"];
_mines set [(count _mines), _mine];
};
_mines

@ -0,0 +1,303 @@
private ["_mission","_position","_difficulty","_name","_missionType","_showMarker","_enableMines","_completionType","_msgstart","_msgwin","_msglose","_mines"];
_mission = _this select 0;
_position = _this select 1;
_difficulty = _this select 2;
_name = _this select 3;
_missionType = _this select 4;
_showMarker = _this select 5;
_enableMines = _this select 6;
_completionType = _this select 7;
_msgstart = (_this select 8) select 0;
_msgwin = (_this select 8) select 1;
_msglose = (_this select 8) select 2;
if(wai_debug_mode) then {diag_log format["WAI: Starting Mission number %1",_mission];};
if(wai_enable_minefield && _enableMines) then {
_mines = [_position,50,75,100] call minefield;
wai_mission_data select _mission set [2, _mines];
};
_color = call {
if(_difficulty == "Easy") exitWith {"ColorGreen"};
if(_difficulty == "Medium") exitWith {"ColorYellow"};
if(_difficulty == "Hard") exitWith {"ColorRed"};
if(_difficulty == "Extreme") exitWith {"ColorBlack"};
};
_name = call {
if(_missionType == "MainHero") exitWith {"Bandit " + _name;};
if(_missionType == "MainBandit") exitWith {"Hero " + _name;};
};
[_difficulty,_msgstart] call wai_server_message;
WAI_MarkerReady = true;
[_position,_mission,_name,_completionType,_color,_showMarker,_msgwin,_msglose,_enableMines,_missionType,_difficulty] spawn {
private ["_left","_leftTime","_claimTime","_acArray","_claimed","_acTime","_acdot","_acMarker","_timeStamp","_unitGroups","_playerArray","_enableMines","_aiVehicles","_aiVehArray","_baseclean","_msgwin","_msglose","_bomb","_position","_minefieldRadius","_timeout","_player_near","_complete","_starttime","_timeout_time","_max_ai","_killpercent","_mission","_missionType","_airemain","_text","_name","_completionType","_marker","_dot","_objectivetarget","_color","_crateLoot","_crate","_showMarker","_cleanunits"];
_position = _this select 0;
_mission = _this select 1;
_name = _this select 2;
_completionType = _this select 3;
_color = _this select 4;
_showMarker = _this select 5;
_msgwin = _this select 6;
_msglose = _this select 7;
_enableMines = _this select 8;
_missionType = _this select 9;
_difficulty = _this select 10;
_timeout = false;
_player_near = false;
_complete = false;
_starttime = diag_tickTime;
_timeout_time = (random((wai_mission_timeout select 1) - (wai_mission_timeout select 0)) + (wai_mission_timeout select 0)) * 60;
_max_ai = (wai_mission_data select _mission) select 0;
_unitGroups = (wai_mission_data select _mission) select 1;
_mines = (wai_mission_data select _mission) select 2;
_crates = (wai_mission_data select _mission) select 3;
_aiVehicles = (wai_mission_data select _mission) select 4;
_vehicles = (wai_mission_data select _mission) select 5;
_baseclean = (wai_mission_data select _mission) select 6;
_killpercent = _max_ai - (_max_ai * (wai_kill_percent / 100));
_playerArray = [];
_timeStamp = diag_tickTime;
_closestPlayer = objNull;
_acArray = [];
_claimed = false;
_acTime = diag_tickTime;
_claimTime = 0;
_left = false;
_leftTime = 0;
while {!_timeout && !_complete} do {
if (count _mines > 0) then {
{
if((isPlayer _x) && (vehicle _x != _x) && (vehicle _x distance _position < 275) && !(_x in _playerArray)) then {
_x call wai_minefield_warning;
_playerArray set [count _playerArray, _x];
};
if((isPlayer _x) && (vehicle _x != _x) && (vehicle _x distance _position < 75) && (alive _x) && ((([vehicle _x] call FNC_GetPos) select 2) < 1)) then {
_bomb = "Bo_GBU12_lgb" createVehicle ([vehicle _x] call FNC_GetPos);
uiSleep 3;
deleteVehicle _bomb;
};
} count playableUnits;
};
if ((diag_tickTime - _timeStamp) > 180 && (count _aiVehicles) > 0) then {
{
if (_x isKindOf "StaticWeapon") then {
(gunner _x) action ["getout",_x];
};
} forEach _aiVehicles;
_timeStamp = diag_tickTime;
};
if (use_wai_autoclaim && _showMarker) then {
#include "\z\addons\dayz_server\WAI\compile\auto_claim.sqf"
};
if (count _aiVehicles > 0) then {
_aiVehicles call wai_monitor_ai_vehicles;
};
if (_showMarker) then {
if (ai_show_count) then {
_aiCount = (wai_mission_data select _mission) select 0;
_text = format["%1 (%2 A.I.)",_name,_aiCount];
} else {
_text = _name;
};
_marker = createMarker [_missionType + str(_mission), _position];
_marker setMarkerColor _color;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerBrush "Solid";
_marker setMarkerSize [300,300];
_dot = createMarker [_missionType + str(_mission) + "dot", _position];
_dot setMarkerColor "ColorBlack";
_dot setMarkerType "mil_dot";
_dot setMarkerText _text;
if (use_wai_autoclaim) then {
_acMarker = createMarker [_missionType + str(_mission) + "auto", _position];
_acMarker setMarkerShape "ELLIPSE";
_acMarker setMarkerBrush "Border";
_acMarker setMarkerColor "ColorRed";
_acMarker setMarkerSize [ac_alert_distance,ac_alert_distance];
if (_claimed) then {
_acdot = createMarker [_missionType + str(_mission) + "autodot", [(_position select 0) + 100, (_position select 1) + 100]];
_acdot setMarkerColor "ColorBlack";
_acdot setMarkerType "mil_objective";
if (_left) then {
_acdot setMarkerText format["%1 Claim Timeout [%2]",(_acArray select 1),_leftTime];
} else {
_acdot setMarkerText format["Claimed by %1",(name _closestPlayer)];
};
};
};
uiSleep 2;
deleteMarker _marker;
deleteMarker _dot;
if (!isNil "_acMarker") then {deleteMarker _acMarker;};
if (!isNil "_acdot") then {deleteMarker _acdot;};
} else {
uiSleep 2;
};
_player_near = [_position,wai_timeout_distance] call isNearPlayer;
if (diag_tickTime - _starttime >= _timeout_time && !_player_near) then {
_timeout = true;
} else {
if (_player_near) then {_starttime = diag_tickTime;};
};
_complete = [_mission,_completionType,_killpercent,_position] call wai_completion_check;
};
if (_complete) then {
if (count _vehicles > 0) then {
{
[_x,_mission,_crates] call wai_generate_vehicle_key;
} count _vehicles;
};
{
[(_x select 0),(_x select 1),_complete] call dynamic_crate;
} count _crates;
if (count _mines > 0) then {
_mines call wai_fnc_remove;
};
[_difficulty,_msgwin] call wai_server_message;
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
diag_log format["WAI: [Mission: %1]: Ended at %2",_name,_position];
if (wai_clean_mission_time > 0) then {
private ["_finish_time","_cleaned","_playernear"];
_finish_time = diag_tickTime;
_cleaned = false;
while {!_cleaned} do {
uiSleep 3;
if (count _aiVehicles > 0) then {
_aiVehicles call wai_monitor_ai_vehicles;
};
if ((diag_tickTime - _finish_time >= 60*wai_clean_mission_time) || ({[_x,_name] call fnc_inString;} count wai_clean_when_clear) != 0) then {
if (count _aiVehicles > 0) then {
_aiVehicles call wai_fnc_remove;
};
_mission call wai_remove_ai;
if (count _vehicles > 0) then {
[_mission,_vehicles] call wai_remove_vehicles;
};
if (count _baseclean > 0) then {
_baseclean call wai_fnc_remove;
};
{
if (count units _x == 0) then {
deleteGroup _x;
};
} forEach _unitGroups;
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
if (wai_clean_mission_crate) then {
_playernear = [_position,75] call isNearPlayer;
if (!_playernear) then {
{
if ((typeOf (_x select 0)) in (crates_large + crates_medium + crates_small)) then {
deleteVehicle (_x select 0);
};
} count _crates;
_cleaned = true;
};
} else {
_cleaned = true;
};
};
};
};
};
if (_timeout) then {
if (count _mines > 0) then {
_mines call wai_fnc_remove;
};
{
deleteVehicle (_x select 0);
} count _crates;
if (count _aiVehicles > 0) then {
_aiVehicles call wai_fnc_remove;
};
_mission call wai_remove_ai;
if (count _vehicles > 0) then {
[_mission,_vehicles] call wai_remove_vehicles;
};
if (count _baseclean > 0) then {
_baseclean call wai_fnc_remove;
};
[_difficulty,_msglose] call wai_server_message;
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
{
if (count units _x == 0) then {
deleteGroup _x;
};
} forEach _unitGroups;
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
diag_log format["WAI: [Mission: %1]: Timed out at %2",_name,_position];
};
};

@ -0,0 +1,124 @@
private ["_rockets","_launcher","_type","_skin","_gain","_mission","_ainum","_unit","_player","_humanity","_banditkills","_humankills","_humanitygain","_cash"];
_unit = _this select 0;
_player = _this select 1;
//_type = _this select 2;
_launcher = secondaryWeapon _unit;
_mission = _unit getVariable ["mission" + dayz_serverKey, nil];
if (!isNil "_mission") then {
if (typeName(wai_mission_data select _mission) == "ARRAY") then {
wai_mission_data select _mission set [0, ((wai_mission_data select _mission) select 0) - 1];
};
} else {
wai_static_data set [0, ((wai_static_data select 0) - 1)];
};
_unit setVariable ["bodyName","mission_ai",false]; //Only needed on server to prevent immediate cleanup in sched_corpses.sqf
if (ai_hasMoney && Z_singleCurrency) then {
_cash = round(random ai_moneyMultiplier) * 50;
_unit setVariable["cashMoney",_cash ,true];
};
if(ai_add_skin) then {
_skin = (typeOf _unit);
_skin = "Skin_" + _skin;
if (isClass (configFile >> "CfgMagazines" >> _skin)) then {
[_unit,_skin] call BIS_fnc_invAdd;
};
};
if (isPlayer _player) then {
private ["_banditkills","_humanity","_humankills"];
if (ai_reward_veh_gunner) then {
_player = (effectiveCommander vehicle _player);
};
if (ai_killfeed && ai_humanity_gain) then {
_aitype = if (_unit getVariable ["Hero", false]) then {"Hero";} else {"Bandit";};
_humanityReward = if (_aitype == "Hero") then {format["-%1 Humanity",ai_remove_humanity];} else {format["+%1 Humanity",ai_add_humanity];};
_aiColor = if (_aitype == "Hero") then {"#3333ff";} else {"#ff0000";};
_params = [_aiColor,"0.50","#FFFFFF",-.4,.2,2,0.5];
RemoteMessage = ["ai_killfeed", [_aitype," AI Kill",_humanityReward],_params];
(owner _player) publicVariableClient "RemoteMessage";
};
_humanity = _player getVariable["humanity",0];
_banditkills = _player getVariable["banditKills",0];
_humankills = _player getVariable["humanKills",0];
if (ai_humanity_gain) then {
_gain = _unit getVariable ["humanity", 0];
call {
if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["humanity",(_humanity - _gain),true]; };
if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["humanity",(_humanity + _gain),true]; };
if (_unit getVariable ["Special", false]) exitWith { if (_humanity < 0) then { _player setVariable ["humanity",(_humanity - _gain),true]; } else { _player setVariable ["humanity",(_humanity + _gain),true]; }; };
};
};
if (ai_kills_gain) then {
if (_unit getVariable ["Hero", false]) then {
_player setVariable ["humanKills",(_humankills + 1),true];
} else {
_player setVariable ["banditKills",(_banditkills + 1),true];
};
};
if (ai_clear_body) then {
{_unit removeMagazine _x;} count (magazines _unit);
{_unit removeWeapon _x;} count (weapons _unit);
};
if (ai_share_info) then {
{
if (((position _x) distance (position _unit)) <= ai_share_distance) then {
_x reveal [_player, 4.0];
};
} count allUnits;
};
} else {
if (ai_clean_roadkill) then {
removeBackpack _unit;
removeAllWeapons _unit;
{
_unit removeMagazine _x
} count magazines _unit;
} else {
if ((random 100) <= ai_rk_damageweapon) then {
removeAllWeapons _unit;
};
};
};
if(wai_remove_launcher && _launcher != "") then {
_rockets = _launcher call find_suitable_ammunition;
_unit removeWeapon _launcher;
{
if(_x == _rockets) then {
_unit removeMagazine _x;
};
} count magazines _unit;
};
if(_unit hasWeapon "NVGoggles" && floor(random 100) < 20) then {
_unit removeWeapon "NVGoggles";
};

@ -0,0 +1,272 @@
private ["_location","_countWP","_wp","_mission","_position","_difficulty","_name","_missionType","_showMarker","_numWaypoints","_completionType","_msgstart","_msgwin","_msglose"];
_mission = _this select 0;
_position = _this select 1;
_difficulty = _this select 2;
_name = _this select 3;
_missionType = _this select 4;
_showMarker = _this select 5;
_numWaypoints = _this select 6;
_locations = _this select 7;
_completionType = _this select 8;
_msgstart = (_this select 9) select 0;
_msgwin = (_this select 9) select 1;
_msglose = (_this select 9) select 2;
_countWP = [];
_unitGroup = ((wai_mission_data select _mission) select 1) select 0;
if(wai_debug_mode) then {diag_log format["WAI: Starting Mission number %1",_mission];};
_color = call {
if (_difficulty == "Easy") exitWith {"ColorGreen"};
if (_difficulty == "Medium") exitWith {"ColorYellow"};
if (_difficulty == "Hard") exitWith {"ColorRed"};
if (_difficulty == "Extreme") exitWith {"ColorBlack"};
};
_name = call {
if (_missionType == "MainHero") exitWith {"Bandit " + _name;};
if (_missionType == "MainBandit") exitWith {"Hero " + _name;};
};
for "_i" from 0 to _numWaypoints - 1 do {
_location = _locations call BIS_fnc_selectRandom;
_countWP set [_i, _location];
_locations set [_i, "rem"];
_locations = _locations - ["rem"];
_wp = _unitGroup addWayPoint [position _location,0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
//_wp setWaypointSpeed "FULL";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointCombatMode "YELLOW";
_wp setWaypointCompletionRadius 300;
};
[_difficulty,_msgstart] call wai_server_message;
WAI_MarkerReady = true;
[_position,_mission,_name,_completionType,_color,_showMarker,_msgwin,_msglose,_missionType,_difficulty,_countWP] spawn {
private ["_horb","_crates","_wpReached","_startMarker","_vehicle","_leader","_countWP","_difficulty","_unitGroup","_msgwin","_msglose","_position","_timeout","_player_near","_complete","_starttime","_timeout_time","_max_ai","_killpercent","_mission","_missionType","_airemain","_text","_name","_completionType","_marker","_dot","_color","_showMarker"];
_position = _this select 0;
_mission = _this select 1;
_name = _this select 2;
_completionType = _this select 3;
_color = _this select 4;
_showMarker = _this select 5;
_msgwin = _this select 6;
_msglose = _this select 7;
_missionType = _this select 8;
_difficulty = _this select 9;
_countWP = _this select 10;
_startMarker = false;
_timeout = false;
_player_near = false;
_complete = false;
_starttime = diag_tickTime;
_timeout_time = (random((wai_mission_timeout select 1) - (wai_mission_timeout select 0)) + (wai_mission_timeout select 0)) * 60;
_max_ai = (wai_mission_data select _mission) select 0;
_unitGroup = ((wai_mission_data select _mission) select 1) select 0;
_crates = (wai_mission_data select _mission) select 3;
_vehicle = ((wai_mission_data select _mission) select 5) select 0;
_killpercent = _max_ai - (_max_ai * (wai_kill_percent / 100));
_leader = leader _unitgroup;
_vehicle setDamage 0;
_vehicle removeAllEventHandlers "HandleDamage";
_vehicle addEventHandler ["HandleDamage",{_this call fnc_veh_handleDam}];
_wpReached = true;
_disabled = false;
_currentWP = nil;
_index = 1;
{
if (_leader == _x) then {
_x assignAsDriver _vehicle;
_x moveInDriver _vehicle;
} else {
if ((_vehicle emptyPositions "GUNNER") > 0) then {
_x assignAsGunner _vehicle;
_x moveInGunner _vehicle;
} else {
_x moveInCargo _vehicle;
};
};
} count units _unitgroup;
while {!_timeout && !_complete} do {
if ((count _countWP == 0) && {_wpReached}) then {
_timeout = true;
};
if ((count _countWP > 0) && {_wpReached}) then {
if (!isNil "_currentWP") then {
_countWP set [0, "rem"];
_countWP = _countWP - ["rem"];
};
_unitGroup setCurrentWaypoint [_unitGroup, _index];
_currentWP = _countWP select 0;
_wpReached = false;
uiSleep 10;
[_difficulty,["STR_CL_PATROL_MOVE",(text _currentWP)]] call wai_server_message;
_index = _index + 1;
};
if (_showMarker && {_startMarker}) then {
if (ai_show_count) then {
_aiCount = (wai_mission_data select _mission) select 0;
_text = format["%1 (%2 A.I.)",_name,_aiCount];
} else {
_text = _name;
};
_marker = createMarker [_missionType + str(_mission), _position];
_marker setMarkerColor _color;
_marker setMarkerShape "ELLIPSE";
_marker setMarkerBrush "Solid";
_marker setMarkerSize [300,300];
_dot = createMarker [_missionType + str(_mission) + "dot", _position];
_dot setMarkerColor "ColorBlack";
_dot setMarkerType "mil_dot";
_dot setMarkerText _text;
uiSleep 2;
deleteMarker _marker;
deleteMarker _dot;
} else {
uiSleep 2;
};
if (count crew _vehicle > 0) then {
_vehicle setVehicleAmmo 1;
_vehicle setFuel 1;
};
if (!_disabled && (!(canMove _vehicle) || !(alive _leader))) then {
_horb = if (_missionType == "MainHero") then {"Hero"} else {"Bandit"};
[_difficulty,["STR_CL_PATROL_DISABLED",_horb]] call wai_server_message;
_disabled = true;
_startMarker = true;
_position = getPos _vehicle;
waitUntil {speed _vehicle < 10};
{
_x action ["eject",vehicle _x];
} count crew _vehicle;
_unitGroup2 = createGroup EAST; // Creating a new group seems to be the best solution here
{[_x] joinSilent _unitGroup2} forEach (units _unitGroup);
_unitGroup2 selectLeader ((units _unitGroup2) select 0);
_unitGroup2 setFormation "ECH LEFT";
_unitGroup2 setCombatMode "RED";
_unitGroup2 setBehaviour "COMBAT";
[_unitGroup2,_position,"easy"] call group_waypoints;
};
if (!_wpReached) then {
if (_vehicle distance (position _currentWP) < 300) then {
_wpReached = true;
[_difficulty,["STR_CL_PATROL_ARRIVE",text _currentWP]] call wai_server_message;
};
};
_player_near = [_position,wai_timeout_distance] call isNearPlayer;
if (diag_tickTime - _starttime >= _timeout_time && !_player_near) then {
_timeout = true;
} else {
if (_player_near) then {_starttime = diag_tickTime;};
};
_complete = [_mission,_completionType,_killpercent,_position] call wai_completion_check;
};
if (_complete) then {
[_vehicle,_mission,[[_vehicle]]] call wai_generate_vehicle_key;
_vehicle setVehicleLock "UNLOCKED";
{
[(_x select 0),(_x select 1)] call dynamic_crate;
} count _crates;
[_difficulty,_msgwin] call wai_server_message;
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
diag_log format["WAI: [Mission: %1]: Ended at %2",_name,_position];
if (wai_clean_mission_time > 0) then {
private ["_finish_time","_cleaned","_playernear"];
_finish_time = diag_tickTime;
_cleaned = false;
while {!_cleaned} do {
uiSleep 3;
if (diag_tickTime - _finish_time >= 60*wai_clean_mission_time) then {
_mission call wai_remove_ai;
deleteVehicle _vehicle;
uiSleep 5;
deleteGroup _unitGroup;
if (!isNil "_unitGroup2") then {deleteGroup _unitGroup2;};
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
_cleaned = true;
};
};
};
};
if (_timeout) then {
_mission call wai_remove_ai;
deleteVehicle _vehicle;
[_difficulty,_msglose] call wai_server_message;
if (_missionType == "MainBandit") then {
b_missionsrunning = b_missionsrunning - 1;
wai_b_starttime = diag_tickTime;
} else {
h_missionsrunning = h_missionsrunning - 1;
wai_h_starttime = diag_tickTime;
};
uiSleep 5;
deleteGroup _unitGroup;
if (!isNil "_unitGroup2") then {deleteGroup _unitGroup2;};
wai_mission_markers = wai_mission_markers - [(_missionType + str(_mission))];
wai_mission_data set [_mission, -1];
diag_log format["WAI: [Mission: %1]: Timed out at %2",_name,_position];
};
};

@ -0,0 +1,133 @@
isNearWater = {
private["_result","_position","_radius"];
_result = false;
_position = _this select 0;
_radius = _this select 1;
for "_i" from 0 to 359 step 45 do {
_position = [(_position select 0) + (sin(_i)*_radius), (_position select 1) + (cos(_i)*_radius)];
if (surfaceIsWater _position) exitWith {
_result = true;
};
};
_result
};
isNearTown = {
private["_result","_position","_radius","_locations"];
_result = false;
_position = _this select 0;
_radius = _this select 1;
_locations = [["NameCityCapital","NameCity","NameVillage"],[_position,_radius]] call BIS_fnc_locations;
if (count _locations > 0) then {
_result = true;
};
_result
};
isNearRoad = {
private["_result","_position","_radius","_roads"];
_result = false;
_position = _this select 0;
_radius = _this select 1;
_roads = _position nearRoads _radius;
if (count _roads > 0) then {
_result = true;
};
_result
};
isNearPlayer = {
private["_result","_position","_radius"];
_result = false;
_position = _this select 0;
_radius = _this select 1;
{
if ((isPlayer _x) && (_x distance _position <= _radius)) then {
_result = true;
};
} count playableUnits;
_result
};
// Player and mission proximity check used in single spawn point missions
wai_validSpotCheck = {
private ["_position","_validspot"];
_position = _this select 0;
_validspot = true;
if (_validspot && wai_avoid_missions != 0) then {
if(wai_debug_mode) then { diag_log("WAI DEBUG: FINDPOS: Checking nearby mission markers: " + str(wai_mission_markers)); };
{
if (getMarkerColor _x != "" && (_position distance (getMarkerPos _x) < wai_avoid_missions)) exitWith { if(wai_debug_mode) then {diag_log("WAI: Invalid Position (Marker: " + str(_x) + ")");}; _validspot = false; };
} count wai_mission_markers;
};
if (_validspot && {wai_avoid_players != 0}) then {
if ([_position,wai_avoid_players] call isNearPlayer) then {
if (wai_debug_mode) then {diag_log "WAI: Invalid Position (player)";};
_validspot = false;
};
};
if(_validspot) then {
if(wai_debug_mode) then { diag_log("WAI: valid position found at" + str(_position));};
};
_validspot
};
// Closest player check used in auto-claim
wai_isClosest = {
private ["_closest","_scandist","_dist","_position"];
_position = _this;
_closest = objNull;
_scandist = ac_alert_distance;
{
_dist = vehicle _x distance _position;
if (isPlayer _x && _dist < _scandist) then {
_closest = _x;
_scandist = _dist;
};
} count playableUnits;
_closest
};
wai_checkReturningPlayer = {
private["_acArray","_position","_playerUID","_returningPlayer"];
_position = _this select 0;
_acArray = _this select 1;
_playerUID = _acArray select 0;
_returningPlayer = objNull;
{
if ((isPlayer _x) && (_x distance _position <= ac_alert_distance) && (getplayerUID _x == _playerUID)) then {
_returningPlayer = _x;
};
} count playableUnits;
_returningPlayer
};

@ -0,0 +1,225 @@
private ["_rocket","_launcher","_pos_x","_pos_y","_pos_z","_aiskin","_unarmed","_gain","_mission","_ainum","_aitype","_mission","_aipack","_aicskill","_position","_unitnumber","_skill","_gun","_mags","_backpack","_skin","_gear","_aiweapon","_aigear","_aiskin","_skillarray","_unitGroup","_weapon","_magazine","_gearmagazines","_geartools","_unit"];
_position = _this select 0;
_pos_x = _position select 0;
_pos_y = _position select 1;
_pos_z = _position select 2;
_unitnumber = _this select 1;
_skill = _this select 2;
_gun = _this select 3;
_mags = _this select 4;
_backpack = _this select 5;
_skin = _this select 6;
_gear = _this select 7;
_aitype = _this select 8;
if (typeName _gun == "ARRAY") then {
_launcher = _gun select 1;
_gun = _gun select 0;
};
if (typeName _aitype == "ARRAY") then {
_gain = _aitype select 1;
_aitype = _aitype select 0;
};
if (count _this > 9) then {
_mission = _this select 9;
} else {
_mission = nil;
};
_aiweapon = [];
_aigear = [];
_aiskin = "";
_aicskill = [];
_aipack = "";
_unarmed = false;
// If zero ai are chosen exit the script
if (_unitnumber == 0) exitWith {};
_unitGroup = if(_aitype == "Hero") then {createGroup RESISTANCE;} else {createGroup EAST;};
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _unitGroup];
} else {
(wai_static_data select 1) set [count (wai_static_data select 1), _unitGroup];
};
if(_pos_z == 0) then {
if(floor(random 2) == 1) then {
_pos_x = _pos_x - (15 + random(10));
} else {
_pos_x = _pos_x + (15 + random(10));
};
if(floor(random 2) == 1) then {
_pos_y = _pos_y - (15 + random(10));
} else {
_pos_y = _pos_y + (15 + random(10));
};
};
for "_x" from 1 to _unitnumber do {
call {
if(typeName(_gun) == "SCALAR") then {
if(_gun == 0) exitWith {_aiweapon = ai_wep_random select (floor (random (count ai_wep_random)));};
if(_gun == 1) exitWith {_aiweapon = ai_wep_machine; };
if(_gun == 2) exitWith {_aiweapon = ai_wep_sniper; };
} else {
if(_gun == "random") exitWith {_aiweapon = ai_wep_random select (floor (random (count ai_wep_random)));};
if(_gun == "unarmed") exitWith {_unarmed = true; };
_aiweapon = _gun;
}
};
if (!_unarmed) then {
_weapon = if (typeName (_aiweapon) == "ARRAY") then {_aiweapon select (floor (random (count _aiweapon)))} else {_aiweapon};
if !(isClass (configFile >> "CfgWeapons" >> _weapon)) then {
diag_log text format ["WAI Error: Weapon classname (%1) is not valid!",_weapon];
_weapon = "M16A2_DZ"; // Replace with known good classname.
};
_magazine = _weapon call find_suitable_ammunition;
};
_aigear = call {
if(typeName(_gear) == "SCALAR") then {
if (_gear == 0) exitWith {ai_gear0;};
if (_gear == 1) exitWith {ai_gear1;};
if (_gear == 2) exitWith {ai_gear2;};
if (_gear == 3) exitWith {ai_gear3;};
if (_gear == 4) exitWith {ai_gear4;};
} else {
if (_gear == "random") exitWith {ai_gear_random select (floor (random (count ai_gear_random)));};
};
};
_gearmagazines = _aigear select 0;
_geartools = _aigear select 1;
_aiskin = call {
if (_skin == "random") exitWith {ai_all_skin select (floor (random (count ai_all_skin)));};
if (_skin == "hero") exitWith {ai_hero_skin select (floor (random (count ai_hero_skin)));};
if (_skin == "bandit") exitWith {ai_bandit_skin select (floor (random (count ai_bandit_skin)));};
if (_skin == "special") exitWith {ai_special_skin select (floor (random (count ai_special_skin)));};
_skin;
};
if(typeName _aiskin == "ARRAY") then {
_aiskin = _aiskin select (floor (random (count _aiskin)));
};
_unit = _unitGroup createUnit [_aiskin,_position,[],0,"CAN_COLLIDE"];
if (surfaceIsWater _position) then {
_unit setPosASL _position;
} else {
_unit setPosATL _position;
};
[_unit] joinSilent _unitGroup;
call {
if (_aitype == "hero") exitWith {_unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity];};
if (_aitype == "bandit") exitWith {_unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity];};
if (_aitype == "special") exitWith {_unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity];};
};
if (!isNil "_gain") then {_unit setVariable ["humanity", _gain];};
call {
if (_backpack == "random") exitWith {_aipack = ai_packs select (floor (random (count ai_packs)));};
if (_backpack == "none") exitWith {};
_aipack = _backpack;
};
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
removeAllWeapons _unit;
removeAllItems _unit;
if (sunOrMoon != 1) then {
_unit addWeapon "NVGoggles";
};
if (!_unarmed) then {
for "_i" from 1 to _mags do {
_unit addMagazine _magazine;
};
_unit addWeapon _weapon;
_unit selectWeapon _weapon;
};
if(_backpack != "none") then {
_unit addBackpack _aipack;
};
{
_unit addMagazine _x
} count _gearmagazines;
{
_unit addWeapon _x
} count _geartools;
_aicskill = call {
if(_skill == "easy") exitWith {ai_skill_easy;};
if(_skill == "medium") exitWith {ai_skill_medium;};
if(_skill == "hard") exitWith {ai_skill_hard;};
if(_skill == "extreme") exitWith {ai_skill_extreme;};
if(_skill == "random") exitWith {ai_skill_random select (floor (random (count ai_skill_random)));};
ai_skill_random select (floor (random (count ai_skill_random)));
};
{
_unit setSkill [(_x select 0),(_x select 1)]
} count _aicskill;
_unit addEventHandler ["Killed",{[_this select 0, _this select 1] call on_kill;}];
if (!isNil "_mission") then {
wai_mission_data select _mission set [0, (((wai_mission_data select _mission) select 0) + 1)];
_unit setVariable ["mission" + dayz_serverKey, _mission, false];
} else {
wai_static_data set [0, ((wai_static_data select 0) + 1)];
};
};
if (!isNil "_launcher" && wai_use_launchers) then {
call {
if (_launcher == "Random") exitWith { _launcher = (ai_launchers_AT + ai_launchers_AA) call BIS_fnc_selectRandom; };
if (_launcher == "at") exitWith { _launcher = ai_wep_launchers_AT select (floor (random (count ai_wep_launchers_AT))); };
if (_launcher == "aa") exitWith { _launcher = ai_wep_launchers_AA select (floor (random (count ai_wep_launchers_AA))); };
};
_rocket = _launcher call find_suitable_ammunition;
_unit addMagazine _rocket;
_unit addMagazine _rocket;
_unit addWeapon _launcher;
};
_unitGroup setFormation "ECH LEFT";
_unitGroup selectLeader ((units _unitGroup) select 0);
if(_aitype == "Hero") then {
_unitGroup setCombatMode ai_hero_combatmode;
_unitGroup setBehaviour ai_hero_behaviour;
} else {
_unitGroup setCombatMode ai_bandit_combatmode;
_unitGroup setBehaviour ai_bandit_behaviour;
};
_unitGroup allowFleeing 0;
[_unitGroup,[_pos_x,_pos_y,_pos_z],_skill] call group_waypoints;
if(wai_debug_mode) then {diag_log format ["WAI: Spawned a group of %1 AI (%3) at %2",_unitnumber,_position,_aitype];};
_unitGroup // this variable is returned for the patrol mission and assassinate missions

@ -0,0 +1,63 @@
// This is a modified version of the DayZ Epoch file fn_spawnObjects.sqf used to spawn WAI mission objects.
private ["_offset","_fires","_position","_object","_objects","_type","_pos","_mission","_destructables"];
_objects = _this select 0;
_pos = _this select 1;
_mission = _this select 2;
_fires = [
"Base_Fire_DZ",
"flamable_DZ",
"Land_Camp_Fire_DZ",
"Land_Campfire",
"Land_Campfire_burning",
"Land_Fire",
"Land_Fire_burning",
"Land_Fire_DZ",
"Land_Fire_barrel",
"Land_Fire_barrel_burning",
"Misc_TyreHeap"
];
// Override god mode on these objects so they can be destroyed if wai_godmode_objects enabled.
_destructables = [
"Gold_Vein_DZE",
"Iron_Vein_DZE",
"Silver_Vein_DZE",
"Supply_Crate_DZE"
];
{
_type = _x select 0;
_offset = _x select 1;
_position = [(_pos select 0) + (_offset select 0), (_pos select 1) + (_offset select 1), 0];
if (count _offset > 2) then {
_position set [2, (_offset select 2)];
};
_object = _type createVehicle [0,0,0];
if (_type == "MQ9PredatorB") then {
_object setVehicleLock "LOCKED";
};
if (count _x > 2) then {
_object setDir (_x select 2);
};
_object setPos _position;
_object setVectorUp surfaceNormal position _object;
if (wai_godmode_objects) then {
if !(_type in _destructables) then {
_object addEventHandler ["HandleDamage",{0}];
if !(_type in _fires) then {_object enableSimulation false;};
};
};
((wai_mission_data select _mission) select 6) set [count ((wai_mission_data select _mission) select 6), _object];
} forEach _objects;
_object

@ -0,0 +1,211 @@
private ["_ainum","_unarmed","_aicskill","_aitype","_mission","_aipack","_class","_position2","_static","_position","_unitnumber","_skill","_gun","_mags","_backpack","_skin","_gear","_aiweapon","_aigear","_aiskin","_skillarray","_unitGroup","_weapon","_magazine","_gearmagazines","_geartools","_unit"];
if (!wai_enable_static_guns) exitWith {};
_position = _this select 0;
_class = _this select 1;
_skill = _this select 2;
_skin = _this select 3;
_aitype = _this select 4;
if (ai_static_useweapon) then {
_gun = _this select 5;
_mags = _this select 6;
_backpack = _this select 7;
_gear = _this select 8;
};
if ((count _this == 10) OR (count _this == 6)) then {
if (count _this == 10) then { _mission = _this select 9; };
if (count _this == 6) then { _mission = _this select 5; };
} else {
_mission = nil;
};
_aiweapon = [];
_aigear = [];
_aiskin = "";
_aipack = "";
_unarmed = false;
_unitnumber = count _position;
_unitGroup = if(_aitype == "Hero") then {createGroup RESISTANCE;} else {createGroup EAST;};
if (!isNil "_mission") then {
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _unitGroup];
} else {
(wai_static_data select 1) set [count (wai_static_data select 1), _unitGroup];
};
{
call {
if(_skin == "random") exitWith { _aiskin = ai_all_skin call BIS_fnc_selectRandom;};
if(_skin == "hero") exitWith { _aiskin = ai_hero_skin call BIS_fnc_selectRandom;};
if(_skin == "bandit") exitWith { _aiskin = ai_bandit_skin call BIS_fnc_selectRandom;};
if(_skin == "special") exitWith { _aiskin = ai_special_skin call BIS_fnc_selectRandom;};
_aiskin = _skin;
};
if(typeName _aiskin == "ARRAY") then {
_aiskin = _aiskin call BIS_fnc_selectRandom;
};
if (_class == "Random") then {_class = ai_static_weapons call BIS_fnc_selectRandom;};
_unit = _unitGroup createUnit [_aiskin, [0,0,0], [], 10, "PRIVATE"];
_static = _class createVehicle _x;
if (surfaceIsWater _x) then {
_static setPosASL _x;
} else {
_static setPosATL _x;
};
[_unit] joinSilent _unitGroup;
call {
if (_aitype == "hero") exitWith {_unit setVariable ["Hero",true,false]; _unit setVariable ["humanity", ai_remove_humanity]; };
if (_aitype == "bandit") exitWith {_unit setVariable ["Bandit",true,false]; _unit setVariable ["humanity", ai_add_humanity]; };
if (_aitype == "special") exitWith {_unit setVariable ["Special",true,false]; _unit setVariable ["humanity", ai_special_humanity]; };
};
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
removeAllWeapons _unit;
removeAllItems _unit;
if (ai_static_useweapon) then {
call {
if(typeName(_gun) == "SCALAR") then {
if(_gun == 0) exitWith { _aiweapon = ai_wep_random call BIS_fnc_selectRandom; };
if(_gun == 1) exitWith { _aiweapon = ai_wep_machine;};
if(_gun == 2) exitWith { _aiweapon = ai_wep_sniper;};
} else {
if(_gun == "random") exitWith { _aiweapon = ai_wep_random call BIS_fnc_selectRandom; };
if(_gun == "unarmed") exitWith { _unarmed = true; };
};
};
if (!_unarmed) then {
_weapon = if (typeName (_aiweapon) == "ARRAY") then {_aiweapon select (floor (random (count _aiweapon)))} else {_aiweapon};
_magazine = _weapon call find_suitable_ammunition;
};
_weapon = _aiweapon call BIS_fnc_selectRandom;
if !(isClass (configFile >> "CfgWeapons" >> _weapon)) then {
diag_log text format ["WAI Error: Weapon classname (%1) is not valid!",_weapon];
_weapon = "M16A2_DZ"; // Replace with known good classname.
};
_magazine = _weapon call find_suitable_ammunition;
_aigear = call {
if(typeName(_gear) == "SCALAR") then {
if(_gear == 0) exitWith {ai_gear0;};
if(_gear == 1) exitWith {ai_gear1;};
if(_gear == 2) exitWith {ai_gear2;};
if(_gear == 3) exitWith {ai_gear3;};
if(_gear == 4) exitWith {ai_gear4;};
} else {
if(_gear == "random") exitWith {ai_gear_random select (floor (random (count ai_gear_random)));};
};
};
call {
if(_backpack == "random") exitWith {_aipack = ai_packs call BIS_fnc_selectRandom;};
if(_backpack == "none") exitWith {};
_aipack = _backpack;
};
_gearmagazines = _aigear select 0;
_geartools = _aigear select 1;
if (!_unarmed) then {
for "_i" from 1 to _mags do {
_unit addMagazine _magazine;
};
_unit addWeapon _weapon;
};
if (_backpack != "none") then {
_unit addBackpack _aipack;
};
{
_unit addMagazine _x
} count _gearmagazines;
{
_unit addWeapon _x
} count _geartools;
};
if (ai_static_skills) then {
{
_unit setSkill [(_x select 0),(_x select 1)]
} count ai_static_array;
} else {
_aicskill = call {
if (_skill == "easy") exitWith {ai_skill_easy;};
if (_skill == "medium") exitWith {ai_skill_medium;};
if (_skill == "hard") exitWith {ai_skill_hard;};
if (_skill == "extreme") exitWith {ai_skill_extreme;};
if (_skill == "random") exitWith {ai_skill_random call BIS_fnc_selectRandom; };
ai_skill_random call BIS_fnc_selectRandom;
};
{
_unit setSkill [(_x select 0),(_x select 1)]
} count _aicskill;
};
_unit addEventHandler ["Killed",{[_this select 0, _this select 1] call on_kill;}];
_static addEventHandler ["GetOut",{
_unit = _this select 2;
_static = _this select 0;
if (alive _unit) then {_unit moveInGunner _static};
}];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_static];
if (sunOrMoon != 1) then {
_unit addWeapon "NVGoggles";
};
_unit moveInGunner _static;
_unit setVariable ["noKey",true];
if (!isNil "_mission") then {
_ainum = (wai_mission_data select _mission) select 0;
wai_mission_data select _mission set [0, (_ainum + 1)];
((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _static];
_static setVariable ["mission" + dayz_serverKey, _mission, false];
_unit setVariable ["mission" + dayz_serverKey, _mission, false];
} else {
wai_static_data set [0, ((wai_static_data select 0) + 1)];
(wai_static_data select 2) set [count (wai_static_data select 2), _static];
};
} forEach _position;
_unitGroup selectLeader ((units _unitGroup) select 0);
if(_aitype == "Hero") then {
_unitGroup setCombatMode ai_hero_combatmode;
_unitGroup setBehaviour ai_hero_behaviour;
} else {
_unitGroup setCombatMode ai_bandit_combatmode;
_unitGroup setBehaviour ai_bandit_behaviour;
};
if (wai_debug_mode) then {diag_log format ["WAI: Spawned in %1 %2",_unitnumber,_class];};

@ -0,0 +1,66 @@
// For Reference: wai_static_data = [0,[],[],[]]; [AI Count, UnitGroups, Vehicles to Monitor, crates]
private ["_unitGroups","_aiVehicles","_staticArray","_timeStamp","_running","_crates"];
_timeStamp = diag_tickTime;
_running = true;
// The loop has to wait until there are existing groups to monitor
// 10 seconds initial sleep to allow crates array to populate
waitUntil {uiSleep 10; (count (wai_static_data select 1)) > 0};
// Spawn loot in crates
_crates = wai_static_data select 3;
if (count _crates > 0) then {
{
[(_x select 0),(_x select 1)] call dynamic_crate;
} count _crates;
};
diag_log "WAI: Initializing static missions";
while {_running} do {
// Refuel and Rearm the AI vehicles until they are destroyed
_aiVehicles = wai_static_data select 2;
if(count _aiVehicles > 0) then {
{
if (alive _x && ({alive _x} count crew _x > 0)) then {
_x setVehicleAmmo 1;
_x setFuel 1;
} else {_x setDamage 1;};
} count _aiVehicles;
};
// Static gun glitch fix
if ((diag_tickTime - _timeStamp) > 180 && (count _aiVehicles) > 0) then {
{
if (_x isKindOf "StaticWeapon") then {
(gunner _x) action ["getout",_x];
};
} forEach _aiVehicles;
_timeStamp = diag_tickTime;
};
_unitGroups = wai_static_data select 1;
{
// delete empty groups
if (count units _x == 0) then {
deleteGroup _x
};
// remove null groups from the array
if (isNull _x) then {
_unitGroups = _unitGroups - [_x];
};
} forEach _unitGroups;
//diag_log _unitGroups; // Used for testing
// When all null groups have been removed from the array, shut the loop down
if (count _unitGroups == 0) then {_running = false;};
uiSleep 5;
};
diag_log "WAI: All Static Spawns have been killed.";

@ -0,0 +1,148 @@
if (!wai_enable_patrols) exitWith {};
local _position = _this select 0;
local _startingpos = _this select 1;
local _radius = _this select 2;
local _wpnum = _this select 3;
local _veh_class = _this select 4;
local _skill = _this select 5;
local _skin = _this select 6;
local _aitype = _this select 7;
local _mission = nil;
if (count _this > 8) then {
_mission = _this select 8;
};
local _unitGroup = grpNull;
local _wp = [];
local _aicskill = call {
if(_skill == "easy") exitWith {ai_skill_easy;};
if(_skill == "medium") exitWith {ai_skill_medium;};
if(_skill == "hard") exitWith {ai_skill_hard;};
if(_skill == "extreme") exitWith {ai_skill_extreme;};
if(_skill == "random") exitWith {ai_skill_random call BIS_fnc_selectRandom;};
ai_skill_random call BIS_fnc_selectRandom;
};
local _aiskin = call {
if(_skin == "random") exitWith {ai_all_skin call BIS_fnc_selectRandom;};
if(_skin == "hero") exitWith {ai_hero_skin call BIS_fnc_selectRandom;};
if(_skin == "bandit") exitWith {ai_bandit_skin call BIS_fnc_selectRandom;};
if(_skin == "special") exitWith {ai_special_skin call BIS_fnc_selectRandom;};
_skin;
};
if(typeName _aiskin == "ARRAY") then {
_aiskin = _aiskin call BIS_fnc_selectRandom;
};
if(_aitype == "Hero") then {
_unitGroup = createGroup RESISTANCE;
} else {
_unitGroup = createGroup EAST;
};
local _driver = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
[_driver] joinSilent _unitGroup;
call {
if (_aitype == "hero") exitWith {_driver setVariable ["Hero",true,false]; _driver setVariable ["humanity", ai_remove_humanity];};
if (_aitype == "bandit") exitWith {_driver setVariable ["Bandit",true,false]; _driver setVariable ["humanity", ai_add_humanity];};
if (_aitype == "special") exitWith {_driver setVariable ["Special",true,false]; _driver setVariable ["humanity", ai_special_humanity];};
};
local _vehicle = createVehicle [_veh_class, [(_startingpos select 0),(_startingpos select 1), 0], [], 0, "CAN_COLLIDE"];
_vehicle setFuel 1;
_vehicle engineOn true;
_vehicle setVehicleAmmo 1;
_vehicle allowCrewInImmobile true;
_vehicle lock true;
_vehicle addEventHandler ["GetOut",{
local _veh = _this select 0;
local _role = _this select 1;
local _unit = _this select 2;
if (_role == "driver") then {
_unit moveInDriver _veh;
} else {
_unit moveInTurret [_veh,[0]];
};
}];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_vehicle];
_driver assignAsDriver _vehicle;
_driver moveInDriver _vehicle;
local _gunner = _unitGroup createUnit [_aiskin, [0,0,0], [], 1, "NONE"];
_gunner assignAsGunner _vehicle;
_gunner moveInTurret [_vehicle,[0]];
[_gunner] joinSilent _unitGroup;
[_driver, _gunner] orderGetIn true;
call {
if (_aitype == "hero") exitWith {_gunner setVariable ["Hero",true,false]; _gunner setVariable ["humanity", ai_remove_humanity];};
if (_aitype == "bandit") exitWith {_gunner setVariable ["Bandit",true,false]; _gunner setVariable ["humanity", ai_add_humanity];};
if (_aitype == "special") exitWith {_gunner setVariable ["Special",true,false]; _gunner setVariable ["humanity", ai_special_humanity];};
};
{
_gunner setSkill [(_x select 0),(_x select 1)];
} count _aicskill;
{
_driver setSkill [_x,1];
} count ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
{
_x addWeapon "Makarov_DZ";
_x addMagazine "8Rnd_9x18_Makarov";
_x addMagazine "8Rnd_9x18_Makarov";
} count (units _unitgroup);
{
_x addEventHandler ["Killed",{[_this select 0, _this select 1, "vehicle"] call on_kill;}];
} forEach (units _unitgroup);
if (!isNil "_mission") then {
_vehicle setVariable ["mission" + dayz_serverKey, _mission, false];
((wai_mission_data select _mission) select 1) set [count ((wai_mission_data select _mission) select 1), _unitGroup];
((wai_mission_data select _mission) select 4) set [count ((wai_mission_data select _mission) select 4), _vehicle];
{
_ainum = (wai_mission_data select _mission) select 0;
wai_mission_data select _mission set [0, (_ainum + 1)];
_x setVariable ["mission" + dayz_serverKey, _mission, false];
_x setVariable ["noKey",true];
} count (crew _vehicle);
} else {
{wai_static_data set [0, ((wai_static_data select 0) + 1)];} count (crew _vehicle);
(wai_static_data select 1) set [count (wai_static_data select 1), _unitGroup];
(wai_static_data select 2) set [count (wai_static_data select 2), _vehicle];
};
_unitGroup allowFleeing 0;
if(_aitype == "Hero") then {
_unitGroup setCombatMode ai_hero_combatmode;
_unitGroup setBehaviour ai_hero_behaviour;
} else {
_unitGroup setCombatMode ai_bandit_combatmode;
_unitGroup setBehaviour ai_bandit_behaviour;
};
if(_wpnum > 0) then {
for "_x" from 1 to _wpnum do
{
_wp = _unitGroup addWaypoint [[(_position select 0),(_position select 1),0],_radius];
_wp setWaypointType "SAD";
_wp setWaypointCompletionRadius 200;
};
};
_wp = _unitGroup addWaypoint [[(_position select 0),(_position select 1),0],100];
_wp setWaypointType "CYCLE";
_wp setWaypointCompletionRadius 200;
_unitGroup