Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/compat_spe/compat_spe_csw/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CfgFunctions {
OVERWRITE_FUNC(can_Reload);
OVERWRITE_FUNC(can_resupply_ammo);
OVERWRITE_FUNC(can_unload_ammo);
OVERWRITE_FUNC(player_put_EH);
OVERWRITE_FUNC(player_take_EH);
};
};
};
50 changes: 50 additions & 0 deletions addons/compat_spe/compat_spe_csw/functions/fnc_player_put_EH.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "..\script_component.hpp"
/*
* Author: Kerc (SPE), original by www.3commandobrigade.com, edited by johnb43 to be made CSW compatible
* EH to allow a player to drop a tripod from the launcher slot, converting it into a weapon base.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Container <OBJECT>
* 2: Item <STRING>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject, "SPE_MLE_27_31_Stand"] call SPE_Weapons_Static_fnc_player_put_EH
*
* Public: No
*/

params ["_unit", "_container", "_item"];

if (!alive _unit) exitWith {};

// Don't run when placing a tripod in a vehicle/box
if !(_container isKindOf "GroundWeaponHolder") exitWith {};

private _weaponConfig = configFile >> "CfgWeapons" >> _item;

// isKindOf does not currently work for weapons
if (getNumber (_weaponConfig >> "SPE_isTripod") == 0) exitWith {};

private _vectorDir = vectorDir _unit;

private _tripodClass = if (EGVAR(csw,defaultAssemblyMode)) then {
getText (_weaponConfig >> "ace_csw" >> "deploy")
} else {
// Note M6 is also considered a tripod as far as the next instruction is concerned
getText (_weaponConfig >> "SPE_Deployed_Tripod_Name")
};

if (_tripodClass == "") exitWith {};

// Remove tripod from container
_container addItemCargoGlobal [_item, -1];

// Create a vehicle replacing the tripod
private _pos = (getPosATL _unit) vectorAdd (_vectorDir vectorMultiply 1.1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it wants AGL (so ASLtoAGL getPosASL _unit)?
but I'm guessing this is part of the original func so it's probably best to leave it alone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I'm guessing this is part of the original func so it's probably best to leave it alone

It is, but I've already extensively rewritten most of the function anyway, so I'll change it.

private _weaponPlatform = createVehicle [_tripodClass, _pos, [], 0, "CAN_COLLIDE"];

_weaponPlatform setVectorDirAndUp [_vectorDir, surfaceNormal _pos];
54 changes: 54 additions & 0 deletions addons/compat_spe/compat_spe_csw/functions/fnc_player_take_EH.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "..\script_component.hpp"
/*
* Author: Kerc (SPE), edited by johnb43 to be made CSW compatible
* EH Backup for when the Put EH does not run (Swapping items).
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Container <OBJECT>
* 2: Item <STRING>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject, "SPE_MLE_27_31_Stand"] call SPE_Weapons_Static_fnc_player_take_EH
*
* Public: No
*/

params ["_unit", "_container", "_item"];

if (!alive _unit) exitWith {};

// Don't run when placing a tripod in a vehicle/box
if !(_container isKindOf "GroundWeaponHolder") exitWith {};

private _cfgWeapons = configFile >> "CfgWeapons";
private _tripods = (weaponCargo _container) select {getNumber (_cfgWeapons >> _x >> "SPE_isTripod") == 1};

if (_tripods isEqualTo []) exitWith {};

private _vectorDir = vectorDir _unit;
private _pos = (getPosATL _unit) vectorAdd (_vectorDir vectorMultiply 1.1);

{
private _tripodClass = if (EGVAR(csw,defaultAssemblyMode)) then {
getText (_cfgWeapons >> _x >> "ace_csw" >> "deploy")
} else {
// Note M6 is also considered a tripod as far as the next instruction is concerned
getText (_cfgWeapons >> _x >> "SPE_Deployed_Tripod_Name")
};

if (_tripodClass == "") then {
continue;
};

// Remove tripod from container
_container addItemCargoGlobal [_x, -1];

// Create a vehicle replacing the tripod
private _weaponPlatform = createVehicle [_tripodClass, _pos, [], 0, ["NONE", "CAN_COLLIDE"] select (_forEachIndex == 0)];

_weaponPlatform setVectorDirAndUp [_vectorDir, surfaceNormal getPosWorld _weaponPlatform];
} forEach _tripods;
Loading