mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Handle turret locality in CSW safer
This commit is contained in:
parent
d56a3a6a95
commit
a6b75ecb92
@ -215,6 +215,7 @@ if (isServer) then {
|
||||
[QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(addWeaponItem), {(_this select 0) addWeaponItem [(_this select 1), (_this select 2)]}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(addMagazineTurret), {(_this select 0) addMagazineTurret (_this select 1)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(removeMagazinesTurret), {(_this select 0) removeMagazinesTurret [_this select 1, _this select 2]}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(triggerAmmo), {triggerAmmo _this}] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
@ -33,11 +33,18 @@ if (_configEnabled && {GVAR(ammoHandling) == 2}) then {
|
||||
_vehicle addEventHandler ["GetIn", LINKFUNC(ai_handleGetIn)]; // handle AI getting inside weapon with no ammo
|
||||
};
|
||||
|
||||
TRACE_2("",local _vehicle,_vehicle turretLocal [0]);
|
||||
if (_configEnabled && {_vehicle turretLocal [0]}) then { // if turret is local to us, then handle mags/weapon
|
||||
if (_configEnabled) then {
|
||||
[{
|
||||
params ["_vehicle"];
|
||||
TRACE_2("",local _vehicle,_vehicle turretLocal [0]);
|
||||
|
||||
if (!alive _vehicle) exitWith { TRACE_1("dead/deleted",_vehicle); };
|
||||
|
||||
// If turret is local, handle mags/weapon
|
||||
if !(_vehicle turretLocal [0]) exitWith {
|
||||
TRACE_1("turret not local",_vehicle);
|
||||
};
|
||||
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
private _assemblyModeIndex = _vehicle getVariable [QGVAR(assemblyMode), 3];
|
||||
private _emptyWeapon = _assemblyModeIndex isEqualTo 2;
|
||||
|
@ -21,6 +21,11 @@
|
||||
params ["_vehicle", "_turret", "_needed", "_emptyWeapon"];
|
||||
TRACE_4("proxyWeapon",_vehicle,_turret,_needed,_emptyWeapon);
|
||||
|
||||
// addWeaponTurret/removeWeaponTurret need to be executed where turret is local
|
||||
if !(_vehicle turretLocal _turret) exitWith {
|
||||
TRACE_1("turret not local",_vehicle);
|
||||
};
|
||||
|
||||
if (_vehicle getVariable [format [QGVAR(proxyHandled_%1), _turret], false]) exitWith { TRACE_1("already handled",typeOf _vehicle); };
|
||||
|
||||
private _proxyWeapon = getText (configOf _vehicle >> QUOTE(ADDON) >> "proxyWeapon");
|
||||
|
@ -62,10 +62,12 @@ private _containerMagazineCount = [];
|
||||
|
||||
TRACE_1("Remove all loaded magazines",_magsToRemove);
|
||||
{
|
||||
_vehicle removeMagazinesTurret _x;
|
||||
[QEGVAR(common,removeMagazinesTurret), [_vehicle, _x select 0, _x select 1], _vehicle, _x select 1] call CBA_fnc_turretEvent;
|
||||
|
||||
if ((_loadedMagazineInfo select [0,2]) isEqualTo _x) then {
|
||||
TRACE_1("Re-add the starting mag",_loadedMagazineInfo);
|
||||
_vehicle addMagazineTurret _loadedMagazineInfo;
|
||||
|
||||
[QEGVAR(common,addMagazineTurret), [_vehicle, _loadedMagazineInfo], _vehicle, _x select 1] call CBA_fnc_turretEvent;
|
||||
};
|
||||
} forEach _magsToRemove;
|
||||
|
||||
@ -83,7 +85,7 @@ if (_secondaryWeaponMagazines isNotEqualTo []) then {
|
||||
|
||||
// If the magazine can be added to the static weapon, do it now
|
||||
if (_vehicleMag in _compatibleMagazinesTurret) then {
|
||||
_vehicle addMagazineTurret [_vehicleMag, _turret, _x select 1];
|
||||
[QEGVAR(common,addMagazineTurret), [_vehicle, [_vehicleMag, _turret, _x select 1]], _vehicle, _turret] call CBA_fnc_turretEvent;
|
||||
} else {
|
||||
// Find a suitable container to place items in if necessary
|
||||
if (isNull _container) then {
|
||||
|
Loading…
Reference in New Issue
Block a user