This commit is contained in:
2022-04-21 16:15:41 +03:00
commit 9d4fc88901
601 changed files with 66252 additions and 0 deletions

View File

@ -0,0 +1,200 @@
//Function frequency definitions
#define CLEANDEAD_FREQ 600
#define VEHICLE_CLEANUP_FREQ 900
#define LOCATION_CLEANUP_FREQ 360
#define RANDSPAWN_CHECK_FREQ 360
#define RANDSPAWN_EXPIRY_TIME 1080
#define SIDECHECK_TIME 900
if (DZAI_debugLevel > 0) then {diag_log "DZAI Server Monitor will start in 1 minute."};
//Initialize timer variables
_cleanDead = diag_tickTime;
_monitorReport = diag_tickTime;
_deleteObjects = diag_tickTime;
_dynLocations = diag_tickTime;
_checkRandomSpawns = diag_tickTime;
_sideCheck = diag_tickTime;
//Define settings
_reportDynOrVehicles = (DZAI_dynAISpawns || ((DZAI_maxHeliPatrols > 0) or {(DZAI_maxLandPatrols > 0)}) || (DZAI_maxRandomSpawns > 0));
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
//Local functions
_getUptime = {
private ["_currentSec","_outSec","_outMin","_outHour"];
_currentSec = diag_tickTime;
_outHour = floor (_currentSec/3600);
_outMin = floor ((_currentSec - (_outHour*3600))/60);
_outSec = floor (_currentSec - (_outHour*3600) - (_outMin*60));
[_outHour,_outMin,_outSec]
};
_purgeEH = {
{_this removeAllEventHandlers _x} count ["Killed","HandleDamage","GetIn","GetOut","Fired"];
};
uiSleep 60;
while {true} do {
//Main cleanup loop
if ((diag_tickTime - _cleanDead) > CLEANDEAD_FREQ) then {
_bodiesCleaned = 0;
_vehiclesCleaned = 0;
_nullObjects = 0;
//Body/vehicle cleanup loop
{
_deathTime = _x getVariable "DZAI_deathTime";
/*
if (!isNil "_deathTime") then {
diag_log format ["DZAI Cleanup Debug: Checking unit %1 (%2). diag_tickTime: %3. deathTime: %4.",_x,typeOf _x,diag_tickTime,_deathTime];
diag_log format ["DZAI Cleanup Debug: is CAManBase: %1. Timer complete: %2. No players: %3.",(_x isKindOf "CAManBase"),((diag_tickTime - _deathTime) > DZAI_cleanupDelay),(({isPlayer _x} count (_x nearEntities [["CAManBase","AllVehicles"],30])) == 0)];
};*/
if (!isNil "_deathTime") then {
if (_x isKindOf "CAManBase") then {
//diag_log "DZAI Cleanup Debug: Unit type is CAManBase";
if ((diag_tickTime - _deathTime) > DZAI_cleanupDelay) then {
//diag_log "DZAI Cleanup Debug: Timer complete, checking for nearby players";
if (({isPlayer _x} count (_x nearEntities [["CAManBase","AllVehicles"],30])) == 0) then {
//diag_log "DZAI Cleanup Debug: No nearby players. Deleting unit";
_soundflies = _x getVariable "sound_flies";
if (!isNil "_soundflies") then {
detach _soundflies;
deleteVehicle _soundflies;
};
_x call _purgeEH;
//diag_log format ["DEBUG :: Deleting object %1 (type: %2).",_x,typeOf _x];
deleteVehicle _x;
_bodiesCleaned = _bodiesCleaned + 1;
};
};
} else {
if (_x isKindOf "AllVehicles") then {
if ((diag_tickTime - _deathTime) > VEHICLE_CLEANUP_FREQ) then {
if (({isPlayer _x} count (_x nearEntities [["CAManBase","AllVehicles"],75])) == 0) then {
if (_x in DZAI_monitoredObjects) then {
{
if (!(alive _x)) then {
deleteVehicle _x;
};
} forEach (crew _x);
//diag_log format ["DEBUG :: Object %1 (type: %2) found in server object monitor.",_x,typeOf _x];
};
_x call _purgeEH;
//diag_log format ["DEBUG :: Deleting object %1 (type: %2).",_x,typeOf _x];
deleteVehicle _x;
_vehiclesCleaned = _vehiclesCleaned + 1;
};
};
};
};
};
uiSleep 0.025;
} count allDead;
//Clean abandoned AI vehicles
{
if (!isNull _x) then {
private ["_deathTime"];
_deathTime = _x getVariable "DZAI_deathTime";
if (!isNil "_deathTime") then {
if ((diag_tickTime - _deathTime) > VEHICLE_CLEANUP_FREQ) then {
_x call _purgeEH;
//diag_log format ["DEBUG :: Deleting object %1 (type: %2).",_x,typeOf _x];
{
if (!alive _x) then {
deleteVehicle _x;
};
} forEach (crew _x);
deleteVehicle _x;
_vehiclesCleaned = _vehiclesCleaned + 1;
_nullObjects = _nullObjects + 1;
};
};
} else {
_nullObjects = _nullObjects + 1;
};
uiSleep 0.025;
} count DZAI_monitoredObjects;
//Clean server object monitor
if (_nullObjects > 4) then {
missionNamespace setVariable [DZAI_serverObjectMonitor,((missionNamespace getVariable DZAI_serverObjectMonitor) - [objNull])];
DZAI_monitoredObjects = DZAI_monitoredObjects - [objNull];
diag_log format ["DZAI Cleanup: Cleaned up %1 null objects from server object monitor.",_nullObjects];
};
if ((_bodiesCleaned + _vehiclesCleaned) > 0) then {diag_log format ["DZAI Cleanup: Cleaned up %1 dead units and %2 destroyed vehicles.",_bodiesCleaned,_vehiclesCleaned]};
_cleanDead = diag_tickTime;
};
//Main location cleanup loop
if ((diag_tickTime - _dynLocations) > LOCATION_CLEANUP_FREQ) then {
_locationsDeleted = 0;
DZAI_tempBlacklist = DZAI_tempBlacklist - [locationNull];
//diag_log format ["DEBUG :: DZAI_tempBlacklist: %1",DZAI_tempBlacklist];
{
_deletetime = _x getVariable "deletetime";
if (diag_tickTime > _deletetime) then {
deleteLocation _x;
_locationsDeleted = _locationsDeleted + 1;
};
uiSleep 0.025;
} count DZAI_tempBlacklist;
DZAI_tempBlacklist = DZAI_tempBlacklist - [locationNull];
if (_locationsDeleted > 0) then {diag_log format ["DZAI Cleanup: Cleaned up %1 expired temporary blacklist areas.",_locationsDeleted]};
_dynLocations = diag_tickTime;
};
if ((diag_tickTime - _checkRandomSpawns) > RANDSPAWN_CHECK_FREQ) then {
DZAI_randTriggerArray = DZAI_randTriggerArray - [objNull];
{
if ((((triggerStatements _x) select 1) != "") && {(diag_tickTime - (_x getVariable ["timestamp",diag_tickTime])) > RANDSPAWN_EXPIRY_TIME}) then {
deleteLocation (_x getVariable ["triggerLocation",locationNull]);
if (_debugMarkers) then {deleteMarker (str _x)};
deleteVehicle _x;
};
if ((_forEachIndex % 3) == 0) then {uiSleep 0.05};
} forEach DZAI_randTriggerArray;
DZAI_randTriggerArray = DZAI_randTriggerArray - [objNull];
_spawnsAvailable = DZAI_maxRandomSpawns - (count DZAI_randTriggerArray);
if (_spawnsAvailable > 0) then {
_nul = _spawnsAvailable spawn DZAI_createRandomSpawns;
};
_checkRandomSpawns = diag_tickTime;
};
if ((diag_tickTime - _sideCheck) > SIDECHECK_TIME) then {
if ((east getFriend west) > 0) then {
east setFriend [west, 0];
};
if ((west getFriend east) > 0) then {
west setFriend [east,0];
};
_sideCheck = diag_tickTime;
};
if (_debugMarkers) then {
{
if ((getMarkerColor _x) != "") then {
_x setMarkerPos (getMarkerPos _x);
} else {
DZAI_mapMarkerArray set [_forEachIndex,""];
};
if ((_forEachIndex % 3) == 0) then {uiSleep 0.05};
} forEach DZAI_mapMarkerArray;
DZAI_mapMarkerArray = DZAI_mapMarkerArray - [""];
};
//Report statistics to RPT log
if ((DZAI_monitorRate > 0) && {((diag_tickTime - _monitorReport) > DZAI_monitorRate)}) then {
_uptime = [] call _getUptime;
diag_log format ["DZAI Monitor :: Server Uptime: %1:%2:%3. Active AI Groups: %4.",_uptime select 0, _uptime select 1, _uptime select 2,({!isNull _x} count DZAI_activeGroups)];
diag_log format ["DZAI Monitor :: Static Spawns: %1. Respawn Queue: %2 groups queued.",(count DZAI_staticTriggerArray),(count DZAI_respawnQueue)];
if (_reportDynOrVehicles) then {diag_log format ["DZAI Monitor :: Dynamic Spawns: %1. Random Spawns: %2. Air Patrols: %3. Land Patrols: %4.",(count DZAI_dynTriggerArray),(count DZAI_randTriggerArray),DZAI_curHeliPatrols,DZAI_curLandPatrols];};
_monitorReport = diag_tickTime;
};
uiSleep 30;
};

