mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Reload - Code cleanup and various improvements (#9343)
* Reload code cleanup * Update fnc_startLinkingBelt.sqf * Update addons/reload/functions/fnc_getAmmoToLinkBelt.sqf Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com> --------- Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
This commit is contained in:
parent
519b1cbeb4
commit
44e0fdb6fa
@ -68,7 +68,7 @@ private _categoryColors = [_category, format ["| %1 |", LLSTRING(subcategory_col
|
||||
QGVAR(persistentLaserEnabled),
|
||||
"CHECKBOX",
|
||||
[LSTRING(SettingPersistentLaserName), LSTRING(SettingPersistentLaserDesc)],
|
||||
localize LSTRING(ACEKeybindCategoryWeapons),
|
||||
LSTRING(ACEKeybindCategoryWeapons),
|
||||
false,
|
||||
false,
|
||||
LINKFUNC(switchPersistentLaser)
|
||||
|
@ -1,7 +1,7 @@
|
||||
[
|
||||
QGVAR(enabled), "CHECKBOX",
|
||||
LSTRING(DisplayName),
|
||||
localize ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
true,
|
||||
1
|
||||
] call CBA_fnc_addSetting;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
|
||||
|
@ -14,16 +14,16 @@ class CfgVehicles {
|
||||
|
||||
class ACE_Actions {
|
||||
class ACE_Weapon {
|
||||
class GVAR(LinkBelt) {
|
||||
displayName = CSTRING(LinkBelt);
|
||||
distance = 2.0;
|
||||
class GVAR(linkBelt) {
|
||||
displayName = CSTRING(linkBelt);
|
||||
distance = 2;
|
||||
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(getAmmoToLinkBelt)) > 0);
|
||||
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
|
||||
exceptions[] = {"isNotInside"};
|
||||
};
|
||||
class GVAR(CheckAmmo) {
|
||||
class GVAR(checkAmmo) {
|
||||
displayName = CSTRING(checkAmmo);
|
||||
distance = 2.0;
|
||||
distance = 2;
|
||||
condition = QUOTE(call FUNC(canCheckAmmo));
|
||||
statement = QUOTE(call FUNC(checkAmmo));
|
||||
exceptions[] = {"isNotInside", "isNotSwimming", "isNotSitting"};
|
||||
@ -36,9 +36,9 @@ class CfgVehicles {
|
||||
class StaticWeapon: LandVehicle {
|
||||
class ACE_Actions {
|
||||
class ACE_MainActions {
|
||||
class GVAR(CheckAmmo) {
|
||||
class GVAR(checkAmmo) {
|
||||
displayName = CSTRING(checkAmmo);
|
||||
distance = 2.0;
|
||||
distance = 2;
|
||||
condition = QUOTE(call FUNC(canCheckAmmo));
|
||||
statement = QUOTE(call FUNC(checkAmmo));
|
||||
exceptions[] = {"isNotInside", "isNotSwimming", "isNotSitting"};
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
PREP(canCheckAmmo);
|
||||
PREP(canCheckAmmoSelf);
|
||||
PREP(getAmmoToLinkBelt);
|
||||
|
@ -1,63 +1,55 @@
|
||||
// by esteldunedain
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
// Add keybinds
|
||||
["ACE3 Weapons", QGVAR(checkAmmo), localize LSTRING(checkAmmo), {
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, vehicle ACE_player, ["isNotInside", "isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !(ACE_player call FUNC(canCheckAmmoSelf)) exitWith {false};
|
||||
// Ignore if controlling UAV (blocks radar keybind)
|
||||
if (!isNull (ACE_controlledUAV param [0, objNull])) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[ACE_player, ACE_player] call FUNC(checkAmmo);
|
||||
true
|
||||
}, {false}, [19, [false, true, false]], false] call CBA_fnc_addKeybind;
|
||||
|
||||
// To propagate the setAmmo change, do it on all clients
|
||||
// See https://github.com/acemod/ACE3/issues/1119 and https://feedback.bistudio.com/T167015
|
||||
[QGVAR(syncAmmo), {
|
||||
//To propagate the setAmmo change, do it on all clients
|
||||
params ["_unit", "_weapon", "_ammo"];
|
||||
TRACE_3("syncAmmo EH",_unit,_weapon,_ammo);
|
||||
|
||||
_unit setAmmo [_weapon, _ammo];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Listen for attempts to link ammo
|
||||
[QGVAR(ammoLinked), {
|
||||
params ["_receiver", "_giver", "_magazine"];
|
||||
|
||||
private _magazineType = currentMagazine _receiver;
|
||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
params ["_target", "_unit", "_magazineInfo"];
|
||||
_magazineInfo params ["_magazine", "_ammo"];
|
||||
|
||||
// Return the magazine if it's the wrong type
|
||||
if (_magazineType != (_magazine select 0)) exitWith {
|
||||
[QGVAR(ammoReturned), [_giver,_receiver,_magazine], [_giver]] call CBA_fnc_targetEvent;
|
||||
if (currentMagazine _target != _magazine) exitWith {
|
||||
[QGVAR(ammoReturned), [_unit, _target, _magazineInfo, false], _unit] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
private _ammoCount = _receiver ammo currentWeapon _receiver;
|
||||
private _ammoMissing = getNumber (_magazineCfg >> "count") - _ammoCount;
|
||||
private _currentWeapon = currentWeapon _target;
|
||||
private _currentAmmo = _target ammo _currentWeapon;
|
||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazine;
|
||||
private _ammoMissing = getNumber (_magazineCfg >> "count") - _currentAmmo;
|
||||
|
||||
// Return the magazine if the belt is full or empty
|
||||
if ((_ammoCount == 0) || _ammoMissing == 0) exitWith {
|
||||
[QGVAR(ammoReturned), [_giver,_receiver,_magazine], [_giver]] call CBA_fnc_targetEvent;
|
||||
if (_currentAmmo == 0 || {_ammoMissing == 0}) exitWith {
|
||||
[QGVAR(ammoReturned), [_unit, _target, _magazineInfo, false], _unit] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
// Add the ammo
|
||||
private _ammoAdded = _ammoMissing min (_magazine select 1);
|
||||
[QGVAR(syncAmmo), [_receiver, currentWeapon _receiver, _ammoCount + _ammoAdded]] call CBA_fnc_globalEvent;
|
||||
private _ammoAdded = _ammoMissing min _ammo;
|
||||
[QGVAR(syncAmmo), [_target, _currentWeapon, _currentAmmo + _ammoAdded]] call CBA_fnc_globalEvent;
|
||||
|
||||
if ((_magazine select 1) - _ammoAdded > 0) then {
|
||||
[QGVAR(ammoReturned), [_giver, _receiver, [_magazineType, (_magazine select 1) - _ammoAdded]], [_giver]] call CBA_fnc_targetEvent;
|
||||
// Return left over ammo to reloading unit
|
||||
if (_ammo - _ammoAdded > 0) then {
|
||||
[QGVAR(ammoReturned), [_unit, _target, [_magazine, _ammo - _ammoAdded], true], _unit] call CBA_fnc_targetEvent;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
// Listen for returned magazines
|
||||
[QGVAR(ammoReturned), {
|
||||
params ["_receiver", "", "_magazine"];
|
||||
TRACE_2("ammoReturned EH",_receiver,_magazine);
|
||||
params ["_unit", "_target", "_magazineInfo", "_success"];
|
||||
TRACE_3("ammoReturned EH",_unit,_target,_magazineInfo);
|
||||
|
||||
_receiver addMagazine _magazine;
|
||||
// If inventory is full, magazine will be dropped on the ground
|
||||
[_unit, _magazineInfo select 0, _magazineInfo select 1, true] call CBA_fnc_addMagazine;
|
||||
|
||||
[[LSTRING(BeltNotLinked), LSTRING(BeltLinked)] select _success] call EFUNC(common,displayTextStructured);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
#include "initKeybinds.sqf"
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Check if the player can check the ammo of the target.
|
||||
* Author: CAA-Picard, johnb43
|
||||
* Check if a unit can check the ammo of the target.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target <OBJECT>
|
||||
* 0: Unit equipped with the weapon <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can link belt<BOOL>
|
||||
* Can check ammo <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [cursorObject] call ace_reload_fnc_canCheckAmmo
|
||||
@ -17,26 +17,18 @@
|
||||
|
||||
params ["_target"];
|
||||
|
||||
// Return true for static weapons if they have been fired once, @todo 1.40 this work-around doesn't work anymore
|
||||
// Static weapons
|
||||
if (_target isKindOf "StaticWeapon") exitWith {
|
||||
if (currentMagazine _target != "") exitWith {true};
|
||||
|
||||
// no check ammo action on destroyed static weapons
|
||||
// No check ammo action on destroyed static weapons
|
||||
if (!alive _target) exitWith {false};
|
||||
|
||||
private _found = false;
|
||||
if (currentMagazine _target != "") exitWith {true};
|
||||
|
||||
{
|
||||
if (_x select 2) exitWith {
|
||||
_found = true;
|
||||
};
|
||||
false
|
||||
} count magazinesAmmoFull _target;
|
||||
|
||||
_found
|
||||
// Check for loaded magazines
|
||||
(magazinesAmmoFull _target) findIf {_x select 2} != -1
|
||||
};
|
||||
|
||||
// Return false for all other vehicles
|
||||
// All other vehicles
|
||||
if !(_target isKindOf "CAManBase") exitWith {false};
|
||||
|
||||
// For men
|
||||
|
@ -7,10 +7,10 @@
|
||||
* 0: Player <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can check ammo <BOOL>
|
||||
* Can check ammo for self <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [cursorObject] call ace_reload_fnc_canCheckAmmoSelf
|
||||
* [player] call ace_reload_fnc_canCheckAmmoSelf
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: commy2 and esteldunedain
|
||||
* Count the ammo of the currently loaded magazine or count rifle grenades. Play animation and display message.
|
||||
* Author: commy2, esteldunedain
|
||||
* Play animation and display message.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target. <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
* 0: Unit equipped with the weapon <OBJECT>
|
||||
* 1: Unit to execute the reload <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -16,13 +16,14 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_target", "_player"];
|
||||
params ["_target", "_unit"];
|
||||
|
||||
if (_player == _target) then {
|
||||
if (_unit == _target) then {
|
||||
if ((vehicle _target) isKindOf "StaticWeapon") then {
|
||||
_target = vehicle _target;
|
||||
};
|
||||
[_player, "Gear", 1] call EFUNC(common,doGesture);
|
||||
|
||||
[_unit, "Gear", 1] call EFUNC(common,doGesture);
|
||||
};
|
||||
|
||||
[FUNC(displayAmmo), [_target], 1] call CBA_fnc_waitAndExecute;
|
||||
[FUNC(displayAmmo), _target, 1] call CBA_fnc_waitAndExecute;
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: commy2 and esteldunedain
|
||||
* Author: commy2, esteldunedain
|
||||
* Display the ammo of the currently loaded magazine of the target or count rifle grenades.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target <OBJECT>
|
||||
* 0: Unit equipped with the weapon <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* player call ace_reload_fnc_displayAmmo
|
||||
* [player] call ace_reload_fnc_displayAmmo
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -21,59 +21,58 @@ params ["_target"];
|
||||
|
||||
private _isStaticWeapon = _target isKindOf "StaticWeapon";
|
||||
|
||||
if (_isStaticWeapon) then {
|
||||
[currentWeapon _target, currentMuzzle _target, "", currentMagazine _target]
|
||||
} else {
|
||||
weaponState _target
|
||||
} params ["_weapon", "_muzzle", "", "_magazine"];
|
||||
// currentWeapon, currentMagazine and weaponState return "" for static weapons before they have been entered once
|
||||
(if (_isStaticWeapon) then {
|
||||
private _weapon = currentWeapon _target;
|
||||
|
||||
// currentWeapon returns "" for static weapons before they are shot once
|
||||
if (_isStaticWeapon) then {
|
||||
if (_weapon == "") then {
|
||||
if (count (weapons _target) == 1) then {
|
||||
_weapon = (weapons _target) select 0;
|
||||
_muzzle = _weapon;
|
||||
private _weapons = weapons _target;
|
||||
|
||||
if (count _weapons == 1) then {
|
||||
_weapon = _weapons select 0;
|
||||
};
|
||||
};
|
||||
|
||||
private _magazine = currentMagazine _target;
|
||||
|
||||
if (_magazine == "") then {
|
||||
// Try to get magazine using magazinesAmmoFull
|
||||
private _magazines = magazinesAmmoFull _target;
|
||||
|
||||
{
|
||||
if (_x select 2) exitWith {
|
||||
_magazine = _x select 0;
|
||||
};
|
||||
} forEach _magazines;
|
||||
} forEach magazinesAmmoFull _target;
|
||||
};
|
||||
|
||||
// For static weapons the muzzle seemingly never returns anything for static weapons with/without people inside
|
||||
if (_muzzle == "") then {
|
||||
_muzzle = _weapon;
|
||||
};
|
||||
};
|
||||
// currentMuzzle always returns ""
|
||||
[_weapon, _weapon, "", _magazine]
|
||||
} else {
|
||||
weaponState _target
|
||||
}) params ["_weapon", "_muzzle", "", "_magazine"];
|
||||
|
||||
TRACE_3("",_weapon,_muzzle,_magazine);
|
||||
|
||||
if ("" in [_weapon, _magazine]) exitWith {};
|
||||
if ("" == _weapon) exitWith {};
|
||||
|
||||
private _ammo = _target ammo _muzzle;
|
||||
private _magazineConfig = configFile >> "CfgMagazines" >> _magazine;
|
||||
private _maxRounds = getNumber (_magazineConfig >> "count") max 1;
|
||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazine;
|
||||
private _maxRounds = getNumber (_magazineCfg >> "count") max 1;
|
||||
private _count = -1; // Show a count instead of ammo bars (ignore if -1)
|
||||
|
||||
if (_muzzle != _weapon) then {
|
||||
// grenade launcher (or some kind of seconday muzzle)
|
||||
if (_ammo > 0) then {
|
||||
if (_maxRounds == 1) then { // singleShot so show count of identical mags available instead of ammo bars
|
||||
_count = 1 + ({_x == _magazine} count magazines _target);
|
||||
};
|
||||
} else {
|
||||
if (_maxRounds <= 3) then { // empty GL/3GL - don't have a real magazine so just show count of any compatible mag
|
||||
_magazine = "";
|
||||
private _compatibleMagazines = [configFile >> "CfgWeapons" >> _weapon >> _muzzle] call CBA_fnc_compatibleMagazines;
|
||||
_count = {_x in _compatibleMagazines} count (magazines _target); // safe because everything is config case
|
||||
};
|
||||
// If secondary muzzle is selected or no magazine in current muzzle
|
||||
if (_muzzle != _weapon || {_magazine == ""}) then {
|
||||
// Check if no or empty magazine; If true, just show count of compatible magazines
|
||||
if (_ammo == 0) exitWith {
|
||||
_magazine = ""; // Make sure, as it could also be secondary muzzle being selected
|
||||
|
||||
private _compatibleMagazines = compatibleMagazines [_weapon, _muzzle];
|
||||
|
||||
_count = {_x in _compatibleMagazines} count (magazines _target);
|
||||
};
|
||||
|
||||
// singleShot, so show count of identical mags available instead of ammo bars
|
||||
if (_ammo > 0 && {_maxRounds == 1}) exitWith {
|
||||
_count = 1 + ({_x == _magazine} count (magazines _target));
|
||||
};
|
||||
};
|
||||
|
||||
@ -83,21 +82,29 @@ private _ammoBarsStructuredText = if (_count >= 0) then {
|
||||
if (_maxRounds >= COUNT_BARS) then {
|
||||
_count = round (COUNT_BARS * _ammo / _maxRounds);
|
||||
|
||||
if (_ammo > 0) then {_count = _count max 1};
|
||||
if (_ammo < _maxRounds) then {_count = _count min (COUNT_BARS - 1)};
|
||||
if (_ammo > 0) then {
|
||||
_count = _count max 1;
|
||||
};
|
||||
|
||||
if (_ammo < _maxRounds) then {
|
||||
_count = _count min (COUNT_BARS - 1);
|
||||
};
|
||||
} else {
|
||||
_count = _ammo;
|
||||
};
|
||||
|
||||
private _color = [((2 * (1 - _ammo / _maxRounds)) min 1), ((2 * _ammo / _maxRounds) min 1), 0];
|
||||
private _color = [(2 * (1 - _ammo / _maxRounds)) min 1, (2 * _ammo / _maxRounds) min 1, 0];
|
||||
|
||||
private _string = "";
|
||||
|
||||
for "_a" from 1 to _count do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
|
||||
private _text = [_string, _color] call EFUNC(common,stringToColoredText);
|
||||
|
||||
_string = "";
|
||||
|
||||
for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
@ -105,16 +112,21 @@ private _ammoBarsStructuredText = if (_count >= 0) then {
|
||||
composeText [_text, [_string, "#808080"] call EFUNC(common,stringToColoredText)];
|
||||
};
|
||||
|
||||
|
||||
if (_isStaticWeapon) then {
|
||||
//Vehicle mags (usualy) don't have pictures, so just show the text above ammo count
|
||||
private _loadedName = getText (_magazineConfig >> "displaynameshort");
|
||||
// Vehicle mags usually don't have pictures, so just show the text above ammo count
|
||||
private _loadedName = getText (_magazineCfg >> "displayNameShort");
|
||||
|
||||
if (_loadedName == "") then {
|
||||
_loadedName = getText (_magazineCfg >> "displayName");
|
||||
};
|
||||
|
||||
_loadedName = parseText format ["<t align='center' >%1</t>", _loadedName];
|
||||
|
||||
private _text = composeText [_loadedName, linebreak, _ammoBarsStructuredText];
|
||||
[_text] call EFUNC(common,displayTextStructured);
|
||||
} else {
|
||||
if (_magazine != "") then {
|
||||
private _picture = getText (_magazineConfig >> "picture");
|
||||
private _picture = getText (_magazineCfg >> "picture");
|
||||
[_ammoBarsStructuredText, _picture] call EFUNC(common,displayTextPicture);
|
||||
} else {
|
||||
[_ammoBarsStructuredText, 1] call EFUNC(common,displayTextStructured);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain, phyma
|
||||
* Check if the target has an MG equiped with belt system that the player can link
|
||||
* Check if the target has an MG equipped with belt system that a unit can link.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target <OBJECT>
|
||||
* 0: Unit wanting to execute the reload <OBJECT>
|
||||
* 1: Unit equipped with the weapon <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Maximum ammo of magazine (-1 on error) <NUMBER>
|
||||
@ -16,12 +16,12 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_player", "_target"];
|
||||
params ["_unit", "_target"];
|
||||
|
||||
if (vehicle _target != _target) exitWith {-1};
|
||||
if !(isNull objectParent _target) exitWith {-1};
|
||||
|
||||
private _magazineType = currentMagazine _target;
|
||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
private _magazine = currentMagazine _target;
|
||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazine;
|
||||
|
||||
if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {-1};
|
||||
|
||||
@ -29,14 +29,13 @@ if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {-1};
|
||||
private _ammoCount = _target ammo currentWeapon _target;
|
||||
|
||||
// Exit if the belt is full or empty
|
||||
if (_ammoCount == 0 || getNumber (_magazineCfg >> "count") - _ammoCount == 0) exitWith {-1};
|
||||
if (_ammoCount == 0 || {getNumber (_magazineCfg >> "count") - _ammoCount == 0}) exitWith {-1};
|
||||
|
||||
// Check if the player has any of the same magazines
|
||||
// Calculate max ammo
|
||||
// Check if the unit has any of the same magazines and calculate max ammo
|
||||
private _maxAmmo = 0;
|
||||
|
||||
{
|
||||
_maxAmmo = _maxAmmo max (_x select 1);
|
||||
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
||||
} forEach (magazinesAmmo _unit select {(_x select 0) == _magazine});
|
||||
|
||||
_maxAmmo
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: ?
|
||||
* Author: jokoho48
|
||||
* Called from "Take" EH.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
@ -11,17 +12,18 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [bob, backpackContainer bob, "ACE_Banana"] call ace_reload_fnc_onTake
|
||||
* [player, backpackContainer player, "ACE_Banana"] call ace_reload_fnc_onTake
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_container", "_item"];
|
||||
|
||||
if (
|
||||
_unit == ACE_player
|
||||
&& {GVAR(DisplayText)}
|
||||
&& {_item == currentMagazine _unit}
|
||||
&& {_container in [uniformContainer _unit, vestContainer _unit, backpackContainer _unit]}
|
||||
_unit == ACE_player &&
|
||||
{GVAR(displayText)} &&
|
||||
{_item == currentMagazine _unit} &&
|
||||
{_container in [uniformContainer _unit, vestContainer _unit, backpackContainer _unit]}
|
||||
) then {
|
||||
_unit call FUNC(displayAmmo);
|
||||
};
|
||||
|
@ -1,58 +1,59 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
* Start linking the belt
|
||||
* Author: esteldunedain, johnb43
|
||||
* Start linking the belt.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target <OBJECT>
|
||||
* 0: Unit executing the reload <OBJECT>
|
||||
* 1: Unit equipped with the weapon <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [bob, kevin] call ace_reload_fnc_startLinkingBelt
|
||||
* [player, cursorTarget] call ace_reload_fnc_startLinkingBelt
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_player", "_target"];
|
||||
params ["_unit", "_target"];
|
||||
|
||||
if (vehicle _target != _target) exitWith {false};
|
||||
if !(isNull objectParent _target) exitWith {false};
|
||||
|
||||
private _magazineType = currentMagazine _target;
|
||||
private _magazine = currentMagazine _target;
|
||||
private _ammo = [_unit, _target] call FUNC(getAmmoToLinkBelt);
|
||||
|
||||
|
||||
private _maxAmmo = [_player, _target] call FUNC(getAmmoToLinkBelt);
|
||||
|
||||
//if _maxAmmo is below 0 we quit
|
||||
if (_maxAmmo <= 0) exitWith {};
|
||||
// If _ammo is below 0 we quit
|
||||
if (_ammo <= 0) exitWith {};
|
||||
|
||||
// Condition to call each frame
|
||||
private _condition = {
|
||||
(_this select 0) params ["_player", "_target"];
|
||||
([_player, _target, []] call EFUNC(common,canInteractWith)) && ((_player distance _target) < 3) && ((speed _target) < 1)
|
||||
(_this select 0) params ["_unit", "_target"];
|
||||
|
||||
([_unit, _target, []] call EFUNC(common,canInteractWith)) && {(_unit distance _target) < 3} && {(speed _target) < 1}
|
||||
};
|
||||
|
||||
private _onFinish = {
|
||||
(_this select 0) params ["_player", "_target", "_magazine"];
|
||||
(_this select 0) params ["_unit", "_target", "_magazineInfo"];
|
||||
|
||||
// Remove the magazine with given remaining ammo; If not possible, quit
|
||||
if !([_unit, _magazineInfo select 0, _magazineInfo select 1] call EFUNC(common,removeSpecificMagazine)) exitWith {
|
||||
[LSTRING(BeltNotLinked)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
// Raise event on remote unit
|
||||
[QGVAR(ammoLinked), [_target, _player, _magazine], [_target]] call CBA_fnc_targetEvent;
|
||||
[QGVAR(ammoLinked), [_target, _unit, _magazineInfo], _target] call CBA_fnc_targetEvent;
|
||||
};
|
||||
|
||||
private _onFailure = {
|
||||
(_this select 0) params ["_player", "_target", "_magazine"];
|
||||
[_player, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
||||
(_this select 0) params ["_unit"];
|
||||
|
||||
// Add back the magazine with the former ammo count
|
||||
_player addMagazine _magazine;
|
||||
[_unit, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
||||
|
||||
[LSTRING(BeltNotLinked)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
[_player, "PutDown"] call EFUNC(common,doGesture);
|
||||
|
||||
// Remove the magazine with maximum remaining ammo
|
||||
[_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine);
|
||||
[_unit, "PutDown"] call EFUNC(common,doGesture);
|
||||
|
||||
// Call progress bar
|
||||
[4, [_player, _target, [_magazineType, _maxAmmo]], _onFinish, _onFailure, (localize LSTRING(LinkingBelt)), _condition, ["isNotInside"]] call EFUNC(common,progressBar);
|
||||
[4, [_unit, _target, [_magazine, _ammo]], _onFinish, _onFailure, LLSTRING(LinkingBelt), _condition, ["isNotInside"]] call EFUNC(common,progressBar);
|
||||
|
16
addons/reload/initKeybinds.sqf
Normal file
16
addons/reload/initKeybinds.sqf
Normal file
@ -0,0 +1,16 @@
|
||||
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
|
||||
|
||||
// Add Keybinds
|
||||
["ACE3 Weapons", QGVAR(checkAmmo), LSTRING(checkAmmo), {
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, vehicle ACE_player, ["isNotInside", "isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Ignore if controlling UAV (blocks radar keybind)
|
||||
if (!isNull (ACE_controlledUAV param [0, objNull])) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !(ACE_player call FUNC(canCheckAmmoSelf)) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[ACE_player, ACE_player] call FUNC(checkAmmo);
|
||||
|
||||
true
|
||||
}, {false}, [DIK_R, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + R
|
@ -1,18 +1,15 @@
|
||||
|
||||
[
|
||||
QGVAR(displayText),
|
||||
"CHECKBOX",
|
||||
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],
|
||||
localize ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
true,
|
||||
0
|
||||
ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
true // default value
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
QGVAR(showCheckAmmoSelf),
|
||||
"CHECKBOX",
|
||||
[LSTRING(SettingShowCheckAmmoSelf), LSTRING(SettingShowCheckAmmoSelfDesc)],
|
||||
localize ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
false, // default value
|
||||
0 // isGlobal
|
||||
ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
false // default value
|
||||
] call CBA_fnc_addSetting;
|
||||
|
@ -129,5 +129,15 @@
|
||||
<Chinesesimp>正在连接弹链...</Chinesesimp>
|
||||
<Chinese>連接彈鏈中...</Chinese>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Reload_BeltLinked">
|
||||
<English>Belt was linked</English>
|
||||
<French>Bande a été attachée</French>
|
||||
<German>Gurt wurde angehängt</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Reload_BeltNotLinked">
|
||||
<English>Belt could not be linked</English>
|
||||
<French>Bande n'a pas pu être attachée</French>
|
||||
<German>Gurt konnte nicht angehängt werden</German>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
@ -1,7 +1,7 @@
|
||||
[
|
||||
QGVAR(displayText), "CHECKBOX",
|
||||
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],
|
||||
localize ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
true, // default value
|
||||
false, // isGlobal
|
||||
{[QGVAR(displayText), _this] call EFUNC(common,cbaSettings_settingChanged)}
|
||||
|
Loading…
Reference in New Issue
Block a user