CSW - Code cleanup (#9777)

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
Grim 2024-02-07 20:36:13 -03:00 committed by GitHub
parent 802560da8a
commit ee79decb45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 229 additions and 251 deletions

View File

@ -4,7 +4,7 @@ class CfgVehicles {
class ACE_SelfActions {
class GVAR(deploy) {
displayName = CSTRING(PlaceTripod_displayName);
condition = QUOTE(call FUNC(assemble_canDeployTripod));
condition = QUOTE(call FUNC(canDeployTripod));
statement = QUOTE(call FUNC(assemble_deployTripod));
exceptions[] = {};
};
@ -36,7 +36,7 @@ class CfgVehicles {
condition = "true";
class GVAR(pickUp) {
displayName = CSTRING(Pickup_displayName);
condition = QUOTE(call FUNC(assemble_canPickupTripod));
condition = QUOTE(call FUNC(canPickupTripod));
statement = QUOTE(call FUNC(assemble_pickupTripod));
};
class GVAR(mountWeapon) {
@ -125,10 +125,11 @@ class CfgVehicles {
class StaticWeapon: LandVehicle {
class ACE_Actions {
class ACE_MainActions {
// Workaround for static weapons' Get In memory point being at the front of the gun
class GVAR(getIn) {
displayName = CSTRING(GetIn_displayName);
condition = QUOTE(call FUNC(canGetIn));
statement = QUOTE(call FUNC(getIn));
statement = QUOTE(_player moveInTurret [ARR_2(_target,[0])]);
};
};
};

View File

@ -6,9 +6,9 @@ PREP(ai_handleFired);
PREP(ai_handleGetIn);
PREP(ai_reload);
PREP(assemble_canDeployTripod);
PREP(canDeployTripod);
PREP(assemble_canDeployWeapon);
PREP(assemble_canPickupTripod);
PREP(canPickupTripod);
PREP(assemble_canPickupWeapon);
PREP(assemble_deployTripod);
PREP(assemble_deployWeapon);
@ -17,13 +17,12 @@ PREP(assemble_pickupTripod);
PREP(assemble_pickupWeapon);
PREP(canGetIn);
PREP(getIn);
PREP(getCarryMagazine);
PREP(proxyWeapon);
PREP(reload_actionsLoad);
PREP(reload_actionsUnload);
PREP(getLoadActions);
PREP(getUnloadActions);
PREP(reload_canLoadMagazine);
PREP(reload_canUnloadMagazine);
PREP(reload_getLoadableMagazines);
@ -33,5 +32,5 @@ PREP(reload_handleRemoveTurretMag);
PREP(reload_handleReturnAmmo);
PREP(reload_loadMagazine);
PREP(staticWeaponInit);
PREP(initVehicle);
PREP(staticWeaponInit_unloadExtraMags);

View File

@ -6,18 +6,27 @@ GVAR(vehicleMagCache) = createHashMap;
TRACE_3("settingsInit",GVAR(defaultAssemblyMode),GVAR(handleExtraMagazines),GVAR(ammoHandling));
["StaticWeapon", "Init", {
// needs a small delay for network syncing, or we end up with duplicate mags with ammo handling
[LINKFUNC(staticWeaponInit), _this, 1] call CBA_fnc_waitAndExecute;
[LINKFUNC(initVehicle), _this, 1] call CBA_fnc_waitAndExecute;
}, true, [], true] call CBA_fnc_addClassEventHandler;
GVAR(quickmountEnabled) = (
missionNamespace getVariable [QEGVAR(quickmount,enabled), false] &&
{(missionNamespace getVariable [QEGVAR(quickmount,enableMenu), -1]) in [1,3]}
);
}] call CBA_fnc_addEventHandler;
["CBA_SettingChanged", {
GVAR(quickmountEnabled) = (
missionNamespace getVariable [QEGVAR(quickmount,enabled), false] &&
{(missionNamespace getVariable [QEGVAR(quickmount,enableMenu), -1]) in [1,3]}
);
}] call CBA_fnc_addEventHandler;
// Event handlers:
[QGVAR(addTurretMag), LINKFUNC(reload_handleAddTurretMag)] call CBA_fnc_addEventHandler;
[QGVAR(removeTurretMag), LINKFUNC(reload_handleRemoveTurretMag)] call CBA_fnc_addEventHandler;
[QGVAR(returnAmmo), LINKFUNC(reload_handleReturnAmmo)] call CBA_fnc_addEventHandler;
#ifdef DEBUG_MODE_FULL
call compile preprocessFileLineNumbers QPATHTOF(dev\checkStaticWeapons.sqf);
#endif

View File

@ -7,14 +7,14 @@ INFO("Checking static weapons");
private _staticWeaponConfigs = configProperties [configFile >> "CfgVehicles", "(isClass _x) && {(configName _x) isKindOf 'StaticWeapon'}", true];
private _staticPublic = _staticWeaponConfigs select {(getNumber (_x >> "scope")) == 2};
INFO_2("Static Weapons [%1] - CSW Enabled [%2]",count _staticPublic,{(getNumber (_x >> "ace_csw" >> "enabled")) == 1} count _staticPublic);
INFO_2("Static Weapons [%1] - CSW Enabled [%2]",count _staticPublic,{(getNumber (_x >> QUOTE(ADDON) >> "enabled")) == 1} count _staticPublic);
INFO("------ Checking static weapons inheritance ------");
private _explicitBases = [];
private _inherited = [];
{
private _config = _x;
private _configEnabled = (getNumber (_config >> "ace_csw" >> "enabled")) == 1;
private _configEnabled = (getNumber (_config >> QUOTE(ADDON) >> "enabled")) == 1;
if (_configEnabled) then {
private _configExplicit = (count configProperties [_config, "configName _x == 'ace_csw'", false]) == 1;
if (_configExplicit) then {
@ -69,7 +69,7 @@ private _logAll = false;
{
//IGNORE_PRIVATE_WARNING ["_x", "_y"];
INFO_2("[%1] has no carry varient - Used in %2",_x,_y);
INFO_2("[%1] has no carry variant - Used in %2",_x,_y);
} forEach _hash;
INFO("------ End -------");

View File

@ -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", "", "", "", "_magazine", "", "_gunner"];
TRACE_4("firedEH:",_vehicle,_weapon,_magazine,_gunner);
if (someAmmo _vehicle) exitWith {};
if ((!local _gunner) || {[_gunner] call EFUNC(common,isPlayer)}) exitWith {};
if (someAmmo _staticWeapon) exitWith {};
TRACE_2("need ammo",someAmmo _staticWeapon,magazinesAllTurrets _staticWeapon);
TRACE_1("need ammo",magazinesAllTurrets _vehicle);
[_staticWeapon, _gunner, _weapon, _magazine] call FUNC(ai_reload);
[_vehicle, _gunner, _weapon, _magazine] call FUNC(ai_reload);

View File

@ -11,12 +11,13 @@
*
* Public: No
*/
params ["_staticWeapon", "_role", "_gunner"];
TRACE_3("getInEH:",_staticWeapon,_role,_gunner);
params ["_vehicle", "", "_gunner"];
TRACE_2("getInEH:",_vehicle,_gunner);
if (someAmmo _vehicle) exitWith {};
if ((!local _gunner) || {[_gunner] call EFUNC(common,isPlayer)}) exitWith {};
if (someAmmo _staticWeapon) exitWith {};
TRACE_2("need ammo",someAmmo _staticWeapon,magazinesAllTurrets _staticWeapon);
TRACE_1("need ammo",magazinesAllTurrets _vehicle);
[_staticWeapon, _gunner, currentWeapon _staticWeapon] call FUNC(ai_reload);
[_vehicle, _gunner, currentWeapon _vehicle] call FUNC(ai_reload);

View File

@ -14,6 +14,7 @@
*
* Public: No
*/
params ["_staticWeapon", "_gunner", "_weapon", ["_magazine", ""]];
private _turretPath = [_gunner] call EFUNC(common,getTurretIndex);

View File

@ -1,21 +0,0 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Checks if the player can deploy the tripod.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Can deploy <BOOL>
*
* Example:
* [player] call ace_csw_fnc_assemble_canDeployTripod
*
* Public: No
*/
params ["_player"];
(getText(configFile >> "CfgWeapons" >> (secondaryWeapon _player) >> QUOTE(ADDON) >> "type") == "mount")

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Checks if you can deploy a weapon on the tripod
*
* Arguments:
@ -22,4 +22,3 @@ if (isNil "_carryWeaponClassname") then { _carryWeaponClassname = secondaryWeapo
// If the current launcher has a config-value that defines the tripod, it is a CSW
(alive _target) &&
{(getText(configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "assembleTo" >> (typeOf _target))) != ""}

View File

@ -1,22 +0,0 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Checks if the player can pick-up the tripod.
*
* Arguments:
* 0: Tripod <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can pickup <BOOL>
*
* Example:
* [tripod, player] call ace_csw_fnc_assemble_canPickupTripod
*
* Public: No
*/
params ["_tripod", "_player"];
((secondaryWeapon _player) isEqualTo "") && {alive _tripod}

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* If the CSW is mounted or in use this will not allow you to dismount the weapon
*
* Arguments:
@ -23,4 +23,3 @@ private _notCrewed = (crew _staticWeapon) isEqualTo [];
private _deadCrew = !(alive (gunner _staticWeapon)); // need to eject body???
_assemblyMode && {_notCrewed || _deadCrew}

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Deploys the tripod
*
* Arguments:
@ -40,7 +40,7 @@
_cswTripod setVariable [QGVAR(secondaryWeaponMagazine), _secondaryWeaponMagazine];
};
if (!GVAR(defaultAssemblyMode)) then {
[_cswTripod, "disableWeaponAssembly", "ace_csw", true] call EFUNC(common,statusEffect_set);
[_cswTripod, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
};
private _posATL = _player getRelPos [2, 0];

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Deploys the current CSW
*
* Arguments:

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Picks up the tripod and adds it to the player launcher slot
*
* Arguments:
@ -44,4 +44,3 @@
TRACE_3("",_pickupTime,typeOf _tripod,_tripodClassname);
[TIME_PROGRESSBAR(_pickupTime), [_tripod, _player, _tripodClassname], _onFinish, {}, localize LSTRING(PickupTripod_progressBar), _condition] call EFUNC(common,progressBar);
}, _this] call CBA_fnc_execNextFrame;

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Dismounts the weapon from the tripod and drops its backpack beside
*
* Arguments:

View File

@ -0,0 +1,22 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Checks if the unit can deploy a tripod
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Can deploy <BOOL>
*
* Example:
* player call ace_csw_fnc_canDeployTripod
*
* Public: No
*/
params ["_unit"];
private _secondaryWeapon = secondaryWeapon _unit;
_secondaryWeapon != "" && {getText (configFile >> "CfgWeapons" >> _secondaryWeapon >> QUOTE(ADDON) >> "type") == "mount"} // return

View File

@ -1,28 +1,23 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Checks if the player can get in the weapon
* Author: tcvm
* Checks if it's possible to get in the CSW
*
* Arguments:
* 0: Static Weapon <OBJECT>
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject] call ace_csw_fnc_canGetIn
* cursorObject call ace_csw_fnc_canGetIn
*
* Public: No
*/
// hide this action if quick mount is enabled
if ((missionNamespace getVariable [QEGVAR(quickmount,enabled), false]) && {(missionNamespace getVariable [QEGVAR(quickmount,enableMenu), -1]) in [1, 3]}) exitWith {
false
};
// Hide this action if quick mount is enabled
if (GVAR(quickmountEnabled)) exitWith {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} && {!(_vehicle lockedTurret [0])} && {0.3 < ((vectorUp _vehicle) select 2)} // return

View File

@ -0,0 +1,21 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Checks if the unit can pickup the tripod
*
* Arguments:
* 0: Tripod <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Can pickup <BOOL>
*
* Example:
* [cursorObject, player] call ace_csw_fnc_canPickupTripod
*
* Public: No
*/
params ["_tripod", "_unit"];
((secondaryWeapon _unit) == "") && {alive _tripod} // return

View File

@ -1,24 +0,0 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* An action for the player to get in the CSW
* Due to the fact that the default static weapons "Get In" memory point is at the front of
* the gun and can't be acssesed from the back, I am implementing this to get around that issue.
*
* Arguments:
* 0: Static Weapon <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject, player] call ace_csw_fnc_getIn
*
* Public: No
*/
params ["_staticWeapon", "_player"];
TRACE_2("getIn",_staticWeapon,_player);
_player moveInTurret [_staticWeapon, [0]];

View File

@ -1,42 +1,42 @@
#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 unit can load into the CSW
*
* Arguments:
* 0: Static Weapon <OBJECT>
* 1: Player <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Unit <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [cursorObject, player] call ace_csw_fnc_reload_actionsLoad
* [cursorObject, player] call ace_csw_fnc_getLoadActions
*
* Public: No
*/
params ["_vehicle", "_player"];
params ["_vehicle", "_unit"];
private _actions = [];
private _loadableMagazines = [_vehicle, _player] call FUNC(reload_getLoadableMagazines);
private _loadableMagazines = [_vehicle, _unit] call FUNC(reload_getLoadableMagazines);
if (_loadableMagazines isEqualTo []) exitWith {[]};
private _statement = {
params ["_target", "_player", "_params"];
_params params ["_carryMag", "_turretPath", "", "_magSource"];
params ["_target", "_player", "_args"];
_args params ["_carryMag", "_turretPath", "", "_magSource"];
[_target, _turretPath, _carryMag, _magSource, _player] call FUNC(reload_loadMagazine);
};
private _condition = {
params ["_target", "_player", "_params"];
_params params ["_carryMag", "_turretPath", "", "_magSource"];
params ["_target", "_player", "_args"];
_args params ["_carryMag", "_turretPath", "", "_magSource"];
([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0
};
private _cfgMagazines = configFile >> "CfgMagazines"; // micro-optimization
private _actions = [];
{
_x params ["_carryMag", "", "_loadInfo"];
_loadInfo params ["", "", "", "_isBeltLinking"];

View File

@ -0,0 +1,74 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Gets sub actions for what can be unloaded from the CSW
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* cursorObject call ace_csw_fnc_getUnloadActions
*
* Public: No
*/
params ["_vehicle"];
private _statement = {
params ["_target", "_player", "_args"];
_args params ["_vehMag", "_turretPath", "_carryMag"];
TRACE_5("starting unload",_target,_turretPath,_player,_carryMag,_vehMag);
private _timeToUnload = 1;
if (!isNull (configOf _target >> QUOTE(ADDON) >> "ammoUnloadTime")) then {
_timeToUnload = getNumber (configOf _target >> QUOTE(ADDON) >> "ammoUnloadTime");
};
[
TIME_PROGRESSBAR(_timeToUnload),
[_target, _turretPath, _player, _carryMag, _vehMag],
{
(_this select 0) params ["_target", "_turretPath", "", "_carryMag", "_vehMag"];
TRACE_5("unload progressBar finish",_target,_turretPath,_carryMag,_vehMag,_player);
[QGVAR(removeTurretMag), [_target, _turretPath, _carryMag, _vehMag, _player]] call CBA_fnc_globalEvent;
},
{TRACE_1("unload progressBar fail",_this);},
format [localize LSTRING(unloadX), getText (configFile >> "CfgMagazines" >> _carryMag >> "displayName")],
{(_this select 0) call FUNC(reload_canUnloadMagazine)},
["isNotInside"]
] call EFUNC(common,progressBar);
};
private _condition = {
params ["_target", "_player", "_args"];
_args params ["_vehMag", "_turretPath", "_carryMag"];
[_target, _turretPath, _player, _carryMag, _vehMag] call FUNC(reload_canUnloadMagazine)
};
private _actions = [];
private _handledMagTypes = [];
private _cfgMagazines = configFile >> "CfgMagazines";
// Go through magazines on static weapon and check if any are unloadable
{
_x params ["_xMag", "_xTurret", "_xAmmo"];
if ((_xAmmo > 0) && {!(_xMag in _handledMagTypes)}) then {
_handledMagTypes pushBack _xMag;
private _carryMag = _xMag call FUNC(getCarryMagazine);
if (_carryMag == "") exitWith {};
private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName");
private _text = format [LLSTRING(unloadX), _displayName];
private _picture = getText (_cfgMagazines >> _carryMag >> "picture");
private _action = [format ["unload_%1", _forEachIndex], _text, _picture, _statement, _condition, {}, [_xMag, _xTurret, _carryMag]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _vehicle];
};
} forEach (magazinesAllTurrets _vehicle);
TRACE_1("unloadActions",count _actions);
_actions

View File

@ -1,62 +1,63 @@
#include "..\script_component.hpp"
/*
* Author: tcvm
* Initializes weapon to disable weapon disassembling
* Initializes CSW systems on vehicle
*
* Arguments:
* 0: Weapon <OBJECT>
* 0: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [weapon] call ace_csw_fnc_staticWeaponInit
* cursorObject call ace_csw_fnc_initVehicle
*
* Public: No
*/
params ["_staticWeapon"];
if (!alive _staticWeapon) exitWith { WARNING_1("%1 not alive",_staticWeapon); };
if (!simulationEnabled _staticWeapon) exitWith {
[{simulationEnabled _this}, FUNC(staticWeaponInit), _staticWeapon] call CBA_fnc_waitUntilAndExecute;
params ["_vehicle"];
if (!alive _vehicle) exitWith { WARNING_1("%1 not alive",_vehicle); };
if (!simulationEnabled _vehicle) exitWith {
[{simulationEnabled _this}, FUNC(initVehicle), _vehicle] call CBA_fnc_waitUntilAndExecute;
};
private _typeOf = typeOf _staticWeapon;
private _configOf = configOf _staticWeapon;
private _configEnabled = (getNumber (_configOf >> "ace_csw" >> "enabled")) == 1;
private _assemblyConfig = _configEnabled && {(getText (_configOf >> "ace_csw" >> "disassembleWeapon")) != ""};
TRACE_4("staticWeaponInit",_staticWeapon,_typeOf,_configEnabled,_assemblyConfig);
private _typeOf = typeOf _vehicle;
private _configOf = configOf _vehicle;
private _configEnabled = (getNumber (_configOf >> QUOTE(ADDON) >> "enabled")) == 1;
private _assemblyConfig = _configEnabled && {(getText (_configOf >> QUOTE(ADDON) >> "disassembleWeapon")) != ""};
TRACE_4("initVehicle",_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 enabled
[_staticWeapon, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
[_vehicle, "disableWeaponAssembly", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
};
}, [_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
@ -79,7 +80,7 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
};
private _childenCode = {
BEGIN_COUNTER(getActions); // can remove for final release
private _ret = (call FUNC(reload_actionsLoad)) + (call FUNC(reload_actionsUnload));
private _ret = (call FUNC(getLoadActions)) + (call FUNC(getUnloadActions));
END_COUNTER(getActions);
_ret
};

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp"
/*
* Author: tcvm, PabstMirror
* Handles the use of proxy weapons to fix engine-reload times
* Handles the use of proxy weapons to bypass engine reload times
*
* Arguments:
* 0: Weapon <OBJECT>
* 0: Vehicle <OBJECT>
* 1: Turret <ARRAY>
* 2: Proxy weapon needed <BOOL>
* 2: Weapon should be emptied <BOOL>
@ -13,34 +13,34 @@
* None
*
* Example:
* [weapon, [0], true, false] call ace_csw_fnc_proxyWeapon
* [cursorObject, [0], true, false] call ace_csw_fnc_proxyWeapon
*
* 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 >> QUOTE(ADDON) >> "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); };
// Rearm compatibility, prevent reloading entire static and breaking CSW
_staticWeapon setVariable [QEGVAR(rearm,scriptedLoadout), true, true];
_vehicle setVariable [QEGVAR(rearm,scriptedLoadout), true, true];
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];

View File

@ -1,75 +0,0 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Gets sub actions for what the player can unload from the static weapon
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [cursorObject, player] call ace_csw_fnc_reload_actionsUnload
*
* Public: No
*/
params ["_vehicle", "_player"];
private _statement = {
params ["_target", "_player", "_params"];
_params params ["_vehMag", "_turretPath", "_carryMag"];
TRACE_5("starting unload",_target,_turretPath,_player,_carryMag,_vehMag);
private _timeToUnload = 1;
if (!isNull(configOf _target >> QUOTE(ADDON) >> "ammoUnloadTime")) then {
_timeToUnload = getNumber(configOf _target >> QUOTE(ADDON) >> "ammoUnloadTime");
};
[
TIME_PROGRESSBAR(_timeToUnload),
[_target, _turretPath, _player, _carryMag, _vehMag],
{
(_this select 0) params ["_target", "_turretPath", "", "_carryMag", "_vehMag"];
TRACE_5("unload progressBar finish",_target,_turretPath,_carryMag,_vehMag,_player);
[QGVAR(removeTurretMag), [_target, _turretPath, _carryMag, _vehMag, _player]] call CBA_fnc_globalEvent;
},
{TRACE_1("unload progressBar fail",_this);},
format [localize LSTRING(unloadX), getText (configFile >> "CfgMagazines" >> _carryMag >> "displayName")],
{(_this select 0) call FUNC(reload_canUnloadMagazine)},
["isNotInside"]
] call EFUNC(common,progressBar);
};
private _condition = {
params ["_target", "_player", "_params"];
_params params ["_vehMag", "_turretPath", "_carryMag"];
[_target, _turretPath, _player, _carryMag, _vehMag] call FUNC(reload_canUnloadMagazine)
};
private _actions = [];
private _handeledMagTypes = [];
private _cfgMagazines = configFile >> "CfgMagazines";
// Go through magazines on static weapon and check if any are unloadable
{
_x params ["_xMag", "_xTurret", "_xAmmo"];
if ((_xAmmo > 0) && {!(_xMag in _handeledMagTypes)}) then {
_handeledMagTypes pushBack _xMag;
private _carryMag = _xMag call FUNC(getCarryMagazine);
if (_carryMag == "") exitWith {};
private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName");
private _text = format [LLSTRING(unloadX), _displayName];
private _picture = getText (_cfgMagazines >> _carryMag >> "picture");
private _action = [format ["unload_%1", _forEachIndex], _text, _picture, _statement, _condition, {}, [_xMag, _xTurret, _carryMag]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _vehicle];
};
} forEach (magazinesAllTurrets _vehicle);
TRACE_1("unloadActions",count _actions);
_actions

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm, PabstMirror
* Author: tcvm, PabstMirror
* Handles adding ammo to a turret
* Called from a global event but only runs where turret is local
*

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author:tcvm
* Author: tcvm
* Handles removing ammo from a turret
* Called from a global event but only runs where turret is local
*

View File

@ -21,5 +21,4 @@ params ["_target", "_unit"];
&& {!alive (gunner _target)}
&& {!(_target getVariable [QGVAR(fired), false])}
&& {!(_target getVariable [QGVAR(sightAttached), ((typeOf _target) == QGVAR(staticAssembled))])}
&& EFUNC(csw,assemble_canPickupTripod)
&& EFUNC(csw,canPickupTripod)