Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add param to allow respawns on attacked sectors, disable by default #827

Merged
merged 10 commits into from
Sep 6, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Added: ACE, TFAR and ACRE items to GM West and East arsenal presets.
* Added: Config value for radio tower classnames.
* Added: Parameter to disable Zeus for commander.
* Added: Disable respawn on attacked FOBs (adjustable via parameter)
* Removed: T-14 from RHS AFRF preset.
* Tweaked: "FOB " removed from resource overlay, so it's just e.g. "ALPHA" again.
* Fixed: Sector monitor got stuck after sector cap was reached until restarting the server.
Expand Down
92 changes: 58 additions & 34 deletions Missionframework/scripts/client/spawn/redeploy_manager.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
choiceslist = [];
#define DEPLOY_DISPLAY (findDisplay 5201)
#define DEPLOY_LIST_IDC 201
#define DEPLOY_BUTTON_IDC 202

KPLIB_respawnPositionsList = [];
fullmap = 0;
private _old_fullmap = 0;
private _oldsel = -999;
Expand Down Expand Up @@ -52,10 +56,14 @@ while {true} do {

waitUntil {dialog};

((findDisplay 5201) displayCtrl 201) ctrlAddEventHandler ["mouseButtonDblClick", {deploy = 1;}];
(DEPLOY_DISPLAY displayCtrl DEPLOY_LIST_IDC) ctrlAddEventHandler ["mouseButtonDblClick", {
if (ctrlEnabled (DEPLOY_DISPLAY displayCtrl DEPLOY_BUTTON_IDC)) then {
deploy = 1;
};
}];

_standard_map_pos = ctrlPosition ((findDisplay 5201) displayCtrl 251);
_frame_pos = ctrlPosition ((findDisplay 5201) displayCtrl 198);
_standard_map_pos = ctrlPosition (DEPLOY_DISPLAY displayCtrl 251);
_frame_pos = ctrlPosition (DEPLOY_DISPLAY displayCtrl 198);

// Get loadouts either from ACE or BI arsenals
private ["_loadouts_data"];
Expand All @@ -80,58 +88,74 @@ while {true} do {
lbSetCurSel [203, 0];

while {dialog && alive player && deploy == 0} do {
choiceslist = [[_basenamestr, getposATL startbase]];
// ARRAY - [[NAME, POSITION(, OBJECT)], ...]
KPLIB_respawnPositionsList = [[_basenamestr, getposATL startbase]];

for [{_idx=0},{_idx < count GRLIB_all_fobs},{_idx=_idx+1}] do {
choiceslist = choiceslist + [[format ["FOB %1 - %2", (military_alphabet select _idx),mapGridPosition (GRLIB_all_fobs select _idx)],GRLIB_all_fobs select _idx]];
};
{
KPLIB_respawnPositionsList pushBack [
format ["FOB %1 - %2", (military_alphabet select _forEachIndex), mapGridPosition _x],
_x
];
} forEach GRLIB_all_fobs;

if (KP_liberation_mobilerespawn) then {
if (KP_liberation_respawn_time <= time) then {
private _respawn_trucks = [] call KPLIB_fnc_getMobileRespawns;

for [ {_idx=0},{_idx < count _respawn_trucks},{_idx=_idx+1} ] do {
choiceslist = choiceslist + [[format ["%1 - %2", localize "STR_RESPAWN_TRUCK",mapGridPosition (getposATL (_respawn_trucks select _idx))],getposATL (_respawn_trucks select _idx),(_respawn_trucks select _idx)]];
};
private _mobileRespawns = [] call KPLIB_fnc_getMobileRespawns;

{
KPLIB_respawnPositionsList pushBack [
format ["%1 - %2", localize "STR_RESPAWN_TRUCK", mapGridPosition getPosATL _x],
getPosATL _x,
_x
];
} forEach _mobileRespawns
};
};

lbClear 201;
lbClear DEPLOY_LIST_IDC;
{
lbAdd [201, (_x select 0)];
} foreach choiceslist;
lbAdd [DEPLOY_LIST_IDC, (_x select 0)];
} foreach KPLIB_respawnPositionsList;

if (lbCurSel 201 == -1) then {
lbSetCurSel [201,0];
if (lbCurSel DEPLOY_LIST_IDC == -1) then {
lbSetCurSel [201, 0];
};

if (lbCurSel 201 != _oldsel) then {
_oldsel = lbCurSel 201;
if (lbCurSel DEPLOY_LIST_IDC != _oldsel) then {
_oldsel = lbCurSel DEPLOY_LIST_IDC;
private _objectpos = [0,0,0];
if (dialog) then {
_objectpos = ((choiceslist select _oldsel) select 1);
_objectpos = ((KPLIB_respawnPositionsList select _oldsel) select 1);
};
respawn_object setposATL ((choiceslist select _oldsel) select 1);
respawn_object setPosATL ((KPLIB_respawnPositionsList select _oldsel) select 1);
private _startdist = 120;
private _enddist = 120;
private _alti = 35;
if (dialog) then {
if (((choiceslist select (lbCurSel 201)) select 0) == _basenamestr) then {
if (((KPLIB_respawnPositionsList select (lbCurSel DEPLOY_LIST_IDC)) select 0) == _basenamestr) then {
_startdist = 200;
_enddist = 300;
_alti = 30;
};
// Disable if sector is under attack
if (!KPLIB_respawnOnAttackedSectors && {_objectpos in KPLIB_sectorsUnderAttack}) then {
(DEPLOY_DISPLAY displayCtrl DEPLOY_BUTTON_IDC) ctrlSetText localize "STR_DEPLOY_UNDERATTACK";
(DEPLOY_DISPLAY displayCtrl DEPLOY_BUTTON_IDC) ctrlEnable false;
} else {
(DEPLOY_DISPLAY displayCtrl DEPLOY_BUTTON_IDC) ctrlSetText localize "STR_DEPLOY_BUTTON";
(DEPLOY_DISPLAY displayCtrl DEPLOY_BUTTON_IDC) ctrlEnable true;
};
};

"spawn_marker" setMarkerPosLocal (getpos respawn_object);
ctrlMapAnimClear ((findDisplay 5201) displayCtrl 251);
ctrlMapAnimClear (DEPLOY_DISPLAY displayCtrl 251);
private _transition_map_pos = getpos respawn_object;
private _fullscreen_map_offset = 4000;
if(fullmap % 2 == 1) then {
_transition_map_pos = [(_transition_map_pos select 0) - _fullscreen_map_offset, (_transition_map_pos select 1) + (_fullscreen_map_offset * 0.75), 0];
};
((findDisplay 5201) displayCtrl 251) ctrlMapAnimAdd [0, 0.3,_transition_map_pos];
ctrlMapAnimCommit ((findDisplay 5201) displayCtrl 251);
(DEPLOY_DISPLAY displayCtrl 251) ctrlMapAnimAdd [0, 0.3,_transition_map_pos];
ctrlMapAnimCommit (DEPLOY_DISPLAY displayCtrl 251);

respawn_camera camSetPos [(getpos respawn_object select 0) - 70, (getpos respawn_object select 1) + _startdist, (getpos respawn_object select 2) + _alti];
respawn_camera camcommit 0;
Expand All @@ -142,26 +166,26 @@ while {true} do {
if (_old_fullmap != fullmap) then {
_old_fullmap = fullmap;
if (fullmap % 2 == 1) then {
((findDisplay 5201) displayCtrl 251) ctrlSetPosition [ (_frame_pos select 0) + (_frame_pos select 2), (_frame_pos select 1), (0.6 * safezoneW), (_frame_pos select 3)];
(DEPLOY_DISPLAY displayCtrl 251) ctrlSetPosition [ (_frame_pos select 0) + (_frame_pos select 2), (_frame_pos select 1), (0.6 * safezoneW), (_frame_pos select 3)];
} else {
((findDisplay 5201) displayCtrl 251) ctrlSetPosition _standard_map_pos;
(DEPLOY_DISPLAY displayCtrl 251) ctrlSetPosition _standard_map_pos;
};
((findDisplay 5201) displayCtrl 251) ctrlCommit 0.2;
(DEPLOY_DISPLAY displayCtrl 251) ctrlCommit 0.2;
_oldsel = -1;
};
uiSleep 0.1;
};

if (dialog && deploy == 1) then {
private _idxchoice = lbCurSel 201;
_spawn_str = (choiceslist select _idxchoice) select 0;
private _idxchoice = lbCurSel DEPLOY_LIST_IDC;
_spawn_str = (KPLIB_respawnPositionsList select _idxchoice) select 0;

if (count (choiceslist select _idxchoice) == 3) then {
private _truck = (choiceslist select _idxchoice) select 2;
if (count (KPLIB_respawnPositionsList select _idxchoice) == 3) then {
private _truck = (KPLIB_respawnPositionsList select _idxchoice) select 2;
player setposATL (_truck getPos [5 + (random 3), random 360]);
KP_liberation_respawn_mobile_done = true;
} else {
private _destpos = ((choiceslist select _idxchoice) select 1);
private _destpos = ((KPLIB_respawnPositionsList select _idxchoice) select 1);
player setposATL [((_destpos select 0) + 5) - (random 10),((_destpos select 1) + 5) - (random 10),(_destpos select 2)];
};

Expand Down
3 changes: 3 additions & 0 deletions Missionframework/scripts/server/game/save_manager.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ KP_liberation_production = [];
KP_liberation_production_markers = [];
// Radio tower classnames per radio tower sector
KPLIB_sectorTowers = [];
// Sectors under attack
KPLIB_sectorsUnderAttack = [];
// Global Intel resource
resources_intel = 0;
// State if the save is fully loaded
Expand Down Expand Up @@ -507,6 +509,7 @@ publicVariable "stats_civilian_vehicles_seized";
publicVariable "stats_ieds_detonated";
publicVariable "blufor_sectors";
publicVariable "GRLIB_all_fobs";
publicVariable "KPLIB_sectorsUnderAttack";
publicVariable "KP_liberation_clearances";

// Check for deleted military sectors or deleted classnames in the locked vehicles array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if ( GRLIB_blufor_defenders ) then {

sleep 60;

KPLIB_sectorsUnderAttack pushBack _thispos;
publicVariable "KPLIB_sectorsUnderAttack";

_ownership = [ _thispos ] call KPLIB_fnc_getSectorOwnership;
if ( _ownership == GRLIB_side_friendly ) exitWith {
if ( GRLIB_blufor_defenders ) then {
Expand Down Expand Up @@ -56,6 +59,9 @@ if ( GRLIB_endgame == 0 ) then {
};
};

KPLIB_sectorsUnderAttack = KPLIB_sectorsUnderAttack - [_thispos];
publicVariable "KPLIB_sectorsUnderAttack";

sleep 60;

if ( GRLIB_blufor_defenders ) then {
Expand Down
5 changes: 5 additions & 0 deletions Missionframework/scripts/shared/fetch_params.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ if(isServer) then {
GET_PARAM_BOOL(KP_liberation_mobilerespawn, "MobileRespawn", 1);
GET_PARAM(KP_liberation_respawn_cooldown, "RespawnCooldown", 900);
GET_PARAM_BOOL(KP_liberation_mobilearsenal, "MobileArsenal", 1);
GET_PARAM_BOOL(KPLIB_respawnOnAttackedSectors, "AttackedSectorRespawn", 0);
GET_PARAM_BOOL(KP_liberation_ailogistics, "AiLogistics", 1);
GET_PARAM_BOOL(KP_liberation_cr_param_buildings, "CR_Building", 0);
GET_PARAM(GRLIB_halo_param, "HaloJump", 1);
Expand Down Expand Up @@ -393,6 +394,10 @@ if (!isDedicated && hasInterface) then {
_value = if (KP_liberation_mobilearsenal) then {localize "STR_PARAMS_ENABLED";} else {localize "STR_PARAMS_DISABLED";};
_text = _text + format ["<font color='#ff8000'>%1</font><br />%2<br /><br />", _param, _value];

_param = localize "STR_PARAMS_ATTACKEDSECTORRESPAWN";
_value = if (KPLIB_respawnOnAttackedSectors) then {localize "STR_PARAMS_ENABLED";} else {localize "STR_PARAMS_DISABLED";};
_text = _text + format ["<font color='#ff8000'>%1</font><br />%2<br /><br />", _param, _value];

_param = localize "STR_PARAMS_AILOGISTICS";
_value = if (KP_liberation_ailogistics) then {localize "STR_PARAMS_ENABLED";} else {localize "STR_PARAMS_DISABLED";};
_text = _text + format ["<font color='#ff8000'>%1</font><br />%2<br /><br />", _param, _value];
Expand Down
8 changes: 8 additions & 0 deletions Missionframework/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3764,6 +3764,10 @@
<Korean>재투입차량에 '무기고' 설치</Korean>
<Czech>Mobilní arzenál</Czech>
</Key>
<Key ID="STR_PARAMS_ATTACKEDSECTORRESPAWN">
<Original>Respawn on attacked sectors</Original>
<German>Respawn bei unter Angriff stehenden Sektoren</German>
</Key>

<!-- Added or changed in v0.95 -->
<Key ID="STR_INDIV_FLAG">
Expand Down Expand Up @@ -7013,6 +7017,10 @@
<Original>Direct arsenal access without KPLIB Loadout Dialog</Original>
<German>Direkter Arsenalzugang ohne KPLIB Loadout Dialog</German>
</Key>
<Key ID="STR_DEPLOY_UNDERATTACK">
<Original>UNDER ATTACK</Original>
<German>WIRD ANGEGRIFFEN</German>
</Key>
</Package>

<Package name="KPPLM">
Expand Down
6 changes: 6 additions & 0 deletions Missionframework/ui/mission_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ class Params {
texts[] = {$STR_PARAMS_DISABLED, $STR_PARAMS_ENABLED};
default = 1;
};
class AttackedSectorRespawn {
title = $STR_PARAMS_ATTACKEDSECTORRESPAWN;
values[] = {0, 1};
texts[] = {$STR_PARAMS_DISABLED, $STR_PARAMS_ENABLED};
default = 0;
};
class AiLogistics {
title = $STR_PARAMS_AILOGISTICS;
values[] = {0, 1};
Expand Down