Updated _fnc_findSafePos/Added some settings
This commit is contained in:
parent
6aaea1b2d2
commit
cd05615532
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
|
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
|
||||||
|
|
||||||
private["_findNew","_coords","_dist","_xpos","_ypos","_newPos","_townPos","_pole"];
|
private["_findNew","_tries","_coords","_dist","_xpos","_ypos","_newPos","_townPos","_pole"];
|
||||||
|
|
||||||
_findNew = true;
|
_findNew = true;
|
||||||
|
_tries = 0;
|
||||||
while {_findNew} do {
|
while {_findNew} do {
|
||||||
_findNew = false;
|
_findNew = false;
|
||||||
//[_centerForSearch,_minDistFromCenter,_maxDistanceFromCenter,_minDistanceFromNearestObj,_waterMode,_maxTerainGradient,_shoreMode] call BIS_fnc_findSafePos
|
//[_centerForSearch,_minDistFromCenter,_maxDistanceFromCenter,_minDistanceFromNearestObj,_waterMode,_maxTerainGradient,_shoreMode] call BIS_fnc_findSafePos
|
||||||
@ -87,7 +87,7 @@ while {_findNew} do {
|
|||||||
// check that missions spawn at least 1 kkm from towns
|
// check that missions spawn at least 1 kkm from towns
|
||||||
{
|
{
|
||||||
_townPos = [((locationPosition _x) select 0), ((locationPosition _x) select 1), 0];
|
_townPos = [((locationPosition _x) select 0), ((locationPosition _x) select 1), 0];
|
||||||
if (_townPos distance2D _coords < 200) exitWith {
|
if (_townPos distance2D _coords < blck_minDistanceFromTowns) exitWith {
|
||||||
_findNew = true;
|
_findNew = true;
|
||||||
};
|
};
|
||||||
} forEach blck_townLocations;
|
} forEach blck_townLocations;
|
||||||
@ -99,15 +99,15 @@ while {_findNew} do {
|
|||||||
if (_mod isEqualTo "Exile") then {_pole = "Exile_Construction_Flag_Static"};
|
if (_mod isEqualTo "Exile") then {_pole = "Exile_Construction_Flag_Static"};
|
||||||
//diag_log format["_fnc_findSafePosn:: -- >> _mod = %1 and _pole = %2",_mod,_pole];
|
//diag_log format["_fnc_findSafePosn:: -- >> _mod = %1 and _pole = %2",_mod,_pole];
|
||||||
{
|
{
|
||||||
if ((_x distance2D _coords) < 600) then
|
if ((_x distance2D _coords) < blck_minDistanceToBases) then
|
||||||
{
|
{
|
||||||
_findNew = true;
|
_findNew = true;
|
||||||
};
|
};
|
||||||
}forEach nearestObjects[player, [_pole], 800];
|
}forEach nearestObjects[blck_mapCenter, [_pole], blck_minDistanceToBases];
|
||||||
|
|
||||||
// check to be sure we do not spawn a mission on top of a player.
|
// check to be sure we do not spawn a mission on top of a player.
|
||||||
{
|
{
|
||||||
if (isPlayer _x && (_x distance2D _coords) < 600) then
|
if (isPlayer _x && (_x distance2D _coords) < blck_minDistanceToPlayer) then
|
||||||
{
|
{
|
||||||
_findNew = true;
|
_findNew = true;
|
||||||
};
|
};
|
||||||
@ -120,6 +120,7 @@ while {_findNew} do {
|
|||||||
deleteVehicle _tavTest;
|
deleteVehicle _tavTest;
|
||||||
if (_tavHeight > 100) then {_FindNew = true;};
|
if (_tavHeight > 100) then {_FindNew = true;};
|
||||||
};
|
};
|
||||||
|
_tries = _tries + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((count _coords) > 2) then
|
if ((count _coords) > 2) then
|
||||||
|
@ -156,13 +156,16 @@ _fn_monitorGroupWaypoints = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_fn_simulationMonitor = {
|
_fn_simulationMonitor = {
|
||||||
|
private["_playerType","_modType","_players"];
|
||||||
_modType = call blck_fnc_getModType;
|
_modType = call blck_fnc_getModType;
|
||||||
|
//diag_log format["_fn_simulationMonitor"" _modType = %1",_modType];
|
||||||
if (_modType isEqualTo "Exile") then
|
if (_modType isEqualTo "Exile") then
|
||||||
{
|
{
|
||||||
_playerType = ["Exile_Unit_Player"];
|
_playerType = ["Exile_Unit_Player"];
|
||||||
}else{
|
}else{
|
||||||
_playerType = ["Epoch_Male_F","Epoch_Female_F"];
|
_playerType = ["Epoch_Male_F","Epoch_Female_F"];
|
||||||
};
|
};
|
||||||
|
//diag_log format["_fn_simulationMonitor:: _playerType = %1",_playerType];
|
||||||
{
|
{
|
||||||
// player nearEntities [["Car", "Motorcycle", "Tank"], 50];
|
// player nearEntities [["Car", "Motorcycle", "Tank"], 50];
|
||||||
_players = (leader _x) nearEntities [_playerType, 1800];
|
_players = (leader _x) nearEntities [_playerType, 1800];
|
||||||
|
@ -163,7 +163,7 @@ if (_useMines) then
|
|||||||
};
|
};
|
||||||
uiSleep _delayTime;
|
uiSleep _delayTime;
|
||||||
_temp = [];
|
_temp = [];
|
||||||
diag_log format["_missionSpawner"" _missionLandscape = %1",_missionLandscape];
|
//diag_log format["_missionSpawner"" _missionLandscape = %1",_missionLandscape];
|
||||||
if (_missionLandscapeMode isEqualTo "random") then
|
if (_missionLandscapeMode isEqualTo "random") then
|
||||||
{
|
{
|
||||||
_temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape;
|
_temp = [_coords,_missionLandscape, 3, 15, 2] call blck_fnc_spawnRandomLandscape;
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
Spawn objects from an array using offsects from a central location.
|
||||||
|
The code provided by M3Editor EDEN has been addapted to add checks for vehicles, should they be present.
|
||||||
|
Returns an array of spawned objects.
|
||||||
|
version of 10/13/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["_center","_objects"];
|
||||||
|
if (count _center == 2) then {_center pushBack 0};
|
||||||
|
//diag_log format["_spawnBaseObjects:: -> _objects = %1",_objects];
|
||||||
|
private ["_newObjs"];
|
||||||
|
|
||||||
|
_newObjs = [];
|
||||||
|
|
||||||
|
{
|
||||||
|
//diag_log format["_fnc_spawnBaseObjects::-->> _x = %1",_x];
|
||||||
|
private _obj = (_x select 0) createVehicle [0,0,0];
|
||||||
|
//diag_log format["_fnc_spawnBaseObjects: _obj = %1",_obj];
|
||||||
|
_newObjs pushback _obj;
|
||||||
|
//diag_log format["_fnc_spawnBaseObjects: _center = %1 and _x select 1 = %2",_center,_x select 1];
|
||||||
|
private _spawnPos = (_center vectorAdd (_x select 1));
|
||||||
|
if (surfaceIsWater _spawnPos) then
|
||||||
|
{
|
||||||
|
_obj setPosASL _spawnPos;
|
||||||
|
//diag_log "_fnc_spawnBaseObjects: detected surface == water";
|
||||||
|
} else {
|
||||||
|
_obj setPosATL _spawnPos;
|
||||||
|
//diag_log "_fnc_spawnBaseObjects: detected surface = Land";
|
||||||
|
};
|
||||||
|
_obj setDir (_x select 2);
|
||||||
|
_obj enableDynamicSimulation true;
|
||||||
|
_obj allowDamage true;
|
||||||
|
// Lock any vehicles placed as part of the mission landscape. Note that vehicles that can be taken by players can be added via the mission template.
|
||||||
|
if ( (typeOf _obj) isKindOf "LandVehicle" || (typeOf _obj) isKindOf "Air" || (typeOf _obj) isKindOf "Sea") then
|
||||||
|
{
|
||||||
|
[_obj] call blck_fnc_configureMissionVehicle;
|
||||||
|
};
|
||||||
|
} forEach _objects;
|
||||||
|
//diag_log format["_fnc_spawnBaseObjects: _newObjs = 51",_newObjs];
|
||||||
|
_newObjs
|
||||||
|
|
@ -16,12 +16,22 @@
|
|||||||
params["_center","_objects"];
|
params["_center","_objects"];
|
||||||
if (count _center == 2) then {_center pushBack 0};
|
if (count _center == 2) then {_center pushBack 0};
|
||||||
//diag_log format["_spawnBaseObjects:: -> _objects = %1",_objects];
|
//diag_log format["_spawnBaseObjects:: -> _objects = %1",_objects];
|
||||||
private ["_newObjs"];
|
private ["_newObjs","_simDam"];
|
||||||
|
|
||||||
_newObjs = [];
|
_newObjs = [];
|
||||||
|
// Assume that the list of objects to spawn has each object defined using one of two methods where parameters for simulation and damage are optional with default settings.
|
||||||
|
// 1. ["class_name",[pos x, y, z], dir, [eneable simulation, enable damage]]
|
||||||
|
|
||||||
{
|
{
|
||||||
//diag_log format["_fnc_spawnBaseObjects::-->> _x = %1",_x];
|
//diag_log format["_fnc_spawnBaseObjects::-->> _x = %1",_x];
|
||||||
|
if (count _x == 3) then
|
||||||
|
{
|
||||||
|
_simDam = [false,false];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_simDam = _x select 3;
|
||||||
|
};
|
||||||
private _obj = (_x select 0) createVehicle [0,0,0];
|
private _obj = (_x select 0) createVehicle [0,0,0];
|
||||||
//diag_log format["_fnc_spawnBaseObjects: _obj = %1",_obj];
|
//diag_log format["_fnc_spawnBaseObjects: _obj = %1",_obj];
|
||||||
_newObjs pushback _obj;
|
_newObjs pushback _obj;
|
||||||
@ -36,8 +46,8 @@ _newObjs = [];
|
|||||||
//diag_log "_fnc_spawnBaseObjects: detected surface = Land";
|
//diag_log "_fnc_spawnBaseObjects: detected surface = Land";
|
||||||
};
|
};
|
||||||
_obj setDir (_x select 2);
|
_obj setDir (_x select 2);
|
||||||
_obj enableDynamicSimulation true;
|
_obj enableDynamicSimulation (_simDam select 0);
|
||||||
_obj allowDamage true;
|
_obj allowDamage (_simDam select 1);
|
||||||
// Lock any vehicles placed as part of the mission landscape. Note that vehicles that can be taken by players can be added via the mission template.
|
// Lock any vehicles placed as part of the mission landscape. Note that vehicles that can be taken by players can be added via the mission template.
|
||||||
if ( (typeOf _obj) isKindOf "LandVehicle" || (typeOf _obj) isKindOf "Air" || (typeOf _obj) isKindOf "Sea") then
|
if ( (typeOf _obj) isKindOf "LandVehicle" || (typeOf _obj) isKindOf "Air" || (typeOf _obj) isKindOf "Sea") then
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,7 @@ if (blck_debugLevel >=2) then
|
|||||||
// [_coords, _minNoAI,_maxNoAI,_aiDifficultyLevel,blck_UMS_uniforms,blck_UMS_headgear,_scubaGroupParameters,blck_UMS_weapons,blck_UMS_vests,isScubaGroup]
|
// [_coords, _minNoAI,_maxNoAI,_aiDifficultyLevel,blck_UMS_uniforms,blck_UMS_headgear,_scubaGroupParameters,blck_UMS_weapons,blck_UMS_vests,isScubaGroup]
|
||||||
params["_coords",["_minNoAI",3],["_maxNoAI",6],["_aiDifficultyLevel","red"],["_uniforms",blck_SkinList],["_headGear",blck_BanditHeadgear],"_missionGroups",["_weapons",[]],["_vests",blck_vests],["_isScubaGroup",false]];
|
params["_coords",["_minNoAI",3],["_maxNoAI",6],["_aiDifficultyLevel","red"],["_uniforms",blck_SkinList],["_headGear",blck_BanditHeadgear],"_missionGroups",["_weapons",[]],["_vests",blck_vests],["_isScubaGroup",false]];
|
||||||
private["_unitsToSpawn","_unitsPerGroup","_ResidualUnits","_newGroup","_blck_AllMissionAI","_abort"];
|
private["_unitsToSpawn","_unitsPerGroup","_ResidualUnits","_newGroup","_blck_AllMissionAI","_abort"];
|
||||||
|
// Can add optional debug code here if needed.
|
||||||
_unitsToSpawn = [[_minNoAI,_maxNoAI]] call blck_fnc_getNumberFromRange; //round(_minNoAI + round(random(_maxNoAI - _minNoAI)));
|
_unitsToSpawn = [[_minNoAI,_maxNoAI]] call blck_fnc_getNumberFromRange; //round(_minNoAI + round(random(_maxNoAI - _minNoAI)));
|
||||||
_unitsPerGroup = floor(_unitsToSpawn/_noAIGroups);
|
_unitsPerGroup = floor(_unitsToSpawn/_noAIGroups);
|
||||||
_ResidualUnits = _unitsToSpawn - (_unitsPerGroup * _noAIGroups);
|
_ResidualUnits = _unitsToSpawn - (_unitsPerGroup * _noAIGroups);
|
||||||
@ -46,7 +47,7 @@ if (blck_debugLevel >=2) then
|
|||||||
diag_log format["_fnc_spawnMissionAI (30):: _unitsToSpawn %1 ; _unitsPerGroup %2 _ResidualUnits %3",_unitsToSpawn,_unitsPerGroup,_ResidualUnits];
|
diag_log format["_fnc_spawnMissionAI (30):: _unitsToSpawn %1 ; _unitsPerGroup %2 _ResidualUnits %3",_unitsToSpawn,_unitsPerGroup,_ResidualUnits];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
if (count _missionGroups > 0) then
|
if ( (count _missionGroups > 0) && _noAIGroups > 0) then
|
||||||
{
|
{
|
||||||
{ //[[-98.9121,-35.9824,-1.20243],5,7,"Green",5,12],[[1,-1,-1],"red",4, 5,10]
|
{ //[[-98.9121,-35.9824,-1.20243],5,7,"Green",5,12],[[1,-1,-1],"red",4, 5,10]
|
||||||
_x params["_position","_minAI","_maxAI","_skillLevel","_minPatrolRadius","_maxPatrolRadius"];
|
_x params["_position","_minAI","_maxAI","_skillLevel","_minPatrolRadius","_maxPatrolRadius"];
|
||||||
@ -81,7 +82,7 @@ if (count _missionGroups > 0) then
|
|||||||
};
|
};
|
||||||
}forEach _missionGroups;
|
}forEach _missionGroups;
|
||||||
};
|
};
|
||||||
if (_missionGroups isEqualTo []) then
|
if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
|
||||||
{
|
{
|
||||||
switch (_noAIGroups) do
|
switch (_noAIGroups) do
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,10 @@ _objects = [];
|
|||||||
// https://community.bistudio.com/wiki/BIS_fnc_findSafePos
|
// https://community.bistudio.com/wiki/BIS_fnc_findSafePos
|
||||||
_pos = [_coords,_min,_max,_nearest,0,5,0] call BIS_fnc_findSafePos;
|
_pos = [_coords,_min,_max,_nearest,0,5,0] call BIS_fnc_findSafePos;
|
||||||
_wreck = createVehicle[_x, _pos, [], 25, "NONE"];
|
_wreck = createVehicle[_x, _pos, [], 25, "NONE"];
|
||||||
|
_wreck allowDamage false;
|
||||||
|
_wreck enableSimulation false;
|
||||||
|
_wreck enableSimulationGlobal false;
|
||||||
|
_wreck enableDynamicSimulation false;
|
||||||
_wreck setVariable ["LAST_CHECK", (diag_tickTime + 100000)];
|
_wreck setVariable ["LAST_CHECK", (diag_tickTime + 100000)];
|
||||||
|
|
||||||
private["_dir","_dirOffset"];
|
private["_dir","_dirOffset"];
|
||||||
|
@ -43,7 +43,7 @@ _fn_destroyVehicleAndCrew = {
|
|||||||
params["_veh"];
|
params["_veh"];
|
||||||
//private["_crew"];
|
//private["_crew"];
|
||||||
//_crew = crew _veh;
|
//_crew = crew _veh;
|
||||||
diag_log format["_fn_destroyVehicleAndCrew: called for _veh = %1",_veh];
|
//diag_log format["_fn_destroyVehicleAndCrew: called for _veh = %1",_veh];
|
||||||
{[_x] call blck_fnc_deleteAI;} forEach (crew _veh);
|
{[_x] call blck_fnc_deleteAI;} forEach (crew _veh);
|
||||||
[_veh] call blck_fn_deleteAIvehicle;
|
[_veh] call blck_fn_deleteAIvehicle;
|
||||||
};
|
};
|
||||||
@ -78,7 +78,7 @@ _fn_reloadAmmo = {
|
|||||||
|
|
||||||
blck_fn_deleteAIvehicle = {
|
blck_fn_deleteAIvehicle = {
|
||||||
params["_veh"];
|
params["_veh"];
|
||||||
diag_log format["blck_fn_deleteAIvehicle: _veh %1 deleted",_veh];
|
//diag_log format["blck_fn_deleteAIvehicle: _veh %1 deleted",_veh];
|
||||||
{
|
{
|
||||||
_veh removeAllEventHandlers _x;
|
_veh removeAllEventHandlers _x;
|
||||||
}forEach ["Hit","HitPart","GetIn","GetOut","Fired","FiredNear","HandleDamage","Reloaded"];
|
}forEach ["Hit","HitPart","GetIn","GetOut","Fired","FiredNear","HandleDamage","Reloaded"];
|
||||||
@ -116,7 +116,7 @@ if (blck_debugLevel > 0) then {diag_log format["_fnc_vehicleMonitor:: function c
|
|||||||
_evaluate = false;
|
_evaluate = false;
|
||||||
_veh setVariable["blck_DeleteAt",0];
|
_veh setVariable["blck_DeleteAt",0];
|
||||||
blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
|
blck_monitoredVehicles = blck_monitoredVehicles - [_veh];
|
||||||
diag_log format["_fnc_vehicleMonitor: vehicle %1 now owned by player %2",_veh, owner _veh];
|
//diag_log format["_fnc_vehicleMonitor: vehicle %1 now owned by player %2",_veh, owner _veh];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_allCrewDead && _evaluate) then
|
if (_allCrewDead && _evaluate) then
|
||||||
@ -140,7 +140,7 @@ if (blck_debugLevel > 0) then {diag_log format["_fnc_vehicleMonitor:: function c
|
|||||||
_veh setDamage 0.7;
|
_veh setDamage 0.7;
|
||||||
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
|
_veh setVariable["blck_DeleteAt",diag_tickTime + 60];
|
||||||
} else {
|
} else {
|
||||||
diag_log format["_fnc_vehicleMonitor:: case of RELEASE where vehicle = %1 and Vehicle is typeOf %2",_veh, typeOf _veh];
|
//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 _fn_releaseVehicle;
|
||||||
};
|
};
|
||||||
_evaluate = false;
|
_evaluate = false;
|
||||||
@ -149,7 +149,7 @@ if (blck_debugLevel > 0) then {diag_log format["_fnc_vehicleMonitor:: function c
|
|||||||
|
|
||||||
if (_missionCompleted && !(_allCrewDead)) then
|
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];
|
//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];
|
||||||
private _cleanupTimer = _veh getVariable["blck_DeleteAt",0]; // The time delete to deleting any alive AI units
|
private _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]};
|
if (_cleanupTimer == 0) then {_veh setVariable["blck_DeleteAt",diag_tickTime + blck_vehicleDeleteTimer]};
|
||||||
_evaluate = false;
|
_evaluate = false;
|
||||||
|
@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
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];
|
|
||||||
|
|
||||||
if (true) exitWith {};
|
|
||||||
|
|
||||||
#ifdef blck_debugMode
|
|
||||||
//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 > 0) 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 = +blck_monitoredVehicles;
|
|
||||||
|
|
||||||
#ifdef blck_debugMode
|
|
||||||
if (blck_debugLevel > 0) 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
|
|
||||||
_isEmplaced
|
|
||||||
_ownerIsPlayer
|
|
||||||
_allCrewDead
|
|
||||||
_deleteNow
|
|
||||||
*/
|
|
||||||
|
|
||||||
private _veh = _x; // (purely for clarity at this point, _x could be used just as well)
|
|
||||||
private _isEmplaced = _veh getVariable["DBD_vehType","none"] isEqualTo "emplaced";
|
|
||||||
private _ownerIsPlayer = if (owner _veh > 2 && !(owner _veh in blck_connectedHCs)) then {true} else {false};
|
|
||||||
private _allCrewDead = {alive _x} count (crew _veh);
|
|
||||||
private _deletenow = if ( (_veh getVariable["blck_DeleteAt",0] > 0) && (diag_tickTime > (_veh getVariable "blck_DeleteAt"))) then {true} else {false};
|
|
||||||
private _missionCompleted = _veh getVariable["missionCompleted",0];
|
|
||||||
private _evaluate = true;
|
|
||||||
|
|
||||||
if (_ownerIsPlayer) then
|
|
||||||
{
|
|
||||||
// disable further monitoring and mark to never be deleted.
|
|
||||||
_evaluate = false;
|
|
||||||
_veh setVariable["blck_DeleteAt",0];
|
|
||||||
blck_monitoredVehicles = blck_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 > 0) 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 _fn_releaseVehicle;
|
|
||||||
};
|
|
||||||
_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 _fn_releaseVehicle;
|
|
||||||
};
|
|
||||||
_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];
|
|
||||||
private _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 _fn_reloadAmmo;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_deleteNow) then
|
|
||||||
{
|
|
||||||
[_veh] call _fn_destroyVehicleAndCrew;
|
|
||||||
_evaluate = false;
|
|
||||||
};
|
|
||||||
}forEach _vehList;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user