Skip to content

Commit

Permalink
Merge pull request SnarkIndustries#11 from dayzai/Experimental-2.2.1
Browse files Browse the repository at this point in the history
Update DZAI to 2.2.1
  • Loading branch information
Butt Face committed Dec 24, 2014
2 parents 63704a6 + a1834ff commit 0b02a79
Show file tree
Hide file tree
Showing 65 changed files with 2,237 additions and 999 deletions.
2 changes: 1 addition & 1 deletion DZAI/compile/BIN_taskPatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if (isServer) then
// End back near start point and then pick a new random point
_wp1 = _grp addWaypoint [_pos, 0];
_wp1 setWaypointType "SAD";
_wp1 setWaypointCompletionRadius (random (_max_dist));
_wp1 setWaypointCompletionRadius (_max_dist max 100);
[_grp,(count waypoints _grp)] setWaypointStatements ["true", "group this setCurrentWaypoint [(group this), (round (random 2) + 1)];"];
};

Expand Down
8 changes: 5 additions & 3 deletions DZAI/compile/ai_death.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ call {
[_victim,_killer,_unitGroup,_groupIsEmpty] call DZAI_AI_killed_dynamic;
0 = [_victim,_killer,_unitGroup,_unitType,_unitsAlive] call DZAI_AI_killed_all;
};
if (_unitType == "randomspawn") exitWith {
[_victim,_killer,_unitGroup,_groupIsEmpty] call DZAI_AI_killed_random;
0 = [_victim,_killer,_unitGroup,_unitType,_unitsAlive] call DZAI_AI_killed_all;
};
if (_unitType in ["air","aircustom"]) exitWith {
[_victim,_unitGroup] call DZAI_AI_killed_air;
};
if (_unitType in ["land","landcustom"]) exitWith {
0 = [_victim,_killer,_unitGroup,_unitType] call DZAI_AI_killed_all;
if (_groupIsEmpty) then {
[_unitGroup] call DZAI_AI_killed_land; //Only run this if entire group has been killed
};
[_victim,_unitGroup,_groupIsEmpty] call DZAI_AI_killed_land;
};
if (_unitType == "aircrashed") exitWith {};
if (_groupIsEmpty) then {
Expand Down
11 changes: 1 addition & 10 deletions DZAI/compile/ai_killed_dynamic.sqf
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
/*
fnc_dynAIDeath
Description: Begins force despawn for dynamic AI when the entire group has been killed.
Usage: [_victim,_unitGroup] spawn DZAI_AI_killed_dynamic;
Last Updated: 10:33 PM 5/14/2014
*/

private ["_victim","_killer","_groupIsEmpty","_trigger","_unitGroup","_dummy"];
private ["_victim","_killer","_groupIsEmpty","_trigger","_unitGroup"];

_victim = _this select 0;
_killer = _this select 1;
Expand Down
39 changes: 31 additions & 8 deletions DZAI/compile/ai_killed_land.sqf
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
private ["_vehicle","_unitGroup"];
private ["_victim","_vehicle","_unitGroup","_groupIsEmpty"];

_unitGroup = _this select 0;
_victim = _this select 0;
_unitGroup = _this select 1;
_groupIsEmpty = _this select 2;

_vehicle = _unitGroup getVariable ["assignedVehicle",objNull];
if (_vehicle isKindOf "LandVehicle") then {
{_vehicle removeAllEventHandlers _x} count ["HandleDamage","Killed"];
[_unitGroup,_vehicle] call DZAI_respawnAIVehicle;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: AI vehicle patrol destroyed, adding vehicle %1 to cleanup queue.",(typeOf _vehicle)];};
if (_groupIsEmpty) then {
if (_vehicle isKindOf "LandVehicle") then {
{_vehicle removeAllEventHandlers _x} count ["HandleDamage","Killed"];
[_unitGroup,_vehicle] call DZAI_respawnAIVehicle;
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: AI vehicle patrol destroyed, adding vehicle %1 to cleanup queue.",(typeOf _vehicle)];};
};
_unitGroup setVariable ["GroupSize",-1];
} else {
if (_victim getVariable ["isDriver",false]) then {
_groupUnits = (units _unitGroup) - [_victim];
_newDriver = _groupUnits call BIS_fnc_selectRandom2; //Find another unit to serve as driver
if (!isNil "_newDriver") then {
_nul = [_newDriver,_vehicle] spawn {
private ["_newDriver","_vehicle"];
_newDriver = _this select 0;
_vehicle = _this select 1;
unassignVehicle _newDriver;
_newDriver assignAsDriver _vehicle;
if (_newDriver in _vehicle) then {
_newDriver moveInDriver _vehicle;
};
[_newDriver] orderGetIn true;
_newDriver setVariable ["isDriver",true];
if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Replaced driver unit for group %1 vehicle %2.",(group _newDriver),(typeOf _vehicle)];};
};
};
};
};

_unitGroup setVariable ["GroupSize",-1];

true
14 changes: 14 additions & 0 deletions DZAI/compile/ai_killed_random.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

private ["_victim","_killer","_groupIsEmpty","_trigger","_unitGroup"];

_victim = _this select 0;
_killer = _this select 1;
_unitGroup = _this select 2;
_groupIsEmpty = _this select 3;

_trigger = _unitGroup getVariable ["trigger",DZAI_defaultTrigger];
if (_groupIsEmpty) then {
[_trigger,true] spawn fnc_despawnBandits_random; //force despawning even if players are present in trigger area.
};

true
2 changes: 1 addition & 1 deletion DZAI/compile/ai_killed_static.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (_groupIsEmpty) then {
_x setVariable ["GroupSize",-1];
} forEach (_trigger getVariable ["GroupArray",[]]);
deleteMarker (_trigger getVariable ["spawnmarker",""]);
_trigger call DZAI_updStaticSpawnCount;
[_trigger,"DZAI_staticTriggerArray"] call DZAI_updateSpawnCount;
deleteVehicle _trigger;
};
};
Expand Down
4 changes: 2 additions & 2 deletions DZAI/compile/ai_setup_loadout.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ private ["_unit","_weapongrade","_weapons","_weapon","_magazine","_backpacks","_
_unit = _this select 0;
_weapongrade = _this select 1;

if (_unit getVariable ["loadoutDone",false]) exitWith {diag_log "DZAI Error: Unit already has loadout!";};
if (_unit getVariable ["loadoutDone",false]) exitWith {diag_log format ["DZAI Error: Unit already has loadout! (%1)",__FILE__];};

if !(_weapongrade in DZAI_weaponGradesAll) then {
_weapongradeInvalid = _weapongrade;
_weapongrade = DZAI_weaponGrades call BIS_fnc_selectRandom2;
diag_log format ["DZAI Error: Invalid weapongrade provided! (%1). Generating random weapongrade...",_weapongradeInvalid,_weapongrade];
diag_log format ["DZAI Error: Invalid weapongrade provided: %1. Generating new weapongrade value: %2. (%3)",_weapongradeInvalid,_weapongrade,__FILE__];
};

if ((count (weapons _unit)) > 0) then {
Expand Down
55 changes: 55 additions & 0 deletions DZAI/compile/createRandomSpawns.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
private ["_maxRandomSpawns","_debugMarkers","_triggerArea","_attempts","_trigPos","_trigger","_markername","_marker"];

_maxRandomSpawns = _this;

_debugMarkers = ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled});
_triggerArea = 600;

