its now possible to set rearm vehicles in the editor && pylons now look also for non-config rearm vehicles

This commit is contained in:
Will 2018-07-09 19:20:55 +02:00
parent 29726946f6
commit 4b1672eaa0
8 changed files with 129 additions and 5 deletions

View File

@ -15,10 +15,14 @@ GVAR(aircraftWithPylons) = (_filter configClasses (configFile >> "CfgVehicles"))
if (!GVAR(enabledFromAmmoTrucks)) exitWith {false}; if (!GVAR(enabledFromAmmoTrucks)) exitWith {false};
private _vehicles = nearestObjects [_target, ["Air", "LandVehicle", "Slingload_base_F", "ReammoBox_F"], GVAR(searchDistance) + 10]; 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 _isRearmVehicle = if (["ace_rearm"] call EFUNC(common,isModLoaded)) then {
private _rearmVehicles = {(getNumber (configFile >> "CfgVehicles" >> typeOf _x >> _filter)) > 0} count _vehicles; _vehicles findIf {[_x] call EFUNC(rearm,isSource)} != -1;
} else {
(_rearmVehicles > 0 && {[ace_player, _target] call FUNC(canConfigurePylons)}) 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); ] call EFUNC(interact_menu,createAction);

25
addons/rearm/Cfg3DEN.hpp Normal file
View 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";
};
};
};
};
};
};

View File

@ -21,7 +21,9 @@ PREP(handleRespawn);
PREP(handleUnconscious); PREP(handleUnconscious);
PREP(hasEnoughSupply); PREP(hasEnoughSupply);
PREP(initSupplyVehicle); PREP(initSupplyVehicle);
PREP(isSource);
PREP(makeDummy); PREP(makeDummy);
PREP(makeSource);
PREP(moduleRearmSettings); PREP(moduleRearmSettings);
PREP(pickUpAmmo); PREP(pickUpAmmo);
PREP(readSupplyCounter); PREP(readSupplyCounter);

View File

@ -9,6 +9,8 @@ GVAR(configTypesAdded) = [];
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler; ["ace_unconscious", LINKFUNC(handleUnconscious)] call CBA_fnc_addEventHandler;
[QGVAR(initSupplyVehicle), LINKFUNC(initSupplyVehicle)] call CBA_fnc_addEventHandler;
["vehicle", { ["vehicle", {
params ["_unit"]; params ["_unit"];
[_unit] call FUNC(dropAmmo); [_unit] call FUNC(dropAmmo);

View File

@ -16,7 +16,7 @@ class CfgPatches {
#include "ACE_Settings.hpp" #include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"
#include "Cfg3DEN.hpp"
#include "CfgAmmo.hpp" #include "CfgAmmo.hpp"
#include "CfgMagazines.hpp" #include "CfgMagazines.hpp"
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"

View 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}

View 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];

View File

@ -573,5 +573,13 @@
<Chinesesimp>FAB-250M-54</Chinesesimp> <Chinesesimp>FAB-250M-54</Chinesesimp>
<Chinese>FAB-250M-54</Chinese> <Chinese>FAB-250M-54</Chinese>
</Key> </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> </Package>
</Project> </Project>