mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Linkingbelt refactoring (#5213)
* Linking belt refatoring startLinking belt now uses canLinkBelt so if condition needs to be changed then you can do it on one position. * Fixed requested change Fixed requested change * simplified it even more canLinkBelt now returns a value over 0 if success and -1 if something is not right. * Fixed bug where if error we would not exit Fixed bug where if error we would not exit * changed name on canLinkBelt Changed name to better reflect the function of the function. * Author hype * fixed return value info fixed return value info * fix header
This commit is contained in:
parent
3b7a3047cd
commit
95ade30d56
@ -6,7 +6,7 @@ class CfgVehicles {
|
|||||||
class GVAR(LinkBelt) {
|
class GVAR(LinkBelt) {
|
||||||
displayName = CSTRING(LinkBelt);
|
displayName = CSTRING(LinkBelt);
|
||||||
distance = 2.0;
|
distance = 2.0;
|
||||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canLinkBelt));
|
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(getAmmoToLinkBelt)) > 0);
|
||||||
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
|
statement = QUOTE([ARR_2(_player, _target)] call FUNC(startLinkingBelt));
|
||||||
};
|
};
|
||||||
class GVAR(CheckAmmo) {
|
class GVAR(CheckAmmo) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
PREP(canCheckAmmo);
|
PREP(canCheckAmmo);
|
||||||
PREP(canLinkBelt);
|
PREP(getAmmoToLinkBelt);
|
||||||
PREP(checkAmmo);
|
PREP(checkAmmo);
|
||||||
PREP(displayAmmo);
|
PREP(displayAmmo);
|
||||||
PREP(startLinkingBelt);
|
PREP(startLinkingBelt);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: esteldunedain
|
* 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 equiped with belt system that the player can link
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -7,10 +7,10 @@
|
|||||||
* 1: Target <OBJECT>
|
* 1: Target <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Can link belt<BOOL>
|
* Maximum ammo of magazine (-1 on error) <NUMBER>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [player, cursorObject] call ace_reload_fnc_canLinkBelt;
|
* [player, cursorObject] call ace_reload_fnc_getAmmoToLinkBelt;
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
@ -18,18 +18,18 @@
|
|||||||
|
|
||||||
params ["_player", "_target"];
|
params ["_player", "_target"];
|
||||||
|
|
||||||
if (vehicle _target != _target) exitWith {false};
|
if (vehicle _target != _target) exitWith {-1};
|
||||||
|
|
||||||
private _magazineType = currentMagazine _target;
|
private _magazineType = currentMagazine _target;
|
||||||
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
private _magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||||
|
|
||||||
if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {false};
|
if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {-1};
|
||||||
|
|
||||||
// Check if the ammo is not empty or full
|
// Check if the ammo is not empty or full
|
||||||
private _ammoCount = _target ammo currentWeapon _target;
|
private _ammoCount = _target ammo currentWeapon _target;
|
||||||
|
|
||||||
// Exit if the belt is full or empty
|
// Exit if the belt is full or empty
|
||||||
if (_ammoCount == 0 || getNumber (_magazineCfg >> "count") - _ammoCount == 0) exitWith {false};
|
if (_ammoCount == 0 || getNumber (_magazineCfg >> "count") - _ammoCount == 0) exitWith {-1};
|
||||||
|
|
||||||
// Check if the player has any of the same magazines
|
// Check if the player has any of the same magazines
|
||||||
// Calculate max ammo
|
// Calculate max ammo
|
||||||
@ -39,4 +39,4 @@ private _maxAmmo = 0;
|
|||||||
_maxAmmo = _maxAmmo max (_x select 1);
|
_maxAmmo = _maxAmmo max (_x select 1);
|
||||||
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
||||||
|
|
||||||
_maxAmmo > 0
|
_maxAmmo
|
@ -17,19 +17,11 @@ if (vehicle _target != _target) exitWith {false};
|
|||||||
|
|
||||||
private _magazineType = currentMagazine _target;
|
private _magazineType = currentMagazine _target;
|
||||||
|
|
||||||
private _canLink = [_player, _target] call FUNC(canLinkBelt);
|
|
||||||
|
|
||||||
if ( !_canLink ) exitWith {} ;
|
private _maxAmmo = [_player, _target] call FUNC(getAmmoToLinkBelt);
|
||||||
|
|
||||||
// Check if the player has any of the same same magazines
|
//if _maxAmmo is below 0 we quit
|
||||||
// Calculate max ammo it can link
|
if (_maxAmmo <= 0) exitWith {};
|
||||||
private _maxAmmo = 0;
|
|
||||||
|
|
||||||
{
|
|
||||||
_maxAmmo = _maxAmmo max (_x select 1);
|
|
||||||
} forEach (magazinesAmmo _player select {_x select 0 == _magazineType});
|
|
||||||
|
|
||||||
if (_maxAmmo == 0) exitWith {};
|
|
||||||
|
|
||||||
// Condition to call each frame
|
// Condition to call each frame
|
||||||
private _condition = {
|
private _condition = {
|
||||||
|
Loading…
Reference in New Issue
Block a user