Build 235 / Fix issue with loot vehicles not being spawend

/ Streamline coding for build 235
This commit is contained in:
Chris Cardozo 2020-11-16 13:32:12 -05:00
parent e11b9338ae
commit 60b1d21d16
3 changed files with 198 additions and 164 deletions

View File

@ -182,10 +182,11 @@ private _mines = [];
private _crates = [];
private _missionAIVehicles = [];
private _blck_AllMissionAI = [];
private _spawnedLootVehicles = [];
private _AI_Vehicles = [];
private _assetSpawned = objNull;
private _missionData = [_coords,_mines,_objects,_hiddenObjects,_crates, _blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_markers];
private _missionData = [_coords,_mines,_objects,_hiddenObjects,_crates, _blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_spawnedLootVehicles,_markers];
blck_activeMissionsList pushBack [_missionCategoryDescriptors,_missionTimeoutAt,_triggered,_spawnPara,_missionData,_missionParameters];
[format["Initialized Mission %1 | description %2 | difficulty %3 at %4",_markerName, _markerMissionName, _difficulty, diag_tickTime]] call blck_fnc_log;

View File

@ -17,16 +17,40 @@ for "_i" from 1 to (count blck_activeMissionsList) do
// Select a mission category (blue, red, green , etd)
private _el = blck_activeMissionsList deleteAt 0;
_el params [
"_missionCategoryDescriptors", // 0
"_missionTimeoutAt", // 1
"_triggered", // 2
"_spawnPara", // 3
"_missionData", // 4
"_missionParameters" // 5
"_missionTimeoutAt", // 1 // server time at which the mission times out.
"_triggered", // 2 // true/false - specifies if mission was triggered by a player or scripting such as debug setting
"_spawnPara", // 3 // true/false - specifies if para reinforcements were spawned
"_missionData", // 4 // variable containing information specific to this instance of the mission such as location and objects
"_missionParameters" // 5 // Variables regarding the configuration of the dynamic mission
];
private _playerInRange = [_missionData select 0, blck_TriggerDistance, false] call blck_fnc_playerInRange;
#define delayTime 1
private _monitorAction = -2;
if (_triggered == 0) then
{
if (diag_tickTime > _missionTimeoutAt) then
{
_monitorAction = -1;
} else {
if (_playerInRange) then {
_monitorAction = 0;
} else {
if (blck_debugLevel >= 3) then {_monitorAction = 0}; // simulate the mission being tripped by a player
};
};
} else {
if (_triggered isEqualTo 1) then
{
_monitorAction = 1;
};
};
if (_monitorAction == -2) exitWith {};
_missionCategoryDescriptors params [
"_difficulty",
"_noMissions", // Max no missions of this category
@ -36,7 +60,7 @@ for "_i" from 1 to (count blck_activeMissionsList) do
"_waitTime", // time at which a mission should be spawned
"_missionsData" //
];
//_missionData = [_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_markers];
_missionData params [
"_coords",
"_mines",
@ -46,9 +70,9 @@ for "_i" from 1 to (count blck_activeMissionsList) do
"_blck_AllMissionAI",
"_assetSpawned",
"_missionAIVehicles",
"_spawnedLootVehicles",
"_markers"
];
_missionParameters params[
"_markerName",
"_markerMissionName",
@ -107,30 +131,6 @@ for "_i" from 1 to (count blck_activeMissionsList) do
"_endCondition",
"_isScubaMission"
];
private _playerInRange = [_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange;
#define delayTime 1
private _monitorAction = -2;
if (_triggered isEqualTo 0) then
{
if (diag_tickTime > _missionTimeoutAt) then
{
_monitorAction = -1;
} else {
if (_playerInRange) then {
_monitorAction = 0;
} else {
if (blck_debugLevel >= 3) then {_monitorAction = 0}; // simulate the mission being tripped by a player
};
};
} else {
if (_triggered isEqualTo 1) then
{
_monitorAction = 1;
};
};
switch (_monitorAction) do
{
@ -145,6 +145,7 @@ for "_i" from 1 to (count blck_activeMissionsList) do
// Handle mission waiting to be triggerd and player is within the range to trigger
case 0:
{
#define triggered 2
#define timedOut 1
_el set[triggered,1];
@ -291,6 +292,11 @@ for "_i" from 1 to (count blck_activeMissionsList) do
};
uisleep 5;
if !(_missionLootVehicles isEqualTo []) then
{
_spawnedLootVehicles = [_coords,_missionLootVehicles,_spawnCratesTiming] call blck_fnc_spawnMissionLootVehicles;
};
private _noPatrols = [_noVehiclePatrols] call blck_fnc_getNumberFromRange;
if (blck_useVehiclePatrols && ((_noPatrols > 0) || !(_missionPatrolVehicles isEqualTo []))) then
@ -331,9 +337,9 @@ for "_i" from 1 to (count blck_activeMissionsList) do
};
if (_loadCratesTiming isEqualTo "atMissionSpawn") then
{
private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
//private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x,_crateMoney] call blck_fnc_addMoneyToObject;
[_x,missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} forEach _crates;
};
};
@ -350,7 +356,7 @@ for "_i" from 1 to (count blck_activeMissionsList) do
} forEach _crates;
private _spawnPara = if (random(1) < _chancePara) then {true} else {false};
_missionData = [_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_markers];
_missionData = [_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_spawnedLootVehicles,_markers];
_el set[missionData, _missionData];
@ -463,7 +469,7 @@ for "_i" from 1 to (count blck_activeMissionsList) do
} forEach _crates;
};
_missionData = [_coords,_mines,_objects,_hiddenObjects,_crates, _blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_markers];
_missionData = [_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetSpawned,_missionAIVehicles,_spawnedLootVehicles,_markers];
_el set[missionData, _missionData];
@ -494,25 +500,31 @@ for "_i" from 1 to (count blck_activeMissionsList) do
{
_objects append _crates;
};
private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
//private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x,_crateMoney] call blck_fnc_addMoneyToObject;
[_x, missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} forEach _crates;
};
};
if (_spawnCratesTiming in ["atMissionSpawnGround","atMissionSpawnAir"] && _loadCratesTiming isEqualTo "atMissionCompletion") then
if (_loadCratesTiming isEqualTo "atMissionCompletion") then
{
if (!(_secureAsset) || (_secureAsset && (alive _assetSpawned))) then
{
//private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x] call blck_fnc_loadMissionCrate;
[_x, missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} forEach _crates;
private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x] call blck_fnc_loadMissionCrate;
[_x,_crateMoney] call blck_fnc_addMoneyToObject;
} forEach _crates;
[_x, missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} forEach _spawnedLootVehicles;
};
};
_missionAIVehicles append _spawnedLootVehicles; // So these are deleted if no player enters the driver's seat.
if (_secureAsset && (alive _assetSpawned)) then
{
if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then
@ -542,17 +554,34 @@ for "_i" from 1 to (count blck_activeMissionsList) do
};
case 2: { // Abort, crate moved.
_endMsg = "Crate Removed from Mission Site Before Mission Completion: Mission Aborted";
_objects append _missionAIVehicles;
_objects append _spawnedLootVehicls;
[_coords,_mines,_objects,_hiddenObjects,_crates, _blck_AllMissionAI,"Crate Removed from Mission Site Before Mission Completion: Mission Aborted",_markers,markerPos (_markers select 1),_markerName,_markerMissionName, _exception] call blck_fnc_endMission;
_waitTime = diag_tickTime + _tMin + random(_tMax - _tMin);
_missionCategoryDescriptors set [noActive,_noActive - 1];
_missionCategoryDescriptors set [waitTime,_waitTime];
};
case 3: { // Abort, key asset killed
_objects append _missionAIVehicles;
_objects append _spawnedLootVehicles;
[_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetKilledMsg,_markers,markerPos (_markers select 1),_markerName,_markerMissionName, _exception] call blck_fnc_endMission;
_waitTime = diag_tickTime + _tMin + random(_tMax - _tMin);
_missionCategoryDescriptors set [noActive,_noActive - 1];
_missionCategoryDescriptors set [waitTime,_waitTime];
};
case 4: { // Reserved for grpNull errors in the future
};
case 5: {
// Used for testing purposes only
[format["Programed mission abort, debut level >= 4"]] call blck_fnc_log;
_objects append _missionAIVehicles;
_objects append _spawnedLootVehicles;
[_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetKilledMsg,_markers,markerPos (_markers select 1),_markerName,_markerMissionName, _exception] call blck_fnc_endMission;
}
_waitTime = diag_tickTime + _tMin + random(_tMax - _tMin);
_missionCategoryDescriptors set [noActive,_noActive - 1];
_missionCategoryDescriptors set [waitTime,_waitTime];
};
};
};
};

View File

@ -16,15 +16,19 @@ if (count _coords isEqualTo 2) then {_coords pushBack 0};
private _vehs = [];
{
_x params["_vehType","_vehOffset",["_dir",0],"_lootArray","_lootCounts"];
private _pos =_coords vectorAdd _vehOffset;
_veh = [_vehType, _pos] call blck_fnc_spawnVehicle;
_veh = [_vehType, _coords vectorAdd _vehOffset] call blck_fnc_spawnVehicle;
[_veh, _dir] call blck_fnc_setDirUp;
_veh lock _lock;
if (_loadCrateTiming isEqualTo "atMissionSpawn") then
if (_loadCrateTiming isEqualTo "atMissionSpawnGround") then
{
[_veh,_lootArray,_lootCounts] call blck_fnc_fillBoxes;
_veh setVariable["lootLoaded",true];
//private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
[_veh,missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} else {
_veh setVariable["lootArray",_lootArray];
_veh setVariable["lootCounts",_lootCounts];
_veh setVariable["lootLoaded",false];
};
_vehs pushback _veh;
}forEach _missionLootVehicles;