Skip to content

Commit 0ee1d29

Browse files
committed
move conditions to functions
1 parent f8711b2 commit 0ee1d29

6 files changed

+106
-7
lines changed

addons/context_actions/CfgContext.hpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,27 @@ class EGVAR(context_menu,actions) {
252252
};
253253
class SwitchWeapon {
254254
displayName = "$STR_A3_Switch1";
255-
condition = QUOTE(2 <= {_x != ''} count [ARR_3(primaryWeapon _hoveredEntity, handgunWeapon _hoveredEntity, binocular _hoveredEntity)]);
255+
condition = QUOTE(_hoveredEntity call FUNC(canSwitchWeapon));
256256
statement = "";
257257
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\reammo_ca.paa";
258-
class Rifle {
258+
class Primary {
259259
displayName = "$STR_A3_RSCDisplayArsenal_Tab_PrimaryWeapon";
260-
condition = QUOTE(!isPlayer _hoveredEntity && {primaryWeapon _hoveredEntity != '' && {primaryWeapon _hoveredEntity != currentWeapon _hoveredEntity}});
260+
condition = QUOTE(_hoveredEntity call FUNC(canSwitchWeaponPrimary));
261261
statement = QUOTE([ARR_3('zen_common_selectWeapon', [ARR_2(_hoveredEntity, primaryWeapon _hoveredEntity)], _hoveredEntity)] call CBA_fnc_targetEvent);
262262
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\primaryWeapon_ca.paa";
263263
args = 0;
264264
modifierFunction = QUOTE(call FUNC(switchWeaponModifier));
265265
};
266-
class Handgun: Rifle {
266+
class Handgun: Primary {
267267
displayName = "$STR_A3_RSCDisplayArsenal_Tab_Handgun";
268-
condition = QUOTE(!isPlayer _hoveredEntity && {handgunWeapon _hoveredEntity != '' && {handgunWeapon _hoveredEntity != currentWeapon _hoveredEntity}});
268+
condition = QUOTE(_hoveredEntity call FUNC(canSwitchWeaponHandgun));
269269
statement = QUOTE([ARR_3('zen_common_selectWeapon', [ARR_2(_hoveredEntity, handgunWeapon _hoveredEntity)], _hoveredEntity)] call CBA_fnc_targetEvent);
270270
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\handgun_ca.paa";
271271
args = 1;
272272
};
273-
class Binoculars: Rifle {
273+
class Binoculars: Primary {
274274
displayName = "$STR_A3_RSCDisplayArsenal_Tab_Binoculars";
275-
condition = QUOTE(!isPlayer _hoveredEntity && {binocular _hoveredEntity != '' && {binocular _hoveredEntity != currentWeapon _hoveredEntity}});
275+
condition = QUOTE(_hoveredEntity call FUNC(canSwitchWeaponBinocular));
276276
statement = QUOTE([ARR_3('zen_common_selectWeapon', [ARR_2(_hoveredEntity, binocular _hoveredEntity)], _hoveredEntity)] call CBA_fnc_targetEvent);
277277
icon = "\a3\ui_f\data\GUI\Rsc\RscDisplayArsenal\binoculars_ca.paa";
278278
args = 2;

addons/context_actions/XEH_PREP.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PREP(canPasteVehicleAppearance);
66
PREP(canRearmVehicles);
77
PREP(canRefuelVehicles);
88
PREP(canRepairVehicles);
9+
PREP(canSwitchWeapon);
10+
PREP(canSwitchWeaponBinocular);
11+
PREP(canSwitchWeaponHandgun);
12+
PREP(canSwitchWeaponPrimary);
913
PREP(canToggleSurrender);
1014
PREP(canUnloadViV);
1115
PREP(copyVehicleAppearance);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Checks if the given unit has multiple weapons to switch between.
5+
*
6+
* Arguments:
7+
* 0: Entity <ANY>
8+
*
9+
* Return Value:
10+
* Can Switch Weapon <BOOL>
11+
*
12+
* Example:
13+
* [_entity] call zen_context_actions_fnc_canSwitchWeapon
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["_entity"];
19+
20+
_entity isEqualType objNull
21+
&& {alive _entity}
22+
&& {!isPlayer _entity}
23+
&& {{_x != ""} count [primaryWeapon _hoveredEntity, handgunWeapon _hoveredEntity, binocular _hoveredEntity] >= 2}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Checks if the given unit can switch to binoculars.
5+
*
6+
* Arguments:
7+
* 0: Entity <ANY>
8+
*
9+
* Return Value:
10+
* Can Switch Weapon <BOOL>
11+
*
12+
* Example:
13+
* [_entity] call zen_context_actions_fnc_canSwitchWeaponBinocular
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["_entity"];
19+
20+
_entity isEqualType objNull
21+
&& {alive _entity}
22+
&& {!isPlayer _entity}
23+
&& {binocular _entity != '' }
24+
&& {binocular _entity != currentWeapon _entity}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Checks if the given unit can switch to handgun weapon.
5+
*
6+
* Arguments:
7+
* 0: Entity <ANY>
8+
*
9+
* Return Value:
10+
* Can Switch Weapon <BOOL>
11+
*
12+
* Example:
13+
* [_entity] call zen_context_actions_fnc_canSwitchWeaponHandgun
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["_entity"];
19+
20+
_entity isEqualType objNull
21+
&& {alive _entity}
22+
&& {!isPlayer _entity}
23+
&& {handgunWeapon _entity != '' }
24+
&& {handgunWeapon _entity != currentWeapon _entity}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Ampersand
4+
* Checks if the given unit can switch to primary weapon.
5+
*
6+
* Arguments:
7+
* 0: Entity <ANY>
8+
*
9+
* Return Value:
10+
* Can Switch Weapon <BOOL>
11+
*
12+
* Example:
13+
* [_entity] call zen_context_actions_fnc_canSwitchWeaponPrimary
14+
*
15+
* Public: No
16+
*/
17+
18+
params ["_entity"];
19+
20+
_entity isEqualType objNull
21+
&& {alive _entity}
22+
&& {!isPlayer _entity}
23+
&& {primaryWeapon _entity != '' }
24+
&& {primaryWeapon _entity != currentWeapon _entity}

0 commit comments

Comments
 (0)