//waitUntil {sleep 1; !isNil "DZAI_locations_ready"};

if (DZAI_debugLevel > 0) then {diag_log format ["DZAI Debug: Attempting to place %1 random spawns on the map...",_maxRandomSpawns];};

for "_i" from 1 to _maxRandomSpawns do {
_attempts = 0;
_keepSearching = true;
_trigPos = [0,0,0];
while {
_keepSearching
} do {
_trigPos = ["DZAI_centerMarker",false,DZAI_randAreaBlacklist] call SHK_pos;
_attempts = _attempts + 1;
_keepSearching = ((count ((nearestLocations [_trigPos, ["Strategic"], 650])) > 0) && {_attempts < 3});
if (_keepSearching) then {uiSleep 0.25};
};

if (_attempts < 3) then {
_trigger = createTrigger ["EmptyDetector",_trigPos];

_location = createLocation ["Strategic",(getPosASL _trigger),600,600]; //Create temporary dynamic spawn blacklist area
_trigger setVariable ["triggerLocation",_location];
[_trigger,"DZAI_randTriggerArray"] call DZAI_updateSpawnCount;

_trigger setTriggerArea [_triggerArea, _triggerArea, 0, false];
_trigger setTriggerActivation ["ANY", "PRESENT", true];
_trigger setTriggerTimeout [5, 5, 5, true];
_trigger setTriggerStatements ["{isPlayer _x} count thisList > 0;","0 = [300,thisTrigger,thisList] call fnc_spawnBandits_random;", "[thisTrigger] spawn fnc_despawnBandits_random;"];
if (_debugMarkers) then {
_markername = str(_trigger);
_marker = createMarker[_markername,_trigPos];
_marker setMarkerShape "ELLIPSE";
_marker setMarkerType "Flag";
_marker setMarkerBrush "SOLID";
_marker setMarkerSize [_triggerArea, _triggerArea];
_marker setMarkerColor "ColorYellow";
_marker setMarkerAlpha 0.6;
DZAI_mapMarkerArray set [(count DZAI_mapMarkerArray),_marker];
};
_trigger setTriggerText format ["Random Spawn at %1",(mapGridPosition _trigger)];
_trigger setVariable ["timestamp",diag_tickTime];
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Random spawn %1 of %2 placed at %3 (Retries: %4).",_i,_maxRandomSpawns,_trigPos,_attempts];};
//DZAI_randTriggerArray set [(count DZAI_randTriggerArray),_trigger];
} else {
if (DZAI_debugLevel > 0) then {diag_log format["DZAI Debug: Could not find suitable location to place random spawn %1 of %2.",_i,_maxRandomSpawns];};
};
uiSleep 3;
};
2 changes: 1 addition & 1 deletion DZAI/compile/fn_abortdynspawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ private["_trigger"];
_trigger = _this;

