Fixed vanishing mags and localized hint

This commit is contained in:
BaerMitUmlaut 2015-09-10 22:23:37 +02:00
parent c26107bc5c
commit 45bfa3eaf5
5 changed files with 44 additions and 12 deletions

View File

@ -34,7 +34,7 @@ class CfgVehicles {
class ACE_PassMagazine {
displayName = CSTRING(PassMagazine);
condition = QUOTE([ARR_2(_player,primaryWeapon _target)] call FUNC(canPassMagazine) || [ARR_2(_player,handgunWeapon _target)] call FUNC(canPassMagazine));
condition = QUOTE([ARR_3(_player,_target,primaryWeapon _target)] call FUNC(canPassMagazine) || [ARR_3(_player,_target,handgunWeapon _target)] call FUNC(canPassMagazine));
statement = "";
showDisabled = 0;
priority = 3.3;
@ -42,7 +42,7 @@ class CfgVehicles {
class ACE_PassMagazinePrimary {
displayName = CSTRING(PassMagazinePrimary);
condition = QUOTE([ARR_2(_player,primaryWeapon _target)] call FUNC(canPassMagazine));
condition = QUOTE([ARR_3(_player,_target,primaryWeapon _target)] call FUNC(canPassMagazine));
statement = QUOTE([ARR_3(_player,_target,primaryWeapon _target)] call FUNC(passMagazine));
showDisabled = 0;
priority = 3;
@ -50,7 +50,7 @@ class CfgVehicles {
};
class ACE_PassMagazineHandgun {
displayName = CSTRING(PassMagazineHandgun);
condition = QUOTE([ARR_2(_player,handgunWeapon _target)] call FUNC(canPassMagazine));
condition = QUOTE([ARR_3(_player,_target,handgunWeapon _target)] call FUNC(canPassMagazine));
statement = QUOTE([ARR_3(_player,_target,handgunWeapon _target)] call FUNC(passMagazine));
showDisabled = 0;
priority = 1;

View File

@ -29,6 +29,7 @@ PREP(openDoor);
PREP(openMenuSelectUI);
PREP(openSelectMenu);
PREP(passMagazine);
PREP(passMagazineLocal);
PREP(prepareSelectMenu);
PREP(push);
PREP(removeTag);

View File

@ -3,23 +3,29 @@
* Checks if unit has a spare magazine for the specified weapon.
*
* Arguments:
* 0: Unit that gets searched <OBJECT>
* 1: Weapon classname <STRING>
* 0: Unit that passes the magazine <OBJECT>
* 1: Unit to pass the magazine to <OBJECT>
* 2: Weapon classname <STRING>
*
* Return Value:
* None
*
* Example:
* [_player, "arifle_MX_F"] call ace_interaction_fnc_canPassMagazine
* [_player, _target, "arifle_MX_F"] call ace_interaction_fnc_canPassMagazine
*
* Public: No
*/
#include "script_component.hpp"
params ["_player", "_weapon"];
private ["_compatibleMags", "_filterFunc"];
params ["_player", "_target", "_weapon"];
private ["_compatibleMags", "_filterFunc", "_filteredMags"];
_compatibleMags = getArray (configfile >> "CfgWeapons" >> _weapon >> "magazines");
_filterFunc = compile format ["((_this select 0) in %1) && (!(_this select 2))", _compatibleMags];
_filteredMags = [magazinesAmmoFull _player, _filterFunc] call EFUNC(common,filter);
count ([magazinesAmmoFull _player, _filterFunc] call EFUNC(common,filter)) > 0
if (count _filteredMags > 0) then {
({(_target canAddItemToUniform (_x select 0)) || (_target canAddItemToVest (_x select 0)) || (_target canAddItemToBackpack (_x select 0))} count _filteredMags) > 0
} else {
false
};

View File

@ -29,7 +29,7 @@ _filteredMags = [magazinesAmmoFull _player, _filterFunc] call EFUNC(common,filte
_magToPass = _filteredMags select 0;
_magToPassIndex = 0;
{
if ((_x select 1) > (_magToPass select 1)) then {
if (((_x select 1) > (_magToPass select 1)) && ((_target canAddItemToUniform (_x select 0)) || (_target canAddItemToVest (_x select 0)) || (_target canAddItemToBackpack (_x select 0)))) then {
_magToPass = _x;
_magToPassIndex = _forEachIndex;
};
@ -46,5 +46,4 @@ _player removeMagazines (_magToPass select 0);
_player playActionNow "PutDown";
_target addMagazine [_magToPass select 0, _magToPass select 1];
[[parseText format [CSTRING(PassMagazineHint), name _player, _magToPass select 0]], QUOTE(FUNC(common,displayTextStructured)), _target] call EFUNC(common,execRemoteFnc);
[[_player, _target, _magToPass select 0, _magToPass select 1], QUOTE(FUNC(passMagazineLocal)), _target] call EFUNC(common,execRemoteFnc);

View File

@ -0,0 +1,26 @@
/*
* Author: BaerMitUmlaut
* Pass spare magazine for the specified weapon.
*
* Arguments:
* 0: Unit that passes the magazine <OBJECT>
* 1: Unit to pass the magazine to <OBJECT>
* 2: Magazine classname <STRING>
* 3: Amount of rounds in magazine <NUMBER>
*
* Return Value:
* None
*
* Example:
* [_unit, _player, "30Rnd_65x39_caseless_mag", 30] call ace_interaction_fnc_magToPassazine
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_target", "_magazine", "_ammoCount"];
_target addMagazine [_magazine, _ammoCount];
if (_target == ACE_player) then {
[parseText format [localize LSTRING(PassMagazineHint), name _unit, getText (configFile >> "CfgMagazines" >> _magazine >> "displayName")]] call EFUNC(common,displayTextStructured);
};