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 possibility to create zeus during mission #6203

Merged
merged 8 commits into from
Nov 10, 2018
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
73 changes: 73 additions & 0 deletions addons/zeus/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "script_component.hpp"

#define IDD_DISPLAY3DEN 313

["ace_settingsInitialized",{
// Only add an InitPost EH if setting is enabled (and apply retroactively)
if (isServer && {GVAR(autoAddObjects)}) then {
Expand Down Expand Up @@ -39,4 +41,75 @@ if (isServer) then {
_x removeCuratorEditableObjects [_objects, true];
} forEach allCurators;
}] call CBA_fnc_addEventHandler;

[QGVAR(createZeus), {
params ["_ownerPlayer"];
private _owner = ["#adminLogged", getPlayerUID _ownerPlayer] select isMultiplayer;
private _group = createGroup sideLogic;
private _zeus = _group createUnit ["ModuleCurator_F", [0,0,0], [], 0, "NONE"];
missionNamespace setVariable [format [QGVAR(zeus_%1), _owner], _zeus];
_zeus setVariable ["owner", _owner, true];
_zeus setVariable ["Addons", 3, true];
_zeus setCuratorCoef ["Place", 0];
_zeus setCuratorCoef ["Delete", 0];
_group deleteGroupWhenEmpty true;
if (!isMultiplayer && {!isNull findDisplay IDD_DISPLAY3DEN}) then {
// if loaded from editor (but not after restart), addons are not activated so we do it manually
private _addons = ('true' configClasses (configFile >> "CfgPatches")) apply {configName _x};
activateAddons _addons;
removeAllCuratorAddons _zeus;
_zeus addCuratorAddons _addons;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a huge amount of addons causes a major lag on all clients. I never actually tried if the lag spike is gone if I remove the addons but it is my biggest suspect.
Should test that out and if it's really this the addons should be spread over a longer time. Many small lags over 10 seconds are better than half a second game freeze.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you talk about addCuratorAddons in multiplayer then ^^ if (!isMultiplayer.
If about _zeus setVariable ["Addons", 3, true] then nothing we can do and it's mentioned in comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First one yeah. I always do addCuratorAddons in my curator script. Didn't know it wasn't needed.

};
[QGVAR(zeusCreated), _zeus, _ownerPlayer] call CBA_fnc_targetEvent;
}] call CBA_fnc_addEventHandler;

addMissionEventHandler ["HandleDisconnect", {
private _owner = _this select 2;
private _zeusVarName = format [QGVAR(zeus_%1), _owner];
private _zeus = missionNamespace getVariable _zeusVarName;
if (!isNil "_zeus") then {
if (!isNull _zeus) then {deleteVehicle _zeus};
missionNamespace setVariable [_zeusVarName, nil];
};
}];
};

if (hasInterface) then {
[QGVAR(zeusCreated), {
params ["_zeus"];
GVAR(zeus) = _zeus;
[localize "str_a3_cfgvehicles_moduletasksetstate_f_arguments_state_values_created_0"] call EFUNC(common,displayTextStructured);
}] call CBA_fnc_addEventHandler;

private _action = [
QGVAR(create),
LLSTRING(CreateZeus),
"\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa",
{
GVAR(zeus) = objNull; // to disable menu while zeus is being created
[QGVAR(createZeus), ACE_player] call CBA_fnc_serverEvent;
},
{
switch (GVAR(canCreateZeus)) do {
case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}};
case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed};
case CAN_CREATE_ALL: {true};
default {false};
}
&& {isNil QGVAR(zeus)}
}
] call EFUNC(interact_menu,createAction);
["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass);

_action = [
QGVAR(delete),
LLSTRING(DeleteZeus),
"\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa",
{
deleteVehicle GVAR(zeus);
GVAR(zeus) = nil;
},
{!(isNil QGVAR(zeus) || {isNull GVAR(zeus)})}
] call EFUNC(interact_menu,createAction);
["CAManBase", 1, ["ACE_SelfActions"], _action, true] call EFUNC(interact_menu,addActionToClass);
};
2 changes: 2 additions & 0 deletions addons/zeus/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ if (isServer) then {

GVAR(GlobalSkillAI) = [0.5,0.5,0.5,0.5,true,true];

#include "initSettings.sqf"

ADDON = true;
22 changes: 22 additions & 0 deletions addons/zeus/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
QGVAR(canCreateZeus),
"LIST",
format [LLSTRING(MenuSetting), LLSTRING(CreateZeus)],
format ["ACE %1", LLSTRING(DisplayName)],
[
[
CAN_CREATE_NONE,
CAN_CREATE_ADMIN,
CAN_CREATE_CONSOLE,
CAN_CREATE_ALL
],
[
localize "STR_A3_None",
localize "str_3den_attributes_enabledebugconsole_host_text",
localize "str_ui_debug_title",
localize "str_3den_attributes_enabledebugconsole_all_text"
],
0
],
true
] call CBA_settings_fnc_init;
5 changes: 5 additions & 0 deletions addons/zeus/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
#define H_PART(num) (num * (SIZEY / 25))
#define X_PART(num) (W_PART(num) + (safeZoneX + (safeZoneW - SIZEX) / 2))
#define Y_PART(num) (H_PART(num) + (safeZoneY + (safeZoneH - SIZEY) / 2))

#define CAN_CREATE_NONE -1
#define CAN_CREATE_ADMIN 0
#define CAN_CREATE_CONSOLE 1
#define CAN_CREATE_ALL 2
12 changes: 12 additions & 0 deletions addons/zeus/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1459,5 +1459,17 @@
<Chinese>移除ACE軍火庫</Chinese>
<Italian>Rimuovi l'arsenale ACE</Italian>
</Key>
<Key ID="STR_ACE_Zeus_CreateZeus">
<English>Create Zeus</English>
<Russian>Создать Зевса</Russian>
</Key>
<Key ID="STR_ACE_Zeus_DeleteZeus">
<English>Delete Zeus</English>
<Russian>Удалить Зевса</Russian>
</Key>
<Key ID="STR_ACE_Zeus_MenuSetting">
<English>"%1" menu</English>
<Russian>Меню "%1"</Russian>
</Key>
</Package>
</Project>