View File

@ -0,0 +1,148 @@
/*
DZAI Startup
Description: Handles post-initialization tasks and starts DZAI cleanup procedure
Last updated: 12:11 AM 6/17/2014
*/
if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: DZAI Startup is running required script files..."};
//Set internal-use variables
DZAI_weaponGrades = [0,1,2,3]; //All possible weapon grades (does not include custom weapon grades). A "weapon grade" is a tiered classification of gear. 0: Civilian, 1: Military, 2: MilitarySpecial, 3: Heli Crash. Weapon grade also influences the general skill level of the AI unit.
DZAI_weaponGradesAll = [0,1,2,3,4,5,6,7,8,9]; //All possible weapon grades (including custom weapon grades).
DZAI_curHeliPatrols = 0; //Current number of active air patrols
DZAI_curLandPatrols = 0; //Current number of active land patrols
DZAI_dynTriggerArray = []; //List of all generated dynamic triggers.
DZAI_staticTriggerArray = []; //List of all static triggers
DZAI_respawnQueue = []; //Queue of AI groups that require respawning. Group ID is removed from queue after it is respawned.
DZAI_gradeIndices0 = [];
DZAI_gradeIndices1 = [];
DZAI_gradeIndices2 = [];
DZAI_gradeIndices3 = [];
DZAI_gradeIndicesDyn = [];
DZAI_dynEquipType = 4;
DZAI_tempBlacklist = []; //Queue of temporary dynamic spawn area blacklists for deletion
DZAI_reinforcePlaces = []; //AI helicopter patrols will periodically check this array for dynamic trigger objects to use as reinforcement positions.
DZAI_checkedClassnames = [[],[],[]]; //Classnames verified - Weapons/Magazines/Vehicles
DZAI_invalidClassnames = [[],[],[]]; //Classnames known as invalid - Weapons/Magazines/Vehicles
DZAI_respawnTimeVariance = (abs (DZAI_respawnTimeMax - DZAI_respawnTimeMin));
DZAI_respawnTimeVarAir = (abs (DZAI_respawnTMaxA - DZAI_respawnTMinA));
DZAI_respawnTimeVarLand = (abs (DZAI_respawnTMaxL - DZAI_respawnTMinL));
DZAI_baseBlood = (DZAI_unitBloodLevel select 0);
DZAI_bonusBlood = ((DZAI_unitBloodLevel select 1) - (DZAI_unitBloodLevel select 0));
DZAI_customSpawnQueue = [];
DZAI_serverObjectMonitorArray = []; //dummy array in case DayZ's server object monitor can't be found
DZAI_monitoredObjects = []; //used to cleanup AI vehicles that may not be destroyed.
DZAI_activeGroups = [];
DZAI_locations = [];
DZAI_locationsLand = [];
DZAI_heliTypesUsable = [];
DZAI_vehTypesUsable = [];
DZAI_randTriggerArray = [];
DZAI_mapMarkerArray = [];
if (DZAI_verifyTables) then {
DZAI_tableChecklist = ["DZAI_Rifles0","DZAI_Rifles1","DZAI_Rifles2","DZAI_Rifles3","DZAI_Pistols0","DZAI_Pistols1","DZAI_Pistols2","DZAI_Pistols3",
"DZAI_Backpacks0","DZAI_Backpacks1","DZAI_Backpacks2","DZAI_Backpacks3","DZAI_Edibles","DZAI_Medicals1","DZAI_Medicals2",
"DZAI_MiscItemS","DZAI_MiscItemL","DZAI_BanditTypes","DZAI_launcherTypes"];
};
//Create gamelogic to act as default trigger object if AI is spawned without trigger object specified (ie: for custom vehicle AI groups)
_nul = [] spawn {
DZAI_defaultTrigger = createTrigger ["EmptyDetector",(getMarkerPos 'center')];
DZAI_defaultTrigger setVariable ["isCleaning",true];
DZAI_defaultTrigger setVariable ["patrolDist",100];
DZAI_defaultTrigger setVariable ["equipType",1];
DZAI_defaultTrigger setVariable ["locationArray",[]];
DZAI_defaultTrigger setVariable ["maxUnits",[0,0]];
DZAI_defaultTrigger setVariable ["GroupSize",0];
DZAI_defaultTrigger setVariable ["initialized",true];
DZAI_defaultTrigger setTriggerText "Default Trigger Object";
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Default trigger check result: %1",[!(isNull DZAI_defaultTrigger),(typeOf DZAI_defaultTrigger),(getPosASL DZAI_defaultTrigger)]]};
};
//Configure AI health system
if (isNil "DZAI_useHealthSystem") then {DZAI_useHealthSystem = true};
if (DZAI_useHealthSystem) then {
DZAI_healthType = "HandleDamage"; //DZAI will manage individual unit health and death.
DZAI_healthStatements = if (isNil "DDOPP_taser_handleHit") then {"_this call DZAI_AI_handledamage"} else {"_this call DDOPP_taser_handleHit;_this call DZAI_AI_handledamage"}; //Check if DDOP Taser Mod is installed
} else {
DZAI_healthType = "Killed"; //DZAI will process individual unit deaths only.
DZAI_healthStatements = "_this call DZAI_unitDeath;";
};
//Find DayZ server object monitor (to prevent AI vehicles from being destroyed due to hacker check)
DZAI_serverObjectMonitor = call {
if (!isNil "dayz_serverObjectMonitor") exitWith {"dayz_serverObjectMonitor"};
"DZAI_serverObjectMonitorArray"
};
[] call compile preprocessFileLineNumbers format ["%1\scripts\buildWeightedTables.sqf",DZAI_directory];
//If serverside object patch enabled, then spawn in serverside objects.
if (DZAI_objPatch) then {
_nul = [] execVM format ['%1\scripts\buildingpatch_all.sqf',DZAI_directory];
};
//Build DZAI weapon classname tables from CfgBuildingLoot data if DZAI_dynamicWeapons = true;
if (DZAI_dynamicWeaponList) then {
_weaponlist = [] execVM format ['%1\scripts\buildWeaponArrays.sqf',DZAI_directory]; //Overwrite default weapon tables with classnames found in DayZ's loot tables.
waitUntil {uiSleep 0.25; scriptDone _weaponlist};
} else {
DZAI_weaponsInitialized = true; //Use default weapon tables defined in global_classnames.sqf
};
//Load additional classname configuration from per-map config file. Weapons are read from loot tables so they are not included here
if (!isNil "DZAI_BanditTypesNew") then {[DZAI_BanditTypes,DZAI_BanditTypesNew] call DZAI_append};
if (!isNil "DZAI_Backpacks0New") then {[DZAI_Backpacks0,DZAI_Backpacks0New] call DZAI_append};
if (!isNil "DZAI_Backpacks1New") then {[DZAI_Backpacks1,DZAI_Backpacks1New] call DZAI_append};
if (!isNil "DZAI_Backpacks2New") then {[DZAI_Backpacks2,DZAI_Backpacks2New] call DZAI_append};
if (!isNil "DZAI_Backpacks3New") then {[DZAI_Backpacks3,DZAI_Backpacks3New] call DZAI_append};
if (!isNil "DZAI_EdiblesNew") then {[DZAI_Edibles,DZAI_EdiblesNew] call DZAI_append};
if (!isNil "DZAI_Medicals1New") then {[DZAI_Medicals1,DZAI_Medicals1New] call DZAI_append};
if (!isNil "DZAI_Medicals2New") then {[DZAI_Medicals2,DZAI_Medicals2New] call DZAI_append};
if (!isNil "DZAI_MiscItemSNew") then {[DZAI_MiscItemS,DZAI_MiscItemSNew] call DZAI_append};
if (!isNil "DZAI_MiscItemLNew") then {[DZAI_MiscItemL,DZAI_MiscItemLNew] call DZAI_append};
//Check classname tables if enabled
if (DZAI_verifyTables) then {
_verify = [] execVM format ["%1\scripts\verifyTables.sqf",DZAI_directory];
waitUntil {uiSleep 0.5; scriptDone _verify}; //wait for verification to complete before proceeding
} else {
DZAI_classnamesVerified = true; //skip classname verification if disabled
};
//Build map location list. If using an unknown map, DZAI will automatically generate basic static triggers at cities and towns.
_nul = [] execVM format ['%1\scripts\setup_locations.sqf',DZAI_directory];
uiSleep 0.1;
if (DZAI_dynAISpawns) then {
if ((count DZAI_dynAreaBlacklist) > 0) then {
_nul = [] execVM format ['%1\scripts\setup_blacklist_areas.sqf',DZAI_directory];
};
if (DZAI_freshSpawnSafeArea) then {
_nul = [] execVM format ['%1\scripts\setup_playerspawn_areas.sqf',DZAI_directory];
};
_dynManagerV2 = [] execVM format ['%1\scripts\dynamicSpawn_manager.sqf',DZAI_directory];
};
if ((DZAI_maxHeliPatrols > 0) or {(DZAI_maxLandPatrols > 0)}) then {
_nul = [] execVM format ['%1\scripts\setup_veh_patrols.sqf',DZAI_directory];
};
_nul = [] spawn {
//diag_log "DEBUG :: Waiting for custom spawn config to be loaded.";
waitUntil {uiSleep 1; !isNil "DZAI_customSpawnsReady"};
if ((count DZAI_customSpawnQueue) == 0) exitWith {};
//diag_log format ["DEBUG :: Custom vehicle spawn queue contents: %1",DZAI_customSpawnQueue];
{
_nul = _x spawn DZAI_spawnVehicle_custom;
uiSleep 1;
} forEach DZAI_customSpawnQueue;
DZAI_customSpawnQueue = nil; //Cleanup used functions
DZAI_customSpawnsReady = nil;
DZAI_spawn_vehicle = nil;
};
_nul = [] execVM format ['%1\scripts\DZAI_serverMonitor.sqf',DZAI_directory];

