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)
This commit is contained in:
eraser1 2015-08-28 20:48:18 -05:00
parent bc2308f1a7
commit 15429d5712
4 changed files with 88 additions and 9 deletions

View File

@ -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";

View File

@ -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]);
};

View File

@ -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;

View File

@ -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;