mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
port magazinerepack
This commit is contained in:
parent
cf08d8cfa6
commit
7cd2bc24c8
@ -1,48 +0,0 @@
|
|||||||
class CfgPatches {
|
|
||||||
class AGM_MagazineRepack {
|
|
||||||
units[] = {};
|
|
||||||
weapons[] = {};
|
|
||||||
requiredVersion = 0.60;
|
|
||||||
requiredAddons[] = {AGM_Core, AGM_Interaction};
|
|
||||||
version = "0.95";
|
|
||||||
versionStr = "0.95";
|
|
||||||
versionAr[] = {0,95,0};
|
|
||||||
author[] = {"commy2", "CAA-Picard"};
|
|
||||||
authorUrl = "https://github.com/commy2/";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class CfgFunctions {
|
|
||||||
class AGM_MagazineRepack {
|
|
||||||
class AGM_MagazineRepack {
|
|
||||||
file = "\AGM_MagazineRepack\functions";
|
|
||||||
class magazineRepack;
|
|
||||||
class magazineRepackCallback;
|
|
||||||
class openSelectMagazineUI;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class CfgVehicles {
|
|
||||||
class Man;
|
|
||||||
|
|
||||||
class CAManBase: Man {
|
|
||||||
class AGM_SelfActions {
|
|
||||||
class AGM_RepackMagazines {
|
|
||||||
displayName = "$STR_AGM_MagazineRepack_RepackMagazines";
|
|
||||||
condition = "true";
|
|
||||||
statement = "call AGM_MagazineRepack_fnc_magazineRepack";
|
|
||||||
showDisabled = 0;
|
|
||||||
priority = -2;
|
|
||||||
icon = "AGM_MagazineRepack\UI\repack_ca.paa";
|
|
||||||
hotkey = "R";
|
|
||||||
enableInside = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class AGM_Parameters_Numeric {
|
|
||||||
AGM_MagazineRepack_TimePerAmmo = 1.5;
|
|
||||||
AGM_MagazineRepack_TimePerMagazine = 2.0;
|
|
||||||
};
|
|
@ -1,74 +0,0 @@
|
|||||||
// by commy2, esteldunedain
|
|
||||||
|
|
||||||
private ["_magazines", "_ammos", "_repackTime", "_magazine", "_ammo", "_count", "_index", "_i", "_j", "_ammoToTransfer", "_ammoAvailable", "_ammoNeeded"];
|
|
||||||
|
|
||||||
_magazines = [];
|
|
||||||
_ammos = [];
|
|
||||||
_repackTime = [];
|
|
||||||
|
|
||||||
// get all mags and ammo count
|
|
||||||
{
|
|
||||||
_magazine = _x select 0;
|
|
||||||
_ammo = _x select 1;
|
|
||||||
|
|
||||||
_count = getNumber (configfile >> "CfgMagazines" >> _magazine >> "count");
|
|
||||||
|
|
||||||
if (_ammo != _count && {_count > 1}) then { // additional checks here
|
|
||||||
if !(_magazine in _magazines) then {
|
|
||||||
_index = count _magazines;
|
|
||||||
_magazines set [_index, _magazine];
|
|
||||||
_ammos set [_index, [_ammo]];
|
|
||||||
} else {
|
|
||||||
_index = _magazines find _magazine;
|
|
||||||
_ammos set [_index, (_ammos select _index) + [_ammo]];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} forEach magazinesAmmoFull AGM_player;
|
|
||||||
|
|
||||||
// Remove invalid magazines
|
|
||||||
{
|
|
||||||
if (count _x < 2) then {
|
|
||||||
_magazines set [_forEachIndex, -1];
|
|
||||||
_ammos set [_forEachIndex, [-1]];
|
|
||||||
};
|
|
||||||
} forEach _ammos;
|
|
||||||
_magazines = _magazines - [-1];
|
|
||||||
_ammos = _ammos - [[-1]];
|
|
||||||
|
|
||||||
{
|
|
||||||
// Calculate actual ammo to transfer during repack
|
|
||||||
_count = getNumber (configfile >> "CfgMagazines" >> (_magazines select _forEachIndex) >> "count");
|
|
||||||
|
|
||||||
// Sort Ascending
|
|
||||||
_list = _x call BIS_fnc_sortNum;
|
|
||||||
|
|
||||||
["MagazineRepack", _list] call AGM_Debug_fnc_log;
|
|
||||||
|
|
||||||
_i = 0;
|
|
||||||
_j = count _x - 1;
|
|
||||||
_ammoToTransfer = 0;
|
|
||||||
_ammoAvailable = 0;
|
|
||||||
while {_i < _j} do {
|
|
||||||
_ammoNeeded = _count - (_list select _j);
|
|
||||||
_exit = false;
|
|
||||||
while {_i < _j && {!_exit}} do {
|
|
||||||
_ammoAvailable = _list select _i;
|
|
||||||
if (_ammoAvailable >= _ammoNeeded) then {
|
|
||||||
_list set [_i, _ammoAvailable - _ammoNeeded];
|
|
||||||
_ammoToTransfer = _ammoToTransfer + _ammoNeeded;
|
|
||||||
_exit = true;
|
|
||||||
} else {
|
|
||||||
_ammoNeeded = _ammoNeeded - _ammoAvailable;
|
|
||||||
_ammoToTransfer = _ammoToTransfer + _ammoAvailable;
|
|
||||||
_i = _i + 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
_j = _j - 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
_repackTime set [_forEachIndex, _ammoToTransfer * AGM_MagazineRepack_TimePerAmmo + (count _x) * AGM_MagazineRepack_TimePerMagazine];
|
|
||||||
} forEach _ammos;
|
|
||||||
|
|
||||||
["MagazineRepack", [_magazines, _repackTime]] call AGM_Debug_fnc_log;
|
|
||||||
|
|
||||||
[_magazines, _repackTime] call AGM_MagazineRepack_fnc_openSelectMagazineUI;
|
|
@ -1,104 +0,0 @@
|
|||||||
// by commy2
|
|
||||||
|
|
||||||
private ["_magazine", "_ammo", "_ammoCount", "_fullMagazinesCount", "_restAmmo", "_isLoaded", "_weapon", "_reloadAction", "_text", "_picture"];
|
|
||||||
|
|
||||||
_magazine = _this select 0;
|
|
||||||
|
|
||||||
// exit if the last magazine of this type was taken out of the backpack
|
|
||||||
if !(_magazine in magazines player) exitWith {};
|
|
||||||
|
|
||||||
// get current ammo count
|
|
||||||
_ammo = 0;
|
|
||||||
{
|
|
||||||
if (_x select 0 == _magazine) then {
|
|
||||||
_ammo = _ammo + (_x select 1);
|
|
||||||
};
|
|
||||||
} forEach magazinesAmmoFull player;
|
|
||||||
|
|
||||||
// how many rounds fit in one mag
|
|
||||||
_ammoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
|
||||||
|
|
||||||
// calculate new vaules
|
|
||||||
_fullMagazinesCount = floor (_ammo / _ammoCount);
|
|
||||||
_restAmmo = _ammo - _fullMagazinesCount * _ammoCount;
|
|
||||||
|
|
||||||
// remove old magazines
|
|
||||||
player removeMagazines _magazine;
|
|
||||||
|
|
||||||
_isLoaded = false;
|
|
||||||
// reload rifle
|
|
||||||
if (_magazine in primaryWeaponMagazine player) then {
|
|
||||||
_weapon = primaryWeapon player;
|
|
||||||
|
|
||||||
if (_fullMagazinesCount > 0) then {
|
|
||||||
player setAmmo [_weapon, _ammoCount];
|
|
||||||
_fullMagazinesCount = _fullMagazinesCount - 1;
|
|
||||||
} else {
|
|
||||||
player setAmmo [_weapon, _restAmmo];
|
|
||||||
_restAmmo = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_weapon == currentWeapon player) then {
|
|
||||||
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
|
||||||
player playActionNow _reloadAction;
|
|
||||||
};
|
|
||||||
|
|
||||||
_isLoaded = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// reload pistol
|
|
||||||
if (_magazine in handgunMagazine player) then {
|
|
||||||
_weapon = handgunWeapon player;
|
|
||||||
|
|
||||||
if (_fullMagazinesCount > 0) then {
|
|
||||||
player setAmmo [_weapon, _ammoCount];
|
|
||||||
_fullMagazinesCount = _fullMagazinesCount - 1;
|
|
||||||
} else {
|
|
||||||
player setAmmo [_weapon, _restAmmo];
|
|
||||||
_restAmmo = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_weapon == currentWeapon player) then {
|
|
||||||
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
|
||||||
player playActionNow _reloadAction;
|
|
||||||
};
|
|
||||||
|
|
||||||
_isLoaded = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// reload rocket launcher (just in case ...)
|
|
||||||
if (_magazine in secondaryWeaponMagazine player) then {
|
|
||||||
_weapon = secondaryWeapon player;
|
|
||||||
|
|
||||||
if (_fullMagazinesCount > 0) then {
|
|
||||||
player setAmmo [_weapon, _ammoCount];
|
|
||||||
_fullMagazinesCount = _fullMagazinesCount - 1;
|
|
||||||
} else {
|
|
||||||
player setAmmo [_weapon, _restAmmo];
|
|
||||||
_restAmmo = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_weapon == currentWeapon player) then {
|
|
||||||
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
|
||||||
player playActionNow _reloadAction;
|
|
||||||
};
|
|
||||||
|
|
||||||
_isLoaded = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// add new magazines
|
|
||||||
for "_a" from 1 to _fullMagazinesCount do {
|
|
||||||
player addMagazine _magazine;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_restAmmo > 0) then {
|
|
||||||
player addMagazine [_magazine, _restAmmo];
|
|
||||||
};
|
|
||||||
|
|
||||||
// display text if successful
|
|
||||||
_text = format [localize "STR_AGM_MagazineRepack_RepackedMagazinesDetail", [_fullMagazinesCount, _fullMagazinesCount + 1] select _isLoaded, _restAmmo];
|
|
||||||
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
|
||||||
|
|
||||||
_text = parseText format ["<img align='center' size='1.8' color='#ffffff' image='%1'/> <br/> <t align='center'>%2</t> <br/> <t align='center'>%3</t>", _picture, localize "STR_AGM_MagazineRepack_RepackedMagazines", _text];
|
|
||||||
|
|
||||||
[_text] call AGM_Core_fnc_displayTextStructured;
|
|
@ -1,38 +0,0 @@
|
|||||||
// by commy2
|
|
||||||
|
|
||||||
private ["_magazines", "_repackTime", "_listIDC", "_count", "_index", "_magazine", "_time", "_displayName", "_picture"];
|
|
||||||
|
|
||||||
_magazines = _this select 0;
|
|
||||||
_repackTime = _this select 1;
|
|
||||||
|
|
||||||
_count = count _magazines;
|
|
||||||
|
|
||||||
_actions = [localize "STR_AGM_MagazineRepack_SelectMagazineMenu", localize "STR_AGM_MagazineRepack_SelectMagazine"] call AGM_Interaction_fnc_prepareSelectMenu;
|
|
||||||
for "_index" from 0 to (_count - 1) do {
|
|
||||||
_magazine = _magazines select _index;
|
|
||||||
_time = _repackTime select _index;
|
|
||||||
_displayName = getText (configFile >> "CfgMagazines" >> _magazine >> "displayName");
|
|
||||||
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
|
||||||
_actions = [
|
|
||||||
_actions,
|
|
||||||
_displayName,
|
|
||||||
_picture,
|
|
||||||
[_magazine, _time]
|
|
||||||
] call AGM_Interaction_fnc_AddSelectableItem;
|
|
||||||
};
|
|
||||||
|
|
||||||
[
|
|
||||||
_actions,
|
|
||||||
{
|
|
||||||
_data = _this;
|
|
||||||
call AGM_Interaction_fnc_hideMenu;
|
|
||||||
if (isNil "_data") exitWith {};
|
|
||||||
_data set [1, [_data select 1] call AGM_Core_fnc_toNumber];
|
|
||||||
[_data select 1, _data, "AGM_MagazineRepack_fnc_magazineRepackCallback", localize "STR_AGM_MagazineRepack_RepackingMagazine"] call AGM_Core_fnc_progressBar;
|
|
||||||
[player] call AGM_core_fnc_goKneeling;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
call AGM_Interaction_fnc_hideMenu;
|
|
||||||
if !(profileNamespace getVariable ["AGM_Interaction_AutoCloseMenu", false]) then {"Default" call AGM_Interaction_fnc_openMenuSelf};
|
|
||||||
}
|
|
||||||
] call AGM_Interaction_fnc_openSelectMenu;
|
|
1
addons/magazinerepack/$PBOPREFIX$
Normal file
1
addons/magazinerepack/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
|||||||
|
z\ace\addons\magazinerepack
|
6
addons/magazinerepack/CfgEventHandlers.hpp
Normal file
6
addons/magazinerepack/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
class Extended_PreInit_EventHandlers {
|
||||||
|
class ADDON {
|
||||||
|
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||||
|
};
|
||||||
|
};
|
18
addons/magazinerepack/CfgVehicles.hpp
Normal file
18
addons/magazinerepack/CfgVehicles.hpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
class CfgVehicles {
|
||||||
|
class Man;
|
||||||
|
class CAManBase: Man {
|
||||||
|
class ACE_SelfActions {
|
||||||
|
class ACE_RepackMagazines {
|
||||||
|
displayName = "$STR_ACE_MagazineRepack_RepackMagazines";
|
||||||
|
condition = QUOTE(true);
|
||||||
|
statement = QUOTE([_player] call FUNC(magazineRepack));
|
||||||
|
showDisabled = 0;
|
||||||
|
priority = -2;
|
||||||
|
icon = PATHTOF(UI\repack_ca.paa);
|
||||||
|
hotkey = "R";
|
||||||
|
enableInside = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
5
addons/magazinerepack/XEH_preInit.sqf
Normal file
5
addons/magazinerepack/XEH_preInit.sqf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PREP(magazineRepack);
|
||||||
|
PREP(magazineRepackCallback);
|
||||||
|
PREP(openSelectMagazineUI);
|
21
addons/magazinerepack/config.cpp
Normal file
21
addons/magazinerepack/config.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
class CfgPatches {
|
||||||
|
class ADDON {
|
||||||
|
units[] = {};
|
||||||
|
weapons[] = {};
|
||||||
|
requiredVersion = REQUIRED_VERSION;
|
||||||
|
requiredAddons[] = {"ace_common","ace_interaction"};
|
||||||
|
author[] = {"commy2","CAA-Picard"};
|
||||||
|
authorUrl = "https://github.com/commy2/";
|
||||||
|
VERSION_CONFIG;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "CfgEventHandlers.hpp"
|
||||||
|
#include "CfgVehicles.hpp"
|
||||||
|
|
||||||
|
class ACE_Parameters_Numeric {
|
||||||
|
GVAR(TimePerAmmo) = 1.5;
|
||||||
|
GVAR(TimePerMagazine) = 2.0;
|
||||||
|
};
|
77
addons/magazinerepack/functions/fnc_magazineRepack.sqf
Normal file
77
addons/magazinerepack/functions/fnc_magazineRepack.sqf
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// by commy2, esteldunedain
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_magazines", "_ammos", "_repackTime", "_magazine", "_ammo", "_count", "_index", "_i", "_j", "_ammoToTransfer", "_ammoAvailable", "_ammoNeeded"];
|
||||||
|
|
||||||
|
_unit = _this select 0;
|
||||||
|
|
||||||
|
_magazines = [];
|
||||||
|
_ammos = [];
|
||||||
|
_repackTime = [];
|
||||||
|
|
||||||
|
// get all mags and ammo count
|
||||||
|
{
|
||||||
|
_magazine = _x select 0;
|
||||||
|
_ammo = _x select 1;
|
||||||
|
|
||||||
|
_count = getNumber (configfile >> "CfgMagazines" >> _magazine >> "count");
|
||||||
|
|
||||||
|
if (_ammo != _count && {_count > 1}) then { // additional checks here
|
||||||
|
if !(_magazine in _magazines) then {
|
||||||
|
_index = count _magazines;
|
||||||
|
_magazines set [_index, _magazine];
|
||||||
|
_ammos set [_index, [_ammo]];
|
||||||
|
} else {
|
||||||
|
_index = _magazines find _magazine;
|
||||||
|
_ammos set [_index, (_ammos select _index) + [_ammo]];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach magazinesAmmoFull _unit;
|
||||||
|
|
||||||
|
// Remove invalid magazines
|
||||||
|
{
|
||||||
|
if (count _x < 2) then {
|
||||||
|
_magazines set [_forEachIndex, -1];
|
||||||
|
_ammos set [_forEachIndex, [-1]];
|
||||||
|
};
|
||||||
|
} forEach _ammos;
|
||||||
|
_magazines = _magazines - [-1];
|
||||||
|
_ammos = _ammos - [[-1]];
|
||||||
|
|
||||||
|
{
|
||||||
|
// Calculate actual ammo to transfer during repack
|
||||||
|
_count = getNumber (configfile >> "CfgMagazines" >> (_magazines select _forEachIndex) >> "count");
|
||||||
|
|
||||||
|
// Sort Ascending
|
||||||
|
_list = _x call BIS_fnc_sortNum;
|
||||||
|
|
||||||
|
["MagazineRepack", _list] call EFUNC(common,log);
|
||||||
|
|
||||||
|
_i = 0;
|
||||||
|
_j = count _x - 1;
|
||||||
|
_ammoToTransfer = 0;
|
||||||
|
_ammoAvailable = 0;
|
||||||
|
while {_i < _j} do {
|
||||||
|
_ammoNeeded = _count - (_list select _j);
|
||||||
|
_exit = false;
|
||||||
|
while {_i < _j && {!_exit}} do {
|
||||||
|
_ammoAvailable = _list select _i;
|
||||||
|
if (_ammoAvailable >= _ammoNeeded) then {
|
||||||
|
_list set [_i, _ammoAvailable - _ammoNeeded];
|
||||||
|
_ammoToTransfer = _ammoToTransfer + _ammoNeeded;
|
||||||
|
_exit = true;
|
||||||
|
} else {
|
||||||
|
_ammoNeeded = _ammoNeeded - _ammoAvailable;
|
||||||
|
_ammoToTransfer = _ammoToTransfer + _ammoAvailable;
|
||||||
|
_i = _i + 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_j = _j - 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
_repackTime set [_forEachIndex, _ammoToTransfer * GVAR(TimePerAmmo) + (count _x) * GVAR(TimePerMagazine)];
|
||||||
|
} forEach _ammos;
|
||||||
|
|
||||||
|
["MagazineRepack", [_magazines, _repackTime]] call EFUNC(common,log);
|
||||||
|
|
||||||
|
[_unit, _magazines, _repackTime] call FUNC(openSelectMagazineUI);
|
106
addons/magazinerepack/functions/fnc_magazineRepackCallback.sqf
Normal file
106
addons/magazinerepack/functions/fnc_magazineRepackCallback.sqf
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_magazine", "_ammo", "_ammoCount", "_fullMagazinesCount", "_restAmmo", "_isLoaded", "_weapon", "_reloadAction", "_text", "_picture"];
|
||||||
|
|
||||||
|
_unit = ACE_player; //_this select 0;
|
||||||
|
_magazine = _this select 1;
|
||||||
|
|
||||||
|
// exit if the last magazine of this type was taken out of the backpack
|
||||||
|
if !(_magazine in magazines _unit) exitWith {};
|
||||||
|
|
||||||
|
// get current ammo count
|
||||||
|
_ammo = 0;
|
||||||
|
{
|
||||||
|
if (_x select 0 == _magazine) then {
|
||||||
|
_ammo = _ammo + (_x select 1);
|
||||||
|
};
|
||||||
|
} forEach magazinesAmmoFull _unit;
|
||||||
|
|
||||||
|
// how many rounds fit in one mag
|
||||||
|
_ammoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >> "count");
|
||||||
|
|
||||||
|
// calculate new vaules
|
||||||
|
_fullMagazinesCount = floor (_ammo / _ammoCount);
|
||||||
|
_restAmmo = _ammo - _fullMagazinesCount * _ammoCount;
|
||||||
|
|
||||||
|
// remove old magazines
|
||||||
|
_unit removeMagazines _magazine;
|
||||||
|
|
||||||
|
_isLoaded = false;
|
||||||
|
// reload rifle
|
||||||
|
if (_magazine in primaryWeaponMagazine _unit) then {
|
||||||
|
_weapon = primaryWeapon _unit;
|
||||||
|
|
||||||
|
if (_fullMagazinesCount > 0) then {
|
||||||
|
_unit setAmmo [_weapon, _ammoCount];
|
||||||
|
_fullMagazinesCount = _fullMagazinesCount - 1;
|
||||||
|
} else {
|
||||||
|
_unit setAmmo [_weapon, _restAmmo];
|
||||||
|
_restAmmo = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_weapon == currentWeapon _unit) then {
|
||||||
|
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
||||||
|
_unit playActionNow _reloadAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
_isLoaded = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// reload pistol
|
||||||
|
if (_magazine in handgunMagazine _unit) then {
|
||||||
|
_weapon = handgunWeapon _unit;
|
||||||
|
|
||||||
|
if (_fullMagazinesCount > 0) then {
|
||||||
|
_unit setAmmo [_weapon, _ammoCount];
|
||||||
|
_fullMagazinesCount = _fullMagazinesCount - 1;
|
||||||
|
} else {
|
||||||
|
_unit setAmmo [_weapon, _restAmmo];
|
||||||
|
_restAmmo = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_weapon == currentWeapon _unit) then {
|
||||||
|
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
||||||
|
_unit playActionNow _reloadAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
_isLoaded = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// reload rocket launcher (just in case ...)
|
||||||
|
if (_magazine in secondaryWeaponMagazine _unit) then {
|
||||||
|
_weapon = secondaryWeapon _unit;
|
||||||
|
|
||||||
|
if (_fullMagazinesCount > 0) then {
|
||||||
|
_unit setAmmo [_weapon, _ammoCount];
|
||||||
|
_fullMagazinesCount = _fullMagazinesCount - 1;
|
||||||
|
} else {
|
||||||
|
_unit setAmmo [_weapon, _restAmmo];
|
||||||
|
_restAmmo = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_weapon == currentWeapon _unit) then {
|
||||||
|
_reloadAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
||||||
|
_unit playActionNow _reloadAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
_isLoaded = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// add new magazines
|
||||||
|
for "_a" from 1 to _fullMagazinesCount do {
|
||||||
|
_unit addMagazine _magazine;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_restAmmo > 0) then {
|
||||||
|
_unit addMagazine [_magazine, _restAmmo];
|
||||||
|
};
|
||||||
|
|
||||||
|
// display text if successful
|
||||||
|
_text = format [localize "STR_ACE_MagazineRepack_RepackedMagazinesDetail", [_fullMagazinesCount, _fullMagazinesCount + 1] select _isLoaded, _restAmmo];
|
||||||
|
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
||||||
|
|
||||||
|
_text = parseText format ["<img align='center' size='1.8' color='#ffffff' image='%1'/> <br/> <t align='center'>%2</t> <br/> <t align='center'>%3</t>", _picture, localize "STR_ACE_MagazineRepack_RepackedMagazines", _text];
|
||||||
|
|
||||||
|
[_text] call EFUNC(common,displayTextStructured);
|
40
addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf
Normal file
40
addons/magazinerepack/functions/fnc_openSelectMagazineUI.sqf
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_magazines", "_repackTime", "_listIDC", "_count", "_index", "_magazine", "_time", "_displayName", "_picture"];
|
||||||
|
|
||||||
|
_unit = _this select 0;
|
||||||
|
_magazines = _this select 1;
|
||||||
|
_repackTime = _this select 2;
|
||||||
|
|
||||||
|
_count = count _magazines;
|
||||||
|
|
||||||
|
_actions = [localize "STR_ACE_MagazineRepack_SelectMagazineMenu", localize "STR_ACE_MagazineRepack_SelectMagazine"] call EFUNC(interaction,prepareSelectMenu);
|
||||||
|
for "_index" from 0 to (_count - 1) do {
|
||||||
|
_magazine = _magazines select _index;
|
||||||
|
_time = _repackTime select _index;
|
||||||
|
_displayName = getText (configFile >> "CfgMagazines" >> _magazine >> "displayName");
|
||||||
|
_picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture");
|
||||||
|
_actions = [
|
||||||
|
_actions,
|
||||||
|
_displayName,
|
||||||
|
_picture,
|
||||||
|
[str _unit, _magazine, _time]
|
||||||
|
] call EFUNC(interaction,addSelectableItem);
|
||||||
|
};
|
||||||
|
|
||||||
|
[
|
||||||
|
_actions,
|
||||||
|
{
|
||||||
|
_data = _this;
|
||||||
|
call EFUNC(interaction,hideMenu);
|
||||||
|
if (isNil "_data") exitWith {};
|
||||||
|
_data set [2, [_data select 2] call EFUNC(common,toNumber)];
|
||||||
|
[_data select 2, _data, QFUNC(magazineRepackCallback), localize "STR_ACE_MagazineRepack_RepackingMagazine"] call EFUNC(common,progressBar);
|
||||||
|
[ACE_player] call EFUNC(common,goKneeling);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
call EFUNC(interaction,hideMenu);
|
||||||
|
if !(profileNamespace getVariable [QGVAR(AutoCloseMenu), false]) then {"Default" call EFUNC(interaction,openMenuSelf)};
|
||||||
|
}
|
||||||
|
] call EFUNC(interaction,openSelectMenu);
|
1
addons/magazinerepack/functions/script_component.hpp
Normal file
1
addons/magazinerepack/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "\z\ace\addons\magazinerepack\script_component.hpp"
|
12
addons/magazinerepack/script_component.hpp
Normal file
12
addons/magazinerepack/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#define COMPONENT magazinerepack
|
||||||
|
#include "\z\ace\addons\main\script_mod.hpp"
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_MAGAZINEREPACK
|
||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_MAGAZINEREPACK
|
||||||
|
#define DEBUG_SETTINGS DEBUG_ENABLED_MAGAZINEREPACK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "\z\ace\addons\main\script_macros.hpp"
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Edited with tabler - 2014-12-17 -->
|
<!-- Edited with tabler - 2014-12-17 -->
|
||||||
<Project name="AGM">
|
<Project name="ACE">
|
||||||
<Package name="MagazineRepack">
|
<Package name="MagazineRepack">
|
||||||
<Key ID="STR_AGM_MagazineRepack_RepackMagazines">
|
<Key ID="STR_ACE_MagazineRepack_RepackMagazines">
|
||||||
<English>Repack Magazines</English>
|
<English>Repack Magazines</English>
|
||||||
<German>Magazine umpacken</German>
|
<German>Magazine umpacken</German>
|
||||||
<Spanish>Reorganizar cargadores</Spanish>
|
<Spanish>Reorganizar cargadores</Spanish>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
<Hungarian>Újratárazás</Hungarian>
|
<Hungarian>Újratárazás</Hungarian>
|
||||||
<Russian>Перепаковать магазины</Russian>
|
<Russian>Перепаковать магазины</Russian>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_AGM_MagazineRepack_SelectMagazineMenu">
|
<Key ID="STR_ACE_MagazineRepack_SelectMagazineMenu">
|
||||||
<English>Select Magazine Menu</English>
|
<English>Select Magazine Menu</English>
|
||||||
<German>Magazinauswahlmenü</German>
|
<German>Magazinauswahlmenü</German>
|
||||||
<Spanish>Menú de selección de cargador</Spanish>
|
<Spanish>Menú de selección de cargador</Spanish>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<Hungarian>Fegyvertár menü kiválasztás</Hungarian>
|
<Hungarian>Fegyvertár menü kiválasztás</Hungarian>
|
||||||
<Russian>Меню выбора магазинов</Russian>
|
<Russian>Меню выбора магазинов</Russian>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_AGM_MagazineRepack_SelectMagazine">
|
<Key ID="STR_ACE_MagazineRepack_SelectMagazine">
|
||||||
<English>Select Mag</English>
|
<English>Select Mag</English>
|
||||||
<German>Magazin auswählen</German>
|
<German>Magazin auswählen</German>
|
||||||
<Spanish>Seleccionar cargador</Spanish>
|
<Spanish>Seleccionar cargador</Spanish>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<Hungarian>Tár kiválasztása</Hungarian>
|
<Hungarian>Tár kiválasztása</Hungarian>
|
||||||
<Russian>Выбрать магазин</Russian>
|
<Russian>Выбрать магазин</Russian>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_AGM_MagazineRepack_RepackingMagazine">
|
<Key ID="STR_ACE_MagazineRepack_RepackingMagazine">
|
||||||
<English>Repacking Magazines ...</English>
|
<English>Repacking Magazines ...</English>
|
||||||
<German>Magazine umpacken ...</German>
|
<German>Magazine umpacken ...</German>
|
||||||
<Spanish>Reorganizando cargadores ...</Spanish>
|
<Spanish>Reorganizando cargadores ...</Spanish>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<Hungarian>Újratárazás ...</Hungarian>
|
<Hungarian>Újratárazás ...</Hungarian>
|
||||||
<Russian>Перепаковка магазинов ...</Russian>
|
<Russian>Перепаковка магазинов ...</Russian>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_AGM_MagazineRepack_RepackedMagazines">
|
<Key ID="STR_ACE_MagazineRepack_RepackedMagazines">
|
||||||
<English>Repacked Magazines</English>
|
<English>Repacked Magazines</English>
|
||||||
<German>Magazine umgepackt</German>
|
<German>Magazine umgepackt</German>
|
||||||
<Spanish>Cargadores reorganizados</Spanish>
|
<Spanish>Cargadores reorganizados</Spanish>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<Hungarian>Újratárazott tárak</Hungarian>
|
<Hungarian>Újratárazott tárak</Hungarian>
|
||||||
<Russian>Магазины перепакованы</Russian>
|
<Russian>Магазины перепакованы</Russian>
|
||||||
</Key>
|
</Key>
|
||||||
<Key ID="STR_AGM_MagazineRepack_RepackedMagazinesDetail">
|
<Key ID="STR_ACE_MagazineRepack_RepackedMagazinesDetail">
|
||||||
<English>%1 full mag(s) and %2 extra round(s)</English>
|
<English>%1 full mag(s) and %2 extra round(s)</English>
|
||||||
<German>%1 volle(s) Magazin(e) und %2 übrig gebliebene Patrone(n)</German>
|
<German>%1 volle(s) Magazin(e) und %2 übrig gebliebene Patrone(n)</German>
|
||||||
<Spanish>%1 cargador(es) completo(s) y %2 bala(s) extra(s)</Spanish>
|
<Spanish>%1 cargador(es) completo(s) y %2 bala(s) extra(s)</Spanish>
|
Loading…
Reference in New Issue
Block a user