Skip to content
Merged
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
1 change: 1 addition & 0 deletions addons/explosives/CfgMagazines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CfgMagazines {
class SatchelCharge_Remote_Mag: CA_Magazine {
useAction = 0;
GVAR(placeable) = 1;
GVAR(isSticky) = 1;
GVAR(setupObject) = "ACE_Explosives_Place_SatchelCharge";
class ACE_Triggers {
SupportedTriggers[] = {"Timer", "Command", "MK16_Transmitter", "DeadmanSwitch"};
Expand Down
29 changes: 23 additions & 6 deletions addons/explosives/functions/fnc_setupExplosive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ _unit setVariable [QGVAR(cancelActionEH), [_unit, "zoomtemp", {true}, {GVAR(plac
private _supportedTriggers = getArray (_configMagazine >> "ACE_Triggers" >> "SupportedTriggers");
private _aceTriggers = configFile >> "ACE_Triggers";
private _isAttachable = _supportedTriggers findIf {(getNumber (_aceTriggers >> _x >> "isAttachable")) == 1} != -1;
private _isSticky = getNumber (_configMagazine >> QGVAR(isSticky)) == 1;

GVAR(pfeh_running) = true;
GVAR(placeAction) = PLACE_WAITING;
Expand All @@ -68,7 +69,7 @@ GVAR(TweakedAngle) = 0;
disableSerialization;

params ["_args", "_pfhID"];
_args params ["_unit", "_magClassname", "_setupObjectClass", "_isAttachable"];
_args params ["_unit", "_magClassname", "_setupObjectClass", "_isAttachable", "_isSticky"];

private _lookDirVector = ((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorFromTo ((positionCameraToWorld [0, 0, 10]) call EFUNC(common,positionToASL));
private _basePosASL = eyePos _unit;
Expand Down Expand Up @@ -121,14 +122,20 @@ GVAR(TweakedAngle) = 0;
} forEach [[0, 0], [-TEST_LENGTH, -TEST_LENGTH], [TEST_LENGTH, -TEST_LENGTH], [-TEST_LENGTH, TEST_LENGTH], [TEST_LENGTH, TEST_LENGTH]];

if (
!isNull _attachVehicle &&
{(_attachVehicle isKindOf "Car") || {_attachVehicle isKindOf "Tank"} || {_attachVehicle isKindOf "Air"} || {_attachVehicle isKindOf "Ship"}} &&
!isNull _attachVehicle && (
// Allow attaching to non-unit objects (if set) or any vehicle
(_isSticky && {!(_attachVehicle isKindOf "Man")}) ||
{_attachVehicle isKindOf "Car"} ||
{_attachVehicle isKindOf "Tank"} ||
{_attachVehicle isKindOf "Air"} ||
{_attachVehicle isKindOf "Ship"}
) &&
{PLACE_RANGE_MIN call _testPositionIsValid}
) then {
private _min = PLACE_RANGE_MIN;
private _max = PLACE_RANGE_MAX;

for "_index" from 0 to 6 do {
for "_" from 0 to 6 do {
_distanceFromBase = (_min + _max) / 2;

if (_distanceFromBase call _testPositionIsValid) then {
Expand Down Expand Up @@ -207,7 +214,17 @@ GVAR(TweakedAngle) = 0;
_expSetupVehicle setPosASL _virtualPosASL;
_placeAngle = _placeAngle + 180; // CfgAmmos seem to be 180 for some reason
} else {
private _modelOffset = _attachVehicle worldToModel (_virtualPosASL call EFUNC(common,ASLToPosition));
// Terrain objects (seemingly) can't have objects attached to them, so create a dummy instead
private _modelOffset = if (_attachVehicle call CBA_fnc_isTerrainObject) then {
_attachVehicle = createVehicle ["Helper_Base_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_attachVehicle setPosASL _virtualPosASL;
_attachVehicle setDir _placeAngle;

[0, 0, 0];
} else {
_attachVehicle worldToModel (_virtualPosASL call EFUNC(common,ASLToPosition));
};

_placeAngle = _cameraAngle - (getDir _attachVehicle) + 180;
_expSetupVehicle attachTo [_attachVehicle, _modelOffset];
_expSetupVehicle setVectorDirAndUp [[0, 0, -1], [sin _placeAngle, cos _placeAngle, 0]];
Expand Down Expand Up @@ -255,6 +272,6 @@ GVAR(TweakedAngle) = 0;
};

END_COUNTER(pfeh);
}, 0, [_unit, _magClassname, _setupObjectClass, _isAttachable]] call CBA_fnc_addPerFrameHandler;
}, 0, [_unit, _magClassname, _setupObjectClass, _isAttachable, _isSticky]] call CBA_fnc_addPerFrameHandler;

nil
1 change: 1 addition & 0 deletions docs/wiki/framework/explosives-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CfgMagazines {
class banana_satchel_remote_mag: CA_Magazine {
useAction = 0; // Disable the vanilla interaction
ace_explosives_placeable = 1; // Can be placed
ace_explosives_isSticky = 1; // 1 = Explosive can be attached to objects, also requires an attachable trigger
ace_explosives_setupObject = "banana_satchel_place"; // The object placed before the explosive is armed
class ACE_Triggers { // Trigger configurations
SupportedTriggers[] = {"Timer", "Command", "MK16_Transmitter", "DeadmanSwitch"}; // Triggers that can be used
Expand Down
Loading