Skip to content

Commit

Permalink
remove free for all mode, do not use resistance side unless absolutel…
Browse files Browse the repository at this point in the history
…y necessary
  • Loading branch information
SnarkIndustries committed Jul 11, 2014
1 parent ef5bb0e commit dee81cb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DZAI/compile/fn_createGroup.sqf
Expand Up @@ -41,7 +41,7 @@ _pos set [2,0];

if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Found spawn position at %3 meters away at position %1 after %2 retries.",_pos,_attempts,(_pos distance _spawnPos)]};

_unitGroup = if (isNull (_this select 1)) then {createGroup (call DZAI_getFreeSide)} else {_this select 1};
_unitGroup = if (isNull (_this select 1)) then {createGroup (call DZAI_getGroupSide)} else {_this select 1};
_unitGroup setCombatMode "BLUE";

for "_i" from 1 to _totalAI do {
Expand Down
4 changes: 0 additions & 4 deletions DZAI/init/dzai_config.sqf
Expand Up @@ -72,10 +72,6 @@ DZAI_lowBloodLevel = 5000;
//Note: AI cannot be attacked or damaged by zombies.(Default: false)
DZAI_weaponNoise = false;

//Enable or disable "Free For All" mode. If FFA mode is enabled, all AI groups will be hostile to each other. (default: false)
//WARNING: This option will affect ALL AI spawned, including those spawned from other addons that create AI units. Not recommended to enable if using other addons with AI.
DZAI_freeForAll = false;

//If enabled, AI group will attempt to track down player responsible for killing a group member. Players with radios will be given text warnings if they are being pursued (Default: true)
DZAI_findKiller = true;

Expand Down
17 changes: 15 additions & 2 deletions DZAI/init/dzai_functions.sqf
Expand Up @@ -119,9 +119,22 @@ if (DZAI_radioMsgs) then {
};

//DZAI group side assignment function. Detects when East side has too many groups, then switches to Resistance side.
DZAI_getFreeSide = {
DZAI_getGroupSide = {
private["_groupSide"];
_groupSide = (if (({(side _x) == east} count allGroups) <= 140) then {east} else {resistance});
_groupSide = (if (({(side _x) == east} count allGroups) < 141) then {
east
} else {
//If there are 140 East groups, set West/Resistance hostility and assign a Resistance group instead.
if ((resistance getFriend west) > 0) then {
createCenter resistance;
resistance setFriend [west,0];
west setFriend [resistance,0];
east setFriend [resistance, 1];
resistance setFriend [east, 1];
diag_log "DZAI Warning: Group maximum reached for East side! Modifying Resistance side for DZAI use.";
};
resistance
});
//diag_log format ["Assigned side %1 to AI group",_groupSide];

_groupSide
Expand Down
18 changes: 3 additions & 15 deletions DZAI/init/dzai_initserver.sqf
Expand Up @@ -13,6 +13,7 @@ _startTime = diag_tickTime;
_directoryAsArray = toArray __FILE__;
_directoryAsArray resize ((count _directoryAsArray) - 25);
DZAI_directory = toString _directoryAsArray;
if (isNil "_this") then {_this = []};
if ((count _this) > 0) then {
//diag_log "DEBUG :: Startup parameters found!";
if ("readoverridefile" in _this) then {DZAI_overrideEnabled = true} else {DZAI_overrideEnabled = nil};
Expand All @@ -34,21 +35,8 @@ call compile preprocessFileLineNumbers format ["%1\init\dzai_config.sqf",DZAI_di
call compile preprocessFileLineNumbers format ["%1\init\dzai_functions.sqf",DZAI_directory];

//Set side relations
createcenter east;
createcenter resistance;
if (DZAI_freeForAll) then {
//Free For All mode - All AI groups are hostile to each other.
east setFriend [resistance, 0];
resistance setFriend [east, 0];
east setFriend [east, 0]; //East is hostile to self (free-for-all between static and dynamic AI. Custom AI will fight static and dynamic AI but not each other.)
} else {
//Normal settings - All AI groups are friendly to each other.
east setFriend [resistance, 1];
resistance setFriend [east, 1];
};
createCenter east;
east setFriend [west, 0];
resistance setFriend [west, 0];
west setFriend [resistance, 0];
west setFriend [east, 0];

//Detect DayZ mod variant being used.
Expand Down Expand Up @@ -102,5 +90,5 @@ if (_worldname in [
//Report DZAI startup settings to RPT log
diag_log format ["[DZAI] DZAI settings: Debug Level: %1. DebugMarkers: %2. WorldName: %3. ModName: %4. DZAI_dynamicWeaponList: %5. VerifyTables: %6.",DZAI_debugLevel,((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}),_worldname,DZAI_modName,DZAI_dynamicWeaponList,DZAI_verifyTables];
diag_log format ["[DZAI] AI spawn settings: Static: %1. Dynamic: %2. Air: %3. Land: %4.",DZAI_staticAI,DZAI_dynAISpawns,(DZAI_maxHeliPatrols>0),(DZAI_maxLandPatrols>0)];
diag_log format ["[DZAI] AI settings: DZAI_findKiller: %1. DZAI_useHealthSystem: %2. DZAI_weaponNoise: %3. DZAI_zombieEnemy: %4. DZAI_freeForAll: %5",DZAI_findKiller,DZAI_useHealthSystem,DZAI_weaponNoise,DZAI_zombieEnemy,DZAI_freeForAll];
diag_log format ["[DZAI] AI settings: DZAI_findKiller: %1. DZAI_useHealthSystem: %2. DZAI_weaponNoise: %3. DZAI_zombieEnemy: %4.",DZAI_findKiller,DZAI_useHealthSystem,DZAI_weaponNoise,DZAI_zombieEnemy];
diag_log format ["[DZAI] DZAI loading completed in %1 seconds.",(diag_tickTime - _startTime)];
2 changes: 1 addition & 1 deletion DZAI/spawn_functions/spawnBandits.sqf
Expand Up @@ -105,7 +105,7 @@ for "_j" from 1 to (_numGroups - _groupsActive) do {
};
if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Spawned group %1 (weapongrade: %2) with %3 units.",_unitGroup,_weapongrade,_totalAI];};
} else {
_unitGroup = createGroup (call DZAI_getFreeSide);
_unitGroup = createGroup (call DZAI_getGroupSide);
_dummy = _unitGroup call DZAI_protectGroup;
_unitGroup setVariable ["GroupSize",0];
_unitGroup setVariable ["trigger",_trigger];
Expand Down
2 changes: 1 addition & 1 deletion DZAI/spawn_functions/spawnBandits_custom.sqf
Expand Up @@ -36,7 +36,7 @@ if !(_trigger getVariable ["respawn",true]) then {
if (_totalAINew > 0) then {_totalAI = _totalAINew}; //Retrieve AI amount if it was updated from initial value (for non-respawning custom spawns only)
};
_spawnPos = [(ASLtoATL getPosASL _trigger),random (_patrolDist),random(360),false] call SHK_pos;
_unitGroup = [_totalAI,(createGroup resistance),_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;
_unitGroup = [_totalAI,grpNull,_spawnPos,_trigger,_weapongrade] call DZAI_setup_AI;

//Set group variables
_unitGroup setVariable ["unitType","static"];
Expand Down
14 changes: 4 additions & 10 deletions DZAI/spawn_functions/spawnBandits_dynamicV2.sqf
Expand Up @@ -8,19 +8,13 @@
Last updated: 10:58 PM 6/6/2014
*/

//#define CHANCE_LOW 0.50
//#define CHANCE_HIGH 1.00

private ["_patrolDist","_trigger","_totalAI","_unitGroup","_targetPlayer","_playerPos","_playerDir","_spawnPos","_startTime","_baseDist","_distVariance","_dirVariance","_vehPlayer","_behavior","_triggerStatements","_spawnDist"];
if (!isServer) exitWith {};

_startTime = diag_tickTime;

_patrolDist = _this select 0;
_trigger = _this select 1;
//_spawnChance = _this select 2;

if (count (_trigger getVariable ["GroupArray",[]]) > 0) exitWith {if (DZAI_debugLevel > 0) then {diag_log "DZAI Debug: Active groups found. Exiting spawn script (spawnBandits_dynamic)";};};

_targetPlayer = _trigger getVariable ["targetplayer",objNull];
if (isNull _targetPlayer) exitWith {
Expand All @@ -31,12 +25,12 @@ if (isNull _targetPlayer) exitWith {
};

_vehPlayer = vehicle _targetPlayer;
_baseDist = 200; //On foot distance: 200-300m
_distVariance = 100;
_baseDist = 200; //On foot distance: 200-275
_distVariance = 75;
_dirVariance = 90;
if !(_vehPlayer isKindOf "Man") then {
_baseDist = 150; //In vehicle distance: 150-225m
_distVariance = 75;
_baseDist = _baseDist - 50; //In vehicle distance: 150-225m
//_distVariance = 75;
_dirVariance = 67.5;
};

Expand Down
2 changes: 1 addition & 1 deletion DZAI/spawn_functions/spawnVehiclePatrol.sqf
Expand Up @@ -38,7 +38,7 @@ if (_isAirVehicle) then {
};
};

_unitGroup = createGroup resistance;
_unitGroup = createGroup (call DZAI_getGroupSide);
_driver = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_driver] joinSilent _unitGroup;

Expand Down
2 changes: 1 addition & 1 deletion DZAI/spawn_functions/spawnVehicle_custom.sqf
Expand Up @@ -49,7 +49,7 @@ while {_keepLooking} do {
};
};

_unitGroup = createGroup resistance;
_unitGroup = createGroup (call DZAI_getGroupSide);
_driver = _unitGroup createUnit [(DZAI_BanditTypes call BIS_fnc_selectRandom2), [0,0,0], [], 1, "NONE"];
[_driver] joinSilent _unitGroup;

Expand Down

0 comments on commit dee81cb

Please sign in to comment.