mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
64a06ddb07
@ -15,10 +15,14 @@ GVAR(aircraftWithPylons) = (_filter configClasses (configFile >> "CfgVehicles"))
|
||||
if (!GVAR(enabledFromAmmoTrucks)) exitWith {false};
|
||||
|
||||
private _vehicles = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F", "ReammoBox_F"], GVAR(searchDistance) + 10];
|
||||
private _filter = ["transportAmmo", QEGVAR(rearm,defaultSupply)] select (["ace_rearm"] call EFUNC(common,isModLoaded));
|
||||
private _rearmVehicles = {(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> _filter)) > 0} count _vehicles;
|
||||
private _isRearmVehicle = if (["ace_rearm"] call EFUNC(common,isModLoaded)) then {
|
||||
_vehicles findIf {[_x] call EFUNC(rearm,isSource)} != -1;
|
||||
} else {
|
||||
private _cfgVehicle = configFile >> "CfgVehicles";
|
||||
_vehicles findIf {getNumber (_cfgVehicle >> typeOf _x >> "transportAmmo") > 0} != -1;
|
||||
};
|
||||
|
||||
(_rearmVehicles > 0 && {[ace_player, _target] call FUNC(canConfigurePylons)})
|
||||
(_isRearmVehicle && {[ace_player, _target] call FUNC(canConfigurePylons)})
|
||||
}
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
|
||||
|
25
addons/rearm/Cfg3DEN.hpp
Normal file
25
addons/rearm/Cfg3DEN.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
|
||||
#define DEFAULT_REARMCARGO GET_NUMBER(configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(defaultSupply),-1)
|
||||
|
||||
|
||||
class Cfg3DEN {
|
||||
class Object {
|
||||
class AttributeCategories {
|
||||
class ace_attributes {
|
||||
class Attributes {
|
||||
class GVAR(rearmCargo) {
|
||||
displayName = CSTRING(rearmCargo_edenName);
|
||||
tooltip = CSTRING(rearmCargo_edenDesc);
|
||||
property = QGVAR(rearmCargo);
|
||||
control = "EditShort";
|
||||
expression = QUOTE(if (_value != DEFAULT_REARMCARGO) then {[ARR_2(_this,_value)] call DFUNC(makeSource)});
|
||||
defaultValue = QUOTE(DEFAULT_REARMCARGO);
|
||||
validate = "number";
|
||||
condition = "(1-objectBrain)*(1-objectAgent)";
|
||||
typeName = "NUMBER";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -21,7 +21,9 @@ PREP(handleRespawn);
|
||||
PREP(handleUnconscious);
|
||||
PREP(hasEnoughSupply);
|
||||
PREP(initSupplyVehicle);
|
||||
PREP(isSource);
|
||||
PREP(makeDummy);
|
||||
PREP(makeSource);
|
||||
PREP(moduleRearmSettings);
|
||||
PREP(pickUpAmmo);
|
||||
PREP(readSupplyCounter);
|
||||
|
@ -9,6 +9,11 @@ GVAR(configTypesAdded) = [];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(initSupplyVehicle), {
|
||||
TRACE_1("initSupplyVehicle EH",_this); // Warning: this can run before settings are init
|
||||
[FUNC(initSupplyVehicle), _this] call EFUNC(common,runAfterSettingsInit);
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["vehicle", {
|
||||
params ["_unit"];
|
||||
[_unit] call FUNC(dropAmmo);
|
||||
|
@ -17,7 +17,7 @@ class CfgPatches {
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "ACE_ZeusActions.hpp"
|
||||
#include "CfgEventHandlers.hpp"
|
||||
|
||||
#include "Cfg3DEN.hpp"
|
||||
#include "CfgAmmo.hpp"
|
||||
#include "CfgMagazines.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
|
@ -19,10 +19,8 @@
|
||||
params ["_truck", "_unit"];
|
||||
|
||||
(alive _unit)
|
||||
&& {_unit isKindOf "CAManBase"}
|
||||
&& {local _unit}
|
||||
&& {alive _truck}
|
||||
&& {(_truck distance _unit) < REARM_ACTION_DISTANCE}
|
||||
&& {GVAR(supply) > 0}
|
||||
&& {[_unit, _truck, ["IsNotInside"]] call EFUNC(common,canInteractWith)} // manually added actions need this
|
||||
|
||||
&& {(_truck getVariable [QGVAR(currentSupply), 0]) >= 0}
|
||||
|
@ -19,9 +19,8 @@
|
||||
params ["_truck", "_unit"];
|
||||
|
||||
(alive _unit)
|
||||
&& {_unit isKindOf "CAManBase"}
|
||||
&& {local _unit}
|
||||
&& {!isNull (_unit getVariable [QGVAR(dummy), objNull])}
|
||||
&& {alive _truck}
|
||||
&& {(_truck distance _unit) < REARM_ACTION_DISTANCE}
|
||||
&& {[_unit, _truck, ["IsNotInside"]] call EFUNC(common,canInteractWith)} // manually added actions need this
|
||||
&& {(_truck getVariable [QGVAR(currentSupply), 0]) >= 0}
|
||||
|
@ -19,9 +19,8 @@
|
||||
params ["_truck", "_unit"];
|
||||
|
||||
(alive _unit)
|
||||
&& {_unit isKindOf "CAManBase"}
|
||||
&& {local _unit}
|
||||
&& {alive _truck}
|
||||
&& {(_truck distance _unit) < REARM_ACTION_DISTANCE}
|
||||
&& {isNull (_unit getVariable [QGVAR(dummy), objNull])}
|
||||
&& {[_unit, _truck, ["IsNotInside"]] call EFUNC(common,canInteractWith)} // manually added actions need this
|
||||
&& {(_truck getVariable [QGVAR(currentSupply), 0]) >= 0}
|
||||
|
@ -68,6 +68,8 @@ if (_oldRearmConfig || {_configSupply > 0}) then {
|
||||
WARNING_1("Actions already present on [%1]. Old Compat PBO?",_typeOf);
|
||||
};
|
||||
} else {
|
||||
if (_vehicle getVariable [QGVAR(objectActionsAdded), false]) exitWith {TRACE_1("Actions already added to object",_vehicle);};
|
||||
_vehicle setVariable [QGVAR(objectActionsAdded), true];
|
||||
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);
|
||||
|
30
addons/rearm/functions/fnc_isSource.sqf
Normal file
30
addons/rearm/functions/fnc_isSource.sqf
Normal file
@ -0,0 +1,30 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: shukari
|
||||
* Returns if vehicle or object is a rearm source.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: target <OBJECT>
|
||||
* 1: check for vanilla rearm vehicle <BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [cursorObject] call ace_rearm_fnc_isSource
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
params [
|
||||
["_target", objNull, [objNull]],
|
||||
["_testVanillaRearm", false, [false]]
|
||||
];
|
||||
|
||||
if ((_target getVariable [QGVAR(currentSupply), 0]) < 0) exitWith {false};
|
||||
|
||||
private _vehCfg = configFile >> "CfgVehicles" >> typeOf _target;
|
||||
private _vanillaCargoConfig = getNumber (_vehCfg >> "transportAmmo");
|
||||
private _rearmCargoConfig = getNumber (_vehCfg >> QGVAR(defaultSupply));
|
||||
private _supplyVehicle = _target getVariable [QGVAR(isSupplyVehicle), false];
|
||||
|
||||
_rearmCargoConfig > 0 || {_supplyVehicle} || {_testVanillaRearm && _vanillaCargoConfig > 0}
|
56
addons/rearm/functions/fnc_makeSource.sqf
Normal file
56
addons/rearm/functions/fnc_makeSource.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: shukari (template from refuel makeSource)
|
||||
* Makes an object into a rearm source.
|
||||
* Run on server only.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Rearm Source <OBJECT>
|
||||
* 1: Rearm amount <NUMBER> (default: 0)
|
||||
* 2: add rearm amount instead of set <BOOL> (default: false)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [cursorObject, 1200] call ace_rearm_fnc_makeSource
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
// Only run this after the settings are initialized
|
||||
if !(EGVAR(common,settingsInitFinished)) exitWith {
|
||||
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(makeSource), _this];
|
||||
};
|
||||
|
||||
params [
|
||||
["_source", objNull, [objNull]],
|
||||
["_rearmCargo", 0, [0]],
|
||||
["_addToCurrent", false, [false]]
|
||||
];
|
||||
TRACE_3("makeSource",_source,_rearmCargo,_addToCurrent);
|
||||
|
||||
if (isNull _source) exitWith {};
|
||||
|
||||
private _currentSupply = if (_addToCurrent) then {
|
||||
_source getVariable [QGVAR(currentSupply), 0]
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
_source setVariable [QGVAR(currentSupply), _currentSupply + _rearmCargo, true];
|
||||
|
||||
private _rearmCargoConfig = getNumber (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(defaultSupply));
|
||||
|
||||
// already initialized because this is a config rearm vehicle
|
||||
if (_rearmCargoConfig > 0 || _source getVariable [QGVAR(isSupplyVehicle), false]) exitWith {};
|
||||
|
||||
_source setVariable [QGVAR(isSupplyVehicle), true, true];
|
||||
|
||||
// check if menu already exists
|
||||
if (!isNil {_source getVariable QGVAR(initSupplyVehicle_jipID)}) exitWith {};
|
||||
|
||||
private _jipID = [QGVAR(initSupplyVehicle), [_source]] call CBA_fnc_globalEventJIP;
|
||||
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
|
||||
_source setVariable [QGVAR(initSupplyVehicle_jipID), _jipID];
|
@ -584,5 +584,13 @@
|
||||
<Chinesesimp>FAB-250M-54</Chinesesimp>
|
||||
<Chinese>FAB-250M-54</Chinese>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_rearmCargo_edenName">
|
||||
<English>Rearm Cargo</English>
|
||||
<German>Munitionsvorrat</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Rearm_rearmCargo_edenDesc">
|
||||
<English>The cargo for rearming (-1 disable)</English>
|
||||
<German>Der Munitionsvorrat, zum Aufmunitionieren von Fahrzeugen (-1 deaktiviert)</German>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user