Merge pull request #3936 from acemod/fixMineDetector

fix mine detector not picking up fused explosives
This commit is contained in:
Glowbal 2016-06-17 09:17:49 +02:00 committed by GitHub
commit a63f496bf6
11 changed files with 70 additions and 27 deletions

View File

@ -0,0 +1,30 @@
class CfgAmmo {
// seems to not get inherited
class Default;
class TimeBombCore: Default {
GVAR(detectable) = 1;
};
// these below do get inherited
class DirectionalBombCore;
class DirectionalBombBase: DirectionalBombCore {
GVAR(detectable) = 1;
};
class BoundingMineCore;
class BoundingMineBase: BoundingMineCore {
GVAR(detectable) = 1;
};
class MineCore;
class MineBase: MineCore {
GVAR(detectable) = 1;
};
class PipeBombCore;
class PipeBombBase: PipeBombCore {
GVAR(detectable) = 1;
};
};

View File

@ -42,7 +42,7 @@ class CfgVehicles {
class MineBase: Static {
GVAR(detectable) = 1;
};
// Zeus placed mines
class ModuleEmpty_F;
class ModuleMine_F: ModuleEmpty_F {

View File

@ -6,14 +6,14 @@
private _config = [_type] call FUNC(getDetectorConfig);
private _helperObject = "ACE_LogicDummy" createVehicleLocal (getPos _unit);
_unit setvariable [QGVAR(helperLogic), _helperObject];
_unit setVariable [QGVAR(helperLogic), _helperObject];
[FUNC(detectorLoop), 0.01, [_unit, _type, _config, CBA_missionTime, _helperObject]] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;
[QGVAR(detectorDisabled), {
params ["_unit", "_type"];
private _helperObject = _unit getvariable [QGVAR(helperLogic), objNull];
private _helperObject = _unit getVariable [QGVAR(helperLogic), objNull];
if !(isNull _helperObject) then {
deleteVehicle _helperObject;
};

View File

@ -5,6 +5,6 @@ ADDON = false;
#include "XEH_PREP.hpp"
// TODO load from config instead of hardcoded in sqf
GVAR(ALL_DETECTABLE_TYPES) = ["ACE_Explosive_Object", "ACE_Explosive_Helper", "ACE_Explosives_Place", "ModuleMine_F", "MineBase"];
GVAR(ALL_DETECTABLE_TYPES) = ["ACE_Explosive_Object", "ACE_Explosive_Helper", "ACE_Explosives_Place", "ModuleMine_F", "TimeBombCore", "MineBase", "DirectionalBombBase", "BoundingMineBase", "PipeBombBase"];
ADDON = true;

View File

@ -15,6 +15,7 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"
#include "CfgWeapons.hpp"
#include "CfgAmmo.hpp"
#include "CfgVehicles.hpp"
#include "CfgSounds.hpp"
#include "ACE_detector.hpp"

View File

@ -17,18 +17,18 @@
params ["_args", "_idPFH"];
_args params ["_unit", "_type", "_detectorConfig", "_lastPlayed"];
if !([_unit, _type] call FUNC(hasDetectorType)) exitwith {
if !([_unit, _type] call FUNC(hasDetectorType)) exitWith {
// disable detector type
[_unit, _type] call FUNC(disableDetector);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
if (!alive _unit) exitwith {
if (!alive _unit) exitWith {
[_unit, _type] call FUNC(disableDetector);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
if !([_unit, _type] call FUNC(isDetectorEnabled)) exitwith {
if !([_unit, _type] call FUNC(isDetectorEnabled)) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

View File

@ -19,6 +19,6 @@
params ["_unit", "_detectorType"];
_unit setvariable [format[QGVAR(enable_%1), _detectorType], false];
_unit setVariable [format[QGVAR(enable_%1), _detectorType], false];
[QGVAR(detectorDisabled), [_unit, _detectorType]] call CBA_fnc_localEvent;

View File

@ -19,6 +19,6 @@
params ["_unit", "_detectorType"];
_unit setvariable [format[QGVAR(enable_%1), _detectorType], true];
_unit setVariable [format[QGVAR(enable_%1), _detectorType], true];
[QGVAR(detectorEnabled), [_unit, _detectorType]] call CBA_fnc_localEvent;

View File

@ -27,10 +27,10 @@ private _direction = _unit weaponDirection "Put";
private _detectorPointAGL = _worldPosition vectorAdd (_direction vectorMultiply __DR);
private _mines = nearestObjects [_detectorPointAGL, _detectableTypes, _radius];
private _nearestObjects = nearestObjects [_detectorPointAGL, [], _radius];
#ifdef DEBUG_MODE_FULL
GVAR(debugDetector) = [_detectorPointAGL, _mines];
GVAR(debugDetector) = [_detectorPointAGL, _nearestObjects];
#endif
private _isDetectable = false;
@ -38,15 +38,27 @@ private _mine = objNull;
private _distance = -1;
{
//Try all mines in range and use first detectable one:
if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> QGVAR(detectable))) == 1) exitWith {
_isDetectable = true;
_mine = _x;
_distance = _detectorPointAGL distance _x;
};
nil
} count _mines;
private _object = _x;
TRACE_3("return",_isDetectable, _mine, _distance);
if ({_object isKindOf _x} count _detectableTypes > 0) then {
//Try all unprepared mines in range and use first detectable one:
if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> QGVAR(detectable))) == 1) exitWith {
_isDetectable = true;
_mine = _x;
_distance = _detectorPointAGL distance _x;
};
//Try all prepared mines in range and use first detectable one:
if ((getNumber (configFile >> "CfgAmmo" >> (typeOf _x) >> QGVAR(detectable))) == 1) exitWith {
_isDetectable = true;
_mine = _x;
_distance = _detectorPointAGL distance _x;
};
};
if (!isNull _mine) exitWith {};
} forEach _nearestObjects;
TRACE_3("return",_isDetectable,_mine,_distance);
[_isDetectable, _mine, _distance];

View File

@ -18,4 +18,4 @@
params ["_unit", "_detectorType"];
alive _unit && {(_unit getvariable [format[QGVAR(enable_%1), _detectorType], false])};
alive _unit && {(_unit getVariable [format[QGVAR(enable_%1), _detectorType], false])};

View File

@ -19,23 +19,23 @@
params ["_unit", "_detectorSound"];
if (isNull _unit) exitwith {
if (isNull _unit) exitWith {
ACE_LOGERROR_1("unit does not exist [%1]",_unit);
};
if (!alive _unit) exitwith {
if (!alive _unit) exitWith {
ACE_LOGERROR_1("unit is not alive [%1]",_unit);
};
private _helperObject = _unit getvariable [QGVAR(helperLogic), objNull];
private _helperObject = _unit getVariable [QGVAR(helperLogic), objNull];
if (!isNull _helperObject) then {
deleteVehicle _helperObject;
};
_helperObject = "ACE_LogicDummy" createVehicleLocal (getPos _unit);
if !(isNull _helperObject) then {
_helperObject attachto [_unit,[0,0,-3],""];
_unit setvariable [QGVAR(helperLogic), _helperObject];
_helperObject attachTo [_unit,[0,0,-3],""];
_unit setVariable [QGVAR(helperLogic), _helperObject];
[_helperObject, _unit] say3D _detectorSound;
} else {
ACE_LOGERROR_1("helper does not exist [%1]",_helperObject);