mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
its now possible to set rearm vehicles in the editor && pylons now look also for non-config rearm vehicles
This commit is contained in:
parent
29726946f6
commit
4b1672eaa0
@ -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;
|
||||
|
||||
(_rearmVehicles > 0 && {[ace_player, _target] call FUNC(canConfigurePylons)})
|
||||
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;
|
||||
};
|
||||
|
||||
(_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,8 @@ GVAR(configTypesAdded) = [];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(initSupplyVehicle), LINKFUNC(initSupplyVehicle)] call CBA_fnc_addEventHandler;
|
||||
|
||||
["vehicle", {
|
||||
params ["_unit"];
|
||||
[_unit] call FUNC(dropAmmo);
|
||||
|
@ -16,7 +16,7 @@ class CfgPatches {
|
||||
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "CfgEventHandlers.hpp"
|
||||
|
||||
#include "Cfg3DEN.hpp"
|
||||
#include "CfgAmmo.hpp"
|
||||
#include "CfgMagazines.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
|
28
addons/rearm/functions/fnc_isSource.sqf
Normal file
28
addons/rearm/functions/fnc_isSource.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
#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]]
|
||||
];
|
||||
|
||||
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}
|
55
addons/rearm/functions/fnc_makeSource.sqf
Normal file
55
addons/rearm/functions/fnc_makeSource.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
#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]]
|
||||
];
|
||||
|
||||
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];
|
@ -573,5 +573,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