mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
_staticWeapon > _vehicle, StaticWeapon > CSW
This commit is contained in:
parent
c96a9daf7b
commit
c46dc339c5
@ -12,12 +12,12 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
|
||||
TRACE_8("firedEH:",_staticWeapon,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_gunner);
|
||||
params ["_vehicle", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
|
||||
TRACE_8("firedEH:",_vehicle,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile,_gunner);
|
||||
|
||||
if ((!local _gunner) || {[_gunner] call EFUNC(common,isPlayer)}) exitWith {};
|
||||
if (someAmmo _staticWeapon) exitWith {};
|
||||
if (someAmmo _vehicle) exitWith {};
|
||||
|
||||
TRACE_2("need ammo",someAmmo _staticWeapon,magazinesAllTurrets _staticWeapon);
|
||||
TRACE_2("need ammo",someAmmo _vehicle,magazinesAllTurrets _vehicle);
|
||||
|
||||
[_staticWeapon, _gunner, _weapon] call FUNC(ai_reload);
|
||||
[_vehicle, _gunner, _weapon] call FUNC(ai_reload);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Grim
|
||||
* Author: LinkIsGrim
|
||||
* Handles AI GetIn on an empty weapon
|
||||
*
|
||||
* Arguments:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror, modified by Grim
|
||||
* Author: PabstMirror, LinkIsGrim
|
||||
* Handles AI reloading
|
||||
*
|
||||
* Arguments:
|
||||
|
@ -4,7 +4,7 @@
|
||||
* If the CSW is mounted or in use this will not allow you to dismount the weapon
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Dismount <BOOL>
|
||||
@ -15,12 +15,11 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon"];
|
||||
params ["_vehicle"];
|
||||
|
||||
// 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???
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]);
|
||||
private _notCrewed = (crew _vehicle) isEqualTo [];
|
||||
private _deadCrew = !(alive (gunner _vehicle)); // need to eject body???
|
||||
|
||||
_assemblyMode && {_notCrewed || _deadCrew}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Dismounts the weapon from the tripod and drops its backpack beside
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -16,26 +16,26 @@
|
||||
*/
|
||||
|
||||
[{
|
||||
params ["_staticWeapon", "_player"];
|
||||
TRACE_2("assemble_pickupWeapon",_staticWeapon,_player);
|
||||
params ["_vehicle", "_player"];
|
||||
TRACE_2("assemble_pickupWeapon",_vehicle,_player);
|
||||
|
||||
private _onDisassembleFunc = getText(configOf _staticWeapon >> QUOTE(ADDON) >> "disassembleFunc");
|
||||
private _carryWeaponClassname = getText(configOf _staticWeapon >> QUOTE(ADDON) >> "disassembleWeapon");
|
||||
private _turretClassname = getText(configOf _staticWeapon >> QUOTE(ADDON) >> "disassembleTurret");
|
||||
private _onDisassembleFunc = getText(configOf _vehicle >> QUOTE(ADDON) >> "disassembleFunc");
|
||||
private _carryWeaponClassname = getText(configOf _vehicle >> QUOTE(ADDON) >> "disassembleWeapon");
|
||||
private _turretClassname = getText(configOf _vehicle >> QUOTE(ADDON) >> "disassembleTurret");
|
||||
private _pickupTime = getNumber(configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "pickupTime");
|
||||
TRACE_4("",typeOf _staticWeapon,_carryWeaponClassname,_turretClassname,_pickupTime);
|
||||
TRACE_4("",typeOf _vehicle,_carryWeaponClassname,_turretClassname,_pickupTime);
|
||||
if (!isClass (configFile >> "CfgWeapons" >> _carryWeaponClassname)) exitWith {ERROR_1("bad weapon classname [%1]",_carryWeaponClassname);};
|
||||
// Turret classname can equal nothing if the deploy bag is the "whole" weapon. e.g Kornet, Metis, other ATGMs
|
||||
if ((_turretClassname isNotEqualTo "") && {!isClass (configFile >> "CfgVehicles" >> _turretClassname)}) exitWith {ERROR_1("bad turret classname [%1]",_turretClassname);};
|
||||
|
||||
private _onFinish = {
|
||||
params ["_args"];
|
||||
_args params ["_staticWeapon", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"];
|
||||
TRACE_4("disassemble finish",_staticWeapon,_player,_carryWeaponClassname,_turretClassname);
|
||||
_args params ["_vehicle", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"];
|
||||
TRACE_4("disassemble finish",_vehicle,_player,_carryWeaponClassname,_turretClassname);
|
||||
|
||||
private _weaponPos = getPosATL _staticWeapon;
|
||||
private _weaponPos = getPosATL _vehicle;
|
||||
_weaponPos set [2, (_weaponPos select 2) + 0.1];
|
||||
private _weaponDir = getDir _staticWeapon;
|
||||
private _weaponDir = getDir _vehicle;
|
||||
|
||||
private _carryWeaponMag = "";
|
||||
private _carryWeaponMags = getArray (configFile >> "CfgWeapons" >> _carryWeaponClassname >> "magazines") apply {toLower _x};
|
||||
@ -54,7 +54,7 @@
|
||||
TRACE_2("Removing ammo",_xMag,_carryMag);
|
||||
[_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo);
|
||||
};
|
||||
} forEach (magazinesAllTurrets _staticWeapon);
|
||||
} forEach (magazinesAllTurrets _vehicle);
|
||||
|
||||
if (_turretClassname isNotEqualTo "") then {
|
||||
private _cswTripod = createVehicle [_turretClassname, [0, 0, 0], [], 0, "NONE"];
|
||||
@ -66,7 +66,7 @@
|
||||
_cswTripod setVelocity [0, 0, -0.05];
|
||||
_cswTripod setVectorUp (surfaceNormal _weaponPos);
|
||||
}, [_cswTripod, _weaponDir, _weaponPos]] call CBA_fnc_execNextFrame;
|
||||
[_cswTripod, _staticWeapon] call (missionNamespace getVariable _onDisassembleFunc);
|
||||
[_cswTripod, _vehicle] call (missionNamespace getVariable _onDisassembleFunc);
|
||||
};
|
||||
|
||||
[{
|
||||
@ -89,16 +89,16 @@
|
||||
}, [_player, _weaponPos, _carryWeaponClassname, _carryWeaponMag]] call CBA_fnc_execNextFrame;
|
||||
|
||||
LOG("delete weapon");
|
||||
deleteVehicle _staticWeapon;
|
||||
deleteVehicle _vehicle;
|
||||
|
||||
LOG("end");
|
||||
};
|
||||
|
||||
private _condition = {
|
||||
params ["_args"];
|
||||
_args params ["_staticWeapon"];
|
||||
((crew _staticWeapon) isEqualTo []) && (alive _staticWeapon)
|
||||
_args params ["_vehicle"];
|
||||
((crew _vehicle) isEqualTo []) && (alive _vehicle)
|
||||
};
|
||||
|
||||
[TIME_PROGRESSBAR(_pickupTime), [_staticWeapon, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, localize LSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
|
||||
[TIME_PROGRESSBAR(_pickupTime), [_vehicle, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, localize LSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
|
||||
}, _this] call CBA_fnc_execNextFrame;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author:Dani (TCVM)
|
||||
* Checks if the player can get in the weapon
|
||||
* Checks if the player can get in the CSW
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -20,9 +20,9 @@ if ((missionNamespace getVariable [QEGVAR(quickmount,enabled), false]) && {(miss
|
||||
false
|
||||
};
|
||||
|
||||
params ["_staticWeapon"];
|
||||
params ["_vehicle"];
|
||||
|
||||
alive _staticWeapon
|
||||
&& {!(alive (gunner _staticWeapon))}
|
||||
&& {(locked _staticWeapon) < 2}
|
||||
&& {0.3 < ((vectorUp _staticWeapon) select 2)}
|
||||
alive _vehicle
|
||||
&& {!(alive (gunner _vehicle))}
|
||||
&& {(locked _vehicle) < 2}
|
||||
&& {0.3 < ((vectorUp _vehicle) select 2)}
|
||||
|
@ -18,6 +18,13 @@
|
||||
*/
|
||||
params [["_csw", objNull, [objNull]]];
|
||||
|
||||
if !(typeOf _csw in GVAR(initializedStaticTypes)) exitWith {createHashMap};
|
||||
|
||||
// fast exit for csw with single weapon, most common scenario
|
||||
if (count allTurrets _csw isEqualTo 1 && {count weapons _csw isEqualTo 1}) exitWith {
|
||||
GVAR(compatibleMagsCache) get ((weapons _csw) select 0) // return
|
||||
};
|
||||
|
||||
private _weapons = [];
|
||||
|
||||
{
|
||||
@ -32,7 +39,7 @@ if (_weapons isEqualTo []) exitWith {[]};
|
||||
private _carryMagazines = createHashMap; // hashmap for constant lookup
|
||||
{
|
||||
private _weapon = _x;
|
||||
if !(_weapon in GVAR(compatibleVehicleMagsCache)) then {continue};
|
||||
if !(_weapon in GVAR(compatibleMagsCache)) then {continue};
|
||||
_carryMagazines merge [GVAR(compatibleMagsCache) get _weapon, true];
|
||||
} forEach _weapons;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: LinkIsGrim
|
||||
* Gets available ammo sources for loading a static weapon
|
||||
* Gets available ammo sources for loading a CSW
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit attempting to load <OBJECT>
|
||||
|
@ -21,6 +21,8 @@ params [["_source", objNull, [objNull]], ["_csw", objNull, [objNull]]];
|
||||
|
||||
if (isNull _source || {isNull _csw}) exitWith {[]};
|
||||
|
||||
if !(typeOf _csw in GVAR(initializedStaticTypes)) exitWith {[]};
|
||||
|
||||
private _magazines = magazinesAmmoCargo _source;
|
||||
|
||||
if (_magazines isEqualTo []) exitWith {[]};
|
||||
|
@ -18,21 +18,21 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon", "_turret", "_needed", "_emptyWeapon"];
|
||||
TRACE_4("proxyWeapon",_staticWeapon,_turret,_needed,_emptyWeapon);
|
||||
params ["_vehicle", "_turret", "_needed", "_emptyWeapon"];
|
||||
TRACE_4("proxyWeapon",_vehicle,_turret,_needed,_emptyWeapon);
|
||||
|
||||
if (_staticWeapon getVariable [format [QGVAR(proxyHandled_%1), _turret], false]) exitWith { TRACE_1("already handled",typeOf _staticWeapon); };
|
||||
if (_vehicle getVariable [format [QGVAR(proxyHandled_%1), _turret], false]) exitWith { TRACE_1("already handled",typeOf _vehicle); };
|
||||
|
||||
private _proxyWeapon = getText (configOf _staticWeapon >> "ace_csw" >> "proxyWeapon");
|
||||
private _proxyWeapon = getText (configOf _vehicle >> "ace_csw" >> "proxyWeapon");
|
||||
|
||||
TRACE_2("",typeOf _staticWeapon,_proxyWeapon);
|
||||
TRACE_2("",typeOf _vehicle,_proxyWeapon);
|
||||
if (_proxyWeapon == "") exitWith {};
|
||||
|
||||
private _currentWeapon = (_staticWeapon weaponsTurret [0]) param [0, "#none"];
|
||||
private _currentWeapon = (_vehicle weaponsTurret [0]) param [0, "#none"];
|
||||
if ((missionNamespace getVariable [_proxyWeapon, objNull]) isEqualType {}) then { // check if string is a function
|
||||
TRACE_1("Calling proxyWeapon function",_proxyWeapon);
|
||||
// This function may replace magazines or do other things to the static weapon
|
||||
_proxyWeapon = [_staticWeapon, _turret, _currentWeapon, _needed, _emptyWeapon] call (missionNamespace getVariable _proxyWeapon);
|
||||
_proxyWeapon = [_vehicle, _turret, _currentWeapon, _needed, _emptyWeapon] call (missionNamespace getVariable _proxyWeapon);
|
||||
_needed = _proxyWeapon != "";
|
||||
};
|
||||
if (!_needed) exitWith { TRACE_2("not needed",_needed,_proxyWeapon); };
|
||||
@ -41,12 +41,10 @@ if (!_needed) exitWith { TRACE_2("not needed",_needed,_proxyWeapon); };
|
||||
if !(_proxyWeapon in GVAR(compatibleVehicleMagsCache)) then {
|
||||
private _compatibleMagazines = compatibleMagazines _proxyWeapon;
|
||||
GVAR(compatibleVehicleMagsCache) set [_proxyWeapon, _compatibleMagazines];
|
||||
GVAR(compatibleCarryMagsCache) set [_proxyWeapon,
|
||||
_compatibleMagazines apply {_x call FUNC(getCarryMagazine)} createHashMapFromArray []
|
||||
];
|
||||
GVAR(compatibleCarryMagsCache) set [_proxyWeapon, (_compatibleMagazines apply {_x call FUNC(getCarryMagazine)}) createHashMapFromArray []];
|
||||
};
|
||||
|
||||
TRACE_2("swapping to proxy weapon",_currentWeapon,_proxyWeapon);
|
||||
_staticWeapon removeWeaponTurret [_currentWeapon, _turret];
|
||||
_staticWeapon addWeaponTurret [_proxyWeapon, _turret];
|
||||
_staticWeapon setVariable [format [QGVAR(proxyHandled_%1), _turret], true, true];
|
||||
_vehicle removeWeaponTurret [_currentWeapon, _turret];
|
||||
_vehicle addWeaponTurret [_proxyWeapon, _turret];
|
||||
_vehicle setVariable [format [QGVAR(proxyHandled_%1), _turret], true, true];
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Gets sub actions for what the player can load into the static weapon
|
||||
* Gets sub actions for what the player can load into the CSW
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: Target <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Gets sub actions for what the player can unload from the static weapon
|
||||
* Gets sub actions for what the player can unload from the CSW
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target <OBJECT>
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror &Dani (TCVM)
|
||||
* Tests if unit can load a magazine into a static weapon.
|
||||
* Tests if unit can load a magazine into a CSW.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Turret Path <ARRAY>
|
||||
* 2: Carryable Magazine <STRING>
|
||||
* 3: Supplier <OBJECT> (default: objNull)
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Tests if unit can unload a magazine from a static weapon.
|
||||
* Tests if unit can unload a magazine from a CSW.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Turret Path <ARRAY>
|
||||
* 2: Player <OBJECT>
|
||||
* 3: Carryable Magazine <STRING>
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror, LinkIsGrim
|
||||
* Gets nearby magazines that can be loaded in the static weapon
|
||||
* Gets nearby magazines that can be loaded into the CSW
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Unit <OBJECT>
|
||||
* 2: AI reloading, skip turret checks <BOOL> (default: false)
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Called from a global event but only runs where turret is local
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Turret Path <ARRAY>
|
||||
* 2: Source of magazine <OBJECT>
|
||||
* 3: Vehicle Magazine <STRING>
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Called from a global event but only runs where turret is local
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Static Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Turret Path <ARRAY>
|
||||
* 2: Magainze Unit Can Carry <STRING>
|
||||
* 3: Magazine To Remove From Static <STRING>
|
||||
|
@ -30,7 +30,7 @@ private _onFinish = {
|
||||
(_this select 0) params ["_vehicle", "_turret", "_carryMag", "_magSource", "_unit", "_ammo"];
|
||||
TRACE_6("load progressBar finish",_vehicle,_turret,_carryMag,_magSource,_unit,_ammo);
|
||||
|
||||
([_vehicle, _turret, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) params ["", "", "_neededAmmo", ""];
|
||||
([_vehicle, _turret, _carryMag] call FUNC(reload_canLoadMagazine)) params ["", "", "_neededAmmo", ""];
|
||||
if (_neededAmmo <= 0) exitWith { ERROR_1("Can't load ammo - %1",_this); };
|
||||
|
||||
[_magSource, _carryMag, _ammo] call EFUNC(common,removeSpecificMagazine);
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Dani (TCVM)
|
||||
* Initializes weapon to disable weapon disassembling
|
||||
* Initializes CSW to disable weapon disassembling
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
@ -15,44 +15,44 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon"];
|
||||
private _typeOf = typeOf _staticWeapon;
|
||||
private _configOf = configOf _staticWeapon;
|
||||
params ["_vehicle"];
|
||||
private _typeOf = typeOf _vehicle;
|
||||
private _configOf = configOf _vehicle;
|
||||
private _configEnabled = (getNumber (_configOf >> "ace_csw" >> "enabled")) == 1;
|
||||
private _assemblyConfig = _configEnabled && {(getText (_configOf >> "ace_csw" >> "disassembleWeapon")) != ""};
|
||||
TRACE_4("staticWeaponInit",_staticWeapon,_typeOf,_configEnabled,_assemblyConfig);
|
||||
TRACE_4("staticWeaponInit",_vehicle,_typeOf,_configEnabled,_assemblyConfig);
|
||||
|
||||
if (_configEnabled && {GVAR(ammoHandling) == 2}) then {
|
||||
TRACE_1("adding AI fired handler",_staticWeapon);
|
||||
_staticWeapon addEventHandler ["Fired", LINKFUNC(ai_handleFired)];
|
||||
_staticWeapon addEventHandler ["GetIn", LINKFUNC(ai_handleGetIn)]; // handle AI getting inside weapon with no ammo
|
||||
TRACE_1("adding AI fired handler",_vehicle);
|
||||
_vehicle addEventHandler ["Fired", LINKFUNC(ai_handleFired)];
|
||||
_vehicle addEventHandler ["GetIn", LINKFUNC(ai_handleGetIn)]; // handle AI getting inside weapon with no ammo
|
||||
};
|
||||
|
||||
TRACE_2("",local _staticWeapon,_staticWeapon turretLocal [0]);
|
||||
if (_configEnabled && {_staticWeapon turretLocal [0]}) then { // if turret is local to us, then handle mags/weapon
|
||||
TRACE_2("",local _vehicle,_vehicle turretLocal [0]);
|
||||
if (_configEnabled && {_vehicle turretLocal [0]}) then { // if turret is local to us, then handle mags/weapon
|
||||
[{
|
||||
params ["_staticWeapon"];
|
||||
if (!alive _staticWeapon) exitWith { TRACE_1("dead/deleted",_staticWeapon); };
|
||||
params ["_vehicle"];
|
||||
if (!alive _vehicle) exitWith { TRACE_1("dead/deleted",_vehicle); };
|
||||
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default]
|
||||
private _assemblyModeIndex = _staticWeapon getVariable [QGVAR(assemblyMode), 3];
|
||||
private _assemblyModeIndex = _vehicle getVariable [QGVAR(assemblyMode), 3];
|
||||
private _emptyWeapon = _assemblyModeIndex isEqualTo 2;
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select _assemblyModeIndex;
|
||||
TRACE_2("turretLocal",_staticWeapon,_assemblyMode);
|
||||
[_staticWeapon, [0], _assemblyMode, _emptyWeapon] call FUNC(proxyWeapon);
|
||||
[_staticWeapon, _assemblyMode, _emptyWeapon] call FUNC(staticWeaponInit_unloadExtraMags);
|
||||
}, [_staticWeapon]] call CBA_fnc_execNextFrame; // need to wait a frame to allow setting object vars during assembly
|
||||
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
|
||||
};
|
||||
|
||||
if (_assemblyConfig) then {
|
||||
[{
|
||||
params ["_staticWeapon"];
|
||||
if (!alive _staticWeapon) exitWith { TRACE_1("dead/deleted",_staticWeapon); };
|
||||
private _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select (_staticWeapon getVariable [QGVAR(assemblyMode), 3]);
|
||||
TRACE_2("assemblyConfig present",_staticWeapon,_assemblyMode);
|
||||
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 eanbled
|
||||
[QGVAR(disableVanillaAssembly), [_staticWeapon]] call CBA_fnc_localEvent;
|
||||
[QGVAR(disableVanillaAssembly), [_vehicle]] call CBA_fnc_localEvent;
|
||||
};
|
||||
}, [_staticWeapon]] call CBA_fnc_execNextFrame; // need to wait a frame to allow setting object vars during assembly
|
||||
}, [_vehicle]] call CBA_fnc_execNextFrame; // need to wait a frame to allow setting object vars during assembly
|
||||
};
|
||||
|
||||
// Add interactions for players
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Dumps ammo to container
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Weapon <OBJECT>
|
||||
* 0: CSW <OBJECT>
|
||||
* 1: Using advanced assembly <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
@ -16,11 +16,11 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_staticWeapon", "_assemblyMode", "_emptyWeapon"];
|
||||
TRACE_3("staticWeaponInit_unloadExtraMags",_staticWeapon,_assemblyMode,_emptyWeapon);
|
||||
params ["_vehicle", "_assemblyMode", "_emptyWeapon"];
|
||||
TRACE_3("staticWeaponInit_unloadExtraMags",_vehicle,_assemblyMode,_emptyWeapon);
|
||||
if (!_assemblyMode) exitWith {};
|
||||
|
||||
private _desiredAmmo = getNumber (configOf _staticWeapon >> QUOTE(ADDON) >> "desiredAmmo");
|
||||
private _desiredAmmo = getNumber (configOf _vehicle >> QUOTE(ADDON) >> "desiredAmmo");
|
||||
private _storeExtraMagazines = GVAR(handleExtraMagazines);
|
||||
if (_emptyWeapon) then {
|
||||
_desiredAmmo = 0;
|
||||
@ -56,31 +56,31 @@ private _containerMagazineCount = [];
|
||||
} else {
|
||||
if ((_xMag select [0,4]) != "fake") then { WARNING_1("Unable to unload [%1] - No matching carry mag",_xMag); };
|
||||
};
|
||||
} forEach (magazinesAllTurrets _staticWeapon);
|
||||
} forEach (magazinesAllTurrets _vehicle);
|
||||
|
||||
|
||||
TRACE_1("Remove all loaded magazines",_magsToRemove);
|
||||
{
|
||||
_staticWeapon removeMagazinesTurret _x;
|
||||
_vehicle removeMagazinesTurret _x;
|
||||
if ((_loadedMagazineInfo select [0,2]) isEqualTo _x) then {
|
||||
TRACE_1("Re-add the starting mag",_loadedMagazineInfo);
|
||||
_staticWeapon addMagazineTurret _loadedMagazineInfo;
|
||||
_vehicle addMagazineTurret _loadedMagazineInfo;
|
||||
};
|
||||
} forEach _magsToRemove;
|
||||
|
||||
if (_staticWeapon getVariable [QGVAR(secondaryWeaponMagazine), ""] isNotEqualTo "") then {
|
||||
private _secondaryWeaponMagazine = _staticWeapon getVariable QGVAR(secondaryWeaponMagazine);
|
||||
private _turret = allTurrets _staticWeapon param [0, []];
|
||||
private _vehicleMag = [_staticWeapon, _turret, _secondaryWeaponMagazine] call FUNC(reload_getVehicleMagazine);
|
||||
if (_vehicle getVariable [QGVAR(secondaryWeaponMagazine), ""] isNotEqualTo "") then {
|
||||
private _secondaryWeaponMagazine = _vehicle getVariable QGVAR(secondaryWeaponMagazine);
|
||||
private _turret = allTurrets _vehicle param [0, []];
|
||||
private _vehicleMag = [_vehicle, _turret, _secondaryWeaponMagazine] call FUNC(reload_getVehicleMagazine);
|
||||
TRACE_3("Re-add previous mag",_secondaryWeaponMagazine,_turret,_vehicleMag);
|
||||
if (!isClass (configFile >> "CfgMagazines" >> _vehicleMag)) exitWith {};
|
||||
_staticWeapon addMagazineTurret [_vehicleMag, _turret, 1];
|
||||
_staticWeapon setVariable [QGVAR(secondaryWeaponMagazine), nil];
|
||||
_vehicle addMagazineTurret [_vehicleMag, _turret, 1];
|
||||
_vehicle setVariable [QGVAR(secondaryWeaponMagazine), nil];
|
||||
};
|
||||
|
||||
if (_storeExtraMagazines) then {
|
||||
TRACE_1("saving extra mags to container",_containerMagazineCount);
|
||||
{
|
||||
[_staticWeapon, _x, _containerMagazineCount select _forEachIndex] call FUNC(reload_handleReturnAmmo);
|
||||
[_vehicle, _x, _containerMagazineCount select _forEachIndex] call FUNC(reload_handleReturnAmmo);
|
||||
} forEach _containerMagazineClassnames;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user