View File

@ -0,0 +1,151 @@
/*
buildWeaponArrays
Description: Do not edit anything in this file unless instructed by the developer.
Last updated: 11:53 AM 6/25/2014
*/
private ["_bldgClasses","_lootItem","_aiWeaponBanList","_lootList","_cfgBuildingLoot","_startTime","_lootConfigFile"];
if (!isNil "DZAI_weaponsInitialized") exitWith {};
_startTime = diag_tickTime;
_lootConfigFile = if !((DZAI_customLootTables) && {(isClass (missionConfigFile >> "CfgBuildingLoot"))}) then {
if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: Building DZAI weapon arrays using CfgBuildingLoot data."};
configFile
} else {
if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: Building DZAI weapon arrays using custom CfgBuildingLoot data."};
missionConfigFile
};
_bldgClasses = [
["Residential","Farm"], //weapongrade 0
["Military"], //weapongrade 1
["MilitarySpecial"], //weapongrade 2
["HeliCrash"]]; //weapongrade 3
//Built-in weapon ban list for melee weapons and nonweapon items
_aiWeaponBanList =
[
"Crossbow_DZ","Crossbow","MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeBaseball","MeleeBaseBallBat","MeleeBaseBallBatBarbed","MeleeBaseBallBatNails","Chainsaw", //Melee weapons
"ItemMap","Binocular","ItemWatch","ItemCompass","ItemFlashlight","ItemKnife","NVGoggles","ItemGPS","ItemEtool","Binocular_Vector","ItemMatchbox","ItemToolbox", //Non-weapon items
"ItemKeyKit","ItemMatchbox" //Epoch items
];
//Add user-specified banned weapons to DZAI weapon banlist.
{
if !(_x in _aiWeaponBanList) then {
_aiWeaponBanList set [count _aiWeaponBanList,_x];
};
} count DZAI_banAIWeapons;
DZAI_banAIWeapons = nil;
//diag_log format ["DEBUG :: List of weapons to be removed from DZAI classname tables: %1",_aiWeaponBanList];
//Compatibility with Namalsk's selectable loot table feature.
if (isNil "dayzNam_buildingLoot") then {
_cfgBuildingLoot = "cfgBuildingLoot";
if (isClass (_lootConfigFile >> _cfgBuildingLoot >> "Barracks")) then {
(_bldgClasses select 2) set [((_bldgClasses select 2) find "MilitarySpecial"),"Barracks"];
};
} else {
_cfgBuildingLoot = dayzNam_buildingLoot;
(_bldgClasses select 3) set [((_bldgClasses select 3) find "HeliCrash"),"HeliCrashNamalsk"];
};
//diag_log format ["DEBUG :: _cfgBuildingLoot: %1",_cfgBuildingLoot];
//Compatibility with DayZ 1.7.7's new HeliCrash tables
if ((isClass (_lootConfigFile >> _cfgBuildingLoot >> "HeliCrashWEST")) && {(isClass (_lootConfigFile >> _cfgBuildingLoot >> "HeliCrashEAST"))}) then {
_bldgClasses set [3,["HeliCrashWEST","HeliCrashEAST"]];
//diag_log format ["DEBUG :: HeliCrash tables modified: %1",(_bldgClasses select 3)];
};
_lootList = call {
if (isArray (_lootConfigFile >> _cfgBuildingLoot >> "Default" >> "lootTypeSmall")) exitWith {["lootType","lootTypeSmall"]}; //Epoch 1.0.5 new loot table structure
if (isArray (_lootConfigFile >> _cfgBuildingLoot >> "Default" >> "lootType")) exitWith {["lootType"]}; //DayZ 1.8.1 and pre-Epoch 1.0.5 loot table structure
["itemType"] //Old DayZ loot table structure.
};
//diag_log format ["DEBUG :: _lootList: %1",_lootList];
//Declare all temporary DZAI weapon arrays. DO NOT EDIT.
_DZAI_Pistols0_temp = [];
_DZAI_Pistols1_temp = [];
_DZAI_Pistols2_temp = [];
_DZAI_Pistols3_temp = [];
_DZAI_Rifles0_temp = [];
_DZAI_Rifles1_temp = [];
_DZAI_Rifles2_temp = [];
_DZAI_Rifles3_temp = [];
//Build the weapon arrays.
for "_i" from 0 to (count _bldgClasses - 1) do { //_i = weapongrade
for "_j" from 0 to (count (_bldgClasses select _i) - 1) do { //If each weapongrade has more than 1 building class, investigate them all
_bldgLoot = [];
{
_bldgLoot = _bldgLoot + (getArray (_lootConfigFile >> _cfgBuildingLoot >> ((_bldgClasses select _i) select _j) >> _x));
} count _lootList;
{
call {
if ((_x select 1) == "weapon") exitWith {
_weaponItem = _x select 0;
if (!(_weaponItem in _aiWeaponBanList)) then {
_itemType = (getNumber (configFile >> "CfgWeapons" >> _weaponItem >> "type"));
call {
if (_itemType == 1) exitWith {
call compile format ["_DZAI_Rifles%1_temp set [(count _DZAI_Rifles%1_temp),'%2'];",_i,_weaponItem]
};
if (_itemType == 2) exitWith {
call compile format ["_DZAI_Pistols%1_temp set [(count _DZAI_Pistols%1_temp),'%2'];",_i,_weaponItem];
};
};
};
};
if ((_x select 1) == "cfglootweapon") exitWith {
{
_weaponItem = _x select 0;
if (!(_weaponItem in _aiWeaponBanList)) then {
_itemType = (getNumber (configFile >> "CfgWeapons" >> _weaponItem >> "type"));
call {
if (_itemType == 1) exitWith {
call compile format ["_DZAI_Rifles%1_temp set [(count _DZAI_Rifles%1_temp),'%2'];",_i,_weaponItem]
};
if (_itemType == 2) exitWith {
call compile format ["_DZAI_Pistols%1_temp set [(count _DZAI_Pistols%1_temp),'%2'];",_i,_weaponItem];
};
};
};
} count (getArray (_lootConfigFile >> "cfgLoot" >> (_x select 0)));
};
};
} forEach _bldgLoot;
};
};
//Redefine each prebuilt weapon array if new table is not empty
if ((count _DZAI_Pistols0_temp) > 0) then {DZAI_Pistols0 = _DZAI_Pistols0_temp};
if ((count _DZAI_Pistols1_temp) > 0) then {DZAI_Pistols1 = _DZAI_Pistols1_temp}; //else {DZAI_Pistols1 = [] + DZAI_Pistols0};
if ((count _DZAI_Pistols2_temp) > 0) then {DZAI_Pistols2 = _DZAI_Pistols2_temp}; //else {DZAI_Pistols2 = [] + DZAI_Pistols1};
if ((count _DZAI_Pistols3_temp) > 0) then {DZAI_Pistols3 = _DZAI_Pistols3_temp} else {DZAI_Pistols3 = [] + DZAI_Pistols2};
if ((count _DZAI_Rifles0_temp) > 0) then {DZAI_Rifles0 = _DZAI_Rifles0_temp};
if ((count _DZAI_Rifles1_temp) > 0) then {DZAI_Rifles1 = _DZAI_Rifles1_temp}; //else {DZAI_Rifles1 = [] + DZAI_Rifles0};
if ((count _DZAI_Rifles2_temp) > 0) then {DZAI_Rifles2 = _DZAI_Rifles2_temp}; //else {DZAI_Rifles2 = [] + DZAI_Rifles1};
if ((count _DZAI_Rifles3_temp) > 0) then {DZAI_Rifles3 = _DZAI_Rifles3_temp} else {DZAI_Rifles3 = [] + DZAI_Rifles2};
if (DZAI_debugLevel > 0) then {
if (DZAI_debugLevel > 1) then {
//Display finished weapon arrays
diag_log format ["Contents of DZAI_Pistols0: %1",DZAI_Pistols0];
diag_log format ["Contents of DZAI_Pistols1: %1",DZAI_Pistols1];
diag_log format ["Contents of DZAI_Pistols2: %1",DZAI_Pistols2];
diag_log format ["Contents of DZAI_Pistols3: %1",DZAI_Pistols3];
diag_log format ["Contents of DZAI_Rifles0: %1",DZAI_Rifles0];
diag_log format ["Contents of DZAI_Rifles1: %1",DZAI_Rifles1];
diag_log format ["Contents of DZAI_Rifles2: %1",DZAI_Rifles2];
diag_log format ["Contents of DZAI_Rifles3: %1",DZAI_Rifles3];
};
diag_log format ["DZAI Debug: Weapon classname tables created in %1 seconds.",(diag_tickTime - _startTime)];
};
DZAI_weaponsInitialized = true;

