Skip to content

Commit

Permalink
Fix comms tower only affecting first objective
Browse files Browse the repository at this point in the history
  • Loading branch information
theace0296 committed Oct 25, 2021
1 parent 2371c23 commit 564fdea
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 160 deletions.
3 changes: 2 additions & 1 deletion RandFramework/Global/common/fn_callNearbyPatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ if (_SpottedUnitCount > 0) then {
_TankMaxCount = 120;
_AirMaxCount = 120;
};
if (TRGM_VAR_bCommsBlocked) then {
private _commsDown = TRGM_VAR_bCommsBlocked select _iTaskIndex;
if (!(isNil "_commsDown") && {_commsDown}) then {
_InfMaxCount = 600; //10 mins
_TankMaxCount = 600;
_AirMaxCount = 600;
Expand Down
227 changes: 127 additions & 100 deletions RandFramework/Global/common/fn_showIntel.sqf
Original file line number Diff line number Diff line change
@@ -1,124 +1,151 @@
// private _fnc_scriptName = "TRGM_GLOBAL_fnc_showIntel";
params ["_AllowedIntelToShow", "_FoundViaType"];
params ["_FoundViaType", "_iTaskIndex"];

if !(side player isEqualTo TRGM_VAR_FriendlySide) exitWith {};


if (side player isEqualTo TRGM_VAR_FriendlySide) then {
private _IntelToShow = 0;
private _iAttemptCount = 0;
while {_IntelToShow isEqualTo 0 && _iAttemptCount < 100} do {
_iAttemptCount = _iAttemptCount + 1;
_IntelToShow = selectRandom _AllowedIntelToShow;
if (_IntelToShow in TRGM_VAR_IntelFound) then {_IntelToShow = 0};
if (isNil _iTaskIndex) then {
_iTaskIndex = TRGM_VAR_ObjectivePositions findIf {!(_x in TRGM_VAR_ClearedPositions);};
if (_iTaskIndex < 0) then {
_iTaskIndex = 0;
};
};

if ((TRGM_VAR_iMissionParamObjectives # _iTaskIndex # 0) in TRGM_VAR_MissionsThatHaveIntel) exitWith {
{
_x params ["_taskType", "_isHeavy", "_isHidden", "_sameAOAsPrev"];
if (_isHidden) then {
format["mrkMainObjective%1", _forEachIndex] setMarkerType "mil_unknown";
} else {
private _showIntelHandle = [_FoundViaType, _forEachIndex] spawn TRGM_GLOBAL_fnc_showIntel;
waitUntil {sleep 1; scriptDone _showIntelHandle;};
};
} forEach TRGM_VAR_iMissionParamObjectives;
[localize "STR_TRGM2_interrogateOfficer_MapIntel"] call TRGM_GLOBAL_fnc_notifyGlobal;
true;
};

TRGM_VAR_TempIntelShowPos = ""; publicVariable "TRGM_VAR_TempIntelShowPos";
private _AllowedIntelToShow = TRGM_VAR_IntelShownType;
private _IntelFound = missionNamespace getVariable [format ["TRGM_VAR_IntelFound_%1", _iTaskIndex], []];

private _IntelToShow = 0;
private _iAttemptCount = 0;
while {_IntelToShow isEqualTo 0 && _iAttemptCount < 100} do {
_iAttemptCount = _iAttemptCount + 1;
_IntelToShow = selectRandom _AllowedIntelToShow;
if (_IntelToShow in _IntelFound) then {_IntelToShow = 0};
};

if (_FoundViaType isEqualTo "CommsTower") then {
[(localize "STR_TRGM2_PickingUpComms")] call TRGM_GLOBAL_fnc_notify;
sleep 4;

TRGM_VAR_TempIntelShowPos = ""; publicVariable "TRGM_VAR_TempIntelShowPos";

private _showIntel = true;

if (_FoundViaType isEqualTo "CommsTower") then {
[(localize "STR_TRGM2_PickingUpComms")] call TRGM_GLOBAL_fnc_notify;
private _TowerBuild = missionNamespace getVariable [format ["TRGM_VAR_CommsTower%1", _iTaskIndex], objNull];
if (!(isNil "_TowerBuild") && {!(isNull _TowerBuild)}) then {
_showIntel = _TowerBuild getVariable ["TRGM_VAR_ShowIntel", true];
_TowerBuild setVariable ["TRGM_VAR_ShowIntel", selectRandom [true, false, false], true];
};
sleep 4;
};



if (_IntelToShow isEqualTo 0) then { //Nothing found
[(localize "STR_TRGM2_showIntel_NoIntel")] call TRGM_GLOBAL_fnc_notify;
if (_IntelToShow isEqualTo 0 || !_showIntel) then { //Nothing found
[(localize "STR_TRGM2_showIntel_NoIntel")] call TRGM_GLOBAL_fnc_notify;
}
else {
missionNamespace setVariable [format ["TRGM_VAR_IntelFound_%1", _iTaskIndex], _IntelFound + [_IntelToShow], true];
};

if (_IntelToShow isEqualTo 1) then { //Mortor team location
[[], {
TRGM_VAR_TempIntelShowPos = nearestObjects [TRGM_VAR_ObjectivePositions select _iTaskIndex,(call sMortar) + (call sMortarMilitia),3000];
publicVariable "TRGM_VAR_TempIntelShowPos";
}] remoteExec ["call", 2];
waitUntil {sleep 2; typeName TRGM_VAR_TempIntelShowPos isEqualTo "ARRAY"};
private _iCount = count TRGM_VAR_TempIntelShowPos;
if (_iCount > 0) then {
{
private _test = createMarker [format["MrkIntelMortor%1",_forEachIndex], getPos _x];
_test setMarkerShape "ICON";
_test setMarkerType "o_art";
_test setMarkerText "Mortar";
} forEach TRGM_VAR_TempIntelShowPos;
[(localize "STR_TRGM2_showIntel_MortarMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
TRGM_VAR_IntelFound pushBack _IntelToShow;
publicVariable "TRGM_VAR_IntelFound";
[(localize "STR_TRGM2_showIntel_MortarMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};

if (_IntelToShow isEqualTo 1) then { //Mortor team location
[[], {
TRGM_VAR_TempIntelShowPos = nearestObjects [TRGM_VAR_ObjectivePositions select 0,(call sMortar) + (call sMortarMilitia),3000];
publicVariable "TRGM_VAR_TempIntelShowPos";
}] remoteExec ["call", 2];
waitUntil {sleep 2; typeName TRGM_VAR_TempIntelShowPos isEqualTo "ARRAY"};
private _iCount = count TRGM_VAR_TempIntelShowPos;
if (_iCount > 0) then {
{
private _test = createMarker [format["MrkIntelMortor%1",_forEachIndex], getPos _x];
_test setMarkerShape "ICON";
_test setMarkerType "o_art";
_test setMarkerText "Mortar";
} forEach TRGM_VAR_TempIntelShowPos;
[(localize "STR_TRGM2_showIntel_MortarMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_MortarMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};
};
if (_IntelToShow isEqualTo 2) then { //AAA team location
[[], {
TRGM_VAR_TempIntelShowPos = nearestObjects [TRGM_VAR_ObjectivePositions select _iTaskIndex,[(call sAAAVeh)] + [(call sAAAVehMilitia)] + (call DestroyAAAVeh),3000];
publicVariable "TRGM_VAR_TempIntelShowPos";
}] remoteExec ["call", 2];
waitUntil {sleep 2; typeName TRGM_VAR_TempIntelShowPos isEqualTo "ARRAY"};
private _iCount = count TRGM_VAR_TempIntelShowPos;
private _iStep = 0;
if (_iCount > 0) then {
{
private _test = createMarker [format["MrkIntelAAA%1",_forEachIndex], getPos _x];
_test setMarkerShape "ICON";
_test setMarkerType "o_art";
_test setMarkerText (localize "STR_TRGM2_showIntel_AAAMarker");
_iStep = _iStep + 1;
} forEach TRGM_VAR_TempIntelShowPos;
[(localize "STR_TRGM2_showIntel_AAAMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_AAAMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};
if (_IntelToShow isEqualTo 2) then { //AAA team location
[[], {
TRGM_VAR_TempIntelShowPos = nearestObjects [TRGM_VAR_ObjectivePositions select 0,[(call sAAAVeh)] + [(call sAAAVehMilitia)] + (call DestroyAAAVeh),3000];
publicVariable "TRGM_VAR_TempIntelShowPos";
}] remoteExec ["call", 2];
waitUntil {sleep 2; typeName TRGM_VAR_TempIntelShowPos isEqualTo "ARRAY"};
private _iCount = count TRGM_VAR_TempIntelShowPos;
private _iStep = 0;
if (_iCount > 0) then {
{
private _test = createMarker [format["MrkIntelAAA%1",_forEachIndex], getPos _x];
_test setMarkerShape "ICON";
_test setMarkerType "o_art";
_test setMarkerText (localize "STR_TRGM2_showIntel_AAAMarker");
_iStep = _iStep + 1;
} forEach TRGM_VAR_TempIntelShowPos;
[(localize "STR_TRGM2_showIntel_AAAMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_AAAMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};
};
if (_IntelToShow isEqualTo 3) then { //Comms tower location
private _TowerBuild = missionNamespace getVariable [format ["TRGM_VAR_CommsTower%1", _iTaskIndex], objNull];
if (!(isNil "_TowerBuild") && {!(isNull _TowerBuild)}) then {
private _test = createMarker ["CommsIntelAAA1", getPos _TowerBuild];
_test setMarkerShape "ICON";
_test setMarkerType "mil_destroy";
_test setMarkerText (localize "STR_TRGM2_showIntel_CommsTowerMarker");
[(localize "STR_TRGM2_showIntel_CommsTowerMapUpdated")] call TRGM_GLOBAL_fnc_notify;
} else {
[(localize "STR_TRGM2_showIntel_CommsTowerMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};
if (_IntelToShow isEqualTo 3) then { //Comms tower location
if (TRGM_VAR_bHasCommsTower) then {
private _test = createMarker ["CommsIntelAAA1", TRGM_VAR_CommsTowerPos];
};
if (_IntelToShow isEqualTo 4) then { //All checkpoints
private _bFoundcheckpoints = false;
{
private _distanceToCheckPoint = (_x select 0) distance (TRGM_VAR_ObjectivePositions select _iTaskIndex);
private _checkpointPos = _x select 0;
if (_distanceToCheckPoint < 1000) then {
_bFoundcheckpoints = true;
private _test = createMarker [format["MrkIntelCheckpoint%1%2",_checkpointPos select 0, _checkpointPos select 1], _checkpointPos];
_test setMarkerShape "ICON";
_test setMarkerType "mil_destroy";
_test setMarkerText (localize "STR_TRGM2_showIntel_CommsTowerMarker");
[(localize "STR_TRGM2_showIntel_CommsTowerMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_CommsTowerMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
_test setMarkerType "o_inf";
_test setMarkerText (localize "STR_TRGM2_setCheckpoint_MarkerText");
};
} forEach TRGM_VAR_CheckPointAreas;
if (_bFoundcheckpoints) then {
[(localize "STR_TRGM2_showIntel_CheckpointMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_CheckpointMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};
if (_IntelToShow isEqualTo 4) then { //All checkpoints
private _bFoundcheckpoints = false;
{
private _distanceToCheckPoint = (_x select 0) distance (TRGM_VAR_ObjectivePositions select 0);
private _checkpointPos = _x select 0;
if (_distanceToCheckPoint < 1000) then {
_bFoundcheckpoints = true;
private _test = createMarker [format["MrkIntelCheckpoint%1%2",_checkpointPos select 0, _checkpointPos select 1], _checkpointPos];
_test setMarkerShape "ICON";
_test setMarkerType "o_inf";
_test setMarkerText (localize "STR_TRGM2_setCheckpoint_MarkerText");
};
} forEach TRGM_VAR_CheckPointAreas;
if (_bFoundcheckpoints) then {
[(localize "STR_TRGM2_showIntel_CheckpointMapUpdated")] call TRGM_GLOBAL_fnc_notify;
}
else {
[(localize "STR_TRGM2_showIntel_CheckpointMapNoUpdate")] call TRGM_GLOBAL_fnc_notify;
};

};
if (_IntelToShow isEqualTo 5) then { //AT Mine field
if (count TRGM_VAR_ATFieldPos isEqualTo 0) then {
[(localize "STR_TRGM2_showIntel_NoATArea")] call TRGM_GLOBAL_fnc_notify;
}
else {
{
private _test = createMarker [format["ATIntel%1%2",_x select 0,_x select 1], _x];
_test setMarkerShape "ICON";
_test setMarkerType "mil_warning";
_test setMarkerText (localize "STR_TRGM2_showIntel_ATAreaMarker");
[(localize "STR_TRGM2_showIntel_ATArea")] call TRGM_GLOBAL_fnc_notify;
} forEach TRGM_VAR_ATFieldPos;
};
};
if (_IntelToShow isEqualTo 5) then { //AT Mine field
if (count TRGM_VAR_ATFieldPos isEqualTo 0) then {
[(localize "STR_TRGM2_showIntel_NoATArea")] call TRGM_GLOBAL_fnc_notify;
}
else {
{
private _test = createMarker [format["ATIntel%1%2",_x select 0,_x select 1], _x];
_test setMarkerShape "ICON";
_test setMarkerType "mil_warning";
_test setMarkerText (localize "STR_TRGM2_showIntel_ATAreaMarker");
[(localize "STR_TRGM2_showIntel_ATArea")] call TRGM_GLOBAL_fnc_notify;
} forEach TRGM_VAR_ATFieldPos;
};
};

Expand Down
6 changes: 2 additions & 4 deletions RandFramework/Global/init/fn_initGlobalVars.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ if (isNil "TRGM_VAR_CampaignInitiated") then {TRGM_VAR_Cam
if (isNil "TRGM_VAR_CheckPointAreas") then {TRGM_VAR_CheckPointAreas = []; publicVariable "TRGM_VAR_CheckPointAreas";};
if (isNil "TRGM_VAR_CivDeathCount") then {TRGM_VAR_CivDeathCount = 0; publicVariable "TRGM_VAR_CivDeathCount";};
if (isNil "TRGM_VAR_ClearedPositions") then {TRGM_VAR_ClearedPositions = []; publicVariable "TRGM_VAR_ClearedPositions";};
if (isNil "TRGM_VAR_CommsTowerPos") then {TRGM_VAR_CommsTowerPos = [0,0]; publicVariable "TRGM_VAR_CommsTowerPos";};
if (isNil "TRGM_VAR_CoreCompleted") then { TRGM_VAR_CoreCompleted = false; publicVariable "TRGM_VAR_CoreCompleted";};
if (isNil "TRGM_VAR_CurrentZeroMissionTitle") then {TRGM_VAR_CurrentZeroMissionTitle = ""; publicVariable "TRGM_VAR_CurrentZeroMissionTitle";};
if (isNil "TRGM_VAR_CustomObjectsSet") then {TRGM_VAR_CustomObjectsSet = false; publicVariable "TRGM_VAR_CustomObjectsSet";};
Expand All @@ -252,7 +251,6 @@ if (isNil "TRGM_VAR_HiddenPossitions") then {TRGM_VAR_Hid
if (isNil "TRGM_VAR_ISUNSUNG") then {TRGM_VAR_ISUNSUNG = false; publicVariable "TRGM_VAR_ISUNSUNG";};
if (isNil "TRGM_VAR_InfTaskCount") then {TRGM_VAR_InfTaskCount = 0; publicVariable "TRGM_VAR_InfTaskCount";};
if (isNil "TRGM_VAR_InfTaskStarted") then {TRGM_VAR_InfTaskStarted = false; publicVariable "TRGM_VAR_InfTaskStarted";};
if (isNil "TRGM_VAR_IntelFound") then {TRGM_VAR_IntelFound = []; publicVariable "TRGM_VAR_IntelFound";};
if (isNil "TRGM_VAR_IntroMusic") then {TRGM_VAR_IntroMusic = selectRandom TRGM_VAR_ThemeAndIntroMusic; publicVariable "TRGM_VAR_IntroMusic";};
if (isNil "TRGM_VAR_IsFullMap") then {TRGM_VAR_IsFullMap = false; publicVariable "TRGM_VAR_IsFullMap";};
if (isNil "TRGM_VAR_IsSnowMap") then {TRGM_VAR_IsSnowMap = false; publicVariable "TRGM_VAR_IsSnowMap";};
Expand All @@ -278,8 +276,8 @@ if (isNil "TRGM_VAR_ToUseMilitia_Side") then {TRGM_VAR_To
if (isNil "TRGM_VAR_bAndSoItBegins") then {TRGM_VAR_bAndSoItBegins = false; publicVariable "TRGM_VAR_bAndSoItBegins";};
if (isNil "TRGM_VAR_bBaseHasChopper") then {TRGM_VAR_bBaseHasChopper = false; publicVariable "TRGM_VAR_bBaseHasChopper";};
if (isNil "TRGM_VAR_bBreifingPrepped") then {TRGM_VAR_bBreifingPrepped = false; publicVariable "TRGM_VAR_bBreifingPrepped";};
if (isNil "TRGM_VAR_bCommsBlocked") then {TRGM_VAR_bCommsBlocked = false; publicVariable "TRGM_VAR_bCommsBlocked";};
if (isNil "TRGM_VAR_bHasCommsTower") then {TRGM_VAR_bHasCommsTower = false; publicVariable "TRGM_VAR_bHasCommsTower";};
if (isNil "TRGM_VAR_bCommsBlocked") then {TRGM_VAR_bCommsBlocked = [false]; publicVariable "TRGM_VAR_bCommsBlocked";};
if (isNil "TRGM_VAR_bHasCommsTower") then {TRGM_VAR_bHasCommsTower = [false]; publicVariable "TRGM_VAR_bHasCommsTower";};
if (isNil "TRGM_VAR_bMortarFiring") then {TRGM_VAR_bMortarFiring = false; publicVariable "TRGM_VAR_bMortarFiring";};
if (isNil "TRGM_VAR_bOptionsSet") then {TRGM_VAR_bOptionsSet = false; publicVariable "TRGM_VAR_bOptionsSet";};
if (isNil "TRGM_VAR_bOptionsSet") then {TRGM_VAR_bOptionsSet = false; publicVariable "TRGM_VAR_bOptionsSet";};
Expand Down
5 changes: 4 additions & 1 deletion RandFramework/Server/mission/fn_startInfMission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ while {(TRGM_VAR_InfTaskCount < count _ThisTaskTypes)} do {
_iTaskIndex = TRGM_VAR_InfTaskCount;
};

TRGM_VAR_bCommsBlocked set [_iTaskIndex, false];
publicVariable "TRGM_VAR_bCommsBlocked";

private _iThisTaskType = _ThisTaskTypes select TRGM_VAR_InfTaskCount;

private _bIsMainObjective = _IsMainObjs select TRGM_VAR_InfTaskCount; if (isNil "_bIsMainObjective") then { _bIsMainObjective = false; }; //more chance of bad things, and set middle area stuff around (comms, base etc...)
Expand Down Expand Up @@ -646,7 +649,7 @@ else {
{
[80 + (_forEachIndex * 2), TRGM_VAR_iMissionIsCampaign] spawn TRGM_GLOBAL_fnc_populateLoadingWait;
if !(_x in TRGM_VAR_HiddenPossitions) then {
private _setAreaEventsHandle = [_x] spawn TRGM_SERVER_fnc_setOtherAreaStuff;
private _setAreaEventsHandle = [_x, _forEachIndex] spawn TRGM_SERVER_fnc_setOtherAreaStuff;
waitUntil { sleep 5; scriptDone _setAreaEventsHandle; };
};
} forEach TRGM_VAR_ObjectivePositions;
Expand Down
7 changes: 3 additions & 4 deletions RandFramework/Server/mission/fn_startMission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if (_bAllowStart) then {

TRGM_VAR_ATFieldPos = []; publicVariable "TRGM_VAR_ATFieldPos";
{
missionNamespace setVariable [format ["TRGM_VAR_IntelFound_%1", _forEachIndex], [], true];
private _y = _x;
{
//if (_y distance getPos _x > TRGM_VAR_PunishmentRadius) then {
Expand Down Expand Up @@ -94,17 +95,15 @@ if (_bAllowStart) then {
TRGM_VAR_InfTaskCount = 0; publicVariable "TRGM_VAR_InfTaskCount";
TRGM_VAR_ActiveTasks = []; publicVariable "TRGM_VAR_ActiveTasks";
TRGM_VAR_ObjectivePositions = []; publicVariable "TRGM_VAR_ObjectivePositions";
TRGM_VAR_bCommsBlocked = false; publicVariable "TRGM_VAR_bCommsBlocked";
TRGM_VAR_bCommsBlocked = [false]; publicVariable "TRGM_VAR_bCommsBlocked";
TRGM_VAR_bBaseHasChopper = false; publicVariable "TRGM_VAR_bBaseHasChopper";
TRGM_VAR_ParaDropped = false; publicVariable "TRGM_VAR_ParaDropped";
TRGM_VAR_bHasCommsTower = false; publicVariable "TRGM_VAR_bHasCommsTower";
TRGM_VAR_CommsTowerPos = [0,0]; publicVariable "TRGM_VAR_CommsTowerPos";
TRGM_VAR_bHasCommsTower = [false]; publicVariable "TRGM_VAR_bHasCommsTower";
TRGM_VAR_AODetails = []; publicVariable "TRGM_VAR_AODetails";
TRGM_VAR_CheckPointAreas = []; publicVariable "TRGM_VAR_CheckPointAreas";
TRGM_VAR_SentryAreas = []; publicVariable "TRGM_VAR_SentryAreas";
TRGM_VAR_bMortarFiring = false; publicVariable "TRGM_VAR_bMortarFiring";
TRGM_VAR_iCampaignDay = TRGM_VAR_iCampaignDay + 1; publicVariable "TRGM_VAR_iCampaignDay";
TRGM_VAR_IntelFound = []; publicVariable "TRGM_VAR_IntelFound";
TRGM_VAR_ClearedPositions = []; publicVariable "TRGM_VAR_ClearedPositions";
TRGM_VAR_AllowUAVLocateHelp = false; publicVariable "TRGM_VAR_AllowUAVLocateHelp";
TRGM_VAR_NewMissionMusic = nil; publicVariable "TRGM_VAR_NewMissionMusic";
Expand Down
Loading

0 comments on commit 564fdea

Please sign in to comment.