mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge Changes
This commit is contained in:
commit
e191105200
@ -147,6 +147,7 @@ PREP(removeCameraEventHandler);
|
||||
PREP(removeCustomEventHandler);
|
||||
PREP(removeMapMarkerCreatedEventHandler);
|
||||
PREP(removeScrollWheelEventHandler);
|
||||
PREP(removeSpecificMagazine);
|
||||
PREP(requestCallback);
|
||||
PREP(resetAllDefaults);
|
||||
PREP(restoreVariablesJIP);
|
||||
|
69
addons/common/functions/fnc_removeSpecificMagazine.sqf
Normal file
69
addons/common/functions/fnc_removeSpecificMagazine.sqf
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Removes a magazine from the unit that has an specific ammo count
|
||||
*
|
||||
* Argument:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Magazine <STRING>
|
||||
* 2: Ammo count <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_player,_magazineType,_ammoCount);
|
||||
|
||||
private ["_magazines","_index","_isRemoved"];
|
||||
_isRemoved = false;
|
||||
|
||||
// Check uniform
|
||||
_magazines = [magazinesAmmoCargo uniformContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromUniform (_x select 0);
|
||||
} forEach _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(uniformContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
};
|
||||
|
||||
// Check vest
|
||||
_magazines = [magazinesAmmoCargo vestContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromVest (_x select 0);
|
||||
} forEach _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(vestContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
};
|
||||
|
||||
// Check backpack
|
||||
_magazines = [magazinesAmmoCargo backpackContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromBackpack (_x select 0);
|
||||
} forEach _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(backpackContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
};
|
@ -481,8 +481,8 @@ class CfgVehicles {
|
||||
class ACE_Actions {
|
||||
class ACE_MainActions {
|
||||
displayName = "$STR_ACE_Interaction_MainAction";
|
||||
selection = "";
|
||||
distance = 10;
|
||||
selection = "gunnerview";
|
||||
distance = 2;
|
||||
condition = "true";
|
||||
};
|
||||
};
|
||||
@ -494,8 +494,8 @@ class CfgVehicles {
|
||||
class ACE_Actions {
|
||||
class ACE_MainActions {
|
||||
displayName = "$STR_ACE_Interaction_MainAction";
|
||||
selection = "";
|
||||
distance = 10;
|
||||
selection = "gunnerview";
|
||||
distance = 2;
|
||||
condition = "true";
|
||||
};
|
||||
};
|
||||
|
@ -65,7 +65,7 @@ class CfgVehicles {
|
||||
displayName = "Bandage Head";
|
||||
distance = 2.0;
|
||||
condition = QUOTE([ARR_4(_player, _target, 'head', 'Bandage')] call DFUNC(canTreat));
|
||||
statement = QUOTE([ARR_4(_player, _target, 'head', 'Bandage Head')] call DFUNC(treatment));
|
||||
statement = QUOTE([ARR_4(_player, _target, 'head', 'Bandage')] call DFUNC(treatment));
|
||||
showDisabled = 1;
|
||||
priority = 2;
|
||||
hotkey = "B";
|
||||
@ -86,10 +86,10 @@ class CfgVehicles {
|
||||
};
|
||||
class ACE_ArmLeft {
|
||||
class Bandage_LeftArm {
|
||||
displayName = "Bandage Right Arm";
|
||||
displayName = "Bandage Left Arm";
|
||||
distance = 2.0;
|
||||
condition = QUOTE([ARR_4(_player, _target, 'hand_r', 'Bandage')] call DFUNC(canTreat));
|
||||
statement = QUOTE([ARR_4(_player, _target, 'hand_r', 'Bandage')] call DFUNC(treatment));
|
||||
condition = QUOTE([ARR_4(_player, _target, 'hand_l', 'Bandage')] call DFUNC(canTreat));
|
||||
statement = QUOTE([ARR_4(_player, _target, 'hand_l', 'Bandage')] call DFUNC(treatment));
|
||||
showDisabled = 1;
|
||||
priority = 2;
|
||||
hotkey = "B";
|
||||
|
@ -13,7 +13,6 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
|
||||
["medical_woundUpdateRequest", FUNC(onWoundUpdateRequest)] call ace_common_fnc_addEventHandler;
|
||||
|
||||
// Initialize all effects
|
||||
// @todo: make this a macro?
|
||||
_fnc_createEffect = {
|
||||
private ["_type", "_layer", "_default"];
|
||||
_type = _this select 0;
|
||||
@ -111,7 +110,6 @@ GVAR(effectTimeBlood) = time;
|
||||
};
|
||||
|
||||
// Bleeding Indicator
|
||||
// @todo: redo this after initial release
|
||||
if (damage ACE_player > 0.1 and GVAR(effectTimeBlood) + 6 < time) then {
|
||||
GVAR(effectTimeBlood) = time;
|
||||
[500 * damage ACE_player] call BIS_fnc_bloodEffect;
|
||||
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Action for checking the pulse or heart rate of the patient
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_caller","_target","_title","_content"];
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
[[_caller, _target], QUOTE(DFUNC(actionCheckPulseLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Action for checking the blood pressure of the patient
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* NONE
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_caller","_target"];
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
[[_caller, _target], QUOTE(DFUNC(actionCheckBloodPressureLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
@ -14,7 +14,7 @@ class Extended_PostInit_EventHandlers {
|
||||
class Extended_Take_EventHandlers {
|
||||
class CAManBase {
|
||||
class ACE_AmmoIndicatorReload {
|
||||
clientTake = QUOTE(if (_this select 0 == ACE_player && {(_this select 1) in [ARR_3(uniformContainer (_this select 0), vestContainer (_this select 0), backpackContainer (_this select 0))]} && {_this select 2 == currentMagazine (_this select 0)}) then {[ARR_3(_this select 0, vehicle (_this select 0), true)] call FUNC(checkAmmo)};);
|
||||
clientTake = QUOTE(if (_this select 0 == ACE_player && {(_this select 1) in [ARR_3(uniformContainer (_this select 0), vestContainer (_this select 0), backpackContainer (_this select 0))]} && {_this select 2 == currentMagazine (_this select 0)}) then {[ARR_2(_this select 0, vehicle (_this select 0))] call FUNC(displayAmmo)};);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
12
addons/reload/CfgMagazines.hpp
Normal file
12
addons/reload/CfgMagazines.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
class CfgMagazines {
|
||||
|
||||
class CA_Magazine;
|
||||
class 150Rnd_762x51_Box : CA_Magazine {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
|
||||
class 100Rnd_65x39_caseless_mag;
|
||||
class 200Rnd_65x39_cased_Box : 100Rnd_65x39_caseless_mag {
|
||||
ACE_isBelt = 1;
|
||||
};
|
||||
};
|
35
addons/reload/CfgVehicles.hpp
Normal file
35
addons/reload/CfgVehicles.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class ACE_Actions {
|
||||
class ACE_Weapon {
|
||||
class ACE_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 {
|
||||
displayName = "$STR_ACE_Reload_checkAmmo";
|
||||
distance = 2.0;
|
||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
||||
statement = QUOTE([ARR_2(_player, _target)] call FUNC(checkAmmo));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class LandVehicle;
|
||||
class StaticWeapon: LandVehicle {
|
||||
class ACE_Actions {
|
||||
class ACE_MainActions {
|
||||
class ACE_CheckAmmo {
|
||||
displayName = "$STR_ACE_Reload_checkAmmo";
|
||||
distance = 2.0;
|
||||
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canCheckAmmo));
|
||||
statement = QUOTE([ARR_2(_player, _target)] call FUNC(checkAmmo));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -19,3 +19,49 @@ if !(hasInterface) exitWith {};
|
||||
},
|
||||
{false},
|
||||
[19, [false, true, false]], false] call cba_fnc_addKeybind;
|
||||
|
||||
|
||||
// Listen for attempts to link ammo
|
||||
["linkedAmmo", {
|
||||
EXPLODE_3_PVT(_this,_receiver,_giver,_magazine);
|
||||
diag_log "linkedAmmo";
|
||||
diag_log _this;
|
||||
|
||||
private ["_magazineCfg","_magazineType"];
|
||||
_magazineType = currentMagazine _receiver;
|
||||
_magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
|
||||
// Return the magazine if it's the wrong type
|
||||
if (_magazineType != (_magazine select 0)) exitWith {
|
||||
["returnedAmmo", [_giver], [_giver,_receiver,_magazine]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
|
||||
private ["_ammoCount","_ammoMissing","_ammoAdded","_ammoRemaining"];
|
||||
_ammoCount = _receiver ammo currentWeapon _receiver;
|
||||
_ammoMissing = getNumber (_magazineCfg >> "count") - _ammoCount;
|
||||
|
||||
// Return the magazine if the belt is full or empty
|
||||
if ((_ammoCount == 0) || _ammoMissing == 0) exitWith {
|
||||
["returnedAmmo", [_giver], [_giver,_receiver,_magazine]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
|
||||
// Add the ammo
|
||||
_ammoAdded = _ammoMissing min (_magazine select 1);
|
||||
_receiver setAmmo [currentWeapon _receiver, _ammoCount + _ammoAdded];
|
||||
|
||||
if ((_magazine select 1) - _ammoAdded > 0) then {
|
||||
["returnedAmmo", [_giver], [_giver,_receiver,[_magazineType,(_magazine select 1) - _ammoAdded]]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
|
||||
}] call EFUNC(common,addEventhandler);
|
||||
|
||||
|
||||
// Listen for returned magazines
|
||||
["returnedAmmo", {
|
||||
EXPLODE_3_PVT(_this,_receiver,_giver,_magazine);
|
||||
diag_log "returnedAmmo";
|
||||
diag_log _this;
|
||||
|
||||
_receiver addMagazine _magazine;
|
||||
}] call EFUNC(common,addEventhandler);
|
||||
>>>>>>> master
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(canCheckAmmo);
|
||||
PREP(canLinkBelt);
|
||||
PREP(checkAmmo);
|
||||
PREP(displayAmmo);
|
||||
PREP(startLinkingBelt);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -5,13 +5,17 @@ class CfgPatches {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common"};
|
||||
author[] = {"commy2","KoffeinFlummi"};
|
||||
requiredAddons[] = {"ace_interaction"};
|
||||
author[] = {"commy2","KoffeinFlummi","CAA-Picard"};
|
||||
authorUrl = "https://github.com/commy2/";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgVehicles.hpp"
|
||||
|
||||
#include "CfgMagazines.hpp"
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
|
||||
#include "CfgActions.hpp"
|
||||
|
35
addons/reload/functions/fnc_canCheckAmmo.sqf
Normal file
35
addons/reload/functions/fnc_canCheckAmmo.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Check if the player can check the ammo of the target.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can link belt<BOOL>
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_player,_target);
|
||||
|
||||
// Return true for static weapons if they have been fired once
|
||||
if (_target isKindOf "StaticWeapon") exitWith {
|
||||
(currentMagazine _target) != ""
|
||||
};
|
||||
|
||||
// Return false for all other vehicles
|
||||
if !(_target isKindOf "CAManBase") exitWith {false};
|
||||
|
||||
// For men
|
||||
if (currentWeapon _target == "") exitWith {false};
|
||||
|
||||
// Check if their current magazine is a belt
|
||||
_magazineType = currentMagazine _target;
|
||||
_magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
if (getNumber (_magazineCfg >> "ACE_isBelt") == 1) exitWith {true};
|
||||
|
||||
// Check for rocket launchers
|
||||
if (currentWeapon _target == secondaryWeapon _target) exitWith {true};
|
||||
|
||||
false
|
39
addons/reload/functions/fnc_canLinkBelt.sqf
Normal file
39
addons/reload/functions/fnc_canLinkBelt.sqf
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Check if the target has an MG equiped with belt system that the player can link
|
||||
*
|
||||
* Argument:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can link belt<BOOL>
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_player,_target);
|
||||
|
||||
if (vehicle _target != _target) exitWith {false};
|
||||
|
||||
private ["_magazineCfg","_magazineType"];
|
||||
_magazineType = currentMagazine _target;
|
||||
_magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {false};
|
||||
|
||||
// Check if the ammo is not empty or full
|
||||
private "_ammoCount";
|
||||
_ammoCount = _target ammo currentWeapon _target;
|
||||
|
||||
// Exit if the belt is full or empty
|
||||
if ((_ammoCount == 0) || (getNumber (_magazineCfg >> "count") - _ammoCount) == 0) exitWith {false};
|
||||
|
||||
// Check if the player has any of the same magazines
|
||||
// Calculate max ammo
|
||||
private "_maxAmmo";
|
||||
_maxAmmo = 0;
|
||||
|
||||
{
|
||||
_maxAmmo = _maxAmmo max (_x select 1);
|
||||
} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter));
|
||||
|
||||
_maxAmmo > 0
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Author: commy2 and CAA-Picard
|
||||
* Count the ammo of the currently loaded magazine or count rifle grenades. Play animation and display message.
|
||||
*
|
||||
*
|
||||
* Argument:
|
||||
* 0: The player (Object)
|
||||
* 1: The vehicle (Object)
|
||||
* 2: Skip the animation? Used after reloading (Bool)
|
||||
*
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target. Optional, if not suplied the player counts his personal or static weapon ammo <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
@ -15,87 +13,24 @@
|
||||
|
||||
#define COUNT_BARS 12
|
||||
|
||||
private ["_unit", "_vehicle"];
|
||||
EXPLODE_1_PVT(_this,_unit);
|
||||
|
||||
_unit = _this select 0;
|
||||
_vehicle = _this select 1;
|
||||
private ["_target"];
|
||||
_target = vehicle _unit;
|
||||
|
||||
if (_unit != _vehicle && !(_vehicle isKindOf "StaticWeapon")) then {
|
||||
_vehicle = _unit;
|
||||
if (count _this > 1) then {
|
||||
_target = _this select 1;
|
||||
} else {
|
||||
|
||||
// If the unit is on foot, count it's own ammo
|
||||
if (_unit == _target) exitWith {};
|
||||
|
||||
// If it's mounted on a movile weapon, count it's own ammo
|
||||
if !(_target isKindOf "StaticWeapon") then {
|
||||
_target = _unit;
|
||||
};
|
||||
};
|
||||
|
||||
[_vehicle, currentWeapon _vehicle, currentMuzzle _vehicle, currentMagazine _vehicle, _this select 2] spawn {
|
||||
_vehicle = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_muzzle = _this select 2;
|
||||
_magazine = _this select 3;
|
||||
_skipDelay = _this select 4;
|
||||
_unit playActionNow "Gear";
|
||||
|
||||
if (currentWeapon _vehicle == "") exitWith {};
|
||||
if (typeName _muzzle != "STRING") then {_muzzle = _weapon};
|
||||
|
||||
_showNumber = false;
|
||||
_ammo = 0;
|
||||
_maxRounds = 1;
|
||||
_count = 0;
|
||||
|
||||
// not grenade launcher
|
||||
if (_muzzle == _weapon) then {
|
||||
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1;
|
||||
|
||||
_ammo = _vehicle ammo _weapon;
|
||||
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)};
|
||||
} else {
|
||||
_count = _ammo;
|
||||
};
|
||||
|
||||
// grenade launcher
|
||||
} else {
|
||||
_showNumber = true;
|
||||
|
||||
_count = if (_magazine != "") then {
|
||||
{_x == _magazine} count (magazines _vehicle + [_magazine])
|
||||
} else {
|
||||
{_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _vehicle
|
||||
};
|
||||
};
|
||||
|
||||
if !(_skipDelay) then {
|
||||
_vehicle playActionNow "Gear";
|
||||
sleep 1
|
||||
};
|
||||
|
||||
_text = 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
|
||||
];
|
||||
|
||||
_string = "";
|
||||
for "_a" from 1 to _count do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
||||
|
||||
_string = "";
|
||||
for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
[FUNC(displayAmmo), [_target], 1, 0.1] call EFUNC(common,waitAndExecute);
|
||||
|
94
addons/reload/functions/fnc_displayAmmo.sqf
Normal file
94
addons/reload/functions/fnc_displayAmmo.sqf
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Author: commy2 and CAA-Picard
|
||||
* Display the ammo of the currently loaded magazine of the target or count rifle grenades.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Target <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define COUNT_BARS 12
|
||||
|
||||
EXPLODE_1_PVT(_this,_target);
|
||||
|
||||
private ["_weapon","_muzzle","_magazine","_showNumber","_ammo","_maxRounds","_count","_text","_color","_picture"];
|
||||
|
||||
_weapon = currentWeapon _target;
|
||||
_muzzle = currentMuzzle _target;
|
||||
_magazine = currentMagazine _target;
|
||||
|
||||
// currentWeapon returns "" for static weapons before they are shot once
|
||||
if (_target isKindOf "StaticWeapon") then {
|
||||
if (_weapon == "") then {
|
||||
if (count (weapons _target) == 1) then {
|
||||
_weapon = (weapons _target) select 0;
|
||||
_muzzle = _weapon;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (_weapon == "") exitWith {};
|
||||
if (typeName _muzzle != "STRING") then {_muzzle = _weapon};
|
||||
|
||||
_showNumber = false;
|
||||
_ammo = 0;
|
||||
_maxRounds = 1;
|
||||
_count = 0;
|
||||
|
||||
// not grenade launcher
|
||||
if (_muzzle == _weapon) then {
|
||||
_maxRounds = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count") max 1;
|
||||
|
||||
_ammo = _target ammo _weapon;
|
||||
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)};
|
||||
} else {
|
||||
_count = _ammo;
|
||||
};
|
||||
|
||||
// grenade launcher
|
||||
} else {
|
||||
_showNumber = true;
|
||||
|
||||
_count = if (_magazine != "") then {
|
||||
{_x == _magazine} count (magazines _target + [_magazine])
|
||||
} else {
|
||||
{_x in getArray (configFile >> "CfgWeapons" >> _weapon >> _muzzle >> "Magazines")} count magazines _target
|
||||
};
|
||||
};
|
||||
|
||||
_text = 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
|
||||
];
|
||||
|
||||
_string = "";
|
||||
for "_a" from 1 to _count do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
||||
|
||||
_string = "";
|
||||
for "_a" from (_count + 1) to (_maxRounds min COUNT_BARS) do {
|
||||
_string = _string + "|";
|
||||
};
|
||||
|
||||
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);
|
69
addons/reload/functions/fnc_startLinkingBelt.sqf
Normal file
69
addons/reload/functions/fnc_startLinkingBelt.sqf
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Start linking the belt
|
||||
*
|
||||
* Argument:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Target <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_player,_target);
|
||||
|
||||
if (vehicle _target != _target) exitWith {false};
|
||||
|
||||
private ["_magazineCfg","_magazineType"];
|
||||
_magazineType = currentMagazine _target;
|
||||
_magazineCfg = configFile >> "CfgMagazines" >> _magazineType;
|
||||
if (getNumber (_magazineCfg >> "ACE_isBelt") == 0) exitWith {false};
|
||||
|
||||
// Check if the ammo is not empty or full
|
||||
private "_ammoCount";
|
||||
_ammoCount = _target ammo currentWeapon _target;
|
||||
|
||||
// Exit if the belt is full or empty
|
||||
if ((_ammoCount == 0) || (getNumber (_magazineCfg >> "count") - _ammoCount) == 0) exitWith {false};
|
||||
|
||||
// Check if the player has any of the same same magazines
|
||||
// Calculate max ammo it can link
|
||||
private "_maxAmmo";
|
||||
_maxAmmo = 0;
|
||||
|
||||
{
|
||||
_maxAmmo = _maxAmmo max (_x select 1);
|
||||
} forEach ([magazinesAmmo _player, {_this select 0 == _magazineType}] call EFUNC(common,filter));
|
||||
|
||||
if (_maxAmmo == 0) exitWith {};
|
||||
|
||||
|
||||
// Condition to call each frame
|
||||
_condition = {
|
||||
EXPLODE_2_PVT((_this select 0),_player,_target);
|
||||
([_player, _target] call EFUNC(common,canInteract)) && ((_player distance _target) < 3) && ((speed _target) < 1)
|
||||
};
|
||||
|
||||
_onFinish = {
|
||||
EXPLODE_3_PVT((_this select 0),_player,_target,_magazine);
|
||||
|
||||
// Raise event on remote unit
|
||||
["linkedAmmo", [_target], [_target, _player, _magazine]] call EFUNC(common,targetEvent);
|
||||
};
|
||||
|
||||
_onFailure = {
|
||||
EXPLODE_3_PVT((_this select 0),_player,_target,_magazine);
|
||||
[_caller, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation);
|
||||
|
||||
// Add back the magazine with the former ammo count
|
||||
_player addMagazine _magazine;
|
||||
};
|
||||
|
||||
[_player, "AinvPknlMstpSnonWnonDr_medic5", 0] call EFUNC(common,doAnimation);
|
||||
|
||||
// Remove the magazine with maximum remaining ammo
|
||||
[_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine);
|
||||
|
||||
// Call progress bar
|
||||
[4, [_player, _target, [_magazineType, _maxAmmo]], _onFinish, _onFailure, (localize "STR_ACE_Reload_LinkingBelt"), _condition] call EFUNC(common,progressBar);
|
@ -26,5 +26,11 @@
|
||||
<Portuguese>Munições</Portuguese>
|
||||
<Russian>Боеприпасы</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Reload_LinkBelt">
|
||||
<English>Link belt</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Reload_LinkingBelt">
|
||||
<English>Linking belt...</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user