CSW - Improve function headers & comments (#10149)

Code formatting changes from 9234
This commit is contained in:
johnb432 2024-07-27 19:42:31 +02:00 committed by GitHub
parent e3d8f40538
commit 56eae4060c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 124 additions and 124 deletions

View File

@ -16,7 +16,7 @@ private _inherited = [];
private _config = _x; private _config = _x;
private _configEnabled = (getNumber (_config >> QUOTE(ADDON) >> "enabled")) == 1; private _configEnabled = (getNumber (_config >> QUOTE(ADDON) >> "enabled")) == 1;
if (_configEnabled) then { if (_configEnabled) then {
private _configExplicit = (count configProperties [_config, "configName _x == 'ace_csw'", false]) == 1; private _configExplicit = (count configProperties [_config, toString {configName _x == QUOTE(ADDON)}, false]) == 1;
if (_configExplicit) then { if (_configExplicit) then {
_explicitBases pushBack (configName _config); _explicitBases pushBack (configName _config);
_inherited pushBack []; _inherited pushBack [];
@ -43,8 +43,8 @@ private _inherited = [];
INFO("------ Logging static magazines with no carry version -------"); INFO("------ Logging static magazines with no carry version -------");
private _hash = createHashMap; private _hash = createHashMap;
// private _logAll = true; // logs all possible weapon magazines (even if not used in a static weapon) private _logAll = false; // logs all possible weapon magazines (even if not used in a static weapon) when set to true
private _logAll = false;
{ {
private _vehicleType = configName _x; private _vehicleType = configName _x;
private _turretConfig = [_vehicleType, [0]] call CBA_fnc_getTurret; private _turretConfig = [_vehicleType, [0]] call CBA_fnc_getTurret;

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Helper function for ace_rearm; Gets magazines that should be loaded by csw * Helper function for ace_rearm; Gets magazines that should be loaded by csw.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Specific Turret or pass bool to check all turrets <ARRAY><BOOL>(default: true) * 1: Specific Turret or pass bool to check all turrets <ARRAY|BOOL> (default: true)
* *
* Return Value: * Return Value:
* [0: compatible veh mags, 1: carry mags] <ARRAY> * [0: compatible veh mags, 1: carry mags] <ARRAY>

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Handles AI Fired EH * Handles AI Fired EH.
* *
* Arguments: * Arguments:
* Fired EH * Fired EH

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: Grim * Author: LinkIsGrim
* Handles AI GetIn on an empty weapon * Handles AI GetIn on an empty CSW.
* *
* Arguments: * Arguments:
* GetIn EH * GetIn EH

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror, modified by Grim * Author: PabstMirror, LinkIsGrim
* Handles AI reloading * Handles AI reloading.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Gunner <OBJECT> * 1: Gunner <OBJECT>
* 2: Weapon <STRING> * 2: Weapon <STRING>
* 3: Magazine <STRING> (default: "") * 3: Magazine <STRING> (default: "")
@ -15,7 +15,7 @@
* Public: No * Public: No
*/ */
params ["_staticWeapon", "_gunner", "_weapon", ["_magazine", ""]]; params ["_vehicle", "_gunner", "_weapon", ["_magazine", ""]];
private _turretPath = [_gunner] call EFUNC(common,getTurretIndex); private _turretPath = [_gunner] call EFUNC(common,getTurretIndex);
private _reloadSource = objNull; private _reloadSource = objNull;
@ -24,7 +24,7 @@ private _reloadNeededAmmo = -1;
private _cfgMagGroups = configFile >> QGVAR(groups); private _cfgMagGroups = configFile >> QGVAR(groups);
private _nearSupplies = [_gunner] + ((_staticWeapon nearSupplies 10) select { private _nearSupplies = [_gunner] + ((_vehicle nearSupplies 10) select {
isNull (group _x) || isNull (group _x) ||
{!([_x] call EFUNC(common,isPlayer)) && {[side group _gunner, side group _x] call BIS_fnc_sideIsFriendly}} {!([_x] call EFUNC(common,isPlayer)) && {[side group _gunner, side group _x] call BIS_fnc_sideIsFriendly}}
}); });
@ -49,7 +49,7 @@ private _nearSupplies = [_gunner] + ((_staticWeapon nearSupplies 10) select {
private _xWeaponMag = _x; private _xWeaponMag = _x;
{ {
if ((getNumber (_cfgMagGroups >> _x >> _xWeaponMag)) == 1) then { if ((getNumber (_cfgMagGroups >> _x >> _xWeaponMag)) == 1) then {
private _loadInfo = [_staticWeapon, _turretPath, _x, _xSource] call FUNC(reload_canLoadMagazine); private _loadInfo = [_vehicle, _turretPath, _x, _xSource] call FUNC(reload_canLoadMagazine);
if (_loadInfo select 0) then { if (_loadInfo select 0) then {
_reloadMag = _x; _reloadMag = _x;
_reloadSource = _xSource; _reloadSource = _xSource;
@ -81,16 +81,16 @@ if (_bestAmmoToSend == -1) exitWith {ERROR("No ammo");};
[_reloadSource, _reloadMag, _bestAmmoToSend] call EFUNC(common,removeSpecificMagazine); [_reloadSource, _reloadMag, _bestAmmoToSend] call EFUNC(common,removeSpecificMagazine);
private _timeToLoad = 1; private _timeToLoad = 1;
if (!isNull(configOf _staticWeapon >> QUOTE(ADDON) >> "ammoLoadTime")) then { if (!isNull(configOf _vehicle >> QUOTE(ADDON) >> "ammoLoadTime")) then {
_timeToLoad = getNumber(configOf _staticWeapon >> QUOTE(ADDON) >> "ammoLoadTime"); _timeToLoad = getNumber(configOf _vehicle >> QUOTE(ADDON) >> "ammoLoadTime");
}; };
TRACE_1("Reloading in progress",_timeToLoad); TRACE_1("Reloading in progress",_timeToLoad);
[{ [{
params ["_staticWeapon", "_turretPath", "_gunner", "_reloadMag", "_bestAmmoToSend"]; params ["_vehicle", "_turretPath", "_gunner", "_reloadMag", "_bestAmmoToSend"];
if ((!alive _staticWeapon) || {!alive _gunner} || {(_staticWeapon distance _gunner) > 10}) exitWith {TRACE_1("invalid state",_this);}; if ((!alive _vehicle) || {!alive _gunner} || {(_vehicle distance _gunner) > 10}) exitWith {TRACE_1("invalid state",_this);};
// Reload the static weapon // Reload the static weapon
TRACE_5("calling addTurretMag event",_staticWeapon,_turretPath,_gunner,_reloadMag,_bestAmmoToSend); TRACE_5("calling addTurretMag event",_vehicle,_turretPath,_gunner,_reloadMag,_bestAmmoToSend);
[QGVAR(addTurretMag), _this] call CBA_fnc_globalEvent; [QGVAR(addTurretMag), _this] call CBA_fnc_globalEvent;
}, [_staticWeapon, _turretPath, _gunner, _reloadMag, _bestAmmoToSend], _timeToLoad] call CBA_fnc_waitAndExecute; }, [_vehicle, _turretPath, _gunner, _reloadMag, _bestAmmoToSend], _timeToLoad] call CBA_fnc_waitAndExecute;

View File

@ -1,14 +1,14 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Checks if you can deploy a weapon on the tripod * Checks if you can deploy a weapon on the tripod.
* *
* Arguments: * Arguments:
* 0: Target Tripod <OBJECT> * 0: Target <OBJECT>
* 1: Player <OBJECT> * 1: Player <OBJECT>
* *
* Return Value: * Return Value:
* Wether or not you can deploy the weapon <BOOL> * Whether or not you can deploy the weapon <BOOL>
* *
* Example: * Example:
* [cursorObject, player] call ace_csw_fnc_assemble_canDeployWeapon * [cursorObject, player] call ace_csw_fnc_assemble_canDeployWeapon

View File

@ -1,23 +1,23 @@
#include "..\script_component.hpp" #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 * If the CSW is mounted or in use this will not allow you to dismount the weapon.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* *
* Return Value: * Return Value:
* Can Dismount <BOOL> * Can dismount weapon <BOOL>
* *
* Example: * Example:
* [cursorObject] call ace_csw_fnc_assemble_canPickupWeapon * cursorObject call ace_csw_fnc_assemble_canPickupWeapon
* *
* Public: No * Public: No
*/ */
params ["_staticWeapon"]; params ["_vehicle"];
// Assembly mode: [0=disabled, 1=enabled, 2=enabled&unload, 3=default] // 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 _assemblyMode = [false, true, true, GVAR(defaultAssemblyMode)] select (_vehicle getVariable [QGVAR(assemblyMode), 3]);
_assemblyMode && {alive _staticWeapon} && {((crew _staticWeapon) findIf {alive _x && {!unitIsUAV _x}}) == -1} // return _assemblyMode && {alive _vehicle} && {((crew _vehicle) findIf {alive _x && {!unitIsUAV _x}}) == -1} // return

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Deploys the tripod * Deploys the tripod.
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
@ -10,7 +10,7 @@
* None * None
* *
* Example: * Example:
* [player] call ace_csw_fnc_assemble_deployTripod * player call ace_csw_fnc_assemble_deployTripod
* *
* Public: No * Public: No
*/ */

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Deploys the current CSW * Deploys the current CSW.
* *
* Arguments: * Arguments:
* 0: Target <OBJECT> * 0: Target <OBJECT>
* 1: Unit <OBJECT> * 1: Player <OBJECT>
* 2: Args <ANY> * 2: Args <ANY>
* 3: Action Data <ARRAY> * 3: Action Data <ARRAY>
* *

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Modifies interaction for deploying weapon * Modifies interaction for deploying weapon.
* *
* Arguments: * Arguments:
* 0: Target <OBJECT> * 0: Target <OBJECT>
@ -21,7 +21,7 @@
params ["_target", "_player", "", "_actionData"]; params ["_target", "_player", "", "_actionData"];
private _carryWeaponClassname = secondaryWeapon _player; private _carryWeaponClassname = secondaryWeapon _player;
private _assembleTo = (getText(configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "assembleTo" >> (typeOf _target))); private _assembleTo = getText (configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "assembleTo" >> typeOf _target);
private _icon = getText (configFile >> "CfgVehicles" >> _assembleTo >> "picture"); private _icon = getText (configFile >> "CfgVehicles" >> _assembleTo >> "picture");
TRACE_2("",_assembleTo,_icon); TRACE_2("",_assembleTo,_icon);

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Picks up the tripod and adds it to the player launcher slot * Picks up the tripod and adds it to the player launcher slot.
* *
* Arguments: * Arguments:
* 0: Tripod <OBJECT> * 0: Tripod <OBJECT>
* 1: Unit <OBJECT> * 1: Player <OBJECT>
* *
* Return Value: * Return Value:
* None * None
@ -56,7 +56,7 @@
if (isNull _weaponHolder || {_tripodPos distance _weaponHolder > 2}) then { if (isNull _weaponHolder || {_tripodPos distance _weaponHolder > 2}) then {
_weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "CAN_COLLIDE"]; _weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_weaponHolder setDir random [0, 180, 360]; _weaponHolder setDir random [0, 180, 360];
_weaponHolder setVehiclePosition [_tripodPos, [], 0, "CAN_COLLIDE"]; // places object on surface below _weaponHolder setVehiclePosition [_tripodPos, [], 0, "CAN_COLLIDE"]; // Places object on surface below
}; };
_weaponHolder addWeaponCargoGlobal [_tripodClassname, 1]; _weaponHolder addWeaponCargoGlobal [_tripodClassname, 1];

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Dismounts the weapon from the tripod and drops its backpack beside * Dismounts the weapon from the tripod and drops its backpack beside.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Unit <OBJECT> * 1: Player <OBJECT>
* *
* Return Value: * Return Value:
* None * None
@ -17,10 +17,10 @@
*/ */
[{ [{
params ["_staticWeapon", "_player"]; params ["_vehicle", "_player"];
TRACE_2("assemble_pickupWeapon",_staticWeapon,_player); TRACE_2("assemble_pickupWeapon",_vehicle,_player);
private _weaponConfig = configOf _staticWeapon >> QUOTE(ADDON); private _weaponConfig = configOf _vehicle >> QUOTE(ADDON);
private _carryWeaponClassname = getText (_weaponConfig >> "disassembleWeapon"); private _carryWeaponClassname = getText (_weaponConfig >> "disassembleWeapon");
if (!isClass (configFile >> "CfgWeapons" >> _carryWeaponClassname)) exitWith { if (!isClass (configFile >> "CfgWeapons" >> _carryWeaponClassname)) exitWith {
@ -37,15 +37,15 @@
private _onDisassembleFunc = getText (_weaponConfig >> "disassembleFunc"); private _onDisassembleFunc = getText (_weaponConfig >> "disassembleFunc");
private _pickupTime = getNumber (configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "pickupTime"); private _pickupTime = getNumber (configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "pickupTime");
TRACE_4("",typeOf _staticWeapon,_carryWeaponClassname,_turretClassname,_pickupTime); TRACE_4("",typeOf _vehicle,_carryWeaponClassname,_turretClassname,_pickupTime);
private _onFinish = { private _onFinish = {
params ["_args"]; params ["_args"];
_args params ["_staticWeapon", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"]; _args params ["_vehicle", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"];
TRACE_4("disassemble finish",_staticWeapon,_player,_carryWeaponClassname,_turretClassname); TRACE_4("disassemble finish",_vehicle,_player,_carryWeaponClassname,_turretClassname);
private _weaponPos = (getPosATL _staticWeapon) vectorAdd [0, 0, 0.1]; private _weaponPos = (getPosATL _vehicle) vectorAdd [0, 0, 0.1];
private _weaponDir = getDir _staticWeapon; private _weaponDir = getDir _vehicle;
private _carryWeaponMag = []; private _carryWeaponMag = [];
private _carryWeaponMags = compatibleMagazines _carryWeaponClassname; private _carryWeaponMags = compatibleMagazines _carryWeaponClassname;
@ -64,7 +64,7 @@
TRACE_2("Removing ammo",_xMag,_carryMag); TRACE_2("Removing ammo",_xMag,_carryMag);
[_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo); [_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo);
}; };
} forEach (magazinesAllTurrets _staticWeapon); } forEach (magazinesAllTurrets _vehicle);
if (_turretClassname isNotEqualTo "") then { if (_turretClassname isNotEqualTo "") then {
private _cswTripod = createVehicle [_turretClassname, [0, 0, 0], [], 0, "NONE"]; private _cswTripod = createVehicle [_turretClassname, [0, 0, 0], [], 0, "NONE"];
@ -76,7 +76,7 @@
_cswTripod setVelocity [0, 0, -0.05]; _cswTripod setVelocity [0, 0, -0.05];
_cswTripod setVectorUp (surfaceNormal _weaponPos); _cswTripod setVectorUp (surfaceNormal _weaponPos);
}, [_cswTripod, _weaponDir, _weaponPos]] call CBA_fnc_execNextFrame; }, [_cswTripod, _weaponDir, _weaponPos]] call CBA_fnc_execNextFrame;
[_cswTripod, _staticWeapon] call (missionNamespace getVariable _onDisassembleFunc); [_cswTripod, _vehicle] call (missionNamespace getVariable _onDisassembleFunc);
}; };
[{ [{
@ -99,7 +99,7 @@
// Create a new weapon holder (don't try to get an existing one, as no guarantee where it could be) // Create a new weapon holder (don't try to get an existing one, as no guarantee where it could be)
private _weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "CAN_COLLIDE"]; private _weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_weaponHolder setDir random [0, 180, 360]; _weaponHolder setDir random [0, 180, 360];
_weaponHolder setVehiclePosition [_weaponPos, [], 0, "CAN_COLLIDE"]; // places object on surface below _weaponHolder setVehiclePosition [_weaponPos, [], 0, "CAN_COLLIDE"]; // Places object on surface below
_weaponHolder addWeaponWithAttachmentsCargoGlobal [[_carryWeaponClassname, "", "", "", _carryWeaponMag, [], ""], 1]; _weaponHolder addWeaponWithAttachmentsCargoGlobal [[_carryWeaponClassname, "", "", "", _carryWeaponMag, [], ""], 1];
}, [_player, _weaponPos, _carryWeaponClassname, _carryWeaponMag, _turretClassname]] call CBA_fnc_execNextFrame; }, [_player, _weaponPos, _carryWeaponClassname, _carryWeaponMag, _turretClassname]] call CBA_fnc_execNextFrame;
@ -108,23 +108,23 @@
// Eject dead units (all crew are dead or UAV at this point, otherwise condition would have failed), but ignore UAV units // Eject dead units (all crew are dead or UAV at this point, otherwise condition would have failed), but ignore UAV units
{ {
if (unitIsUAV _x) then { if (unitIsUAV _x) then {
_staticWeapon deleteVehicleCrew _x; _vehicle deleteVehicleCrew _x;
} else { } else {
moveOut _x; moveOut _x;
}; };
} forEach (crew _staticWeapon); } forEach (crew _vehicle);
deleteVehicle _staticWeapon; deleteVehicle _vehicle;
LOG("end"); LOG("end");
}; };
private _condition = { private _condition = {
params ["_args"]; params ["_args"];
_args params ["_staticWeapon"]; _args params ["_vehicle"];
_staticWeapon call FUNC(assemble_canPickupWeapon) _vehicle call FUNC(assemble_canPickupWeapon)
}; };
[TIME_PROGRESSBAR(_pickupTime), [_staticWeapon, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, LLSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar); [TIME_PROGRESSBAR(_pickupTime), [_vehicle, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, LLSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
}, _this] call CBA_fnc_execNextFrame; }, _this] call CBA_fnc_execNextFrame;

View File

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

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Checks if it's possible to get in the CSW * Checks if it's possible to get in the CSW.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* *
* Return Value: * Return Value:
* None * None

View File

@ -1,17 +1,16 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Checks if the unit can pickup the tripod * Checks if the player can pickup the tripod.
* *
* Arguments: * Arguments:
* 0: Tripod <OBJECT> * 0: Tripod <OBJECT>
* 1: Unit (not used) <OBJECT>
* *
* Return Value: * Return Value:
* Can pickup <BOOL> * Can pickup <BOOL>
* *
* Example: * Example:
* [cursorObject, player] call ace_csw_fnc_canPickupTripod * cursorObject call ace_csw_fnc_canPickupTripod
* *
* Public: No * Public: No
*/ */

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror, Dystopian * Author: PabstMirror, Dystopian
* Gets magazine that the player can carry, suitable to vehicle magazine * Gets magazine that the player can carry, suitable to vehicle magazine.
* *
* Arguments: * Arguments:
* 0: Vehicle Magazine <STRING> * 0: Vehicle Magazine <STRING>

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Gets sub actions for what the unit can load into the CSW * Gets sub actions for what the player can load into the CSW.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Unit <OBJECT> * 1: Unit <OBJECT>
* *
* Return Value: * Return Value:
@ -35,7 +35,7 @@ private _condition = {
([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0 ([_target, _turretPath, _carryMag, _magSource] call FUNC(reload_canLoadMagazine)) select 0
}; };
private _cfgMagazines = configFile >> "CfgMagazines"; // micro-optimization private _cfgMagazines = configFile >> "CfgMagazines"; // Micro-optimization
private _actions = []; private _actions = [];
{ {
_x params ["_carryMag", "", "_loadInfo"]; _x params ["_carryMag", "", "_loadInfo"];

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Initializes CSW systems on vehicle * Initializes CSW systems on vehicle.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: Vehicle <OBJECT>
@ -78,7 +78,7 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
if ((GVAR(ammoHandling) == 0) && {!([false, true, true, GVAR(defaultAssemblyMode)] select (_target getVariable [QGVAR(assemblyMode), 3]))}) exitWith { false }; 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) [_player, _target, ["isNotSwimming", "isNotSitting"]] call EFUNC(common,canInteractWith)
}; };
private _childenCode = { private _childrenCode = {
BEGIN_COUNTER(getActions); // can remove for final release BEGIN_COUNTER(getActions); // can remove for final release
private _ret = (call FUNC(getLoadActions)) + (call FUNC(getUnloadActions)); private _ret = (call FUNC(getLoadActions)) + (call FUNC(getUnloadActions));
END_COUNTER(getActions); END_COUNTER(getActions);
@ -86,10 +86,10 @@ if (hasInterface && {!(_typeOf in GVAR(initializedStaticTypes))}) then {
}; };
if (_configEnabled && {_magazineLocation != ""}) then { if (_configEnabled && {_magazineLocation != ""}) then {
private _positionCode = compile _magazineLocation; private _positionCode = compile _magazineLocation;
private _ammoAction = [QGVAR(magazine), LLSTRING(AmmoHandling_displayName), "", {}, _condition, _childenCode, [], _positionCode, 4] call EFUNC(interact_menu,createAction); private _ammoAction = [QGVAR(magazine), LLSTRING(AmmoHandling_displayName), "", {}, _condition, _childrenCode, [], _positionCode, 4] call EFUNC(interact_menu,createAction);
_ammoActionPath = [_typeOf, 0, [], _ammoAction] call EFUNC(interact_menu,addActionToClass); _ammoActionPath = [_typeOf, 0, [], _ammoAction] call EFUNC(interact_menu,addActionToClass);
} else { } else {
private _ammoAction = [QGVAR(magazine), LLSTRING(AmmoHandling_displayName), "", {}, _condition, _childenCode] call EFUNC(interact_menu,createAction); private _ammoAction = [QGVAR(magazine), LLSTRING(AmmoHandling_displayName), "", {}, _condition, _childrenCode] call EFUNC(interact_menu,createAction);
_ammoActionPath = [_typeOf, 0, ["ACE_MainActions"], _ammoAction] call EFUNC(interact_menu,addActionToClass); _ammoActionPath = [_typeOf, 0, ["ACE_MainActions"], _ammoAction] call EFUNC(interact_menu,addActionToClass);
}; };

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm, PabstMirror * Author: tcvm, PabstMirror
* Handles the use of proxy weapons to bypass engine reload times * Handles the use of proxy weapons to fix engine-reload times.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Turret <ARRAY> * 1: Turret <ARRAY>
* 2: Proxy weapon needed <BOOL> * 2: Proxy weapon needed <BOOL>
* 2: Weapon should be emptied <BOOL> * 2: Weapon should be emptied <BOOL>

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror &tcvm * Author: PabstMirror, tcvm
* Tests if unit can load a magazine into a static weapon. * Tests if unit can load a magazine into a CSW.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Turret Path <ARRAY> * 1: Turret Path <ARRAY>
* 2: Carryable Magazine <STRING> * 2: Carryable Magazine <STRING>
* 3: Supplier <OBJECT> * 3: Supplier <OBJECT> (default: objNull)
* *
* Return Value: * Return Value:
* [Can Load <BOOL>, Loaded Mag <STRING>, Ammo Needed <NUMBER>, Is Belt Linking <BOOL>] <ARRAY> * [Can Load <BOOL>, Loaded Mag <STRING>, Ammo Needed <NUMBER>, Is Belt Linking <BOOL>] <ARRAY>
@ -28,7 +28,7 @@ if (!alive _vehicle) exitWith { _return };
// Verify holder has carry magazine // Verify holder has carry magazine
if ( if (
(!isNull _magSource) && (!isNull _magSource) &&
{!((_magSource isKindOf "Bag_Base") || {_magSource isKindOf "ContainerSupply"})} && // hacky workaround for magazines within dropped backpacks {!((_magSource isKindOf "Bag_Base") || {_magSource isKindOf "ContainerSupply"})} && // Hacky workaround for magazines within dropped backpacks
{ {
((_vehicle distance _magSource) > 10) || ((_vehicle distance _magSource) > 10) ||
{((magazineCargo _magSource) findIf {_x == _carryMag}) == -1} {((magazineCargo _magSource) findIf {_x == _carryMag}) == -1}
@ -42,7 +42,7 @@ private _cfgGroupsCarryMag = configFile >> QGVAR(groups) >> _carryMag;
private _desiredAmmo = getNumber (configOf _vehicle >> QUOTE(ADDON) >> "desiredAmmo"); private _desiredAmmo = getNumber (configOf _vehicle >> QUOTE(ADDON) >> "desiredAmmo");
if (_desiredAmmo == 0) then { _desiredAmmo = 100; }; if (_desiredAmmo == 0) then { _desiredAmmo = 100; };
private _ammoNeeded = _desiredAmmo min getNumber (_cfgMagazinesCarryMag >> "count"); // assume it needs full carry mag private _ammoNeeded = _desiredAmmo min getNumber (_cfgMagazinesCarryMag >> "count"); // Assume it needs full carry mag
private _loadedMag = ""; private _loadedMag = "";
private _isBeltLinking = false; private _isBeltLinking = false;
@ -62,7 +62,7 @@ scopeName "main";
}; };
private _maxMagazineAmmo = _desiredAmmo min getNumber (_cfgMagazines >> _xMag >> "count"); private _maxMagazineAmmo = _desiredAmmo min getNumber (_cfgMagazines >> _xMag >> "count");
if (_xAmmo >= _maxMagazineAmmo) exitWith { if (_xAmmo >= _maxMagazineAmmo) exitWith {
[false, _loadedMag, -6, false] breakOut "main"; // Already at capicity [false, _loadedMag, -6, false] breakOut "main"; // Already at capacity
}; };
_ammoNeeded = _maxMagazineAmmo - _xAmmo; _ammoNeeded = _maxMagazineAmmo - _xAmmo;
_isBeltLinking = true; _isBeltLinking = true;

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Tests if unit can unload a magazine from a static weapon. * Tests if unit can unload a magazine from a CSW.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Turret Path <ARRAY> * 1: Turret Path <ARRAY>
* 2: Player <OBJECT> * 2: Player <OBJECT>
* 3: Carryable Magazine <STRING> * 3: Carryable Magazine <STRING>

View File

@ -1,15 +1,15 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Gets magazines that the player is carrying that can be loaded into the static weapon * Gets nearby magazines that can be loaded into the CSW.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Player <OBJECT> * 1: Unit <OBJECT>
* *
* Return Value: * Return Value:
* Mags <ARRAY> * Mags <ARRAY>
* [Carry Magazine <STRING>, Turret Path <ARRAY>, Load Info <NUMBER>, Magazine Source <OBJECT>] * [Carry Magazine <STRING>, Turret Path <ARRAY>, Load Info <ARRAY>, Magazine Source <OBJECT>]
* *
* Example: * Example:
* [cursorObject, player] call ace_csw_fnc_reload_getLoadableMagazines * [cursorObject, player] call ace_csw_fnc_reload_getLoadableMagazines

View File

@ -4,7 +4,7 @@
* Finds the best vehicle magazines to create from a carryable magazine for a given weapon. * Finds the best vehicle magazines to create from a carryable magazine for a given weapon.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Turret <ARRAY> * 1: Turret <ARRAY>
* 2: Magazine that is carryable <STRING> * 2: Magazine that is carryable <STRING>
* *

View File

@ -1,11 +1,11 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm, PabstMirror * Author: tcvm, PabstMirror
* Handles adding ammo to a turret * Handles adding ammo to a turret.
* Called from a global event but only runs where turret is local * Called from a global event but only runs where turret is local.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Turret Path <ARRAY> * 1: Turret Path <ARRAY>
* 2: Source of magazine <OBJECT> * 2: Source of magazine <OBJECT>
* 3: Vehicle Magazine <STRING> * 3: Vehicle Magazine <STRING>

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm * Author: tcvm
* Handles removing ammo from a turret * Handles removing ammo from a turret.
* Called from a global event but only runs where turret is local * Called from a global event but only runs where turret is local.
* *
* Arguments: * Arguments:
* 0: Static Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Turret Path <ARRAY> * 1: Turret Path <ARRAY>
* 2: Magainze Unit Can Carry <STRING> * 2: Magazine Unit Can Carry <STRING>
* 3: Magazine To Remove From Static <STRING> * 3: Magazine To Remove From Static <STRING>
* 4: Unit or container to unload to <OBJECT> * 4: Unit or container to unload to <OBJECT>
* *

View File

@ -1,7 +1,7 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm and PabstMirror * Author: tcvm, PabstMirror
* Handles returned ammo (either from unloading or leftovers from linking) * Handles returned ammo (either from unloading or leftovers from linking).
* *
* Arguments: * Arguments:
* 0: Man or Vehicle <OBJECT> * 0: Man or Vehicle <OBJECT>

View File

@ -1,10 +1,10 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: PabstMirror * Author: PabstMirror
* Loads a magazine into a static weapon from a magazine carried by or next to the player. * Loads a magazine into a CSW from a magazine carried by or next to the player.
* *
* Arguments: * Arguments:
* 0: Vehicle <OBJECT> * 0: CSW <OBJECT>
* 1: Turret <ARRAY> * 1: Turret <ARRAY>
* 2: Unit Carried Magazine <STRING> * 2: Unit Carried Magazine <STRING>
* 3: Magazine source <OBJECT> * 3: Magazine source <OBJECT>

View File

@ -1,11 +1,12 @@
#include "..\script_component.hpp" #include "..\script_component.hpp"
/* /*
* Author: tcvm, PabstMirror * Author: tcvm, PabstMirror
* Dumps ammo to container * Dumps ammo to container.
* *
* Arguments: * Arguments:
* 0: Weapon <OBJECT> * 0: CSW <OBJECT>
* 1: Using advanced assembly <BOOL> * 1: Using advanced assembly <BOOL>
* 2: Empty weapon <BOOL>
* *
* Return Value: * Return Value:
* None * None
@ -16,11 +17,11 @@
* Public: No * Public: No
*/ */
params ["_staticWeapon", "_assemblyMode", "_emptyWeapon"]; params ["_vehicle", "_assemblyMode", "_emptyWeapon"];
TRACE_3("staticWeaponInit_unloadExtraMags",_staticWeapon,_assemblyMode,_emptyWeapon); TRACE_3("staticWeaponInit_unloadExtraMags",_vehicle,_assemblyMode,_emptyWeapon);
if (!_assemblyMode) exitWith {}; if (!_assemblyMode) exitWith {};
private _desiredAmmo = getNumber (configOf _staticWeapon >> QUOTE(ADDON) >> "desiredAmmo"); private _desiredAmmo = getNumber (configOf _vehicle >> QUOTE(ADDON) >> "desiredAmmo");
private _storeExtraMagazines = GVAR(handleExtraMagazines); private _storeExtraMagazines = GVAR(handleExtraMagazines);
if (_emptyWeapon) then { if (_emptyWeapon) then {
_desiredAmmo = 0; _desiredAmmo = 0;
@ -56,41 +57,41 @@ private _containerMagazineCount = [];
} else { } else {
if ((_xMag select [0,4]) != "fake") then { WARNING_1("Unable to unload [%1] - No matching carry mag",_xMag); }; 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); TRACE_1("Remove all loaded magazines",_magsToRemove);
{ {
_staticWeapon removeMagazinesTurret _x; _vehicle removeMagazinesTurret _x;
if ((_loadedMagazineInfo select [0,2]) isEqualTo _x) then { if ((_loadedMagazineInfo select [0,2]) isEqualTo _x) then {
TRACE_1("Re-add the starting mag",_loadedMagazineInfo); TRACE_1("Re-add the starting mag",_loadedMagazineInfo);
_staticWeapon addMagazineTurret _loadedMagazineInfo; _vehicle addMagazineTurret _loadedMagazineInfo;
}; };
} forEach _magsToRemove; } forEach _magsToRemove;
private _secondaryWeaponMagazines = _staticWeapon getVariable [QGVAR(secondaryWeaponMagazines), []]; private _secondaryWeaponMagazines = _vehicle getVariable [QGVAR(secondaryWeaponMagazines), []];
if (_secondaryWeaponMagazines isNotEqualTo []) then { if (_secondaryWeaponMagazines isNotEqualTo []) then {
// Check if the static weapon can take magazines // Check if the static weapon can take magazines
private _turret = (allTurrets _staticWeapon) param [0, []]; private _turret = (allTurrets _vehicle) param [0, []];
private _compatibleMagazinesTurret = flatten ((_staticWeapon weaponsTurret _turret) apply {compatibleMagazines _x}); private _compatibleMagazinesTurret = flatten ((_vehicle weaponsTurret _turret) apply {compatibleMagazines _x});
private _container = objNull; private _container = objNull;
{ {
private _vehicleMag = [_staticWeapon, _turret, _x select 0] call FUNC(reload_getVehicleMagazine); private _vehicleMag = [_vehicle, _turret, _x select 0] call FUNC(reload_getVehicleMagazine);
TRACE_3("Re-add previous mag",_x select 0,_turret,_vehicleMag); TRACE_3("Re-add previous mag",_x select 0,_turret,_vehicleMag);
// If the magazine can be added to the static weapon, do it now // If the magazine can be added to the static weapon, do it now
if (_vehicleMag in _compatibleMagazinesTurret) then { if (_vehicleMag in _compatibleMagazinesTurret) then {
_staticWeapon addMagazineTurret [_vehicleMag, _turret, _x select 1]; _vehicle addMagazineTurret [_vehicleMag, _turret, _x select 1];
} else { } else {
// Find a suitable container to place items in if necessary // Find a suitable container to place items in if necessary
if (isNull _container) then { if (isNull _container) then {
_container = (nearestObjects [_staticWeapon, ["GroundWeaponHolder"], 10]) param [0, objNull]; _container = (nearestObjects [_vehicle, ["GroundWeaponHolder"], 10]) param [0, objNull];
// Create ammo storage container // Create ammo storage container
if (isNull _container) then { if (isNull _container) then {
_container = createVehicle ["GroundWeaponHolder", getPosATL _staticWeapon, [], 0, "NONE"]; _container = createVehicle ["GroundWeaponHolder", getPosATL _vehicle, [], 0, "NONE"];
}; };
}; };
@ -99,12 +100,12 @@ if (_secondaryWeaponMagazines isNotEqualTo []) then {
}; };
} forEach _secondaryWeaponMagazines; } forEach _secondaryWeaponMagazines;
_staticWeapon setVariable [QGVAR(secondaryWeaponMagazines), nil, true]; _vehicle setVariable [QGVAR(secondaryWeaponMagazines), nil, true];
}; };
if (_storeExtraMagazines) then { if (_storeExtraMagazines) then {
TRACE_1("saving extra mags to container",_containerMagazineCount); 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; } forEach _containerMagazineClassnames;
}; };