Skip to content

Commit

Permalink
Save individual components for CSWs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Sep 7, 2024
1 parent e4d0968 commit 762e296
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions addons/csw/functions/fnc_assemble_deployWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

private _onFinish = {
params ["_args"];
_args params ["_tripod", "_player", "_assembledClassname", "", "_carryWeaponInfo"];
_args params ["_tripod", "_player", "_assembledClassname", "_tripodClassname", "_carryWeaponClassname", "_carryWeaponInfo"];
TRACE_3("deployWeapon finish",_tripod,_player,_assembledClassname);

private _secondaryWeaponMagazines = _tripod getVariable [QGVAR(secondaryWeaponMagazines), []];
Expand All @@ -56,10 +56,11 @@
_tripodPos set [2, (_tripodPos select 2) + 0.1];
// Delay a frame so tripod has a chance to be deleted
[{
params ["_assembledClassname", "_tripodDir", "_tripodPos", "_player", "_carryWeaponInfo", "_secondaryWeaponMagazines"];
params ["_assembledClassname", "_componentClasses", "_tripodDir", "_tripodPos", "_player", "_carryWeaponInfo", "_secondaryWeaponMagazines"];
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
_csw setVariable [QGVAR(componentClasses), _componentClasses, true];

{
// Magazines
Expand All @@ -86,12 +87,12 @@
};
[QGVAR(deployWeaponSucceeded), [_csw]] call CBA_fnc_localEvent;
TRACE_2("csw placed",_csw,_assembledClassname);
}, [_assembledClassname, _tripodDir, _tripodPos, _player, _carryWeaponInfo, _secondaryWeaponMagazines]] call CBA_fnc_execNextFrame;
}, [_assembledClassname, [_tripodClassname, _carryWeaponClassname], _tripodDir, _tripodPos, _player, _carryWeaponInfo, _secondaryWeaponMagazines]] call CBA_fnc_execNextFrame;
};

private _onFailure = {
params ["_args"];
_args params ["", "_player", "", "_carryWeaponClassname", "_carryWeaponInfo"];
_args params ["", "_player", "", "", "_carryWeaponClassname", "_carryWeaponInfo"];
TRACE_2("deployWeapon failure",_player,_carryWeaponClassname);

// Add weapon back
Expand All @@ -110,5 +111,5 @@
alive _tripod
};

[TIME_PROGRESSBAR(_deployTime), [_tripod, _player, _assembledClassname, _carryWeaponClassname, _carryWeaponInfo], _onFinish, _onFailure, LLSTRING(AssembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
[TIME_PROGRESSBAR(_deployTime), [_tripod, _player, _assembledClassname, _tripodClassname, _carryWeaponClassname, _carryWeaponInfo], _onFinish, _onFailure, LLSTRING(AssembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
}, _this] call CBA_fnc_execNextFrame;
10 changes: 7 additions & 3 deletions addons/csw/functions/fnc_assemble_pickupWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
TRACE_2("assemble_pickupWeapon",_vehicle,_player);

private _weaponConfig = configOf _vehicle >> QUOTE(ADDON);
private _carryWeaponClassname = getText (_weaponConfig >> "disassembleWeapon");
private _componentClasses = _vehicle getVariable QGVAR(componentClasses);

(if (!isNil "_componentClasses") then {
_componentClasses
} else {
[getText (_weaponConfig >> "disassembleTurret"), getText (_weaponConfig >> "disassembleWeapon")]
}) params ["_turretClassname", "_carryWeaponClassname"];

if (!isClass (configFile >> "CfgWeapons" >> _carryWeaponClassname)) exitWith {
ERROR_1("bad weapon classname [%1]",_carryWeaponClassname);
};

private _turretClassname = getText (_weaponConfig >> "disassembleTurret");

// Turret classname can equal nothing if the deploy bag is the "whole" weapon. e.g Kornet, Metis, other ATGMs
if ((_turretClassname != "") && {!isClass (configFile >> "CfgVehicles" >> _turretClassname)}) exitWith {
ERROR_1("bad turret classname [%1]",_turretClassname);
Expand Down

0 comments on commit 762e296

Please sign in to comment.