View File

@ -0,0 +1,63 @@
private ["_startTime","_getWeightedIndices"];
_startTime = diag_tickTime;
//Function exerpt from fn_selectRandomWeighted.sqf written by Joris-Jan van 't Land
_getWeightedIndices = {
private ["_array", "_weights","_index","_weighted","_i"];
_array = _this select 0;
_weights = _this select 1;
//Parameter validation.
if ((typeName _array) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Array (0) must be an Array!"; nil};
if ((typeName _weights) != (typeName [])) exitWith {debugLog "Log: [selectRandomWeighted] Weights (1) must be an Array!"; nil};
if ((count _array) > (count _weights)) exitWith {debugLog "Log: [selectRandomWeighted] There must be at least as many elements in Weights (1) as there are in Array (0)!"; nil};
//Created weighted array of indices.
private ["_weighted"];
_weighted = [];
for "_i" from 0 to ((count _weights) - 1) do
{
private ["_weight"];
_weight = _weights select _i;
//Ensure the weight is a Number.
//If it's not, set weight to 0 to exclude it.
if ((typeName _weight) != (typeName 0)) then {debugLog "Log: [selectRandomWeighted] Weights should be Numbers; weight set to 0!"; _weight = 0};
//The weight should be a Number between 0 and 1.
if (_weight < 0) then {debugLog "Log: [selectRandomWeighted] Weights should be more than or equal to 0; weight set to 0!"; _weight = 0};
//if (_weight > 1) then {debugLog "Log: [selectRandomWeighted] Weights should be less than or equal to 1; weight set to 1!"; _weight = 1};
//Normalize the weight for a precision of hundreds.
_weight = round(_weight * 100);
for "_k" from 0 to (_weight - 1) do
{
//_weighted = _weighted + [_i];
_weighted set [count _weighted,_i];
};
};
_weighted
};
{
private ["_weightedTable","_gradeChances"];
_gradeChances = missionNamespace getVariable (_x select 0);
_weightedTable = [DZAI_weaponGrades,_gradeChances] call _getWeightedIndices;
missionNamespace setVariable [_x select 1,_weightedTable];
missionNamespace setVariable [_x select 0,nil];
} count [
//Input variable - Gradechances array, Output variable - Gradeindices array
["DZAI_gradeChances0","DZAI_gradeIndices0"],
["DZAI_gradeChances1","DZAI_gradeIndices1"],
["DZAI_gradeChances2","DZAI_gradeIndices2"],
["DZAI_gradeChances3","DZAI_gradeIndices3"],
["DZAI_gradeChancesDyn","DZAI_gradeIndicesDyn"]
];
if (DZAI_debugLevel > 0) then {diag_log format ["[DZAI] DZAI finished building weighted weapongrade tables in %1 seconds.",(diag_tickTime - _startTime)]};
true

View File

@ -0,0 +1,52 @@
private ["_startTime","_generatorStr","_cfgLocation","_locationArray","_config","_spawnServerObj"];
_generatorStr = format ["CfgTownGenerator%1",worldName];
_configExists = ((isClass (configFile >> _generatorStr)) or {isClass (configFile >> "CfgTownGenerator")});
if (_configExists) then {
_startTime = diag_tickTime;
_cfgLocation = configFile >> _generatorStr;
if ((count _cfgLocation) < 1) then {_generatorStr = "CfgTownGenerator";_cfgLocation = configFile >> "CfgTownGenerator";};
_locationArray = [];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Spawning in serverside objects... Reading from file %1.",_generatorStr];};
for "_i" from 0 to ((count _cfgLocation) - 1) do {
_locationArray set [count _locationArray,configName (_cfgLocation select _i)];
};
///////////////////////////////////////////////////////////////
_spawnServerObj = {
private ["_config","_objType","_objPos","_objDir","_object"];
for "_i" from ((count _this) - 1) to 0 step -1 do {
_config = _this select _i;
if (isClass (_config)) then {
_objType = getText (_config >> "type");
_objPos = [] + getArray (_config >> "position");
_objDir = getNumber (_config >> "direction");
//diag_log format ["OBJECT PATCH :: Creating object %1 at %2.",_objType,_objPos];
_object = _objType createVehicleLocal [_objPos select 0,_objPos select 1,0];
_object setDir _objDir;
_object setPos [_objPos select 0,_objPos select 1,0];
_object allowDamage false;
_object enableSimulation false;
if ((_i % 25) == 0) then {uiSleep 0.01;};
};
};
};
///////////////////////////////////////////////////////////////
{
_config = configFile >> _generatorStr >> _x;
_config call _spawnServerObj;
uiSleep 0.001;
} forEach _locationArray;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Serverside object patch completed in %1 seconds.",(diag_tickTime - _startTime)]};
} else {
if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: CfgTownGenerator not found. Aborting serverside object patch. (This is not an error)";};
};

View File

@ -0,0 +1,131 @@
/*
DZAI Dynamic Spawn Manager
Last updated: 6:45 PM 2/28/2014
*/
if (DZAI_debugLevel > 0) then {diag_log "Starting DZAI Dynamic Spawn Manager in 5 minutes.";};
uiSleep 300;
//uiSleep 30; //FOR DEBUGGING
if (DZAI_debugLevel > 0) then {diag_log "DZAI V2 Dynamic Spawn Manager started.";};
//Maximum chance to be selected for spawn condition check. Prevents unfairly high probability when few players are online.
#define CHANCE_CAP 0.5
//Maximum number of players to select each cycle. If number of online players is less than SPAWN_MAX, all online players will be selected.
#define SPAWN_MAX 10
//Proportion of online players to select each cycle.
#define SELECT_RATIO 0.3
//Frequency of each cycle
#define SLEEP_DELAY 300
//#define SLEEP_DELAY 60 //FOR DEBUGGING
//Cycle frequency variance.
#define SLEEP_VARY 120
//#define SLEEP_VARY 30 //FOR DEBUGGING
_playerUIDs = []; //Array of all collected playerUIDs
_timestamps = []; //Array of timestamps for each corresponding playerUID
//_playerData = [];
_maxSpawnTime = DZAI_maxSpawnTime; //Time required for maximum % spawn probability. (seconds)
//_maxSpawnTime = 1; //FOR DEBUGGING
_retainMaxSpawnTime = DZAI_maxSpawnTime + DZAI_keepMaxSpawnTime;
_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
while {true} do {
if (({isPlayer _x} count playableUnits) > 0) then {
_allPlayers = []; //Do not edit
{
if (isPlayer _x) then {
_allPlayers set [count _allPlayers,_x];
_playerUID = getPlayerUID _x;
if (!(_playerUID in _playerUIDs)) then {
_index = (count _playerUIDs);
_playerUIDs set [_index,_playerUID];
_timestamps set [_index,diag_tickTime];
};
//diag_log format ["DZAI Debug: Found a player at %1 (%2).",mapGridPosition _x,name _x];
};
uiSleep 0.05;
} forEach playableUnits;
_activeDynamicSpawns = (count DZAI_dynTriggerArray);
_playerCount = (count _allPlayers);
_maxSpawnsPossible = (((ceil (SELECT_RATIO * _playerCount)) min SPAWN_MAX) - _activeDynamicSpawns);
_chanceAdjust = (((_maxSpawnsPossible/_playerCount)/CHANCE_CAP) max 1);
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Preparing to spawn dynamic triggers using selection probability limit %1, %2 dynamic spawns are possible.",(1/_chanceAdjust),_maxSpawnsPossible];};
while {_allPlayers = _allPlayers - [objNull]; (((_maxSpawnsPossible - _activeDynamicSpawns) > 0) && {(count _allPlayers) > 0})} do { //_spawns: Have we created enough spawns? _allPlayers: Are there enough players to create spawns for?
_time = diag_tickTime;
_player = _allPlayers call BIS_fnc_selectRandom2;
//[_player,"DEBUG :: Selected for dynamic spawn."] call DZAI_radioSend;
if ((alive _player) && {((random _chanceAdjust) < 1)}) then {
_playername = name _player;
_index = _playerUIDs find (getPlayerUID _player);
if (_index < 0) then { //Failsafe: Add player UID at last minute if not found
_index = (count _playerUIDs);
_playerUIDs set [_index,(getPlayerUID _player)];
_timestamps set [_index,diag_tickTime];
};
_lastSpawned = _timestamps select _index;
_spawnChance = (((diag_tickTime - _lastSpawned) % _retainMaxSpawnTime) / _maxSpawnTime);
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Player %1 has %2 probability of generating dynamic spawn.",_playername,_spawnChance];};
if (_spawnChance call DZAI_chance) then {
_playerPos = ASLtoATL getPosASL _player;
if (
(((vehicle _player) isKindOf "Man") or {(vehicle _player) isKindOf "Land"}) && //Player must be on foot or in land vehicle
{(!(_playerPos in (nearestLocation [_playerPos,"Strategic"])))} && //Player must not be in blacklisted area
{(!(surfaceIsWater _playerPos))} && //Player must not be on water position
{((_playerPos distance getMarkerpos "respawn_west") > 2000)} && //Player must not be in debug area
{((count (_playerPos nearObjects ["DZE_Base_Object",100])) == 0)} //Player must not be near Epoch buildables
) then {
_timestamps set [_index,diag_tickTime + (0.10 * DZAI_maxSpawnTime)];
_trigger = createTrigger ["EmptyDetector",_playerPos];
_trigger setTriggerArea [600, 600, 0, false];
_trigger setTriggerActivation ["ANY", "PRESENT", true];
_trigger setTriggerTimeout [3, 3, 3, true];
_trigger setTriggerText (format ["Dynamic Trigger (Target: %1)",_playername]);
_trigger setVariable ["targetplayer",_player];
_trigActStatements = format ["0 = [175,thisTrigger,%1] call fnc_spawnBandits_dynamic;",_spawnChance];
_trigger setTriggerStatements ["{isPlayer _x} count thisList > 0;",_trigActStatements, "[thisTrigger] spawn fnc_despawnBandits_dynamic;"];
if (_debugMarkers) then {
_nul = _trigger spawn {
_marker = str(_this);
if ((getMarkerColor _marker) != "") then {deleteMarker _marker};
_marker = createMarker[_marker,(getPosASL _this)];
_marker setMarkerShape "ELLIPSE";
_marker setMarkerType "Flag";
_marker setMarkerBrush "SOLID";
_marker setMarkerSize [600, 600];
_marker setMarkerAlpha 0;
};
};
if (((count DZAI_reinforcePlaces) < DZAI_curHeliPatrols) && {DZAI_heliReinforceChance call DZAI_chance}) then {
DZAI_reinforcePlaces set [(count DZAI_reinforcePlaces),_trigger];
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Sending AI helicopter patrol to search for %1.",_playername];};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Created dynamic trigger at %1. Target player: %2.",(mapGridPosition _trigger),_playername];};
} else {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Dynamic spawn conditions failed for player %1.",_playername];};
};
} else {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Dynamic spawn probability check failed for player %1.",_playername];};
};
} else {
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Cancel dynamic spawn check for player %1 (Reason: Probability reduction or Player death).",_player]};
};
_allPlayers = _allPlayers - [_player];
_activeDynamicSpawns = _activeDynamicSpawns + 1;
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Processed a spawning probability check in %1 seconds.",diag_tickTime - _time]};
uiSleep 5;
};
} else {
if (DZAI_debugLevel > 1) then {diag_log "DZAI Extended Debug: No players online. Dynamic spawn manager is entering waiting state.";};
};
_nextSpawn = SLEEP_DELAY + random(SLEEP_VARY);
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Dynamic spawn manager is sleeping for %1 seconds.",_nextSpawn];};
uiSleep (_nextSpawn);
};

