SetPosition Event - Fix digging down (#1991)

This commit is contained in:
PabstMirror 2015-08-16 01:51:44 -05:00
parent fc6cd34d33
commit b9638f749b
8 changed files with 46 additions and 14 deletions

View File

@ -38,7 +38,7 @@ onSetup parameters:
isAttachable = 0;
displayName = CSTRING(PressurePlate);
picture = PATHTOF(Data\UI\PressurePlate.paa);
onPlace = "_dist=GetNumber(ConfigFile >> 'CfgMagazines' >> (_this select 2) >> 'ACE_Triggers' >> 'PressurePlate' >> 'digDistance');_ex=_this select 1;_ex setPosATL ((getPosATL _ex) vectorDiff ((VectorUp _ex) vectorCrossProduct [0,0,_dist]));false";
onPlace = QUOTE(false);
};
class IRSensor {
isAttachable = 0;

View File

@ -8,7 +8,7 @@ class CfgMagazines {
class ACE_Triggers {
SupportedTriggers[] = {"PressurePlate"};
class PressurePlate {
digDistance = 0.1;
digDistance = 0.06;
};
};
};
@ -17,7 +17,7 @@ class CfgMagazines {
class ACE_Triggers {
SupportedTriggers[] = {"PressurePlate"};
class PressurePlate {
digDistance = 0.075;
digDistance = 0.08;
};
};
};
@ -26,7 +26,7 @@ class CfgMagazines {
class ACE_Triggers {
SupportedTriggers[] = {"PressurePlate"};
class PressurePlate {
digDistance = 0.05;
digDistance = 0.025;
};
};
};

View File

@ -15,6 +15,9 @@
*/
#include "script_component.hpp"
//Event for setting explosive placement angle/pitch:
[QGVAR(place), {_this call FUNC(setPosition)}] call EFUNC(common,addEventHandler);
//When getting knocked out in medical, trigger deadman explosives:
//Event is global, only run on server (ref: ace_medical_fnc_setUnconscious)
if (isServer) then {

View File

@ -25,7 +25,7 @@
params ["_unit", "_pos", "_dir", "_magazineClass", "_triggerConfig", "_triggerSpecificVars", ["_setupPlaceholderObject", objNull]];
TRACE_7("params",_unit,_pos,_dir,_magazineClass,_triggerConfig,_triggerSpecificVars,_setupPlaceholderObject);
private ["_ammo", "_explosive", "_attachedTo", "_magazineTrigger"];
private ["_ammo", "_explosive", "_attachedTo", "_magazineTrigger", "_pitch", "_digDistance", "_canDigDown", "_soundEnviron", "_surfaceType"];
_unit playActionNow "PutDown";
@ -54,6 +54,27 @@ if (isText(_magazineTrigger >> "ammo")) then {
};
_triggerSpecificVars pushBack _triggerConfig;
//Dig the explosive down into the ground (usually on "pressurePlate")
if (isNumber (_magazineTrigger >> "digDistance")) then {
_digDistance = getNumber (_magazineTrigger >> "digDistance");
//Get Surface Type:
_canDigDown = true;
_surfaceType = surfaceType _pos;
if ((_surfaceType select [0,1]) == "#") then {_surfaceType = _surfaceType select [1, 99];};
if ((_surfaceType != "") || {isClass (configfile >> "CfgSurfaces" >> _surfaceType >> "soundEnviron")}) then {
_soundEnviron = (configfile >> "CfgSurfaces" >> _surfaceType >> "soundEnviron");
_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)
if (_canDigDown && {(_pos select 2) > 0.1}) then {
TRACE_2("Can Dig Down",_digDistance,_pos);
_pos = _pos vectorAdd [0,0, (-1 * _digDistance)];
} else {
TRACE_2("Can NOT Dig Down",_digDistance,_pos);
};
};
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
_explosive setPosATL _pos;
@ -62,10 +83,17 @@ if (!isNull _attachedTo) then {
_explosive attachTo [_attachedTo];
};
if (isText(_triggerConfig >> "onPlace") && {[_unit,_explosive,_magazineClass,_triggerSpecificVars]
call compile (getText (_triggerConfig >> "onPlace"))}) exitWith {_explosive};
//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
[[_explosive, _dir, getNumber (_magazineTrigger >> "pitch")], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc);
_pitch = getNumber (_magazineTrigger >> "pitch");
//Globaly set the position angle:
[QGVAR(place), [_explosive, _dir, _pitch]] call EFUNC(common,globalEvent);
_explosive

View File

@ -25,6 +25,8 @@ private ["_config"];
_config = ConfigFile >> "ACE_Triggers" >> _trigger;
// If the onSetup function returns true, it is handled elsewhere
if (isText(_config >> "onSetup") && {[_explosive,_magazine] call compile getText (_config >> "onSetup")}) exitWith {};
if (isText(_config >> "onSetup") && {[_explosive,_magazine] call compile getText (_config >> "onSetup")}) exitWith {
TRACE_2("onSetup returned true",_explosive,_trigger);
};
[ACE_player, getPosATL _explosive, _explosive getVariable [QGVAR(Direction), 0],_magazine, _trigger, [], _explosive] call FUNC(placeExplosive);

View File

@ -13,7 +13,7 @@
* Example:
* [_explosive, 150, 90] call ACE_Explosives_fnc_setPosition;
*
* Public: Yes
* Public: No
*/
#include "script_component.hpp"
@ -26,7 +26,6 @@ if (isNull (attachedTo _explosive)) then {
[_explosive, _pitch, 0] call CALLSTACK(BIS_fnc_setPitchBank);
};
} else {
//Attaching to a vehicle (dirAndUp based on vehicle)
_explosive setVectorDirAndUp [[0,0,1],[(sin _direction),(cos _direction),0]];
};

View File

@ -15,7 +15,7 @@
*
* Public: Yes
*/
#define ENABLE_PERFORMANCE_COUNTERS
// #define ENABLE_PERFORMANCE_COUNTERS
#include "script_component.hpp"
#define PLACE_RANGE_MAX 1