mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Separate assembly mod and ammo handling more
They aren't entirely separate. If you enable advanced assembly, you need ammo handling to be enabled.
This commit is contained in:
parent
7f16ba8961
commit
fa8161bc03
@ -4,6 +4,24 @@ GVAR(vehicleMagCache) = createHashMap;
|
||||
|
||||
["CBA_settingsInitialized", {
|
||||
TRACE_3("settingsInit",GVAR(defaultAssemblyMode),GVAR(handleExtraMagazines),GVAR(ammoHandling));
|
||||
|
||||
// Do not allow no ammo handling when advanced assembly is enabled
|
||||
if (GVAR(defaultAssemblyMode) && GVAR(ammoHandling) == 0) then {
|
||||
if (isServer) then {
|
||||
[QGVAR(ammoHandling), 2, 2, "server"] call CBA_settings_fnc_set;
|
||||
};
|
||||
|
||||
// Notify everyone about change
|
||||
[QEGVAR(common,displayTextStructured), [composeText [
|
||||
lineBreak,
|
||||
parseText format [
|
||||
"<t align='center'>%1</t>", format ["%1 requires %2 to be set higher than 0.", QGVAR(defaultAssemblyMode), QGVAR(ammoHandling)]
|
||||
],
|
||||
lineBreak,
|
||||
parseText format ["<t align='center'>%1</t>", "No mission restart is required."]
|
||||
], 4]] call CBA_fnc_localEvent;
|
||||
};
|
||||
|
||||
["StaticWeapon", "Init", {
|
||||
// needs a small delay for network syncing, or we end up with duplicate mags with ammo handling
|
||||
[LINKFUNC(initVehicle), _this, 1] call CBA_fnc_waitAndExecute;
|
||||
|
@ -21,8 +21,7 @@ params ["_vehicle", ["_targetTurret", true, [[], true]]];
|
||||
private _return = [[], []];
|
||||
|
||||
if !(_vehicle isKindOf "StaticWeapon") exitWith {_return}; // limit to statics for now
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]))}) exitWith {_return};
|
||||
if (GVAR(ammoHandling) == 0) exitWith {_return};
|
||||
|
||||
private _turretMagsCSW = _return select 0;
|
||||
private _allCarryMags = _return select 1;
|
||||
|
@ -17,9 +17,7 @@
|
||||
|
||||
params ["_staticWeapon"];
|
||||
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select (_staticWeapon getVariable [QGVAR(assemblyMode), 3]);
|
||||
private _notCrewed = (crew _staticWeapon) isEqualTo [];
|
||||
private _deadCrew = !(alive (gunner _staticWeapon)); // need to eject body???
|
||||
|
||||
_assemblyMode && {_notCrewed || _deadCrew}
|
||||
GVAR(defaultAssemblyMode) && {_notCrewed || _deadCrew}
|
||||
|
@ -34,12 +34,11 @@
|
||||
|
||||
// Create a tripod
|
||||
private _cswTripod = createVehicle [_tripodClassname, [0, 0, 0], [], 0, "NONE"];
|
||||
// Because the tripod can be a "full weapon" we disable any data that will allow it to be loaded
|
||||
_cswTripod setVariable [QGVAR(assemblyMode), 2, true]; // Explicitly set enabled&unload assembly mode and broadcast
|
||||
_cswTripod setVariable [QGVAR(assembled), true, true];
|
||||
if (_secondaryWeaponMagazine isNotEqualTo "") then {
|
||||
_cswTripod setVariable [QGVAR(secondaryWeaponMagazine), _secondaryWeaponMagazine];
|
||||
};
|
||||
if (!GVAR(defaultAssemblyMode)) then {
|
||||
if (GVAR(defaultAssemblyMode)) then {
|
||||
[_cswTripod, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
|
||||
|
@ -43,9 +43,8 @@
|
||||
[{
|
||||
params ["_assembledClassname", "_tripodDir", "_tripodPos"];
|
||||
private _csw = createVehicle [_assembledClassname, [0, 0, 0], [], 0, "NONE"];
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
_csw setVariable [QGVAR(assemblyMode), 2, true]; // Explicitly set advanced assembly mode + unload, and broadcast
|
||||
if (!GVAR(defaultAssemblyMode)) then {
|
||||
_csw setVariable [QGVAR(assembled), true, true];
|
||||
if (GVAR(defaultAssemblyMode)) then {
|
||||
[_csw, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
_csw setDir _tripodDir;
|
||||
|
@ -35,31 +35,29 @@ if (_configEnabled && {GVAR(ammoHandling) == 2}) then {
|
||||
|
||||
TRACE_2("",local _vehicle,_vehicle turretLocal [0]);
|
||||
if (_configEnabled && {_vehicle turretLocal [0]}) then { // if turret is local to us, then handle mags/weapon
|
||||
[{
|
||||
params ["_vehicle"];
|
||||
if (!alive _vehicle) exitWith { TRACE_1("dead/deleted",_vehicle); };
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
private _assemblyModeIndex = _vehicle getVariable [QGVAR(assemblyMode), 3];
|
||||
private _emptyWeapon = _assemblyModeIndex isEqualTo 2;
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select _assemblyModeIndex;
|
||||
TRACE_2("turretLocal",_vehicle,_assemblyMode);
|
||||
[_vehicle, [0], _assemblyMode, _emptyWeapon] call FUNC(proxyWeapon);
|
||||
[_vehicle, _assemblyMode, _emptyWeapon] call FUNC(staticWeaponInit_unloadExtraMags);
|
||||
}, [_vehicle]] call CBA_fnc_execNextFrame; // need to wait a frame to allow setting object vars during assembly
|
||||
TRACE_2("turretLocal",_vehicle,GVAR(defaultAssemblyMode));
|
||||
|
||||
// If the weapon was assembled by players, remove all magazines that spawn with the weapon
|
||||
private _emptyWeapon = _csw getVariable [QGVAR(assembled), false];
|
||||
|
||||
[_vehicle, [0], GVAR(defaultAssemblyMode), _emptyWeapon] call FUNC(proxyWeapon);
|
||||
|
||||
// If magazine handling is disabled, do not unload magazines
|
||||
if (GVAR(ammoHandling) == 0) exitWith {};
|
||||
|
||||
[_vehicle, _emptyWeapon] call FUNC(staticWeaponInit_unloadExtraMags);
|
||||
};
|
||||
|
||||
if (_assemblyConfig) then {
|
||||
[{
|
||||
params ["_vehicle"];
|
||||
if (!alive _vehicle) exitWith { TRACE_1("dead/deleted",_vehicle); };
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]);
|
||||
TRACE_2("assemblyConfig present",_vehicle,_assemblyMode);
|
||||
if (_assemblyMode) then { // Disable vanilla assembly if assemblyMode enabled
|
||||
[_vehicle, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
}, [_vehicle]] call CBA_fnc_execNextFrame; // need to wait a frame to allow setting object vars during assembly
|
||||
TRACE_2("assemblyConfig present",_vehicle,GVAR(defaultAssemblyMode));
|
||||
if (GVAR(defaultAssemblyMode)) then { // Disable vanilla assembly if assemblyMode enabled
|
||||
[_vehicle, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
||||
};
|
||||
};
|
||||
|
||||
// If magazine handling is disabled, don't enable ammo handling
|
||||
if (GVAR(ammoHandling) == 0) exitWith {};
|
||||
|
||||
// Add interactions for players
|
||||
if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
|
||||
GVAR(initializedStaticTypes) pushBack _typeOf;
|
||||
@ -74,8 +72,6 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
|
||||
private _ammoActionPath = [];
|
||||
private _magazineLocation = getText (_configOf >> QUOTE(ADDON) >> "magazineLocation");
|
||||
private _condition = { //IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
||||
// If magazine handling is enabled or weapon assembly/disassembly is enabled we enable ammo handling
|
||||
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_target getVariable [QGVAR(assemblyMode), 3]))}) exitWith { false };
|
||||
[_player, _target, ["isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)
|
||||
};
|
||||
private _childenCode = {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Weapon <OBJECT>
|
||||
* 1: Using advanced assembly <BOOL>
|
||||
* 1: Empty the weapon? <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -16,9 +16,8 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon", "_assemblyMode", "_emptyWeapon"];
|
||||
TRACE_3("staticWeaponInit_unloadExtraMags",_staticWeapon,_assemblyMode,_emptyWeapon);
|
||||
if (!_assemblyMode) exitWith {};
|
||||
params ["_staticWeapon", "_emptyWeapon"];
|
||||
TRACE_2("staticWeaponInit_unloadExtraMags",_staticWeapon,_emptyWeapon);
|
||||
|
||||
private _desiredAmmo = getNumber (configOf _staticWeapon >> QUOTE(ADDON) >> "desiredAmmo");
|
||||
private _storeExtraMagazines = GVAR(handleExtraMagazines);
|
||||
|
Loading…
Reference in New Issue
Block a user