See Below

removed unnecessary logging.
Fixed an error that resulted in the number of missions running being incorrectly tracked.
AI In vehicles are now ejected upon death.
First part of work to deal with locality of vehicles in which AI are transferred to HC
This commit is contained in:
Ghostrider-GRG- 2018-04-28 08:10:19 -04:00
parent 5b311a01ff
commit adb5a7ce3f
23 changed files with 445 additions and 174 deletions

View File

@ -54,8 +54,9 @@ while {true} do
{
//diag_log format["_fnc_mainThread: 60 second events run at %1",diag_tickTime];
_timer1min = diag_tickTime;
//diag_log format["_fnc_mainThread: blck_missionsRunning = %1 | blck_maxSpawnedMissions = %2", blck_missionsRunning,blck_maxSpawnedMissions];
[] call blck_fnc_spawnPendingMissions;
//diag_log format["_fnc_mainThrea: blck_numberUnderwaterDynamicMissions = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_numberUnderwaterDynamicMissions,blck_dynamicUMS_MissionsRuning];
diag_log format["_fnc_mainThread: blck_numberUnderwaterDynamicMissions = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_numberUnderwaterDynamicMissions,blck_dynamicUMS_MissionsRuning];
if (blck_dynamicUMS_MissionsRuning < blck_numberUnderwaterDynamicMissions) then
{
//diag_log "Adding dynamic UMS Mission";
@ -75,6 +76,7 @@ while {true} do
};
if (diag_tickTime - _timer5min > 300) then
{
diag_log format["[blckeagls] Dynamic Missions Running %1 | UMS Running %2 | Vehicles %3 | Groups %4 | Server FPS %5 | Server Uptime %6 Min | Missions Run %7",blck_missionsRunning,blck_dynamicUMS_MissionsRuning,count blck_monitoredVehicles,count blck_monitoredMissionAIGroups,diag_FPS,floor(diag_tickTime/60),blck_missionsRun];
if (blck_useTimeAcceleration) then
{
_timer5min = diag_tickTime;

View File

@ -15,8 +15,8 @@
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
/////////////////////////////////////////////////////
params["_startTime"];
params["_startTime",["_timeoutTime",blck_MissionTimout]];
private["_return"];
if ((diag_tickTime - _startTime) > blck_MissionTimout ) then {_return = true} else {_return = false};
if ((diag_tickTime - _startTime) > _timeoutTime) then {_return = true} else {_return = false};
//diag_log format["fnc_timedOut:: blck_MissionTimout = %2 || _return = %1",_return,blck_MissionTimout];
_return;

View File

@ -38,6 +38,11 @@ if ((count blck_connectedHCs) > 0) then
_numTransfered = 0;
if (_x getVariable["blck_group",false]) then
{
if ((leader _x) != vehicle (leader _x)) then
{
private _v = vehicle (leader _x);
blck_monitoredVehicles = blck_monitoredVehicles - [_v];
];
//diag_log format["group belongs to blckeagls mission system so time to transfer it"];
if ((typeName _x) isEqualTo "GROUP") then
{
@ -48,16 +53,16 @@ if ((count blck_connectedHCs) > 0) then
//diag_log format["group %1 is already assigned to an HC with _id of %2",_x,_id];
_swap = false;
} else {
//diag_log format["group %1 should be moved to HC %2 with _idHC %3",_x,_idHC];
diag_log format["group %1 should be moved to HC %2 with _idHC %3",_x,_idHC];
_x setVariable["owner",owner _idHC];
_rc = _x setGroupOwner (owner _idHC);
[_x] remoteExec["blck_fnc_HC_XferGroup",_idHC];
if ( _rc ) then
{
_numTransfered = _numTransfered + 1;
//diag_log format["group %1 transferred to %2",_x, groupOwner _x];
diag_log format["group %1 transferred to %2",_x, groupOwner _x];
} else {
//diag_log format["something went wrong with the transfer of group %1",_x];
diag_log format["something went wrong with the transfer of group %1",_x];
};
};
};
@ -68,31 +73,8 @@ if ((count blck_connectedHCs) > 0) then
} forEach (allGroups);
diag_log format["_passToHCs:: %1 groups transferred to HC %2",_numTransfered,_idHC];
_numTransfered = 0;
/*
{
if (typeName _x isEqualTo "GROUP") then {_idHC = groupOwner _x};
if (typeName _x isEqualTo "OBJECT") then {_idHC = owner _x};
if (_idHC > 2) then
{
//diag_log format["vehicle %1 is already assigned to an HC with _id of %2",_x,_id];
_swap = false;
} else {
//diag_log format["vehicle %1 should be moved to an HC",_x];
_x setVariable["owner",_idHC];
if (typeOf _x isEqualTo "GROUP") then {_rc = _x setGroupOwner _idHC};
if (typeOf _x isEqualTo "OBJECT") then {_rc = _x setOwner _idHC};
[_x] remoteExec["blck_fnc_HC_XferVehicle",_idHC];
if ( _rc ) then
{
_numTransfered = _numTransfered + 1;
//diag_log format["group %1 transferred to %2",_x, groupOwner _x];
} else {
//diag_log format["something went wrong with the transfer of group %1",_x];
};
};
}forEach blck_monitoredVehicles;
*/
//diag_log format["_passToHCs:: %1 vehicles transferred",_numTransfered];
// Note : the owner of a vehicle is the owner of the driver so vehicles are automatically transferred to the HC when the group to which the driver is assigned is transferred.
} else {
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log "_fnc_passToHCs:: No headless clients connected"};

View File

@ -8,5 +8,11 @@ _client = clientOwner;
_tempEH = ["reloaded",_unit addEventHandler ["reloaded", {_this call compile preprocessfilelinenumbers blck_EH_unitWeaponReloaded;}]];
_localEH pushBack _tempEH;
_x setVariable["localEH",_localEH,true];
if(_unit != vehicle _unit) then
{
diag_log format["_fnc_HC_XferGroup: _unit %1 is in vehicle %2",_unit, vehicle _unit];
blck_HC_monitoredVehicles pushBack (vehicle _unit);
diag_log format["_fnc_HC_XferGroup: blck_HC_monitoredVehicles = %1", blck_HC_monitoredVehicles];
};
}forEach (units _group);
diag_log format["blckHC:: group %1 transferred to HC %1",_group,_client];

View File

@ -0,0 +1,107 @@
/*
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
//diag_log format["_fnc_vehicleMonitor: starting function at diag_tickTime = %1",diag_tickTime];
#ifdef blck_debugMode
//diag_log format["_fnc_vehicleMonitor:: blck_debugMode defined"];
#endif
private ["_vehList","_veh","_isEmplaced","_ownerIsPlayer","_allCrewDead","_deleteNow","_missionCompleted","_evaluate","_cleanupTimer"];
_vehList = +blck_HC_monitoredVehicles;
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 and blck_HC_monitoredVehicles %3",diag_tickTime,_vehList,blck_HC_monitoredVehicles];};
#endif
//blck_fnc_releaseVehicleToPlayers
{
/*
Determine state of vehicle
_isEmplaced
_ownerIsPlayer
_allCrewDead
_deleteNow
*/
diag_log format["_fnc_vehicleMonitor: evaluating vehicle %1",_x];
_veh = _x; // (purely for clarity at this point, _x could be used just as well)
_isEmplaced = _veh getVariable["DBD_vehType","none"] isEqualTo "emplaced";
_ownerIsPlayer = if (owner _veh > 2 && !(owner _veh in blck_connectedHCs)) then {true} else {false};
{
diag_log format["_fnc_vehicleMonitor: vehicle %1 crew %2 alive = %3",_veh,_x, alive _x];
}forEach (crew _veh);
_allCrewDead = if (({alive _x} count (crew _veh)) == 0) then {true} else {false};
diag_log format["_fnc_vehicleMonitor: _allCrewDead = %1",_allCrewDead];
_deletenow = false;
if ( (_veh getVariable["blck_DeleteAt",0] > 0) && (diag_tickTime > (_veh getVariable "blck_DeleteAt"))) then {_deleteNow = true};
_missionCompleted = if (_veh getVariable["missionCompleted",0] != 0) then {true} else {false};
_evaluate = true;
if (_ownerIsPlayer) then
{
// disable further monitoring and mark to never be deleted.
_evaluate = false;
_veh setVariable["blck_DeleteAt",0];
blck_HC_monitoredVehicles = blck_HC_monitoredVehicles - [_veh];
//diag_log format["_fnc_vehicleMonitor: vehicle %1 now owned by player %2",_veh, owner _veh];
};
if (_allCrewDead && _evaluate) then
{
if (_isEmplaced) then
{
if (blck_killEmptyStaticWeapons) then
{
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: case of destroyed where vehicle = %1",_veh];};
#endif
_veh setDamage 1;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
}else {
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
} else {
if (blck_killEmptyAIVehicles) then
{
_veh setDamage 0.7;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
} else {
//diag_log format["_fnc_vehicleMonitor:: case of RELEASE where vehicle = %1 and Vehicle is typeOf %2",_veh, typeOf _veh];
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
};
};
if (_missionCompleted && !(_allCrewDead)) then
{
//diag_log format["_fnc_vehicleMonitor:: case of mission vehicle with AI alive at mission end: schedule destruction with _veh = %1 and typeOf _veh = %2",_veh, typeOf _veh];
_cleanupTimer = _veh getVariable["blck_DeleteAt",0]; // The time delete to deleting any alive AI units
if (_cleanupTimer == 0) then {_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer]};
_evaluate = false;
};
if (_evaluate) then
{
[_veh] call blck_fnc_reloadVehicleAmmo;
};
if (_deleteNow) then
{
[_veh] call blck_fnc_destroyVehicleAndCrew;
_evaluate = false;
};
}forEach _vehList;

View File

@ -5,13 +5,23 @@ diag_log "_fnc_HCmonitor.sqf";
_blckGroups = 0;
_otherGroups = 0;
_totalGroups = 0;
_timerOneSec =0;
_timerSixtySec = 0;
while {true} do
{
if (diag_tickTime > _timerOneSec) then
{
_timerOneSec = diag_tickTime;
[] call blck_fnc_HC_vehicleMonitor;
};
if (diag_tickTime > _timerSixtySec) then
{
_timerSixtySec = diag_tickTime;
_blckGroups = {_x getVariable["blck_group",false] && (groupOwner _x isEqualTo clientOwner)} count allGroups;
_totalGroups = {(groupOwner _x) isEqualTo clientOwner} count allGroups;
_totalGroups = _blckGroups + _otherGroups;
diag_log format["blckHC:: headless client %1 at diag_tickTime running %3 fps",clientOwner,diag_tickTime,diag_fps];
diag_log format["blckHC:: headless client %1 _blckGroups = %1 and _otherGroups = %2",_blckGroups,_otherGroups];
uiSleep 60;
};
uiSleep 1;
};

View File

@ -16,10 +16,12 @@ private["_cleanupAliveAITimer","_cleanupCompositionTimer","_isScubaMission"];
_fn_missionCleanup = {
params["_mines","_objects","_blck_AllMissionAI","_mission","_cleanupAliveAITimer","_cleanupCompositionTimer",["_isScubaMission",false]];
[_mines] spawn blck_fnc_clearMines;
[_objects, _cleanupCompositionTimer] spawn blck_fnc_addObjToQue;
[_blck_AllMissionAI, (_cleanupAliveAITimer)] spawn blck_fnc_addLiveAItoQue;
diag_log format["_fn_missionCleanup: blck_missionsRunning Started at %1", blck_missionsRunning];
[_mines] call blck_fnc_clearMines;
[_objects, _cleanupCompositionTimer] call blck_fnc_addObjToQue;
[_blck_AllMissionAI, (_cleanupAliveAITimer)] call blck_fnc_addLiveAItoQue;
blck_missionsRunning = blck_missionsRunning - 1;
diag_log format["_fn_missionCleanup: blck_missionsRunning reset to %1", blck_missionsRunning];
blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords];
if !(_isScubaMission) then
{
@ -41,7 +43,7 @@ _fn_missionCleanup = {
diag_log format["_fnc_endMission: _this = %1",_this];
#endif
params["_mines","_objects","_crates","_blck_AllMissionAI","_endMsg","_blck_localMissionMarker","_coords","_mission",["_endCondition",0],["_vehicles",[]],["_isScubaMission",false]];
diag_log format["_fnc_endMission (44): _blck_localMissionMarker %1 | _coords %2 | _mission %3 | _endCondition %4",_blck_localMissionMarker,_coords,_mission,_endCondition];
#ifdef blck_debugMode
if (blck_debugLevel > 0) then
{
@ -54,6 +56,7 @@ _fn_missionCleanup = {
if (_endCondition > 0) exitWith // Mision aborted for some reason
{
diag_log format["_fnc_endMission: mission end condition > 0 | setting all timers to 0"];
#ifdef blck_debugMode
if (blck_debugLevel > 0) then {
diag_log format["_fnc_endMission: Mission Aborted, setting all timers to 0"];
@ -79,6 +82,7 @@ _fn_missionCleanup = {
};
if (_endCondition == 0) then // Normal Mission End State
{
diag_log format["_fnc_endMission: mission end condition == 0 | setting all timers to 0"];
private["_cleanupAliveAITimer","_cleanupCompositionTimer"];
if (blck_useSignalEnd) then
{
@ -132,4 +136,5 @@ _fn_missionCleanup = {
#ifdef blck_debugMode
diag_log format["_fnc_endMission: after to running mission end functions -> blck_missionsRunning = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_missionsRunning,blck_dynamicUMS_MissionsRuning];
#endif
diag_log format["_fnc_endMission (138): after to running mission end functions -> blck_missionsRunning = %1 | blck_dynamicUMS_MissionsRuning = %2",blck_missionsRunning,blck_dynamicUMS_MissionsRuning];
_endCondition

View File

@ -135,7 +135,7 @@
_a1 = _boxLoot select 5;
for "_i" from 1 to _tries do {
_item = selectRandom _a1;
diag_log format["_fnc_fillBoxes: _item = %1",_item];
//diag_log format["_fnc_fillBoxes: _item = %1",_item];
if (typeName _item isEqualTo "ARRAY") then
{
_diff = (_item select 2) - (_item select 1);

View File

@ -31,6 +31,7 @@ params["_coords","_markerClass","_aiDifficultyLevel"];
[_markerClass, "active",_coords] call blck_fnc_updateMissionQue;
blck_ActiveMissionCoords pushback _coords;
blck_missionsRunning = blck_missionsRunning + 1;
diag_log format["[blckeagls] missionSpawner (17):: Initializing mission: _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName];
if (isNil "_assetKilledMsg") then {_assetKilledMsg = ""};
@ -165,11 +166,11 @@ while {_wait} do
{
#ifdef blck_debugMode
//diag_log "missionSpawner:: top of mission trigger loop";
if (blck_debugLevel > 2) exitWith {_playerInRange = true;};
if (blck_debugLevel > 2) exitWith {_playerInRange = true;diag_log "_fnc_missionSpawner (168): player trigger loop triggered by scripting";};
#endif
if ([_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange) exitWith {_playerInRange = true;};
if ([_missionStartTime] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;};
if ([_missionStartTime,blck_MissionTimout] call blck_fnc_timedOut) exitWith {_missionTimedOut = true;};
uiSleep 5;
#ifdef blck_debugMode
@ -177,13 +178,16 @@ while {_wait} do
{
diag_log format["missionSpawner:: Trigger Loop - blck_debugLevel = %1 and _coords = %2",blck_debugLevel, _coords];
diag_log format["missionSpawner:: Trigger Loop - players in range = %1",{isPlayer _x && _x distance2D _coords < blck_TriggerDistance} count allPlayers];
diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime] call blck_fnc_timedOut];
diag_log format["missionSpawner:: Trigger Loop - timeout = %1", [_missionStartTime,blck_MissionTimout] call blck_fnc_timedOut];
};
#endif
};
if (_missionTimedOut) exitWith
{
diag_log format["_fnc_missionSpawner (187): mission timed out"];
[_mines,_objects,_crates, _blck_AllMissionAI,_endMsg,_blck_localMissionMarker,_coords,_markerClass, 1] call blck_fnc_endMission;
/*
// Deal with the case in which the mission timed out.
blck_recentMissionCoords pushback [_coords,diag_tickTime];
blck_ActiveMissionCoords = blck_ActiveMissionCoords - [ _coords];
@ -191,6 +195,7 @@ if (_missionTimedOut) exitWith
blck_missionsRunning = blck_missionsRunning - 1;
[_blck_localMissionMarker select 0] call blck_fnc_deleteMarker;
[_objects, 0.1] spawn blck_fnc_cleanupObjects;
*/
};
////////
@ -393,7 +398,7 @@ if (blck_debugLevel > 0) then {diag_log format["missionSpawner:: (389) preparing
uiSleep 15;
private["_noEmplacedToSpawn"];
_noEmplacedToSpawn = [_noEmplacedWeapons] call blck_fnc_getNumberFromRange;
diag_log format["_fnc_missionSpawner: -> _noEmplacedToSpawn = %1 | blck_useStatic = %2",_noEmplacedToSpawn,blck_useStatic];
//diag_log format["_fnc_missionSpawner: -> _noEmplacedToSpawn = %1 | blck_useStatic = %2",_noEmplacedToSpawn,blck_useStatic];
if (blck_useStatic && (_noEmplacedToSpawn > 0)) then
{
// _params = ["_coords","_missionEmplacedWeapons","_useRelativePos","_noEmplacedWeapons","_aiDifficultyLevel","_uniforms","_headGear","_vests","_backpacks","_weaponList","_sideArms"];
@ -477,7 +482,7 @@ if (blck_showCountAliveAI) then
_crateStolen = false;
_locations = [_coords];
private _spawnPara = if (random(1) < _chancePara) then {true} else {false};
diag_log format["_fnc_missionSpawner (477): _spawnPara = %1 | _chancePara = %2",_spawnPara,_chancePara];
//diag_log format["_fnc_missionSpawner (477): _spawnPara = %1 | _chancePara = %2",_spawnPara,_chancePara];
{
_locations pushback (getPos _x);
_x setVariable["crateSpawnPos", (getPos _x)];
@ -485,7 +490,9 @@ diag_log format["_fnc_missionSpawner (477): _spawnPara = %1 | _chancePara = %2",
while {_missionComplete isEqualTo -1} do
{
if (blck_debugLevel isEqualTo 3) exitWith {uiSleep 180};
#ifdef blck_debugMode
if (blck_debugLevel > 2) exitWith {uiSleep blck_triggerLoopCompleteTime;diag_log "_missionSpawner (492) scripted Mission End blck_debugLevel = 3";};
#endif
if (_endIfPlayerNear) then
{
if ([_locations,10,true] call blck_fnc_playerInRangeArray) then {_missionComplete = 1};
@ -635,4 +642,6 @@ _result = [_mines,_objects,_crates,_blck_AllMissionAI,_endMsg,_blck_localMission
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["[blckeagls] missionSpawner:: (507)end of mission: blck_fnc_endMission has returned control to _fnc_missionSpawner"]};
#endif
diag_log format["_fnc_missionSpawner (637) Mission Completed | _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName];
diag_log format["_fnc_missionSpawner (643) Mission Completed | _cords %1 : _markerClass %2 : _aiDifficultyLevel %3 _markerMissionName %4",_coords,_markerClass,_aiDifficultyLevel,_markerMissionName];
blck_missionsRun = blck_missionsRun + 1;
diag_log format["_fnc_missionSpawner (644): Total Dyanamic Land and UMS Run = %1", blck_missionsRun];

View File

@ -45,10 +45,10 @@ _readyToSpawnQue = [];
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format["_fnc_spawnPendingMissions: count _readyToSpawnQue = %1", count _readyToSpawnQue];
diag_log format["_fnc_spawnPendingMissions:: --- >> _readyToSpawnQue diag_tickTime %6 _marker %1 _difficulty %2 _tMin %3 _tMax %4 _waitTime %5",_readyToSpawnQue select 1, _readyToSpawnQue select 2, _readyToSpawnQue select 3, _readyToSpawnQue select 4, _readyToSpawnQue select 5, diag_tickTime];
};
#endif
diag_log format["_fnc_spawnPendingMissions: count _readyToSpawnQue = %1", count _readyToSpawnQue];
if (count _readyToSpawnQue > 0) then
{
_missionToSpawn = selectRandom _readyToSpawnQue;
@ -72,7 +72,7 @@ if (count _readyToSpawnQue > 0) then
//diag_log format["_fnc_spawnPendingMissions: _missionDifficulty %1",_missionDifficulty];
//diag_log format["_fnc_spawnPendingMissions: _compiledMission %1",_compiledMission];
[_coords,_missionMarker,_missionDifficulty] spawn _compiledMission;
blck_missionsRunning = blck_missionsRunning + 1;
diag_log format["_fnc_spawnPendingMissions: blck_missionsRunning = %1", blck_missionsRunning];
};
true

View File

@ -51,7 +51,7 @@ for "_i" from 1 to (count blck_liveMissionAI) do
if ((alive _x) && !(isNull objectParent _x)) then // mark the vehicle for deletion
{
//diag_log format["_fnc_cleanupAliveAI: deleteing objectParent %1 [%3] for unit %2",objectParent _x, _x, typeName (objectParent _x), typeOf (objectParent _x)];
[objectParent _x] call blck_fn_deleteAIvehicle;
[objectParent _x] call blck_fnc_deleteAIvehicle;
};
[_x] call blck_fnc_deleteAI;
}forEach (_units select 0);

View File

@ -25,7 +25,9 @@ if (blck_debugLevel >= 2) then
};
#endif
if (!(alive _unit)) exitWith {};
if (!(alive _unit)) exitWith {[_unit, _instigator] call blck_fnc_processAIKill};
if (damage _unit > 0.95) exitWith {_unit setDamage 1.2; [_unit, _instigator] call blck_fnc_processAIKill};
if (!(isPlayer _instigator)) exitWith {};
[_unit,_instigator] call blck_fnc_alertGroupUnits;
[_instigator] call blck_fnc_alertNearbyVehicles;

View File

@ -0,0 +1,79 @@
/*
Handle AI Deaths
Last Modified 7/27/17
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private["_group","_isLegal","_weapon","_lastkill","_kills","_message","_killstreakMsg"];
params["_unit","_killer","_isLegal"];
//diag_log format["_fnc_processAIKills:: function called with _this = %1",_this];
_unit setVariable ["blck_cleanupAt", (diag_tickTime) + blck_bodyCleanUpTimer, true];
blck_deadAI pushback _unit;
_group = group _unit;
[_unit] joinSilent grpNull;
if (count(units _group) < 1) then {
#ifdef useDynamicSimulation
_group enableDynamicSimulation false;
#endif
deleteGroup _group;
};
if (blck_launcherCleanup) then {[_unit] spawn blck_fnc_removeLaunchers;};
if (blck_removeNVG) then {[_unit] spawn blck_fnc_removeNVG;};
if !(isPlayer _killer) exitWith {};
[_unit,_killer] call blck_fnc_alertGroupUnits;
[_killer] call blck_fnc_alertNearbyVehicles;
_group = group _unit;
_wp = [_group, currentWaypoint _group];
_wp setWaypointBehaviour "COMBAT";
_group setCombatMode "RED";
_wp setWaypointCombatMode "RED";
_isLegal = [_unit,_killer] call blck_fnc_processIlleagalAIKills;
if !(_isLegal) exitWith {};
_lastkill = _killer getVariable["blck_lastkill",diag_tickTime];
_killer setVariable["blck_lastkill",diag_tickTime];
_kills = (_killer getVariable["blck_kills",0]) + 1;
if ((diag_tickTime - _lastkill) < 240) then
{
_killer setVariable["blck_kills",_kills];
} else {
_killer setVariable["blck_kills",0];
};
_unit action ["Eject", vehicle _unit];
if (blck_useKillMessages) then
{
_weapon = currentWeapon _killer;
_killstreakMsg = format[" %1X KILLSTREAK",_kills];
if (blck_useKilledAIName) then
{
_message = format["[blck] %2: killed by %1 from %3m",name _killer,name _unit,round(_unit distance _killer)];
}else{
_message = format["[blck] %1 killed with %2 from %3 meters",name _killer,getText(configFile >> "CfgWeapons" >> _weapon >> "DisplayName"), round(_unit distance _killer)];
};
_message =_message + _killstreakMsg;
//diag_log format["[blck] unit killed message is %1",_message,""];
[["aikilled",_message,"victory"],playableUnits] call blck_fnc_messageplayers;
};
[_unit,_killer] call blck_fnc_rewardKiller;
if (blck_showCountAliveAI) then
{
//diag_log "_fnc_processAIKills: Updating Map Marker AI Counts - blck_missionMarkers items are";
{
//diag_log format["_fnc_processAIKills: blck_missionMarkers itm %1 = %2",_forEachIndex,_x];
[_x select 0, _x select 1, _x select 2] call blck_fnc_updateMarkerAliveCount;
} forEach blck_missionMarkers;
//call blck_fnc_updateAllMarkerAliveCounts;
};

View File

@ -0,0 +1,76 @@
/*
Handle AI Deaths
Last Modified 7/27/17
By Ghostrider [GRG]
Copyright 2016
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private["_group","_isLegal","_weapon","_lastkill","_kills","_message","_killstreakMsg"];
params["_unit","_killer","_isLegal"];
//diag_log format["_fnc_processAIKills:: function called with _this = %1",_this];
_unit setVariable ["blck_cleanupAt", (diag_tickTime) + blck_bodyCleanUpTimer, true];
blck_deadAI pushback _unit;
_group = group _unit;
[_unit] joinSilent grpNull;
if (count(units _group) < 1) then {
#ifdef useDynamicSimulation
_group enableDynamicSimulation false;
#endif
deleteGroup _group;
};
if (blck_launcherCleanup) then {[_unit] spawn blck_fnc_removeLaunchers;};
if (blck_removeNVG) then {[_unit] spawn blck_fnc_removeNVG;};
if !(isPlayer _killer) exitWith {};
[_unit,_killer] call blck_fnc_alertGroupUnits;
[_killer] call blck_fnc_alertNearbyVehicles;
_group = group _unit;
_wp = [_group, currentWaypoint _group];
_wp setWaypointBehaviour "COMBAT";
_group setCombatMode "RED";
_wp setWaypointCombatMode "RED";
_isLegal = [_unit,_killer] call blck_fnc_processIlleagalAIKills;
if !(_isLegal) exitWith {};
_lastkill = _killer getVariable["blck_lastkill",diag_tickTime];
_killer setVariable["blck_lastkill",diag_tickTime];
_kills = (_killer getVariable["blck_kills",0]) + 1;
if ((diag_tickTime - _lastkill) < 240) then
{
_killer setVariable["blck_kills",_kills];
} else {
_killer setVariable["blck_kills",0];
};
if (blck_useKillMessages) then
{
_weapon = currentWeapon _killer;
_killstreakMsg = format[" %1X KILLSTREAK",_kills];
if (blck_useKilledAIName) then
{
_message = format["[blck] %2: killed by %1 from %3m",name _killer,name _unit,round(_unit distance _killer)];
}else{
_message = format["[blck] %1 killed with %2 from %3 meters",name _killer,getText(configFile >> "CfgWeapons" >> _weapon >> "DisplayName"), round(_unit distance _killer)];
};
_message =_message + _killstreakMsg;
//diag_log format["[blck] unit killed message is %1",_message,""];
[["aikilled",_message,"victory"],playableUnits] call blck_fnc_messageplayers;
};
[_unit,_killer] call blck_fnc_rewardKiller;
if (blck_showCountAliveAI) then
{
//diag_log "_fnc_processAIKills: Updating Map Marker AI Counts - blck_missionMarkers items are";
{
//diag_log format["_fnc_processAIKills: blck_missionMarkers itm %1 = %2",_forEachIndex,_x];
[_x select 0, _x select 1, _x select 2] call blck_fnc_updateMarkerAliveCount;
} forEach blck_missionMarkers;
//call blck_fnc_updateAllMarkerAliveCounts;
};

View File

@ -14,9 +14,26 @@
private["_group","_isLegal","_weapon","_lastkill","_kills","_message","_killstreakMsg"];
params["_unit","_killer","_isLegal"];
// if blck_cleanupAt > 0 then the death was already processed.
if (_unit getVariable["blck_cleanupAt",-1] > 0) exitWith {};
//diag_log format["_fnc_processAIKills:: function called with _this = %1",_this];
_unit setVariable ["blck_cleanupAt", (diag_tickTime) + blck_bodyCleanUpTimer, true];
diag_log format["_fnc_processAIKills: _unit = %1 | vehicle unit = %2",_unit, vehicle _unit];
/*
if (_unit != (vehicle _unit) then
{
diag_log format["_fnc_processAIKills: evaluating status of crew of vehicle %1",vehicle _unit]
if ( {alive _x} count (crew (vehicle _unit)) < 1) then
{
diag_log format["_fnc_processAIKills: all crew dead, releasing vehicle"];
[vehicle _unit] call blck_fnc_releaseVehicleToPlayers;
} else {
diag_log format["_fnc_processAIKills: vehicle %1 still has %2 crew alive",vehicle _unit, {alive _x} crew (vehicle _unit)];
};
};
*/
blck_deadAI pushback _unit;
_group = group _unit;
[_unit] joinSilent grpNull;
@ -48,6 +65,8 @@ if ((diag_tickTime - _lastkill) < 240) then
_killer setVariable["blck_kills",0];
};
_unit action ["Eject", vehicle _unit];
if (blck_useKillMessages) then
{
_weapon = currentWeapon _killer;
@ -63,6 +82,7 @@ if (blck_useKillMessages) then
//diag_log format["[blck] unit killed message is %1",_message,""];
[["aikilled",_message,"victory"],playableUnits] call blck_fnc_messageplayers;
};
[_unit,_killer] call blck_fnc_rewardKiller;
if (blck_showCountAliveAI) then
{

View File

@ -24,6 +24,9 @@ if (_clearInventory) then
_veh setVehicleLock "LOCKEDPLAYER";
_veh addEventHandler ["GetIn",{ // Note: only fires when vehicle is local to player
private["_unit","_veh"];
if (_veh getVariable["blck_releasedAt",0] > 0) then {{ _veh removeAllEventHandlers _x} forEach["getin","getout"]};
if !(_veh getVariable["blck_releasedAt",0] > 0) then
{
_unit = _this select 2;
_veh = _this select 0;
if (isPlayer _unit) then
@ -31,6 +34,7 @@ _veh addEventHandler ["GetIn",{ // Note: only fires when vehicle is local to pl
_unit action ["eject",_veh];
titleText ["You are not allowed to enter that vehicle at this time","PLAIN DOWN"];
};
};
}];
_veh

View File

@ -0,0 +1,9 @@
params["_veh"];
//diag_log format["blck_fnc_deleteAIvehicle: _veh %1 deleted",_veh];
{
_veh removeAllEventHandlers _x;
}forEach ["Hit","HitPart","GetIn","GetOut","Fired","FiredNear","HandleDamage","Reloaded"];
blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
deleteVehicle _veh;

View File

@ -0,0 +1,8 @@
//_fn_destroyVehicleAndCrew = {
params["_veh"];
//private["_crew"];
//_crew = crew _veh;
//diag_log format["_fn_destroyVehicleAndCrew: called for _veh = %1",_veh];
{[_x] call blck_fnc_deleteAI;} forEach (crew _veh);
[_veh] call blck_fnc_deleteAIvehicle;

View File

@ -1,45 +1,23 @@
/*
Handle the case that all AI assigned to a vehicle are dead.
Allows players to enter and use the vehicle.
By Ghostrider [GRG]
Copyright 2016
Last updated 3-24-17
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
params["_v"];
//diag_log format["_fnc_releastVehicletoPlayers.sqf: removing vehicle %1 from ",_v,blck_monitoredVehicles];
//blck_monitoredVehicles = blck_monitoredVehicles - [_v];
_v removeAllEventHandlers "GetIn";
_v removeAllEventHandlers "GetOut";
_v removeAllEventHandlers "Fired";
_v removeAllEventHandlers "Reloaded";
_v removeAllMPEventHandlers "MPHit";
_v removeAllMPEventHandlers "MPKilled";
_v setVehicleLock "UNLOCKED" ;
_v setVariable["releasedToPlayers",true];
[_v] call blck_fnc_emptyObject;
//{
//_v removealleventhandlers _x;
//}forEach["Fired","Hit","HitPart","Reloaded","Dammaged","HandleDamage","GetIn","GetOut"];
params["_veh"];
//blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
_veh setVehicleLock "UNLOCKED" ;
//_v setVariable["releasedToPlayers",true];
//[_v] call blck_fnc_emptyObject;
{
_veh removealleventhandlers _x;
} forEach ["GetIn","GetOut","fired","hit","hitpart","reloaded","dammaged","HandleDamage"];
{
_veh removeAllMPEventHandlers _x;
} forEach ["MPHit","MPKilled"];
_veh setVariable["blck_releasedAt",diag_tickTime,true];
_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer,true];
if ((damage _veh) > 0.5) then {_veh setDamage 0.5};
//diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle released to players where vehicle = %1 and blck_deleteAT = %2",_veh, _veh getVariable["blck_DeleteAt",0]];
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle released to players where vehicle = %1",_v];
diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle released to players where vehicle = %1",_veh];
};
#endif

View File

@ -0,0 +1,29 @@
//_fn_reloadAmmo = {
params["_veh"];
private ["_crew","_mag","_allMags","_cnt"];
// https://community.bistudio.com/wiki/fullCrew
// 0 1 2 3 4
// returns Array - format [[<Object>unit,<String>role,<Number>cargoIndex,<Array>turretPath,<Boolean>personTurret], ...]
//diag_log format["_fnc_vehicleMonitor:: (65) _veh = %1",_veh];
if ({alive _x and !(isPlayer _x)} count (crew _veh) > 0) then
{
_crew = fullCrew _veh;
//diag_log format["_fnc_vehicleMonitor:: (67) _crew = %1",_crew];
{
//diag_log format ["_fnc_vehicleMonitor:: (69) _x = %1",_x];
_mag = _veh currentMagazineTurret (_x select 3);
if (count _mag > 0) then
{
//diag_log format["_fnc_vehicleMonitor:: (71) _mag is typeName %1", typeName _mag];
//diag_log format ["_fnc_vehicleMonitor:: (71) length _mag = %2 and _mag = %1",_mag,count _mag];
_allMags = magazinesAmmo _veh;
//diag_log format["_fnc_vehicleMonitor:: (71) _allMags = %1",_allMags];
_cnt = ( {_mag isEqualTo (_x select 0)}count _allMags);
//diag_log format["_fnc_vehicleMonitor:: (75) _cnt = %1",_cnt];
if (_cnt < 2) then {_veh addMagazineCargo [_mag,2]};
};
} forEach _crew;
};
//};

View File

@ -1,6 +1,7 @@
/*
By Ghostrider [GRG]
Copyright 2016
Scans vehicles local to the machine the script is run on.
--------------------------
License
--------------------------
@ -16,83 +17,13 @@
//diag_log format["_fnc_vehicleMonitor:: blck_debugMode defined"];
#endif
_fn_releaseVehicle = {
params["_veh"];
//blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
_veh setVehicleLock "UNLOCKED" ;
//_v setVariable["releasedToPlayers",true];
//[_v] call blck_fnc_emptyObject;
{
_veh removealleventhandlers _x;
} forEach ["GetIn","GetOut","fired","hit","hitpart","reloaded","dammaged","HandleDamage"];
{
_veh removeAllMPEventHandlers _x;
} forEach ["MPHit","MPKilled"];
_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer,true];
if ((damage _veh) > 0.5) then {_veh setDamage 0.5};
//diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle released to players where vehicle = %1 and blck_deleteAT = %2",_veh, _veh getVariable["blck_DeleteAt",0]];
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format["_fnc_vehicleMonitor:: case of patrol vehicle released to players where vehicle = %1",_veh];
};
#endif
};
_fn_destroyVehicleAndCrew = {
params["_veh"];
//private["_crew"];
//_crew = crew _veh;
//diag_log format["_fn_destroyVehicleAndCrew: called for _veh = %1",_veh];
{[_x] call blck_fnc_deleteAI;} forEach (crew _veh);
[_veh] call blck_fn_deleteAIvehicle;
};
_fn_reloadAmmo = {
params["_veh"];
private ["_crew","_mag","_allMags","_cnt"];
// https://community.bistudio.com/wiki/fullCrew
// 0 1 2 3 4
// returns Array - format [[<Object>unit,<String>role,<Number>cargoIndex,<Array>turretPath,<Boolean>personTurret], ...]
//diag_log format["_fnc_vehicleMonitor:: (65) _veh = %1",_veh];
if ({alive _x and !(isPlayer _x)} count (crew _veh) > 0) then
{
_crew = fullCrew _veh;
//diag_log format["_fnc_vehicleMonitor:: (67) _crew = %1",_crew];
{
//diag_log format ["_fnc_vehicleMonitor:: (69) _x = %1",_x];
_mag = _veh currentMagazineTurret (_x select 3);
if (count _mag > 0) then
{
//diag_log format["_fnc_vehicleMonitor:: (71) _mag is typeName %1", typeName _mag];
//diag_log format ["_fnc_vehicleMonitor:: (71) length _mag = %2 and _mag = %1",_mag,count _mag];
_allMags = magazinesAmmo _veh;
//diag_log format["_fnc_vehicleMonitor:: (71) _allMags = %1",_allMags];
_cnt = ( {_mag isEqualTo (_x select 0)}count _allMags);
//diag_log format["_fnc_vehicleMonitor:: (75) _cnt = %1",_cnt];
if (_cnt < 2) then {_veh addMagazineCargo [_mag,2]};
};
} forEach _crew;
};
};
blck_fn_deleteAIvehicle = {
params["_veh"];
//diag_log format["blck_fn_deleteAIvehicle: _veh %1 deleted",_veh];
{
_veh removeAllEventHandlers _x;
}forEach ["Hit","HitPart","GetIn","GetOut","Fired","FiredNear","HandleDamage","Reloaded"];
blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
deleteVehicle _veh;
};
private ["_vehList","_veh","_isEmplaced","_ownerIsPlayer","_allCrewDead","_deleteNow","_missionCompleted","_evaluate","_cleanupTimer"];
_vehList = +blck_monitoredVehicles;
#ifdef blck_debugMode
if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function called at %1 with _vehList %2 and blck_monitoredVehicles %3",diag_tickTime,_vehList,blck_monitoredVehicles];};
#endif
//blck_fnc_releaseVehicleToPlayers
{
/*
Determine state of vehicle
@ -105,7 +36,13 @@ if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function c
_veh = _x; // (purely for clarity at this point, _x could be used just as well)
_isEmplaced = _veh getVariable["DBD_vehType","none"] isEqualTo "emplaced";
_ownerIsPlayer = if (owner _veh > 2 && !(owner _veh in blck_connectedHCs)) then {true} else {false};
/*
{
diag_log format["_fnc_vehicleMonitor: vehicle %1 crew %2 alive = %3",_veh,_x, alive _x];
}forEach (crew _veh);
*/
_allCrewDead = if (({alive _x} count (crew _veh)) == 0) then {true} else {false};
//diag_log format["_fnc_vehicleMonitor: _allCrewDead = %1",_allCrewDead];
_deletenow = false;
if ( (_veh getVariable["blck_DeleteAt",0] > 0) && (diag_tickTime > (_veh getVariable "blck_DeleteAt"))) then {_deleteNow = true};
_missionCompleted = if (_veh getVariable["missionCompleted",0] != 0) then {true} else {false};
@ -132,7 +69,7 @@ if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function c
_veh setDamage 1;
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
}else {
[_veh] call _fn_releaseVehicle;
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
} else {
@ -142,7 +79,7 @@ if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function c
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
} else {
//diag_log format["_fnc_vehicleMonitor:: case of RELEASE where vehicle = %1 and Vehicle is typeOf %2",_veh, typeOf _veh];
[_veh] call _fn_releaseVehicle;
[_veh] call blck_fnc_releaseVehicleToPlayers;
};
_evaluate = false;
};
@ -158,12 +95,12 @@ if (blck_debugLevel > 2) then {diag_log format["_fnc_vehicleMonitor:: function c
if (_evaluate) then
{
[_veh] call _fn_reloadAmmo;
[_veh] call blck_fnc_reloadVehicleAmmo;
};
if (_deleteNow) then
{
[_veh] call _fn_destroyVehicleAndCrew;
[_veh] call blck_fnc_destroyVehicleAndCrew;
_evaluate = false;
};

View File

@ -106,6 +106,10 @@ blck_fnc_HandleAIVehicleHit = compileFinal preprocessFileLineNumbers "\q\addons\
blck_EH_VehicleKilled = "\q\addons\custom_server\Compiles\Vehicles\GMS_EH_VehicleKilled.sqf";
blck_fnc_processAIVehicleKill = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_processAIVehicleKill.sqf";
blck_fnc_selectPatrolVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_selectPatrolVehicle.sqf";
blck_fnc_releaseVehicleToPlayers = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_releaseVehicleToPlayers.sqf";
blck_fnc_deleteAIVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_deleteAIVehicle.sqf";
blck_fnc_destroyVehicleAndCrew = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_destroyVehicleAndCrew.sqf";
blck_fnc_reloadVehicleAmmo = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Vehicles\GMS_fnc_reloadVehicleAmmo.sqf";
// functions to support Units
blck_fnc_removeGear = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Units\GMS_fnc_removeGear.sqf"; // Strip an AI unit of all gear.
@ -135,10 +139,12 @@ blck_fnc_nextAnim = compileFinal preprocessFileLineNumbers "\q\addons\custom_se
// HC support functions
blck_fnc_HC_XferGroup = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HC_XferGroup.sqf";
blck_fnc_HC_XferVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HC_XferVehicle.sqf";
//blck_fnc_HC_XferVehicle = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HC_XferVehicle.sqf";
blck_fnc_onPlayerDisconnected = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_onPlayerDisconnected.sqf";
//blck_fnc_HC_groupsAssigned = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HC_groupsAssigned.sqf";
blck_fnc_HCmonitor = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HCmonitor.sqf";
blck_fnc_HC_vehicleMonitor = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\HC\GMS_fnc_HC_vehicleMonitor.sqf";
onPlayerDisconnected {[_name,_owner] call blck_fnc_onPlayerDisconnected;};
diag_log "[blckeagls] Functions Loaded";
blck_functionsCompiled = true;

View File

@ -29,10 +29,12 @@ blck_monitoredMissionAIGroups = []; // Used to track groups in active missions
blck_oldMissionObjects = [];
blck_pendingMissions = [];
blck_missionsRunning = 0;
blck_missionsRun = 0;
blck_activeMissions = [];
blck_deadAI = [];
blck_connectedHCs = [];
blck_missionMarkers = [];
blck_HC_monitoredVehicles = [];
#ifdef useDynamicSimulation
"Group" setDynamicSimulationDistance 1800;
enableDynamicSimulationSystem true;