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

Initial ZEN functionality #124

Merged
merged 2 commits into from
Oct 10, 2024
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
3 changes: 3 additions & 0 deletions addons/overthrow_main/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ class CfgFunctions
file = "\overthrow_main\functions\integration";
//class advancedTowingInit {};
class detectItems {};
class zenSetMoney {};
class zenSetStability {};
class zenChangeSupport {};
};
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Description:
Creates the dialog to change the support of the nearest town.
Parameters:
_position: ARRAY - The position the module was placed
_logic: OBJECT - The module object
Usage:
[_hoveredEntity] call OT_zenChangeSupport;
Returns: BOOL - Dialog created
*/

params ["_position", "_logic"];
deleteVehicle _logic;

private _nearestTown = _position call OT_fnc_nearestTown;
private _support = [_nearestTown] call OT_fnc_support;

[
format ["Change Town Support: %1", _nearestTown],
[[
"EDIT",
"Change this towns support by",
"0"
]],
{
params ["_result", "_args"];
_args params ["_town"];
[_town, parseNumber (_result # 0)] call OT_fnc_support;
},
{},
[_nearestTown, _support]
] call zen_dialog_fnc_create;
25 changes: 25 additions & 0 deletions addons/overthrow_main/functions/integration/fn_zenSetMoney.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Description:
Creates the dialog to change money, and sets the money.
Parameters:
_unit: OBJECT - Unit to change the money of
Usage:
[_hoveredEntity] call OT_zenSetMoney;
Returns: BOOL - Dialog created
*/

params ["_unit"];

if !(isPlayer _unit) exitWith {false};

[
"Set Unit Money",
[[
"EDIT",
"Set this units money to",
"0"
]],
{params ["_result", "_unit"]; _unit setVariable ["money", parseNumber (_result # 0), true]},
{},
_unit
] call zen_dialog_fnc_create;
34 changes: 34 additions & 0 deletions addons/overthrow_main/functions/integration/fn_zenSetStability.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Description:
Creates the dialog to change the stability of the nearest town.
Parameters:
_position: ARRAY - The position the module was placed
_logic: OBJECT - The module object
Usage:
[_hoveredEntity] call OT_zenSetStability;
Returns: BOOL - Dialog created
*/

params ["_position", "_logic"];
deleteVehicle _logic;

private _nearestTown = _position call OT_fnc_nearestTown;
private _stability = server getVariable [format ["stability%1", _nearestTown], 100];

[
format ["Set Town Stability: %1", _nearestTown],
[[
"SLIDER:PERCENT",
"Set this towns stability to:",
0,
1,
(_stability / 100)
]],
{
params ["_result", "_args"];
_args params ["_town"];
server setVariable [format ["stability%1", _town], round ((_result # 0) * 100)]
},
{},
[_nearestTown, _stability]
] call zen_dialog_fnc_create;
9 changes: 9 additions & 0 deletions addons/overthrow_main/functions/player/fn_initPlayerLocal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ player call OT_fnc_mapSystem;
};
}foreach(server getVariable ["bases",[]]);

// ZEN integration
if (isClass (configFile >> "CfgPatches" >> "zen_common")) then {
systemChat "Zeus Enhanced has been detected, Overthrow specific functionality has been added to Zeus";
["Overthrow", "Change Town Stability", {_this call OT_fnc_zenSetStability}] call zen_custom_modules_fnc_register;
["Overthrow", "Change Town Support", {_this call OT_fnc_zenChangeSupport}] call zen_custom_modules_fnc_register;
} else {
systemChat "Zeus Enhanced not detected, consider adding it to your modlist for Overthrow specific functionality";
};

[] call OT_fnc_setupPlayer;
_introcam cameraEffect ["Terminate", "BACK" ];
camDestroy _introcam;
12 changes: 12 additions & 0 deletions addons/overthrow_main/mission_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,15 @@ class Params {
default = 1;
};
};

// ZEN integration
// This will do nothing if ZEN is loaded
class zen_context_menu_actions {
class ot_setmoney {
displayName = "Overthrow: Set Money";
icon = "\overthrow_main\ui\markers\shop-General.paa";
statement = "[_hoveredEntity] call OT_fnc_zenSetMoney";
condition = "_hoveredEntity isKindOf 'CAManBase' && {isPlayer _hoveredEntity}";
priority = 50;
};
};