Show Loaded Ammo for static weapons

This commit is contained in:
PabstMirror 2015-04-21 19:35:04 -05:00
parent b2c5e5e9f1
commit 8ec86a337f
7 changed files with 67 additions and 66 deletions

View File

@ -1,4 +1,3 @@
class CfgActions {
class LoadMagazine;
class LoadEmptyMagazine : LoadMagazine {

View File

@ -1,4 +1,3 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));

View File

@ -3,13 +3,13 @@ class CfgVehicles {
class CAManBase: Man {
class ACE_Actions {
class ACE_Weapon {
class ACE_LinkBelt {
class GVAR(LinkBelt) {
displayName = "$STR_ACE_Reload_LinkBelt";
distance = 2.0;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
};
class ACE_CheckAmmo {
class GVAR(CheckAmmo) {
displayName = "$STR_ACE_Reload_checkAmmo";
distance = 2.0;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
@ -23,7 +23,7 @@ class CfgVehicles {
class StaticWeapon: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
class ACE_CheckAmmo {
class GVAR(CheckAmmo) {
displayName = "$STR_ACE_Reload_checkAmmo";
distance = 2.0;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));

View File

@ -7,10 +7,9 @@ if !(hasInterface) exitWith {};
["ACE3", QGVAR(checkAmmo), localize "STR_ACE_Reload_checkAmmo",
{
// 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
if !([ACE_player] call EFUNC(common,canUseWeapon) ||
{(vehicle ACE_player) isKindOf 'StaticWeapon'}) exitWith {false};
if !([ACE_player] call EFUNC(common,canUseWeapon) || {(vehicle ACE_player) isKindOf "StaticWeapon"}) exitWith {false};
// Statement
[ACE_player] call FUNC(checkAmmo);

View File

@ -8,6 +8,11 @@
*
* Return value:
* Can link belt<BOOL>
*
* Example:
* [player, bob] call ace_reload_fnc_canCheckAmmo
*
* Public: No
*/
#include "script_component.hpp"

View File

@ -33,8 +33,6 @@ if (count _this > 1) then {
if (_unit == _target) then {
_unit playActionNow "Gear";
} else {
_unit playActionNow "PutDown";
};
[FUNC(displayAmmo), [_target], 1, 0.1] call EFUNC(common,waitAndExecute);

View File

@ -14,7 +14,7 @@
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;
_muzzle = currentMuzzle _target;
@ -64,7 +64,7 @@ if (_muzzle == _weapon) then {
_count = _ammo;
};
// grenade launcher
// grenade launcher
} else {
_showNumber = true;
@ -75,14 +75,10 @@ if (_muzzle == _weapon) then {
};
};
_text = if (_showNumber) then {
_ammoBarsStructuredText = if (_showNumber) then {
parseText format ["<t align='center' >%1x</t>", _count]
} else {
_color = [
2 * (1 - _ammo / _maxRounds) min 1,
2 * _ammo / _maxRounds min 1,
00
];
_color = [((2 * (1 - _ammo / _maxRounds)) min 1), ((2 * _ammo / _maxRounds) min 1), 0];
_string = "";
for "_a" from 1 to _count do {
@ -95,12 +91,17 @@ _text = if (_showNumber) then {
_string = _string + "|";
};
composeText [
_text,
[_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText)
]
composeText [_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);
};