DZAI_dynTriggerArray = DZAI_dynTriggerArray - [_trigger];
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {deleteMarker format["trigger_%1",_trigger]};
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {deleteMarker str(_trigger)};

deleteVehicle _trigger;

Expand Down
14 changes: 14 additions & 0 deletions DZAI/compile/fn_abortrandspawn.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
private["_trigger","_triggerLocation"];
_trigger = _this;

[_trigger,"DZAI_randTriggerArray"] call DZAI_updateSpawnCount;
if ((!isNil "DZAI_debugMarkersEnabled") && {DZAI_debugMarkersEnabled}) then {deleteMarker (str _trigger)};

_triggerLocation = _trigger getVariable "triggerLocation";
deleteLocation _triggerLocation;
//_triggerLocation setVariable ["deletetime",(diag_tickTime + 900)];
//DZAI_tempBlacklist set [(count DZAI_tempBlacklist),_triggerLocation];

deleteVehicle _trigger;

false
2 changes: 1 addition & 1 deletion DZAI/compile/fn_checkclassname.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ call {
if (_configIndex > -1) then {
_check = (str(inheritsFrom (configFile >> _config >> _classname)));
_classnameArray = [];
if ((_check != "") && {(_check != _banString)} && {(getNumber (configFile >> _config >> _classname >> "scope")) == 2}) then {
if ((_check != "") && {(_check != _banString)} && {(getNumber (configFile >> _config >> _classname >> "scope")) != 0}) then {
_classnameArray = DZAI_checkedClassnames;
_result = true;
} else {
Expand Down
6 changes: 5 additions & 1 deletion DZAI/compile/fn_createStaticSpawn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if ((count _this) > 1) then {
};

if (_abort) exitWith {
diag_log format ["DZAI Error: Zero AI amount for spawn area %1. Spawn area not created.",_spawnMarker];
diag_log format ["DZAI Error: Zero AI amount for spawn area %1. Spawn area not created. (%2)",_spawnMarker,__FILE__];

objNull
};
Expand All @@ -37,6 +37,8 @@ _numGroups = if ((count _this) > 4) then {_this select 4} else {1};

_patrolDist = (getMarkerSize _spawnMarker) select 0;

if !(_equipType in [0,1,2,3]) then {_equipType = 1};

_onActStatements = format ["_nul = [%1,%2,%3,thisTrigger,%4,%5,%6] call DZAI_spawnBandits_init;",_minAI,_addAI,_patrolDist,_positionArray,_equipType,_numGroups];
_trigger = createTrigger ["EmptyDetector", getMarkerPos(_spawnMarker)];
_trigger setTriggerArea [600, 600, 0, false];
Expand All @@ -45,4 +47,6 @@ _trigger setTriggerTimeout [10, 10, 10, true];
_trigger setTriggerText _spawnMarker;
_trigger setTriggerStatements ["{isPlayer _x} count thisList > 0;",_onActStatements,""];

deleteMarker _spawnMarker;

_trigger
26 changes: 14 additions & 12 deletions DZAI/compile/fn_damageHandlerAI2.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (_damage > 0.4) then {
if (_hit == "legs") exitWith {
_partdamage = (_unithealth select 1) + (_damage/2);
_unithealth set [1,_partdamage]; //Record leg damage internally
if ((_partdamage >= 1) && {!(_unithealth select 2)}) then {
if ((_partdamage > 0.99) && {!(_unithealth select 2)}) then {
_nul = _unit spawn {_this setHit["legs",1]}; //Break legs when enough damage taken
[nil,_unit,rSAY,["z_fracture_1",40]] call RE;
_unithealth set [2,true];
Expand All @@ -34,6 +34,19 @@ if (_damage > 0.4) then {
};
};

//additional damage if attacker is a player
if (isPlayer _source) then {
_scale = _scale + 800;
if (_headHit) then {
if (_damage > 1.5) then {
_deathType = "shothead";
_scale = 12000; //sufficient head shot damage causes instant death
} else {
_scale = _scale + 500;
};
};
};

//special death types
call {
if (_ammo isKindOf "GrenadeBase") exitWith {
Expand All @@ -52,17 +65,6 @@ if (_damage > 0.4) then {
};
};

//additional damage if attacker is a player
if (isPlayer _source) then {
_scale = _scale + 800;
if (_headHit) then {
_scale = _scale + 500;
if (_damage > 1.5) then {
_deathType = "shothead";
_scale = 12000; //sufficient head shot damage causes instant death
};
};
};
_blooddamage = (_damage * _scale);
_newbloodlevel = (_unithealth select 0) - _blooddamage;
_unithealth set [0,_newbloodlevel];
Expand Down
55 changes: 42 additions & 13 deletions DZAI/compile/fn_init_trigger.sqf
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
private["_trigger"];
private["_trigger","_mode"];

_mode = _this select 0;
_trigger = _this select 1;

_trigger = _this select 0;
_trigger setVariable ["isCleaning",false];
_trigger setVariable ["GroupArray",(_this select 1)];
if ((count _this) > 3) then {
_trigger setVariable ["patrolDist",(_this select 2)];
_trigger setVariable ["equipType",(_this select 3)];
_trigger setVariable ["locationArray",(_this select 4)];
_trigger setVariable ["maxUnits",(_this select 5)];
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized static trigger at %1. GroupArray: %2, PatrolDist: %3. equipType: %4. %LocationArray %5 positions, MaxUnits %6.",triggerText _trigger,(_this select 1),(_this select 2),(_this select 3),count (_this select 4),(_this select 5)];};
} else {
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized dynamic trigger at %1. GroupArray: %2.",triggerText _trigger,(_this select 1)];};
_location = createLocation ["Strategic",(getPosASL _trigger),600,600]; //Create temporary dynamic spawn blacklist area
_trigger setVariable ["triggerLocation",_location];
_trigger setVariable ["GroupArray",(_this select 2)];

call {
if (_mode == 0) exitWith {
//Static spawns
_trigger setVariable ["patrolDist",(_this select 3)];
_trigger setVariable ["equipType",(_this select 4)];
_trigger setVariable ["locationArray",(_this select 5)];
_trigger setVariable ["maxUnits",(_this select 6)];
_trigger setVariable ["spawnChance",missionNamespace getVariable [format ["DZAI_spawnChance%1",(_this select 4)],1]];
DZAI_locations set [(count DZAI_locations),[(triggerText _trigger),(getPosASL _trigger),"NameLocal"]]; //Add helicopter patrol WP pointing to static spawn location
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized static spawn at %1. GroupArray: %2, PatrolDist: %3. equipType: %4. %LocationArray %5 positions, MaxUnits %6.",triggerText _trigger,(_this select 2),(_this select 3),(_this select 4),count (_this select 5),(_this select 6)];};
};
if (_mode == 1) exitWith {
//Dynamic spawns
_location = createLocation ["Strategic",(getPosASL _trigger),600,600]; //Create temporary dynamic spawn blacklist area
_trigger setVariable ["triggerLocation",_location];
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized dynamic spawn at %1. GroupArray: %2.",triggerText _trigger,(_this select 2)];};
};
if (_mode == 2) exitWith {
//Random spawns
_triggerPos = getPosASL _trigger;
_location = _trigger getVariable ["triggerLocation",_triggerPos];
if ((_triggerPos distance _location) > 0) then {
_location setPosition _triggerPos;
};
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized random spawn at %1. GroupArray: %2.",triggerText _trigger,(_this select 2)];};
};
if (_mode == 3) exitWith {
//Static spawns (custom)
_trigger setVariable ["patrolDist",(_this select 3)];
_trigger setVariable ["equipType",(_this select 4)];
_trigger setVariable ["locationArray",(_this select 5)];
_trigger setVariable ["maxUnits",(_this select 6)];
_trigger setVariable ["spawnChance",1];
if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Initialized custom spawn at %1. GroupArray: %2, PatrolDist: %3. equipType: %4. %LocationArray %5 positions, MaxUnits %6.",triggerText _trigger,(_this select 2),(_this select 3),(_this select 4),count (_this select 5),(_this select 6)];};
};
};

_trigger setVariable ["triggerStatements",+(triggerStatements _trigger)];
_trigger setVariable ["initialized",true];

Expand Down
2 changes: 2 additions & 0 deletions DZAI/compile/fn_skillboost.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
_unit setSkill [_x,_skillLevel];
uiSleep 0.01;
} count ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","general"];
_bandageAmount = _x getVariable ["bandageAmount",0];
_x setVariable ["bandageAmount",(_bandageAmount+1)];
};
uiSleep 0.05;
} forEach (units _this);
Loading

0 comments on commit 0b02a79

Please sign in to comment.