View File

@ -0,0 +1,143 @@
//Generates static spawns for maps that DZAI is not configured to support
waitUntil {uiSleep 3; !isNil "DZAI_locations_ready"};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: DZAI is generating static spawns..."];};
{
private ["_placeName","_placePos","_placeType"];
_placeName = _x select 0;
_placePos = _x select 1;
_placeType = _x select 2;
if ((_placeType != "NameLocal") && {!(surfaceIsWater _placePos)}) then {
private ["_nearbldgs"];
_nearbldgs = _placePos nearObjects ["HouseBase",250];
if ((count _nearbldgs) > 19) then {
_ignoredObj = missionNamespace getVariable ["DayZ_SafeObjects",[]];
_spawnPositions = [];
_spawnPoints = 0;
{
scopeName "bldgloop";
_pos = ASLtoATL getPosASL _x;
if (!((typeOf _x) in _ignoredObj) && {!(surfaceIsWater _pos)}) then {
_spawnPositions set [(count _spawnPositions),_pos];
_spawnPoints = _spawnPoints + 1;
};
if (_spawnPoints >= 150) then {
breakOut "bldgloop";
};
} forEach _nearbldgs;
_blacklist = createLocation ["Strategic",_placePos,600,600];
_trigger = createTrigger ["EmptyDetector", _placePos];
_trigger setTriggerArea [600, 600, 0, false];
_trigger setTriggerActivation ["ANY", "PRESENT", true];
_trigger setTriggerTimeout [10, 15, 20, true];
_trigger setTriggerText _placeName;
private ["_aiCount","_equipType","_patrolRad"];
switch (_placeType) do {
case "NameCityCapital":
{
_aiCount = [2,1];
_equipType = 1;
_patrolRad = 200;
};
case "NameCity":
{
_aiCount = [1,2];
_equipType = 1;
_patrolRad = 175;
};
case "NameVillage":
{
_aiCount = [1,1];
_equipType = 0;
_patrolRad = 125;
};
};
_statements = format ["0 = [%1,%2,%3,thisTrigger,[],%4] call fnc_spawnBandits;",_aiCount select 0,_aiCount select 1,_patrolRad,_equipType];
_trigger setTriggerStatements ["{isPlayer _x} count thisList > 0;", _statements, "0 = [thisTrigger] spawn fnc_despawnBandits;"];
0 = [0,_trigger,[],_patrolRad,_equipType,_spawnPositions,_aiCount] call DZAI_setTrigVars;
};
};
uiSleep 0.1;
} forEach DZAI_locations;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: DZAI has finished generating static spawns."];
if (!isNil "DZAI_devMode") then {
_outputMarkerCode = {
_markerName = _this select 0;
_markerPos = _this select 1;
_markerSize = _this select 2;
diag_log text format ['POSITION="%1";',_markerPos];
diag_log text format ['NAME="DZAI_%1";',_markerName];
diag_log text format ['A="%1";',_markerSize];
diag_log text format ['B="%1";',_markerSize];
true
};
_outputSpawnConfig = {
_markerName = _this select 0;
_aiCount = _this select 1;
_equipType = _this select 2;
diag_log text format ["['DZAI_%1',%2,[],%3] call DZAI_static_spawn;",_markerName,_aiCount,_equipType];
true
};
diag_log format ["DEBUG :: Output configs for areas_%1.sqf.",toLower worldName];
{
private ["_placeName","_placePos"];
_placeName = _x select 0;
_placePos = _x select 1;
_placeType = _x select 2;
_markerSize = switch (_placeType) do {
case "NameCityCapital": {200};
case "NameCity": {175};
case "NameVillage": {150};
case "NameLocal": {150};
case default {0};
};
_output = [_placeName,_placePos,_markerSize] call _outputMarkerCode;
uiSleep 0.1;
} forEach DZAI_locations;
diag_log format ["DEBUG :: Output configs for world_%1.sqf.",toLower worldName];
{
private ["_placeName","_aiCount","_equipType","_placeType"];
_placeName = _x select 0;
_placeType = _x select 2;
_aiCount = [0,1];
_equipType = 0;
switch (_placeType) do {
case "NameCityCapital": {
_aiCount = [2,1];
_equipType = 1;
};
case "NameCity": {
_aiCount = [1,2];
_equipType = 1;
};
case "NameVillage": {
_aiCount = [1,1];
_equipType = 0;
};
case "NameLocal": {
_aiCount = [1,1];
_equipType = 1;
};
case default {
_aiCount = [1,2];
_equipType = 1;
};
};
_output = [_placeName,_aiCount,_equipType] call _outputSpawnConfig;
uiSleep 0.1;
} forEach DZAI_locations;
};
};

