Skip to content

Commit

Permalink
CSW/Reload - Don't allow interactions with hostile CSWs (acemod#10152)
Browse files Browse the repository at this point in the history
Don't allow interactions with hostile CSWs

Co-authored-by: PabstMirror <[email protected]>
  • Loading branch information
johnb432 and PabstMirror authored Aug 23, 2024
1 parent 7cdafe1 commit 87333a1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion addons/csw/functions/fnc_getLoadActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private _condition = {
params ["_target", "_player", "_args"];
_args params ["_carryMag", "_turretPath", "", "_magSource"];

([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0
[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew) &&
{([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0}
};

private _cfgMagazines = configFile >> "CfgMagazines"; // Micro-optimization
Expand Down
4 changes: 3 additions & 1 deletion addons/csw/functions/fnc_getUnloadActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ private _statement = {
private _condition = {
params ["_target", "_player", "_args"];
_args params ["_vehMag", "_turretPath", "_carryMag"];
[_target, _turretPath, _player, _carryMag, _vehMag] call FUNC(reload_canUnloadMagazine)

[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew) &&
{[_target, _turretPath, _player, _carryMag, _vehMag] call FUNC(reload_canUnloadMagazine)}
};

private _actions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Unit can interact with vehicle crew <BOOL>
*
* Example:
* [cursorObject, player] call ace_interaction_fnc_canInteractWithVehicleCrew
* [player, cursorObject] call ace_interaction_fnc_canInteractWithVehicleCrew
*
* Public: No
*/
Expand Down
9 changes: 5 additions & 4 deletions addons/reload/functions/fnc_canCheckAmmo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
* Check if a unit can check the ammo of the target.
*
* Arguments:
* 0: Unit equipped with the weapon <OBJECT>
* 0: Unit equipped with the weapon/CSW to check <OBJECT>
* 1: Unit checking ammo <OBJECT>
*
* Return Value:
* Can check ammo <BOOL>
*
* Example:
* [cursorObject] call ace_reload_fnc_canCheckAmmo
* [cursorObject, player] call ace_reload_fnc_canCheckAmmo
*
* Public: No
*/

params ["_target"];
params ["_target", "_player"];

// Static weapons
if (_target isKindOf "StaticWeapon") exitWith {
// No check ammo action on destroyed static weapons
if (!alive _target) exitWith {false};
if (!alive _target || {!([_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew))}) exitWith {false};

if (currentMagazine _target != "") exitWith {true};

Expand Down

0 comments on commit 87333a1

Please sign in to comment.