mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Repack Mag Child Actions
This commit is contained in:
parent
43a9e7bfc8
commit
0d27806571
@ -2,6 +2,7 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(getMagazineChildren);
|
||||
PREP(magazineRepackFinish);
|
||||
PREP(magazineRepackProgress);
|
||||
PREP(openSelectMagazineUI);
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Author: PabstMirror (based on repack from commy2, esteldunedain, Ruthberg)
|
||||
* Opens the selectMenu UI to chose which magazine to repack.
|
||||
* Only shows classnames that have 2+ partial magazines
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit (player) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [_player] call ace_magazinerepack_fnc_openSelectMagazineUI
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unitMagazines", "_unitMagCounts", "_xFullMagazineCount", "_index", "_actions", "_displayName", "_picture"];
|
||||
|
||||
PARAMS_1(_unit);
|
||||
|
||||
_unitMagazines = [];
|
||||
_unitMagCounts = [];
|
||||
|
||||
// get all mags and ammo count
|
||||
{
|
||||
EXPLODE_2_PVT(_x,_xClassname,_xCount);
|
||||
_xFullMagazineCount = getNumber (configfile >> "CfgMagazines" >> _xClassname >> "count");
|
||||
|
||||
if ((_xCount != _xFullMagazineCount) && {_xCount > 0}) then {//for every partial magazine
|
||||
_index = _unitMagazines find _xClassname;
|
||||
if (_index == -1) then {
|
||||
_unitMagazines pushBack _xClassname;
|
||||
_unitMagCounts pushBack [_xCount];
|
||||
} else {
|
||||
(_unitMagCounts select _index) pushBack _xCount;
|
||||
};
|
||||
};
|
||||
} forEach (magazinesAmmoFull _unit);
|
||||
|
||||
_actions = [localize "STR_ACE_MagazineRepack_SelectMagazineMenu", localize "STR_ACE_MagazineRepack_SelectMagazine"] call EFUNC(interaction,prepareSelectMenu);
|
||||
|
||||
{
|
||||
if ((count (_unitMagCounts select _forEachIndex)) >= 2) then {// Ignore invalid magazines types (need 2+ partial mags to do anything)
|
||||
_displayName = getText (configFile >> "CfgMagazines" >> _x >> "displayName");
|
||||
_picture = getText (configFile >> "CfgMagazines" >> _x >> "picture");
|
||||
_actions = [_actions, _displayName, _picture, _x] call EFUNC(interaction,addSelectableItem);
|
||||
};
|
||||
} forEach _unitMagazines;
|
||||
|
||||
[
|
||||
_actions,
|
||||
{ [_this] call FUNC(startRepackingMagazine); },
|
||||
{
|
||||
call EFUNC(interaction,hideMenu); //ToDo: Self Interaction Integration
|
||||
}
|
||||
] call EFUNC(interaction,openSelectMenu);
|
@ -5,7 +5,9 @@
|
||||
* Precalcs all the event timings and starts the progressBar.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Magazine Classname <STRING>
|
||||
* 0: Target <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
* 2: Magazine Classname <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
@ -17,23 +19,19 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_player", "_fullMagazineCount", "_startingAmmoCounts", "_simEvents", "_totalTime", "_magazineCfg"];
|
||||
private ["_fullMagazineCount", "_startingAmmoCounts", "_simEvents", "_totalTime", "_magazineCfg"];
|
||||
|
||||
PARAMS_2(_target,_player,_magazineClassname);
|
||||
|
||||
PARAMS_1(_magazineClassname);
|
||||
if (isNil "_magazineClassname" || {_magazineClassname == ""}) exitWith {ERROR("Bad Mag Classname");};
|
||||
|
||||
_magazineCfg = configfile >> "CfgMagazines" >> _magazineClassname;
|
||||
// Calculate actual ammo to transfer during repack
|
||||
_fullMagazineCount = getNumber (_magazineCfg >> "count");
|
||||
//Is linked belt magazine:
|
||||
_isBelt = (isNumber (_magazineCfg >> "ACE_isBelt")) && {(getNumber (_magazineCfg >> "ACE_isBelt")) == 1};
|
||||
|
||||
|
||||
_player = ACE_player;
|
||||
|
||||
[_player] call EFUNC(common,goKneeling);
|
||||
|
||||
|
||||
_startingAmmoCounts = [];
|
||||
{
|
||||
EXPLODE_4_PVT(_x,_xClassname,_xCount,_xLoaded,_xType);
|
||||
|
Loading…
Reference in New Issue
Block a user