View File

@ -0,0 +1,16 @@
waitUntil {uiSleep 1; !isNil "DZAI_locations_ready"};
for "_i" from 0 to ((count DZAI_dynAreaBlacklist) -1) do {
private ["_area"];
_area = DZAI_dynAreaBlacklist select _i;
if (((typeName _area) == "STRING") && {((getMarkerColor _area) != "")}) then {
private ["_areaSize","_sizeX","_sizeY","_blacklist"];
_areaSize = getMarkerSize _area;
_sizeX = if ((_areaSize select 0) > 0) then {_areaSize select 0} else {100};
_sizeY = if ((_areaSize select 1) > 0) then {_areaSize select 1} else {100};
_blacklist = createLocation ["Strategic",getMarkerPos _area,_sizeX,_sizeY];
};
uiSleep 0.001;
};

View File

@ -0,0 +1,81 @@
/*
Reads from CfgWorlds config and extracts information about city/town names, positions, and types.
Used to generate waypoint positions for AI vehicle patrols.
*/
private ["_location","_cfgWorldName","_startTime","_trader_markers","_allPlaces"];
_startTime = diag_tickTime;
_allPlaces = [];
_cfgWorldName = configFile >> "CfgWorlds" >> worldName >> "Names";
_trader_markers = [];
if (DZAI_modName == "epoch") then {
_worldName = (toLower worldName);
_trader_markers = call {
if (_worldName == "chernarus") exitWith {["Tradercitystary","wholesaleSouth","boatTraderEast","BoatDealerSouth","AirVehicles","BanditDen","Klen","BoatDealerEast","TradercityBash","HeroTrader"]};
if (_worldName == "napf") exitWith {["NeutralTraderCity","FriendlyTraderCity","HeroVendor","UnarmedAirVehicles","West Wholesaler","NorthWholesaler","NorthBoatVendor","BanditVendor","SouthBoatVendor","NeutralTraderCIty2"]};
if (_worldName == "sauerland") exitWith {["NeutralTraderCity","FriendlyTraderCity","HeroVendor","UnarmedAirVehicles","SouthWholesaler","NorthWholesaler","BanditVendor","NeutralTraderCIty2"]};
if (_worldName == "tavi") exitWith {["TraderCityLyepestok","TraderCitySabina","TraderCityBilgrad","TraderCityBranibor","BanditVendor","HeroVendor","AircraftDealer","AircraftDealer2","Misc.Vendor","Misc.Vendor2","BoatDealer","BoatDealer2","BoatDealer3","BoatDealer4","Wholesaler","Wholesaler2"]};
if (_worldName == "namalsk") exitWith {["GerneralPartsSupplies","WholesalerNorth","Doctor","HighEndWeaponsAmmo","HeroVendor","VehicleFriendly","NeutralVendors","WholesalerSouth","LowEndWeaponsAmmo","BoatVendor","Bandit Trader","PlaneVendor"]};
if (_worldName == "panthera2") exitWith {["AirVehiclesF","WholesalerWest","HeroVehicles","NeutralAirVehicles","Boats","NeutralTraders","NeutralTraderCity2","WholesaleSouth","PlanicaTraders","IslandVehiclePartsVendors"]};
if (_worldName == "smd_sahrani_a2") exitWith {["Tradercitycorazol","wholesaleSouth","boatTraderEast","BoatDealerSouth","AirVehicles","BanditDen","Ixel","BoatDealerEast","TradercityBag","HeroTrader"]};
if (_worldName == "sara") exitWith {["Tradercitycorazol","wholesaleSouth","boatTraderEast","BoatDealerSouth","AirVehicles","BanditDen","Ixel","BoatDealerEast","TradercityBag","HeroTrader"]};
if (_worldName == "fdf_isle1_a") exitWith {["wholesaleSouth","boatTraderEast","BoatDealerSouth","AirVehicles","BanditDen","Jesco","TradercityBash","HeroTrader"]};
if (_worldName == "caribou") exitWith {["boatTraderEast","BoatDealerSouth","AirVehicles","BanditDen","NorthNeutralVendors","SouthNeutralVendors","HeroTrader","BlackMarket","SouthWestWholesale"]};
if (_worldName == "lingor") exitWith {["RaceTrack","RepairGuy","PlaneVendor","Wholesale","HighWeapons/ammo","Parts","Choppers","lowEndCars","LowEndWeapons","HighEndCars","MedicalandBags","Wholesaler","BagsNFood","Wholesalers","DirtTrackVendor","OffRoad4x4","BoatVendor","BoatVendor1","BoatVendor2","BagVendor1","BagVendor2","Doctor2","BanditTrader","HeroTrader"]};
if (_worldName == "dingor") exitWith {["RaceTrack","RepairGuy","PlaneVendor","Wholesale","HighWeapons/ammo","Parts","Choppers","lowEndCars","LowEndWeapons","HighEndCars","MedicalandBags","Wholesaler","BagsNFood","Wholesalers","DirtTrackVendor","OffRoad4x4","BoatVendor","BoatVendor1","BoatVendor2","BagVendor1","BagVendor2","Doctor2","BanditTrader","HeroTrader"]};
if (_worldName == "takistan") exitWith {["tradercitykush","Trader_City_Nur","Trader_City_Garm","Wholesaler","Wholesaler_1","Airplane Dealer","BanditTrader","BlackMarketVendor"]};
if (_worldName == "fapovo") exitWith {["BanditTrader","AirVehicleUnarmed","TraderCity1","TraderCity2","Wholesaler","BanditVendor","HeroVendor","BoatVendor"]};
if (_worldName == "zargabad") exitWith {["HeroCamp","BanditCamp"]};
if (_worldName == "isladuala") exitWith {["Trader City Camara","st_3","st_4","st_3_1","st_3_1_1","st_3_1_1_1","st_3_2","st_3_2_1","st_3_2_2","st_3_2_3","st_3_2_3_1"]};
if (_worldName == "cmr_ovaron") exitWith {["AirVehiclesF","WholesalerWest","HeroVehicles","NeutralAirVehicles","Boats","NeutralTraders","NeutralTraderCity2","WholesaleSouth","PlanicaTraders","IslandVehiclePartsVendors"]};
if (_worldName == "shapur_baf") exitWith {["Safe Zone","test"]};
[]
};
_scanTargets = if (!isNil "serverTraders") then {serverTraders} else {["CAManBase"]};
for "_i" from 0 to ((count _trader_markers) - 1) do {
_traderPos = (getMarkerPos (_trader_markers select _i));
if (((_traderPos select 0) != 0) && {((_traderPos select 1) != 0)}) then {
if (DZAI_dynAISpawns) then {_blacklist = createLocation ["Strategic",_traderPos,250,250];};
_nearbyUnits = _traderPos nearEntities [_scanTargets,250];
{
if ((local _x) && {!simulationEnabled _x}) then {
_x setCaptive true;
};
} count _nearbyUnits;
};
uiSleep 0.01;
};
};
for "_i" from 0 to ((count _cfgWorldName) -1) do {
_allPlaces set [(count _allPlaces),configName (_cfgWorldName select _i)];
//diag_log format ["DEBUG :: Added location %1 to allPlaces array.",configName (_cfgWorldName select _i)];
};
{
_placeType = getText (_cfgWorldName >> _x >> "type");
if (_placeType in ["NameCityCapital","NameCity","NameVillage","NameLocal"]) then {
_placeName = getText (_cfgWorldName >> _x >> "name");
_placePos = [] + getArray (_cfgWorldName >> _x >> "position");
_isAllowedPos = ((({(_placePos distance (getMarkerPos _x)) < 300} count _trader_markers) == 0) && {({(_placePos distance (getMarkerPos _x)) < ((getMarkerSize _x) select 0)} count DZAI_waypointBlacklist) == 0});
if (_placeType != "NameLocal") then {
_blacklist = createLocation ["Strategic",_placePos,600,600];
if (_isAllowedPos) then {
DZAI_locationsLand set [(count DZAI_locationsLand),[_placeName,_placePos,_placeType]]; //Location Name, Position, Type.
};
};
if (_isAllowedPos) then {
DZAI_locations set [(count DZAI_locations),[_placeName,_placePos,_placeType]]; //Location Name, Position, Type.
};
};
if ((_forEachIndex % 10) == 0) then {uiSleep 0.05};
} forEach _allPlaces;
DZAI_locations_ready = true;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Location configuration completed with %1 locations found in %2 seconds.",(count DZAI_locations),(diag_tickTime - _startTime)]};

