mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
77 lines
2.9 KiB
Plaintext
77 lines
2.9 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Githawk, PabstMirror
|
|
* Adds rearm supply actions to a vehicle or ammo container.
|
|
*
|
|
* Arguments:
|
|
* 0: Object <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [ammoTruck] call ace_rearm_fnc_initSupplyVehicle;
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
if (!hasInterface) exitWith {}; // For now we just add actions, so no need non-clients
|
|
|
|
params ["_vehicle"];
|
|
private _typeOf = typeOf _vehicle;
|
|
TRACE_2("initSupplyVehicle",_vehicle,_typeOf);
|
|
|
|
if (!alive _vehicle) exitWith {};
|
|
|
|
private _configSupply = getNumber (configFile >> "CfgVehicles" >> _typeOf >> QGVAR(defaultSupply));
|
|
private _isSupplyVehicle = _vehicle getVariable [QGVAR(isSupplyVehicle), false];
|
|
private _oldRearmConfig = isClass (configFile >> "CfgVehicles" >> _typeOf >> "ACE_Actions" >> "ACE_MainActions" >> QGVAR(takeAmmo));
|
|
TRACE_3("",_configSupply,_isSupplyVehicle,_oldRearmConfig);
|
|
|
|
if ((_configSupply <= 0) && {!_isSupplyVehicle} && {!_oldRearmConfig}) exitWith {}; // Ignore if not enabled
|
|
if ((_oldRearmConfig || {_configSupply > 0}) && {_typeOf in GVAR(configTypesAdded)}) exitWith {}; // Only add class actions once
|
|
if (_oldRearmConfig || {_configSupply > 0}) then {GVAR(configTypesAdded) pushBack _typeOf};
|
|
|
|
|
|
private _actionReadSupplyCounter = [ // GVAR(supply) > 0
|
|
QGVAR(ReadSupplyCounter),
|
|
localize LSTRING(ReadSupplyCounter), // Check remaining ammunition
|
|
QPATHTOF(ui\icon_rearm_interact.paa),
|
|
{_this call FUNC(readSupplyCounter)},
|
|
{_this call FUNC(canReadSupplyCounter)}
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
private _actionTakeAmmo = [
|
|
QGVAR(takeAmmo),
|
|
localize ([LSTRING(Rearm), LSTRING(TakeAmmo)] select (GVAR(level) > 0)),
|
|
QPATHTOF(ui\icon_rearm_interact.paa),
|
|
{},
|
|
{_this call FUNC(canTakeAmmo)},
|
|
{_this call FUNC(addRearmActions)}
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
private _actionStoreAmmo = [
|
|
QGVAR(StoreAmmo),
|
|
localize LSTRING(StoreAmmo), // "Store ammo"
|
|
QPATHTOF(ui\icon_rearm_interact.paa),
|
|
{_this call FUNC(storeAmmo)},
|
|
{_this call FUNC(canStoreAmmo)}
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
if (_oldRearmConfig || {_configSupply > 0}) then {
|
|
TRACE_1("Adding Class Actions",_typeOf);
|
|
[_typeOf, 0, ["ACE_MainActions"], _actionReadSupplyCounter] call EFUNC(interact_menu,addActionToClass);
|
|
if (!_oldRearmConfig) then {
|
|
[_typeOf, 0, ["ACE_MainActions"], _actionTakeAmmo] call EFUNC(interact_menu,addActionToClass);
|
|
[_typeOf, 0, ["ACE_MainActions"], _actionStoreAmmo] call EFUNC(interact_menu,addActionToClass);
|
|
} else {
|
|
WARNING_1("Actions already present on [%1]. Old Compat PBO?",_typeOf);
|
|
};
|
|
} else {
|
|
TRACE_1("Adding Object Actions",_typeOf);
|
|
[_vehicle, 0, ["ACE_MainActions"], _actionReadSupplyCounter] call EFUNC(interact_menu,addActionToObject);
|
|
[_vehicle, 0, ["ACE_MainActions"], _actionTakeAmmo] call EFUNC(interact_menu,addActionToObject);
|
|
[_vehicle, 0, ["ACE_MainActions"], _actionStoreAmmo] call EFUNC(interact_menu,addActionToObject);
|
|
};
|
|
|