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,102 +17,20 @@ 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
];
_missionCategoryDescriptors params [
"_difficulty",
"_noMissions", // Max no missions of this category
"_noActive", // Number active
"_tMin", // Used to calculate waittime in the future
"_tMax", // as above
"_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",
"_objects",
"_hiddenObjects",
"_crates",
"_blck_AllMissionAI",
"_assetSpawned",
"_missionAIVehicles",
"_markers"
];
_missionParameters params[
"_markerName",
"_markerMissionName",
"_endMsg",
"_startMsg",
"_defaultMissionLocations",
"_crateLoot",
"_lootCounts",
"_markerType",
"_markerColor",
"_markerSize",
"_markerBrush",
"_missionLandscapeMode",
"_garrisonedBuildings_BuildingPosnSystem",
"_garrisonedBuilding_ATLsystem",
"_missionLandscape",
"_simpleObjects",
"_missionLootBoxes",
"_missionLootVehicles",
"_missionPatrolVehicles",
"_submarinePatrols",
"_submarinePatrolParameters",
"_airPatrols",
"_noVehiclePatrols",
"_vehicleCrewCount",
"_missionEmplacedWeapons",
"_noEmplacedWeapons",
"_useMines",
"_minNoAI",
"_maxNoAI",
"_noAIGroups",
"_missionGroups",
"_scubaPatrols",
"_scubaGroupParameters",
"_hostageConfig",
"_enemyLeaderConfig",
"_assetKilledMsg",
"_uniforms",
"_headgear",
"_vests",
"_backpacks",
"_weaponList",
"_sideArms",
"_chanceHeliPatrol",
"_noChoppers",
"_missionHelis",
"_chancePara",
"_noPara",
"_paraTriggerDistance",
"_paraSkill",
"_chanceLoot",
"_paraLoot",
"_paraLootCounts",
"_spawnCratesTiming",
"_loadCratesTiming",
"_endCondition",
"_isScubaMission"
];
private _playerInRange = [_coords, blck_TriggerDistance, false] call blck_fnc_playerInRange;
private _playerInRange = [_missionData select 0, blck_TriggerDistance, false] call blck_fnc_playerInRange;
#define delayTime 1
private _monitorAction = -2;
if (_triggered isEqualTo 0) then
if (_triggered == 0) then
{
if (diag_tickTime > _missionTimeoutAt) then
{
@ -127,10 +45,92 @@ for "_i" from 1 to (count blck_activeMissionsList) do
} else {
if (_triggered isEqualTo 1) then
{
_monitorAction = 1;
_monitorAction = 1;
};
};
if (_monitorAction == -2) exitWith {};
_missionCategoryDescriptors params [
"_difficulty",
"_noMissions", // Max no missions of this category
"_noActive", // Number active
"_tMin", // Used to calculate waittime in the future
"_tMax", // as above
"_waitTime", // time at which a mission should be spawned
"_missionsData" //
];
_missionData params [
"_coords",
"_mines",
"_objects",
"_hiddenObjects",
"_crates",
"_blck_AllMissionAI",
"_assetSpawned",
"_missionAIVehicles",
"_spawnedLootVehicles",
"_markers"
];
_missionParameters params[
"_markerName",
"_markerMissionName",
"_endMsg",
"_startMsg",
"_defaultMissionLocations",
"_crateLoot",
"_lootCounts",
"_markerType",
"_markerColor",
"_markerSize",
"_markerBrush",
"_missionLandscapeMode",
"_garrisonedBuildings_BuildingPosnSystem",
"_garrisonedBuilding_ATLsystem",
"_missionLandscape",
"_simpleObjects",
"_missionLootBoxes",
"_missionLootVehicles",
"_missionPatrolVehicles",
"_submarinePatrols",
"_submarinePatrolParameters",
"_airPatrols",
"_noVehiclePatrols",
"_vehicleCrewCount",
"_missionEmplacedWeapons",
"_noEmplacedWeapons",
"_useMines",
"_minNoAI",
"_maxNoAI",
"_noAIGroups",
"_missionGroups",
"_scubaPatrols",
"_scubaGroupParameters",
"_hostageConfig",
"_enemyLeaderConfig",
"_assetKilledMsg",
"_uniforms",
"_headgear",
"_vests",
"_backpacks",
"_weaponList",
"_sideArms",
"_chanceHeliPatrol",
"_noChoppers",
"_missionHelis",
"_chancePara",
"_noPara",
"_paraTriggerDistance",
"_paraSkill",
"_chanceLoot",
"_paraLoot",
"_paraLootCounts",
"_spawnCratesTiming",
"_loadCratesTiming",
"_endCondition",
"_isScubaMission"
];
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];
@ -476,83 +482,106 @@ for "_i" from 1 to (count blck_activeMissionsList) do
switch (_exception) do
{
case 1: { // Normal Mission End
//diag_log format["_monitorInitializedMissions: Normal mission end"];
if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then
//diag_log format["_monitorInitializedMissions: Normal mission end"];
if (_spawnCratesTiming in ["atMissionEndGround","atMissionEndAir"]) then
{
if (!(_secureAsset) || (_secureAsset && (alive _assetSpawned))) then
{
if (count _missionLootBoxes > 0) then
{
if (!(_secureAsset) || (_secureAsset && (alive _assetSpawned))) then
{
if (count _missionLootBoxes > 0) then
{
_crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _difficulty] call blck_fnc_spawnMissionCrates;
}
else
{
_crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _difficulty] call blck_fnc_spawnMissionCrates;
};
if (blck_cleanUpLootChests) then
{
_objects append _crates;
};
private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x,_crateMoney] call blck_fnc_addMoneyToObject;
} forEach _crates;
};
};
if (_spawnCratesTiming in ["atMissionSpawnGround","atMissionSpawnAir"] && _loadCratesTiming isEqualTo "atMissionCompletion") then
_crates = [_coords,_missionLootBoxes,_loadCratesTiming,_spawnCratesTiming, "end", _difficulty] call blck_fnc_spawnMissionCrates;
}
else
{
if (!(_secureAsset) || (_secureAsset && (alive _assetSpawned))) then
{
private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x] call blck_fnc_loadMissionCrate;
[_x,_crateMoney] call blck_fnc_addMoneyToObject;
} forEach _crates;
};
_crates = [_coords,[[selectRandom blck_crateTypes,[0,0,0],_crateLoot,_lootCounts]], _loadCratesTiming,_spawnCratesTiming, "end", _difficulty] call blck_fnc_spawnMissionCrates;
};
if (_secureAsset && (alive _assetSpawned)) then
if (blck_cleanUpLootChests) then
{
if (_assetSpawned getVariable["assetType",0] isEqualTo 1) then
{
_assetSpawned setVariable["GMSAnimations",[""],true];
[_assetSpawned,""] remoteExec["switchMove",-2];;
uiSleep 0.1;
_assetSpawned enableAI "ALL";
private _newPos = (getPos _assetSpawned) getPos [1000, random(360)];
(group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0];
[group _assetSpawned,0] setWaypointPosition [_newPos,0];
[group _assetSpawned,0] setWaypointType "MOVE";
};
if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then
{
[_assetSpawned,""] remoteExec["switchMove",-2];
_assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]],true];
[_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]])] remoteExec["switchMove",-2];
};
_objects append _crates;
};
[_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_endMsg,_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];
//private _crateMoney = missionNamespace getVariable (format["blck_crateMoney%1",_difficulty]);
{
[_x, missionNamespace getVariable (format["blck_crateMoney%1",_difficulty])] call blck_fnc_addMoneyToObject;
} forEach _crates;
};
};
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, 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
{
_assetSpawned setVariable["GMSAnimations",[""],true];
[_assetSpawned,""] remoteExec["switchMove",-2];;
uiSleep 0.1;
_assetSpawned enableAI "ALL";
private _newPos = (getPos _assetSpawned) getPos [1000, random(360)];
(group _assetSpawned) setCurrentWaypoint [group _assetSpawned, 0];
[group _assetSpawned,0] setWaypointPosition [_newPos,0];
[group _assetSpawned,0] setWaypointType "MOVE";
};
if (_assetSpawned getVariable["assetType",0] isEqualTo 2) then
{
[_assetSpawned,""] remoteExec["switchMove",-2];
_assetSpawned setVariable["GMSAnimations",_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]],true];
[_assetSpawned,selectRandom(_assetSpawned getVariable["endAnimation",["AidlPercMstpSnonWnonDnon_AI"]])] remoteExec["switchMove",-2];
};
};
[_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_endMsg,_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 2: { // Abort, crate moved.
_endMsg = "Crate Removed from Mission Site Before Mission Completion: Mission Aborted";
[_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;
};
case 3: { // Abort, key asset killed
[_coords,_mines,_objects,_hiddenObjects,_crates,_blck_AllMissionAI,_assetKilledMsg,_markers,markerPos (_markers select 1),_markerName,_markerMissionName, _exception] call blck_fnc_endMission;
};
_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;