View File

@ -0,0 +1,9 @@
_index = 0;
while {(getMarkerColor ("spawn" + (str _index))) != ""} do {
_markerPos = getMarkerPos ("spawn" + (str _index));
_blacklist = createLocation ["Strategic",_markerPos,600,600];
_index = _index + 1;
uiSleep 0.5;
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Created %1 dynamic spawn blacklist areas for new player spawn areas.",_index]};

View File

@ -0,0 +1,61 @@
waitUntil {uiSleep 0.1; (!isNil "DZAI_locations_ready" && {!isNil "DZAI_classnamesVerified"})};
if (DZAI_maxHeliPatrols > 0) then {
_nul = [] spawn {
for "_i" from 0 to ((count DZAI_heliList) - 1) do {
_heliType = (DZAI_heliList select _i) select 0;
_amount = (DZAI_heliList select _i) select 1;
if ([_heliType,"vehicle"] call DZAI_checkClassname) then {
for "_j" from 1 to _amount do {
DZAI_heliTypesUsable set [count DZAI_heliTypesUsable,_heliType];
};
} else {
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: %1 attempted to spawn invalid vehicle type %2.",__FILE__,_heliType];};
};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Assembled helicopter list: %1",DZAI_heliTypesUsable];};
_maxHelis = (DZAI_maxHeliPatrols min (count DZAI_heliTypesUsable));
for "_i" from 1 to _maxHelis do {
_index = floor (random (count DZAI_heliTypesUsable));
_heliType = DZAI_heliTypesUsable select _index;
_nul = _heliType spawn DZAI_spawnVehiclePatrol;
DZAI_heliTypesUsable set [_index,objNull];
DZAI_heliTypesUsable = DZAI_heliTypesUsable - [objNull];
if (_i < _maxHelis) then {uiSleep 20};
};
};
uiSleep 5;
};
if (DZAI_maxLandPatrols > 0) then {
_nul = [] spawn {
for "_i" from 0 to ((count DZAI_vehList) - 1) do {
_vehType = (DZAI_vehList select _i) select 0;
_amount = (DZAI_vehList select _i) select 1;
if ([_vehType,"vehicle"] call DZAI_checkClassname) then {
for "_j" from 1 to _amount do {
DZAI_vehTypesUsable set [count DZAI_vehTypesUsable,_vehType];
};
} else {
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: %1 attempted to spawn invalid vehicle type %2.",__FILE__,_vehType];};
};
};
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Assembled vehicle list: %1",DZAI_vehTypesUsable];};
_maxVehicles = (DZAI_maxLandPatrols min (count DZAI_vehTypesUsable));
for "_i" from 1 to _maxVehicles do {
_index = floor (random (count DZAI_vehTypesUsable));
_vehType = DZAI_vehTypesUsable select _index;
_nul = _vehType spawn DZAI_spawnVehiclePatrol;
DZAI_vehTypesUsable set [_index,objNull];
DZAI_vehTypesUsable = DZAI_vehTypesUsable - [objNull];
if (_i < _maxVehicles) then {uiSleep 20};
};
};
};

View File

@ -0,0 +1,101 @@
#define WEAPON_BANNED_STRING "bin\config.bin/CfgWeapons/FakeWeapon"
#define VEHICLE_BANNED_STRING "bin\config.bin/CfgVehicles/Banned"
#define MAGAZINE_BANNED_STRING "bin\config.bin/CfgMagazines/FakeMagazine"
private["_verified","_errorFound","_startTime"];
//waitUntil {sleep 0.5; !isNil "DZAI_weaponsInitialized"};
_startTime = diag_tickTime;
_verified = [];
_index = 4;
while {(typeName (missionNamespace getVariable ("DZAI_Rifles"+str(_index)))) == "ARRAY"} do {
DZAI_tableChecklist set [count DZAI_tableChecklist,("DZAI_Rifles"+str(_index))];
_index = _index + 1;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Found custom weapon array %1.",("DZAI_Rifles"+str(_index))]};
};
{
_array = missionNamespace getVariable [_x,[]];
_errorFound = false;
{
if !(_x in _verified) then {
call {
if (isClass (configFile >> "CfgWeapons" >> _x)) exitWith {
if (((str(inheritsFrom (configFile >> "CfgWeapons" >> _x))) == WEAPON_BANNED_STRING) or {(getNumber (configFile >> "CfgWeapons" >> _x >> "scope")) == 0}) then {
diag_log format ["[DZAI] Removing invalid classname: %1.",_x];
_array set [_forEachIndex,""];
if (!_errorFound) then {_errorFound = true};
} else {
_verified set [count _verified,_x];
};
};
if (isClass (configFile >> "CfgMagazines" >> _x)) exitWith {
if (((str(inheritsFrom (configFile >> "CfgMagazines" >> _x))) == MAGAZINE_BANNED_STRING) or {(getNumber (configFile >> "CfgMagazines" >> _x >> "scope")) == 0}) then {
diag_log format ["[DZAI] Removing invalid classname: %1.",_x];
_array set [_forEachIndex,""];
if (!_errorFound) then {_errorFound = true};
} else {
_verified set [count _verified,_x];
};
};
if (isClass (configFile >> "CfgVehicles" >> _x)) exitWith {
if (((str(inheritsFrom (configFile >> "CfgVehicles" >> _x))) == VEHICLE_BANNED_STRING) or {(getNumber (configFile >> "CfgVehicles" >> _x >> "scope")) == 0}) then {
diag_log format ["[DZAI] Removing banned classname: %1.",_x];
_array set [_forEachIndex,""];
if (!_errorFound) then {_errorFound = true};
} else {
_verified set [count _verified,_x];
};
};
diag_log format ["[DZAI] Removing invalid classname: %1.",_x]; //Default case - if classname doesn't exist at all
_array set [_forEachIndex,""];
if (!_errorFound) then {_errorFound = true};
};
};
} forEach _array;
if (_errorFound) then {
_array = _array - [""];
missionNamespace setVariable [_x,_array];
diag_log format ["[DZAI] Contents of %1 failed verification. Invalid entries removed.",_x];
//diag_log format ["DEBUG :: Corrected contents of %1: %2.",_x,_array];
//diag_log format ["DEBUG :: Comparison check of %1: %2.",_x,missionNamespace getVariable [_x,[]]];
};
} forEach DZAI_tableChecklist;
if (DZAI_extendedVerify) then {
{
if (
!(_x isKindOf "CAManBase") or
{(getNumber (configFile >> "CfgVehicles" >> _x >> "side")) != 1} or
{(getNumber (configFile >> "CfgVehicles" >> _x >> "canCarryBackPack")) != 1}
) then {
diag_log format ["[DZAI] Removing invalid classname from DZAI_BanditTypes array: %1.",_x];
DZAI_BanditTypes set [_forEachIndex,""];
};
} forEach DZAI_BanditTypes;
{
if !((_x select 0) isKindOf "Air") then {
diag_log format ["[DZAI] Removing invalid classname from DZAI_heliList array: %1.",(_x select 0)];
DZAI_heliList set [_forEachIndex,""];
};
} forEach DZAI_heliList;
DZAI_heliList = DZAI_heliList - [""];
{
if !((_x select 0) isKindOf "LandVehicle") then {
diag_log format ["[DZAI] Removing invalid classname from DZAI_vehList array: %1.",(_x select 0)];
DZAI_vehList set [_forEachIndex,""];
};
} forEach DZAI_vehList;
DZAI_vehList = DZAI_vehList - [""];
};
//Anticipate cases where all elements of an array are invalid
if ((count DZAI_BanditTypes) == 0) then {DZAI_BanditTypes = ["Survivor2_DZ"]}; //Failsafe in case all AI skin classnames are invalid.
diag_log format ["[DZAI] Verified %1 unique classnames in %2 seconds.",(count _verified),(diag_tickTime - _startTime)];
DZAI_classnamesVerified = true;