mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Show Loaded Ammo for static weapons
This commit is contained in:
parent
b2c5e5e9f1
commit
8ec86a337f
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
class CfgActions {
|
class CfgActions {
|
||||||
class LoadMagazine;
|
class LoadMagazine;
|
||||||
class LoadEmptyMagazine : LoadMagazine {
|
class LoadEmptyMagazine : LoadMagazine {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
class Extended_PreInit_EventHandlers {
|
class Extended_PreInit_EventHandlers {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||||
|
@ -3,13 +3,13 @@ class CfgVehicles {
|
|||||||
class CAManBase: Man {
|
class CAManBase: Man {
|
||||||
class ACE_Actions {
|
class ACE_Actions {
|
||||||
class ACE_Weapon {
|
class ACE_Weapon {
|
||||||
class ACE_LinkBelt {
|
class GVAR(LinkBelt) {
|
||||||
displayName = "$STR_ACE_Reload_LinkBelt";
|
displayName = "$STR_ACE_Reload_LinkBelt";
|
||||||
distance = 2.0;
|
distance = 2.0;
|
||||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt));
|
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt));
|
||||||
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
|
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
|
||||||
};
|
};
|
||||||
class ACE_CheckAmmo {
|
class GVAR(CheckAmmo) {
|
||||||
displayName = "$STR_ACE_Reload_checkAmmo";
|
displayName = "$STR_ACE_Reload_checkAmmo";
|
||||||
distance = 2.0;
|
distance = 2.0;
|
||||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
||||||
@ -23,7 +23,7 @@ class CfgVehicles {
|
|||||||
class StaticWeapon: LandVehicle {
|
class StaticWeapon: LandVehicle {
|
||||||
class ACE_Actions {
|
class ACE_Actions {
|
||||||
class ACE_MainActions {
|
class ACE_MainActions {
|
||||||
class ACE_CheckAmmo {
|
class GVAR(CheckAmmo) {
|
||||||
displayName = "$STR_ACE_Reload_checkAmmo";
|
displayName = "$STR_ACE_Reload_checkAmmo";
|
||||||
distance = 2.0;
|
distance = 2.0;
|
||||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
||||||
|
@ -7,10 +7,9 @@ if !(hasInterface) exitWith {};
|
|||||||
["ACE3", QGVAR(checkAmmo), localize "STR_ACE_Reload_checkAmmo",
|
["ACE3", QGVAR(checkAmmo), localize "STR_ACE_Reload_checkAmmo",
|
||||||
{
|
{
|
||||||
// Conditions: canInteract
|
// Conditions: canInteract
|
||||||
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
if !([ACE_player, (vehicle ACE_player), ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||||
// Conditions: specific
|
// Conditions: specific
|
||||||
if !([ACE_player] call EFUNC(common,canUseWeapon) ||
|
if !([ACE_player] call EFUNC(common,canUseWeapon) || {(vehicle ACE_player) isKindOf "StaticWeapon"}) exitWith {false};
|
||||||
{(vehicle ACE_player) isKindOf 'StaticWeapon'}) exitWith {false};
|
|
||||||
|
|
||||||
// Statement
|
// Statement
|
||||||
[ACE_player] call FUNC(checkAmmo);
|
[ACE_player] call FUNC(checkAmmo);
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
* 1: Target <OBJECT>
|
* 1: Target <OBJECT>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* Can link belt<BOOL>
|
* Can link belt<BOOL>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, bob] call ace_reload_fnc_canCheckAmmo
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ if (count _this > 1) then {
|
|||||||
|
|
||||||
if (_unit == _target) then {
|
if (_unit == _target) then {
|
||||||
_unit playActionNow "Gear";
|
_unit playActionNow "Gear";
|
||||||
} else {
|
|
||||||
_unit playActionNow "PutDown";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[FUNC(displayAmmo), [_target], 1, 0.1] call EFUNC(common,waitAndExecute);
|
[FUNC(displayAmmo), [_target], 1, 0.1] call EFUNC(common,waitAndExecute);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
EXPLODE_1_PVT(_this,_target);
|
EXPLODE_1_PVT(_this,_target);
|
||||||
|
|
||||||
private ["_weapon","_muzzle","_magazine","_showNumber","_ammo","_maxRounds","_count","_text","_color","_picture", "_a", "_string"];
|
private ["_weapon","_muzzle","_magazine","_showNumber","_ammo","_maxRounds","_count","_text","_color","_picture","_ammoBarsStructuredText", "_a", "_loadedName", "_string"];
|
||||||
|
|
||||||
_weapon = currentWeapon _target;
|
_weapon = currentWeapon _target;
|
||||||
_muzzle = currentMuzzle _target;
|
_muzzle = currentMuzzle _target;
|
||||||
@ -22,23 +22,23 @@ _magazine = currentMagazine _target;
|
|||||||
|
|
||||||
// currentWeapon returns "" for static weapons before they are shot once
|
// currentWeapon returns "" for static weapons before they are shot once
|
||||||
if (_target isKindOf "StaticWeapon") then {
|
if (_target isKindOf "StaticWeapon") then {
|
||||||
if (_weapon == "") then {
|
if (_weapon == "") then {
|
||||||
if (count (weapons _target) == 1) then {
|
if (count (weapons _target) == 1) then {
|
||||||
_weapon = (weapons _target) select 0;
|
_weapon = (weapons _target) select 0;
|
||||||
_muzzle = _weapon;
|
_muzzle = _weapon;
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_magazine == "") then {
|
|
||||||
// Try to get magazine using magazinesAmmoFull
|
|
||||||
private ["_magazines"];
|
|
||||||
_magazines = magazinesAmmoFull _target;
|
|
||||||
{
|
|
||||||
if (_x select 2) exitWith {
|
|
||||||
_magazine = _x select 0;
|
|
||||||
};
|
};
|
||||||
} forEach _magazines;
|
};
|
||||||
};
|
|
||||||
|
if (_magazine == "") then {
|
||||||
|
// Try to get magazine using magazinesAmmoFull
|
||||||
|
private ["_magazines"];
|
||||||
|
_magazines = magazinesAmmoFull _target;
|
||||||
|
{
|
||||||
|
if (_x select 2) exitWith {
|
||||||
|
_magazine = _x select 0;
|
||||||
|
};
|
||||||
|
} forEach _magazines;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_magazine == "") exitWith {};
|
if (_magazine == "") exitWith {};
|
||||||
@ -52,55 +52,56 @@ _count = 0;
|
|||||||
|
|
||||||
// not grenade launcher
|
// not grenade launcher
|
||||||
if (_muzzle == _weapon) then {
|
if (_muzzle == _weapon) then {
|
||||||
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1;
|
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1;
|
||||||
|
|
||||||
_ammo = _target ammo _weapon;
|
_ammo = _target ammo _weapon;
|
||||||
if (_maxRounds >= COUNT_BARS) then {
|
if (_maxRounds >= COUNT_BARS) then {
|
||||||
_count = round (COUNT_BARS * _ammo / _maxRounds);
|
_count = round (COUNT_BARS * _ammo / _maxRounds);
|
||||||
|
|
||||||
if (_ammo > 0) then {_count = _count max 1};
|
if (_ammo > 0) then {_count = _count max 1};
|
||||||
if (_ammo < _maxRounds) then {_count = _count min (COUNT_BARS - 1)};
|
if (_ammo < _maxRounds) then {_count = _count min (COUNT_BARS - 1)};
|
||||||
} else {
|
} else {
|
||||||
_count = _ammo;
|
_count = _ammo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// grenade launcher
|
// grenade launcher
|
||||||
} else {
|
} else {
|
||||||
_showNumber = true;
|
_showNumber = true;
|
||||||
|
|
||||||
_count = if (_magazine != "") then {
|
_count = if (_magazine != "") then {
|
||||||
{_x == _magazine} count (magazines _target + [_magazine])
|
{_x == _magazine} count (magazines _target + [_magazine])
|
||||||
} else {
|
} else {
|
||||||
{_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _target
|
{_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _target
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
_text = if (_showNumber) then {
|
_ammoBarsStructuredText = if (_showNumber) then {
|
||||||
parseText format ["<t align='center' >%1x</t>", _count]
|
parseText format ["<t align='center' >%1x</t>", _count]
|
||||||
} else {
|
} else {
|
||||||
_color = [
|
_color = [((2 * (1 - _ammo / _maxRounds)) min 1), ((2 * _ammo / _maxRounds) min 1), 0];
|
||||||
2 * (1 - _ammo / _maxRounds) min 1,
|
|
||||||
2 * _ammo / _maxRounds min 1,
|
|
||||||
00
|
|
||||||
];
|
|
||||||
|
|
||||||
_string = "";
|
_string = "";
|
||||||
for "_a" from 1 to _count do {
|
for "_a" from 1 to _count do {
|
||||||
_string = _string + "|";
|
_string = _string + "|";
|
||||||
};
|
};
|
||||||
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
||||||
|
|
||||||
_string = "";
|
_string = "";
|
||||||
for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do {
|
for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do {
|
||||||
_string = _string + "|";
|
_string = _string + "|";
|
||||||
};
|
};
|
||||||
|
|
||||||
composeText [
|
composeText [_text, [_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText)];
|
||||||
_text,
|
|
||||||
[_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText)
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
|
||||||
|
|
||||||
[_text, _picture] call EFUNC(common,displayTextPicture);
|
if (_target isKindOf "StaticWeapon") then {
|
||||||
|
//Vehicle mags (usualy) don't have pictures, so just show the text above ammo count
|
||||||
|
_loadedName = getText (configFile >> "CfgMagazines" >> _magazine >> "displaynameshort");
|
||||||
|
_loadedName = parseText format ["<t align='center' >%1</t>", _loadedName];
|
||||||
|
_text = composeText [_loadedName, linebreak, _ammoBarsStructuredText];
|
||||||
|
[_text] call EFUNC(common,displayTextStructured);
|
||||||
|
} else {
|
||||||
|
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
||||||
|
[_ammoBarsStructuredText, _picture] call EFUNC(common,displayTextPicture);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user