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

[Feature] - Improve ceasefire side relations #101

Merged
merged 16 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions components/ceasefire/fn_ceasefire.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,29 @@ if (!isServer) exitWith {};


// Set up some variables
if (isNil "cafe_ceasefire_active") then {cafe_ceasefire_active = false};
if (isNil "cafe_ceasefire_server_EH") then {cafe_ceasefire_server_EH = -1};
if (isNil "cafe_ceasefire_server_sideRelations") then {cafe_ceasefire_server_sideRelations = []};
private _ceasefireStateChanged = (cafe_ceasefire_active != _enabled);

cafe_ceasefire_active = _enabled;
cafe_ceasefire_endTime = [-1, CBA_missionTime + _duration] select (_duration > 0);





// Define some macros
#define MACRO_FNC_ALLSIDERELATIONS(THISSIDE) \
[THISSIDE, [east, THISSIDE getFriend east]], \
[THISSIDE, [resistance, THISSIDE getFriend resistance]], \
[THISSIDE, [west, THISSIDE getFriend west]], \
[THISSIDE, [civilian, THISSIDE getFriend civilian]]





// Relay the ceasefire to all clients (JIP compatible)
[_enabled, cafe_ceasefire_endTime, _justification] remoteExecCall ["f_fnc_client_ceasefire", 0, "cafe_ceasefire"];
publicVariable "cafe_ceasefire_active";
Expand All @@ -48,6 +63,41 @@ publicVariable "cafe_ceasefire_active";



if (_ceasefireStateChanged) then {

// Enforce the ceasefire via side relations
if (_enabled) then {

cafe_ceasefire_server_sideRelations = [
MACRO_FNC_ALLSIDERELATIONS(east),
MACRO_FNC_ALLSIDERELATIONS(resistance),
MACRO_FNC_ALLSIDERELATIONS(west),
MACRO_FNC_ALLSIDERELATIONS(civilian)
];

private _allSides = [east, resistance, west, civilian];
private "_sideX";
{
_sideX = _x;
{
_sideX setFriend [_x, 1];
} forEach _allSides;
} forEach _allSides;

// Otherwise, restore the previous side relations
} else {

{
_x params ["_side", "_state"];
_side setFriend _state;
} forEach cafe_ceasefire_server_sideRelations;
};
};





// Keep track of the countdown
removeMissionEventHandler ["EachFrame", cafe_ceasefire_server_EH];

Expand All @@ -62,6 +112,12 @@ if (_duration > 0) then {
cafe_ceasefire_server_EH = -1;
cafe_ceasefire_active = false;

// Restore the previous side relations
{
_x params ["_side", "_state"];
_side setFriend _state;
} forEach cafe_ceasefire_server_sideRelations;

[false] remoteExecCall ["f_fnc_client_ceasefire", 0, "cafe_ceasefire"];
publicVariable "cafe_ceasefire_active";
};
Expand Down
2 changes: 1 addition & 1 deletion configuration/zeusSpawner/unitPresets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CA_ZeusUI_Units

class AMV_7_Reinforcements
{
unitName = "AMV-7 Marshall + Squad 6x"
unitName = "AMV-7 Marshall + Squad 6x";
vehicle = "B_APC_Wheeled_01_cannon_F";
units[] = {"crew", "crew", "crew"};
reinforcements[] = {"ftl", "ar", "aar", "lat", "rif", "mk"}; // When defined, this group spawns in the cargo space of the vehicle. The vehicle gets a TR unload waypoint and a RTB waypoint (only if it's unarmed), the group a Move waypoint. The vehicle will also despawn on RTB. If the vehicle is a Heli, it will spawn flying and always RTB
Expand Down