mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
CSW - Improve tripod and weapon disassembly (#9915)
* Add disassembly for tripods when players have occupied launcher slots * Update fnc_assemble_canDeployWeapon.sqf * Update fnc_assemble_canPickupWeapon.sqf * Revert file renaming (see #9777) * Correct headers * Update fnc_canPickupTripod.sqf * Fixed checks and eject dead bodies * Invert checks
This commit is contained in:
parent
1f5044aabd
commit
cd66f495ad
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Target Tripod <OBJECT>
|
* 0: Target Tripod <OBJECT>
|
||||||
* 0: Player <OBJECT>
|
* 1: Player <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Wether or not you can deploy the weapon <BOOL>
|
* Wether or not you can deploy the weapon <BOOL>
|
||||||
@ -16,9 +16,8 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_target", "_player", "", "_carryWeaponClassname"];
|
params ["_target", "_player"];
|
||||||
if (isNil "_carryWeaponClassname") then { _carryWeaponClassname = secondaryWeapon _player };
|
|
||||||
|
|
||||||
// If the current launcher has a config-value that defines the tripod, it is a CSW
|
// If the current launcher has a config-value that defines the tripod, it is a CSW
|
||||||
(alive _target) &&
|
(alive _target) &&
|
||||||
{(getText(configFile >> "CfgWeapons" >> _carryWeaponClassname >> QUOTE(ADDON) >> "assembleTo" >> (typeOf _target))) != ""}
|
{(getText (configFile >> "CfgWeapons" >> secondaryWeapon _player >> QUOTE(ADDON) >> "assembleTo" >> typeOf _target)) != ""}
|
||||||
|
@ -19,7 +19,5 @@ params ["_staticWeapon"];
|
|||||||
|
|
||||||
// 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 (_staticWeapon getVariable [QGVAR(assemblyMode), 3]);
|
||||||
private _notCrewed = (crew _staticWeapon) isEqualTo [];
|
|
||||||
private _deadCrew = !(alive (gunner _staticWeapon)); // need to eject body???
|
|
||||||
|
|
||||||
_assemblyMode && {alive _staticWeapon} && {_notCrewed || _deadCrew}
|
_assemblyMode && {alive _staticWeapon} && {((crew _staticWeapon) findIf {alive _x && {!unitIsUAV _x}}) == -1} // return
|
||||||
|
@ -103,12 +103,12 @@
|
|||||||
} forEach _carryWeaponInfo;
|
} forEach _carryWeaponInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _codeCheck = {
|
private _condition = {
|
||||||
params ["_args"];
|
params ["_args"];
|
||||||
_args params ["_tripod"];
|
_args params ["_tripod"];
|
||||||
|
|
||||||
alive _tripod
|
alive _tripod
|
||||||
};
|
};
|
||||||
|
|
||||||
[TIME_PROGRESSBAR(_deployTime), [_tripod, _player, _assembledClassname, _carryWeaponClassname, _carryWeaponInfo], _onFinish, _onFailure, LLSTRING(AssembleCSW_progressBar), _codeCheck] call EFUNC(common,progressBar);
|
[TIME_PROGRESSBAR(_deployTime), [_tripod, _player, _assembledClassname, _carryWeaponClassname, _carryWeaponInfo], _onFinish, _onFailure, LLSTRING(AssembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
|
||||||
}, _this] call CBA_fnc_execNextFrame;
|
}, _this] call CBA_fnc_execNextFrame;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [tripod, player] call ace_csw_fnc_assemble_pickupTripod
|
* [cursorObject, player] call ace_csw_fnc_assemble_pickupTripod
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
@ -28,16 +28,45 @@
|
|||||||
_args params ["_tripod", "_player", "_tripodClassname"];
|
_args params ["_tripod", "_player", "_tripodClassname"];
|
||||||
TRACE_3("assemble_pickupTripod finish",_tripod,_player,_tripodClassname);
|
TRACE_3("assemble_pickupTripod finish",_tripod,_player,_tripodClassname);
|
||||||
|
|
||||||
|
// Save tripod position before it's deleted
|
||||||
|
private _tripodPos = getPosATL _tripod;
|
||||||
|
|
||||||
|
// Eject dead units (all crew are dead at this point, otherwise condition would have failed), but ignore UAV units
|
||||||
|
{
|
||||||
|
if (unitIsUAV _x) then {
|
||||||
|
_tripod deleteVehicleCrew _x;
|
||||||
|
} else {
|
||||||
|
moveOut _x;
|
||||||
|
};
|
||||||
|
} forEach (crew _tripod);
|
||||||
|
|
||||||
deleteVehicle _tripod;
|
deleteVehicle _tripod;
|
||||||
_player addWeaponGlobal _tripodClassname;
|
|
||||||
[_player, "PutDown"] call EFUNC(common,doGesture);
|
[_player, "PutDown"] call EFUNC(common,doGesture);
|
||||||
|
|
||||||
|
// If the player has space, give it to him
|
||||||
|
if ((alive _player) && {(secondaryWeapon _player) == ""}) exitWith {
|
||||||
|
[_player, _tripodClassname] call CBA_fnc_addWeaponWithoutItems;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Try to find existing weapon holders
|
||||||
|
private _weaponHolder = nearestObject [_tripodPos, "WeaponHolder"];
|
||||||
|
|
||||||
|
// If there are none or too far away, make a new one
|
||||||
|
if (isNull _weaponHolder || {_tripodPos distance _weaponHolder > 2}) then {
|
||||||
|
_weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "CAN_COLLIDE"];
|
||||||
|
_weaponHolder setDir random [0, 180, 360];
|
||||||
|
_weaponHolder setVehiclePosition [_tripodPos, [], 0, "CAN_COLLIDE"]; // places object on surface below
|
||||||
|
};
|
||||||
|
|
||||||
|
_weaponHolder addWeaponCargoGlobal [_tripodClassname, 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
private _condition = {
|
private _condition = {
|
||||||
params ["_args"];
|
params ["_args"];
|
||||||
_args params ["_tripod", "_player"];
|
_args params ["_tripod"];
|
||||||
|
|
||||||
(alive _tripod) && {secondaryWeapon _player == ""}
|
_tripod call FUNC(canPickupTripod)
|
||||||
};
|
};
|
||||||
|
|
||||||
TRACE_3("",_pickupTime,typeOf _tripod,_tripodClassname);
|
TRACE_3("",_pickupTime,typeOf _tripod,_tripodClassname);
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Static Weapon <OBJECT>
|
* 0: Static Weapon <OBJECT>
|
||||||
|
* 1: Unit <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [weapon] call ace_csw_fnc_assemble_pickupWeapon
|
* [cursorObject, player] call ace_csw_fnc_assemble_pickupWeapon
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
@ -43,11 +44,10 @@
|
|||||||
_args params ["_staticWeapon", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"];
|
_args params ["_staticWeapon", "_player", "_carryWeaponClassname", "_turretClassname", "_onDisassembleFunc"];
|
||||||
TRACE_4("disassemble finish",_staticWeapon,_player,_carryWeaponClassname,_turretClassname);
|
TRACE_4("disassemble finish",_staticWeapon,_player,_carryWeaponClassname,_turretClassname);
|
||||||
|
|
||||||
private _weaponPos = getPosATL _staticWeapon;
|
private _weaponPos = (getPosATL _staticWeapon) vectorAdd [0, 0, 0.1];
|
||||||
_weaponPos set [2, (_weaponPos select 2) + 0.1];
|
|
||||||
private _weaponDir = getDir _staticWeapon;
|
private _weaponDir = getDir _staticWeapon;
|
||||||
|
|
||||||
private _carryWeaponMag = "";
|
private _carryWeaponMag = [];
|
||||||
private _carryWeaponMags = compatibleMagazines _carryWeaponClassname;
|
private _carryWeaponMags = compatibleMagazines _carryWeaponClassname;
|
||||||
LOG("remove ammo");
|
LOG("remove ammo");
|
||||||
{
|
{
|
||||||
@ -55,9 +55,9 @@
|
|||||||
if (_xAmmo == 0) then {continue};
|
if (_xAmmo == 0) then {continue};
|
||||||
|
|
||||||
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
private _carryMag = _xMag call FUNC(getCarryMagazine);
|
||||||
if (_carryWeaponMag == "" && {_carryMag in _carryWeaponMags}) then {
|
if (_carryWeaponMag isEqualTo [] && {_carryMag in _carryWeaponMags}) then {
|
||||||
TRACE_3("Adding mag to secondary weapon",_xMag,_xAmmo,_carryMag);
|
TRACE_3("Adding mag to secondary weapon",_xMag,_xAmmo,_carryMag);
|
||||||
_carryWeaponMag = _carryMag;
|
_carryWeaponMag = [_carryMag, _xAmmo];
|
||||||
DEC(_xAmmo);
|
DEC(_xAmmo);
|
||||||
};
|
};
|
||||||
if ((_xAmmo > 0) && {_carryMag != ""}) then {
|
if ((_xAmmo > 0) && {_carryMag != ""}) then {
|
||||||
@ -80,25 +80,40 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
[{
|
[{
|
||||||
params ["_player", "_weaponPos", "_carryWeaponClassname", "_carryWeaponMag"];
|
params ["_player", "_weaponPos", "_carryWeaponClassname", "_carryWeaponMag", "_turretClassname"];
|
||||||
|
|
||||||
|
// Give the weapon to the player if possible
|
||||||
if ((alive _player) && {(secondaryWeapon _player) == ""}) exitWith {
|
if ((alive _player) && {(secondaryWeapon _player) == ""}) exitWith {
|
||||||
_player addWeapon _carryWeaponClassname;
|
[_player, _carryWeaponClassname] call CBA_fnc_addWeaponWithoutItems;
|
||||||
if (_carryWeaponMag isNotEqualTo "") then {
|
|
||||||
|
if (_carryWeaponMag isNotEqualTo []) then {
|
||||||
_player addWeaponItem [_carryWeaponClassname, _carryWeaponMag, true];
|
_player addWeaponItem [_carryWeaponClassname, _carryWeaponMag, true];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
private _weaponRelPos = _weaponPos getPos RELATIVE_DIRECTION(90);
|
|
||||||
private _weaponHolder = createVehicle ["groundWeaponHolder", [0, 0, 0], [], 0, "NONE"];
|
// If there is no turret, place the ground holder where the turret was
|
||||||
_weaponHolder setDir random [0, 180, 360];
|
if (_turretClassname != "") then {
|
||||||
_weaponHolder setPosATL [_weaponRelPos select 0, _weaponRelPos select 1, _weaponPos select 2];
|
_weaponPos = _weaponPos getPos RELATIVE_DIRECTION(90);
|
||||||
if (_carryWeaponMag isEqualTo "") then {
|
|
||||||
_weaponHolder addWeaponCargoGlobal [_carryWeaponClassname, 1];
|
|
||||||
} else {
|
|
||||||
_weaponHolder addWeaponWithAttachmentsCargoGlobal [[_carryWeaponClassname, "", "", "", [_carryWeaponMag, 1], [], ""], 1];
|
|
||||||
};
|
};
|
||||||
}, [_player, _weaponPos, _carryWeaponClassname, _carryWeaponMag]] call CBA_fnc_execNextFrame;
|
|
||||||
|
// 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"];
|
||||||
|
_weaponHolder setDir random [0, 180, 360];
|
||||||
|
_weaponHolder setVehiclePosition [_weaponPos, [], 0, "CAN_COLLIDE"]; // places object on surface below
|
||||||
|
_weaponHolder addWeaponWithAttachmentsCargoGlobal [[_carryWeaponClassname, "", "", "", _carryWeaponMag, [], ""], 1];
|
||||||
|
}, [_player, _weaponPos, _carryWeaponClassname, _carryWeaponMag, _turretClassname]] call CBA_fnc_execNextFrame;
|
||||||
|
|
||||||
LOG("delete weapon");
|
LOG("delete weapon");
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
_staticWeapon deleteVehicleCrew _x;
|
||||||
|
} else {
|
||||||
|
moveOut _x;
|
||||||
|
};
|
||||||
|
} forEach (crew _staticWeapon);
|
||||||
|
|
||||||
deleteVehicle _staticWeapon;
|
deleteVehicle _staticWeapon;
|
||||||
|
|
||||||
LOG("end");
|
LOG("end");
|
||||||
@ -107,7 +122,8 @@
|
|||||||
private _condition = {
|
private _condition = {
|
||||||
params ["_args"];
|
params ["_args"];
|
||||||
_args params ["_staticWeapon"];
|
_args params ["_staticWeapon"];
|
||||||
((crew _staticWeapon) isEqualTo []) && (alive _staticWeapon)
|
|
||||||
|
_staticWeapon call FUNC(assemble_canPickupWeapon)
|
||||||
};
|
};
|
||||||
|
|
||||||
[TIME_PROGRESSBAR(_pickupTime), [_staticWeapon, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, LLSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
|
[TIME_PROGRESSBAR(_pickupTime), [_staticWeapon, _player, _carryWeaponClassname, _turretClassname, _onDisassembleFunc], _onFinish, {}, LLSTRING(DisassembleCSW_progressBar), _condition] call EFUNC(common,progressBar);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Tripod <OBJECT>
|
* 0: Tripod <OBJECT>
|
||||||
* 1: Unit <OBJECT>
|
* 1: Unit (not used) <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Can pickup <BOOL>
|
* Can pickup <BOOL>
|
||||||
@ -16,6 +16,6 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_tripod", "_unit"];
|
params ["_tripod"];
|
||||||
|
|
||||||
((secondaryWeapon _unit) == "") && {alive _tripod} // return
|
alive _tripod && {((crew _tripod) findIf {alive _x && {!unitIsUAV _x}}) == -1} // return
|
||||||
|
Loading…
Reference in New Issue
Block a user