2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
2017-09-22 15:33:08 +00:00
|
|
|
* Places an explosive at the requested position.
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Position to place explosive <POSITION>
|
|
|
|
* 2: Rotation <NUMBER>
|
|
|
|
* 3: Magazine class <STRING>
|
2015-02-20 01:28:16 +00:00
|
|
|
* 4: Config of trigger <STRING>
|
2015-02-02 08:35:17 +00:00
|
|
|
* 5: Variables required for the trigger type <ARRAY>
|
2017-09-22 15:33:08 +00:00
|
|
|
* 6: Explosive placeholder <OBJECT> (default: objNull)
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Placed explosive <OBJECT>
|
|
|
|
*
|
|
|
|
* Example:
|
2017-09-22 15:33:08 +00:00
|
|
|
* _explosive = [player, player modelToWorldVisual [0,0.5, 0.1], 134, "SatchelCharge_Remote_Mag", "Command", []] call ace_explosives_fnc_placeExplosive
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-08-15 19:35:33 +00:00
|
|
|
|
|
|
|
params ["_unit", "_pos", "_dir", "_magazineClass", "_triggerConfig", "_triggerSpecificVars", ["_setupPlaceholderObject", objNull]];
|
|
|
|
TRACE_7("params",_unit,_pos,_dir,_magazineClass,_triggerConfig,_triggerSpecificVars,_setupPlaceholderObject);
|
|
|
|
|
2016-07-12 14:16:01 +00:00
|
|
|
[_unit, "PutDown"] call EFUNC(common,doGesture);
|
2015-05-19 18:29:23 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _attachedTo = objNull;
|
2015-04-29 04:57:11 +00:00
|
|
|
if (!isNull _setupPlaceholderObject) then {
|
|
|
|
_attachedTo = attachedTo _setupPlaceholderObject;
|
|
|
|
deleteVehicle _setupPlaceholderObject;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (isNil "_triggerConfig") exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR_1("Config not passed to PlaceExplosive: %1",_this);
|
2015-04-06 20:20:11 +00:00
|
|
|
objNull
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _magazineTrigger = ConfigFile >> "CfgMagazines" >> _magazineClass >> "ACE_Triggers" >> _triggerConfig;
|
2015-04-10 03:56:19 +00:00
|
|
|
_triggerConfig = ConfigFile >> "ACE_Triggers" >> _triggerConfig;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if (isNil "_triggerConfig") exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR_1("Config not found in PlaceExplosive: %1",_this);
|
2015-04-06 20:20:11 +00:00
|
|
|
objNull
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _ammo = getText(ConfigFile >> "CfgMagazines" >> _magazineClass >> "ammo");
|
2015-01-11 16:42:31 +00:00
|
|
|
if (isText(_magazineTrigger >> "ammo")) then {
|
2015-04-06 20:20:11 +00:00
|
|
|
_ammo = getText (_magazineTrigger >> "ammo");
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
_triggerSpecificVars pushBack _triggerConfig;
|
2015-03-31 21:20:32 +00:00
|
|
|
|
2015-08-16 06:51:44 +00:00
|
|
|
//Dig the explosive down into the ground (usually on "pressurePlate")
|
|
|
|
if (isNumber (_magazineTrigger >> "digDistance")) then {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _digDistance = getNumber (_magazineTrigger >> "digDistance");
|
2015-08-16 06:51:44 +00:00
|
|
|
|
|
|
|
//Get Surface Type:
|
2017-10-10 14:39:59 +00:00
|
|
|
private _canDigDown = true;
|
|
|
|
private _surfaceType = surfaceType _pos;
|
2015-08-16 06:51:44 +00:00
|
|
|
if ((_surfaceType select [0,1]) == "#") then {_surfaceType = _surfaceType select [1, 99];};
|
2015-11-30 16:23:02 +00:00
|
|
|
if ((_surfaceType != "") || {isClass (configFile >> "CfgSurfaces" >> _surfaceType >> "soundEnviron")}) then {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _soundEnviron = getText (configFile >> "CfgSurfaces" >> _surfaceType >> "soundEnviron");
|
2015-08-16 07:05:34 +00:00
|
|
|
TRACE_2("Dig Down Surface",_surfaceType,_soundEnviron);
|
2015-08-16 06:51:44 +00:00
|
|
|
_canDigDown = !(_soundEnviron in ["road", "tarmac", "concrete", "concrete_int", "int_concrete", "concrete_ext"]);
|
|
|
|
};
|
|
|
|
//Don't dig down if pos ATL is high (in a building or A2 road)
|
2015-08-16 07:05:34 +00:00
|
|
|
if (_canDigDown && {(_pos select 2) < 0.1}) then {
|
2015-08-16 06:51:44 +00:00
|
|
|
TRACE_2("Can Dig Down",_digDistance,_pos);
|
|
|
|
_pos = _pos vectorAdd [0,0, (-1 * _digDistance)];
|
|
|
|
} else {
|
|
|
|
TRACE_2("Can NOT Dig Down",_digDistance,_pos);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
|
2015-03-31 21:20:32 +00:00
|
|
|
_explosive setPosATL _pos;
|
2015-02-20 01:28:16 +00:00
|
|
|
|
2015-04-29 04:57:11 +00:00
|
|
|
if (!isNull _attachedTo) then {
|
|
|
|
TRACE_1("Attaching Live Explosive",_attachedTo);
|
|
|
|
_explosive attachTo [_attachedTo];
|
|
|
|
};
|
|
|
|
|
2015-08-16 06:51:44 +00:00
|
|
|
//If trigger has "onPlace" and it returns true, just exitWith the explosive
|
|
|
|
if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars] call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {
|
|
|
|
TRACE_1("onPlace returns true",_explosive);
|
|
|
|
_explosive
|
|
|
|
};
|
|
|
|
|
|
|
|
//TODO: placing explosives on hills looks funny
|
2015-08-05 17:22:43 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _pitch = getNumber (_magazineTrigger >> "pitch");
|
2015-08-05 17:22:43 +00:00
|
|
|
|
2016-01-01 20:47:39 +00:00
|
|
|
//Globaly set the position and angle:
|
2016-05-22 15:29:05 +00:00
|
|
|
[QGVAR(place), [_explosive, _dir, _pitch, _unit]] call CBA_fnc_globalEvent;
|
2015-08-05 17:22:43 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_explosive
|