From 15429d57128f380b5eb71ab53d44e00694ce3eb5 Mon Sep 17 00:00:00 2001 From: eraser1 <hackinz4gamez@hotmail.com> Date: Fri, 28 Aug 2015 20:48:18 -0500 Subject: [PATCH] Tweaks + New Functions Move mission variable initialization to mission_init Create mission_init Create selectMission Add "_missionSide" to missionstatuscheck params ("bandit" or "hero". Only "bandit" functionality currently) --- @ExileServer/addons/a3_dms/fn_DMS_preInit.sqf | 9 +---- .../addons/a3_dms/missions/SelectMission.sqf | 35 +++++++++++++++++++ .../addons/a3_dms/missions/mission_init.sqf | 29 +++++++++++++++ .../a3_dms/scripts/MissionStatusCheck.sqf | 24 ++++++++++++- 4 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 @ExileServer/addons/a3_dms/missions/SelectMission.sqf create mode 100644 @ExileServer/addons/a3_dms/missions/mission_init.sqf diff --git a/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf b/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf index 169d64b..88a7a61 100644 --- a/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf +++ b/@ExileServer/addons/a3_dms/fn_DMS_preInit.sqf @@ -3,15 +3,9 @@ Written by eraser1 (trainwreckdayz.com) */ -// Initialize Variables -DMS_Mission_Arr = []; -DMS_MissionCount = 0; -DMS_CleanUpList = []; - /* compiles DMS_CreateMarker = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\DMS_CreateMarker.sqf"; DMS_spawnAI = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\DMS_spawnAI.sqf"; -DMS_selectMission = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\DMS_selectMission.sqf"; spawn_group = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\spawn_group.sqf"; spawn_soldier = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\spawn_soldier.sqf"; spawn_static = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\spawn_static.sqf"; @@ -22,11 +16,10 @@ vehicle_patrol = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts on_kill = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\on_kill.sqf"; bandit_behaviour = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\bandit_behaviour.sqf"; vehicle_monitor = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\vehicle_monitor.sqf"; -find_position = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\find_position.sqf"; -load_ammo = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\load_ammo.sqf"; */ //Completed +DMS_selectMission = compileFinal preprocessFileLineNumbers "\x\addons\dms\missions\SelectMission.sqf"; DMS_MissionStatusCheck = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\MissionStatusCheck.sqf"; DMS_MissionSuccessState = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\MissionSuccessState.sqf"; DMS_findSafePos = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\FindSafePos.sqf"; diff --git a/@ExileServer/addons/a3_dms/missions/SelectMission.sqf b/@ExileServer/addons/a3_dms/missions/SelectMission.sqf new file mode 100644 index 0000000..8442883 --- /dev/null +++ b/@ExileServer/addons/a3_dms/missions/SelectMission.sqf @@ -0,0 +1,35 @@ +/* + DMS_selectMission + Influenced by WAI + Created by eraser1 + + Selects/Spawns missions. Takes no arguments, returns nothing. +*/ +private "_time"; + +_time = diag_tickTime; + +if (DMS_RunningBMissionCount isEqualTo DMS_MaxBanditMissions) then +{ + DMS_BMissionLastStart = _time; +}; + +if ((_time - DMS_BMissionLastStart >= DMS_TimeBetweenMissions) && {diag_fps >= DMS_MinServerFPS && {(count allPlayers) >= DMS_MinPlayerCount}}) then +{ + private "_mission"; + + DMS_MissionCount = DMS_MissionCount + 1; + DMS_RunningBMissionCount = DMS_RunningBMissionCount + 1; + + DMS_BMissionLastStart = _time; + _mission = DMS_MissionTypesArray call BIS_fnc_selectRandom; + + DMS_BMissionDelay = (DMS_TimeBetweenMissions select 0) + random((DMS_TimeBetweenMissions select 1) - (DMS_TimeBetweenMissions select 0)); + + if (DMS_DEBUG) then + { + diag_log format ["DMS_DEBUG SelectMission :: Spawning mission: %1 | DMS_BMissionDelay set to %2",_mission,DMS_TimeBetweenMissions]; + }; + + call compile preprocessFileLineNumbers (format ["\x\addons\DMS\missions\%1.sqf",_mission]); +}; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/missions/mission_init.sqf b/@ExileServer/addons/a3_dms/missions/mission_init.sqf new file mode 100644 index 0000000..d28ed27 --- /dev/null +++ b/@ExileServer/addons/a3_dms/missions/mission_init.sqf @@ -0,0 +1,29 @@ +/* + DMS: mission_init.sqf + Created by eraser1 + + Initializes variables for DMS +*/ + +diag_log "DMS :: Initializing"; + +// Initialize Variables +DMS_Mission_Arr = []; +DMS_CleanUpList = []; +DMS_MissionCount = 0; +DMS_RunningBMissionCount = 0; +DMS_BMissionLastStart = diag_tickTime; + +DMS_BMissionDelay = (DMS_TimeBetweenMissions select 0) + random((DMS_TimeBetweenMissions select 1) - (DMS_TimeBetweenMissions select 0)); + +if (DMS_DEBUG) then +{ + diag_log format ["DMS_DEBUG mission_init :: Random time between missions is initialized at %1s",DMS_TimeBetweenMissions]; +}; + +// Set mission frequencies from config +{ + for "_i" from 1 to (_x select 1) do { + DMS_MissionTypesArray pushBack (_x select 0); + }; +} count DMS_MissionTypes; \ No newline at end of file diff --git a/@ExileServer/addons/a3_dms/scripts/MissionStatusCheck.sqf b/@ExileServer/addons/a3_dms/scripts/MissionStatusCheck.sqf index 74de6be..578a744 100644 --- a/@ExileServer/addons/a3_dms/scripts/MissionStatusCheck.sqf +++ b/@ExileServer/addons/a3_dms/scripts/MissionStatusCheck.sqf @@ -16,7 +16,8 @@ [_crate_loot_values] ], [_msgWIN,_msgLose], - _markers + _markers, + _missionSide ] */ if (DMS_Mission_Arr isEqualTo []) exitWith // Empty array, no missions running @@ -47,12 +48,23 @@ _index = 0; _msgWIN = _x select 5 select 0; _msgLose = _x select 5 select 1; _markers = _x select 6; + _missionSide = _x select 7; if (_success) exitWith { //Use FSM for cleanup instead //[DMS_CompletedMissionCleanupTime,DMS_CleanUp,(_units+_buildings),false] call ExileServer_system_thread_addTask; DMS_CleanUpList pushBack [_units+_building,diag_tickTime,DMS_CompletedMissionCleanupTime]; + + if (_missionSide isEqualTo "bandit") then + { + DMS_RunningBMissionCount = DMS_RunningBMissionCount -1; + } + else + { + // Not yet implemented + }; + _arr = DMS_Mission_Arr deleteAt _index; [_loot select 0,_crate_loot_values] call DMS_FillCrate; @@ -79,6 +91,16 @@ _index = 0; { //Nobody is nearby so just cleanup objects from here (_units+_buildings+_loot) call DMS_CleanUp; + + if (_missionSide isEqualTo "bandit") then + { + DMS_RunningBMissionCount = DMS_RunningBMissionCount -1; + } + else + { + // Not yet implemented + }; + _arr = DMS_Mission_Arr deleteAt _index; _msgLose call DMS_BroadcastMissionStatus;