Skip to content

Commit

Permalink
[Feature] - Improve ceasefire side relations (#101)
Browse files Browse the repository at this point in the history
* Ceasefire UI, first draft

* UI handler function

- Added a clientside function to draw and update the ceasefire UI
- Added a default RscTitle to the mission description

* Implemented server/client handling

- Added serverside function to initiate (or terminate) a ceasefire
- Added clientside function to handle ceasefire limitations on the player (god mode, captivity, projectile removal)
- Added component initialisation with default mission start duration of 60 seconds (subject to change)

* Zeus integration, Zen module

- Added a Zen module to handle ceasefire from Zeus
- Ceasefire UI no longer shows in the debug camera (no longer
- Player captivity is no longer reset when exiting Zeus during a ceasefire
- Removed "Default" RscTitle (`cutFadeOut` does the job aswell)

* Component init

- Added ceasefire component init to the client group (necessary for global vars initialisation )

* ACE throwing, UI improvements

- Fixed ACE throwing not being detected as fire event; now inhibited during ceasefire
- Player captivity no longer gets reset when toggling player visibility as Zeus during ceasefire
- Added a fade-in animation to the ceasefire UI
- Added sounds to the ceasefire UI

* Initial justification

Added a configuration macro to override the justification text for the initial ceasefire (on mission start)

* Removed SafeStart/SafeEnd components

With the completion of the Ceasefire component, SafeStart and SafeEnd are now obsolete and have thus been removed

* Removed border on safestart box to align with rest of CAFE UI design, fixed config indent alignment.
Re-centered mission.sqm camera position.

* Removed UI outline

* Side relations

- Enforced ceasefire on AI via side relations

* *notices missing semicolon*

OwO who did this

* Update fn_ceasefire.sqf

- Initialised global variable to prevent an error on first execution
- Fixed varname casing for _ceasefireStateChanged

Co-authored-by: Bubbus <splambob@googlemail.com>
  • Loading branch information
Cre8or and Bubbus authored Apr 13, 2022
1 parent 0a0bec0 commit 218d4c7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
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

0 comments on commit 218d4c7

Please sign in to comment.