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

Move SelfActions from postInit to config #6791

Merged
merged 10 commits into from
Feb 24, 2019
24 changes: 24 additions & 0 deletions addons/interaction/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,30 @@ class CfgVehicles {
};
};

class Land_Camping_Light_off_F: ThingX {
class ACE_Actions {
class ACE_MainActions {
displayName = CSTRING(MainAction);
distance = 2;

// to make "Camping Lantern (Off)" be turned on we replace it with "Camping Lantern"
class GVAR(TurnOn) {
displayName = CSTRING(TurnOn);
icon = "\A3\Ui_f\data\IGUI\Cfg\VehicleToggles\LightsIconOn_ca.paa";
condition = QUOTE(alive _target);
statement = QUOTE(\
private _position = getPosATL _target;\
private _vectorDirAndUp = [ARR_2(vectorDir _target,vectorUp _target)];\
deleteVehicle _target;\
private _newLamp = 'Land_Camping_Light_F' createVehicle [ARR_3(0,0,0)];\
_newLamp setPosATL _position;\
_newLamp setVectorDirAndUp _vectorDirAndUp;\
);
};
};
};
};

class RoadCone_F: ThingX {
class ACE_Actions {
class ACE_MainActions {
Expand Down
18 changes: 0 additions & 18 deletions addons/interaction/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,3 @@ GVAR(isOpeningDoor) = false;
}];
};
}] call CBA_fnc_addEventHandler;


// to make "Camping Lantern (Off)" be turned on we replace it with "Camping Lantern"
private _action = [
QGVAR(TurnOn),
localize LSTRING(TurnOn),
"\A3\Ui_f\data\IGUI\Cfg\VehicleToggles\LightsIconOn_ca.paa",
{
private _position = getPosATL _target;
private _vectorDirAndUp = [vectorDir _target, vectorUp _target];
deleteVehicle _target;
private _newLamp = "Land_Camping_Light_F" createVehicle [0,0,0];
_newLamp setPosATL _position;
_newLamp setVectorDirAndUp _vectorDirAndUp;
},
{alive _target}
] call EFUNC(interact_menu,createAction);
["Land_Camping_Light_off_F", 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
31 changes: 31 additions & 0 deletions addons/zeus/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,35 @@ class CfgVehicles {
class ModuleArsenal_F: Module_F {
function=QFUNC(bi_moduleArsenal);
};

class Man;
class CAManBase: Man {
class ACE_SelfActions {
class GVAR(create) {
displayName = CSTRING(CreateZeus);
condition = QUOTE(\
Copy link
Contributor

Choose a reason for hiding this comment

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

14:09:37 File z\ace\addons\zeus\CfgVehicles.hpp, line 325: '/CfgVehicles/CAManBase/ACE_SelfActions/ace_zeus_create.condition': Missing ';' at the end of line
14:09:37 ErrorMessage: File z\ace\addons\zeus\CfgVehicles.hpp, line 325: /CfgVehicles/CAManBase/ACE_SelfActions/ace_zeus_create/: Wrong # directive
14:09:37 Application terminated intentionally
ErrorMessage: File z\ace\addons\zeus\CfgVehicles.hpp, line 325: /CfgVehicles/CAManBase/ACE_SelfActions/ace_zeus_create/: Wrong # directive

I think complex code like this should just be in a function, I hate dealing with ARR_X and string escaping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that mikeros tools? Might be a bug in his parser ^^
Yeah I'll move it.. Name?
zeus_fnc_actionCreateCondition ?

Copy link
Member

Choose a reason for hiding this comment

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

It's a condition, so zeus_fnc_canCreate (something with canX).

Copy link
Contributor

Choose a reason for hiding this comment

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

it was crashing arma on game start
the way it's now handled in master is good enough imho (https://github.com/acemod/ACE3/blob/master/addons/zeus/XEH_postInit.sqf#L85-L121)
otherwise zeus_fnc_actionCreateCondition/zeus_fnc_actionCreateStatement isn't bad because they are sorted alphabetically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code in current master will still execute code when you spawn units in Zeus right? Even if just once per type. Whereas the config one wouldn't even do that?
Also it seems like with the script code we'll be adding it to tons of CAManBase based classes, even though we really only need CAManBase once.

I checked the config code using the make script, Don't remember whether mikero or armake.

Copy link
Contributor

Choose a reason for hiding this comment

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

no code happens on object init
only fires once each time the player controls a new man/vehicle type

isNil QQGVAR(zeus) && {\
switch (GVAR(canCreateZeus)) do {\
case CAN_CREATE_ADMIN: {isServer || {IS_ADMIN_LOGGED}};\
dedmen marked this conversation as resolved.
Show resolved Hide resolved
case CAN_CREATE_CONSOLE: {call BIS_fnc_isDebugConsoleAllowed};\
case CAN_CREATE_ALL: {true};\
default {false};\
}\
});
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
//Set GVAR(zeus) to null first to disable the action through the isNil check
statement = QUOTE(GVAR(zeus) = objNull; [ARR_2(QQGVAR(createZeus), ACE_player)] call CBA_fnc_serverEvent);
showDisabled = 1;
icon = "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa";
};
class GVAR(delete) {
displayName = CSTRING(DeleteZeus);
condition = QUOTE(!(isNil QQGVAR(zeus) || {isNull GVAR(zeus)}));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE(deleteVehicle GVAR(zeus); GVAR(zeus) = nil);
showDisabled = 1;
icon = "\A3\Ui_F_Curator\Data\Logos\arma3_curator_eye_32_ca.paa";
};
};
};
};
32 changes: 0 additions & 32 deletions addons/zeus/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -81,36 +81,4 @@ if (hasInterface) then {
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);
};
4 changes: 2 additions & 2 deletions include/x/cba/addons/main/script_macros_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ Macro: IS_ADMIN
Author:
commy2
------------------------------------------- */
#define IS_ADMIN serverCommandAvailable "#kick"
#define IS_ADMIN serverCommandAvailable '#kick'

/* -------------------------------------------
Macro: IS_ADMIN_LOGGED
Expand All @@ -1727,7 +1727,7 @@ Macro: IS_ADMIN_LOGGED
Author:
commy2
------------------------------------------- */
#define IS_ADMIN_LOGGED serverCommandAvailable "#shutdown"
#define IS_ADMIN_LOGGED serverCommandAvailable '#shutdown'

/* -------------------------------------------
Macro: FILE_EXISTS
Expand Down