mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge remote-tracking branch 'refs/remotes/origin/add-mine-detector'
Conflicts: addons/minedetector/functions/fnc_detectorLoop.sqf
This commit is contained in:
commit
7ba02a21ec
@ -12,7 +12,7 @@ class CfgVehicles {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class GVAR(activate) {
|
||||
displayName = "Activate Detector";
|
||||
displayName = CSTRING(ActivateDetector);
|
||||
condition = QUOTE(call FUNC(canActivateDetector));
|
||||
statement = QUOTE(call FUNC(activateDetector));
|
||||
showDisabled = 0;
|
||||
@ -21,7 +21,7 @@ class CfgVehicles {
|
||||
exceptions[] = {};
|
||||
};
|
||||
class GVAR(deactivate) {
|
||||
displayName = "Deactivate Detector";
|
||||
displayName = CSTRING(DeactivateDetector);
|
||||
condition = QUOTE(call FUNC(canDeactivateDetector));
|
||||
statement = QUOTE(call FUNC(deactivateDetector));
|
||||
showDisabled = 0;
|
||||
|
@ -18,3 +18,23 @@
|
||||
deleteVehicle _helperObject;
|
||||
};
|
||||
}] call EFUNC(common,addEventhandler);
|
||||
|
||||
|
||||
|
||||
//Shows detector and mine posistions in 3d when debug is on
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(debugDetector) = [];
|
||||
addMissionEventHandler ["Draw3D", {
|
||||
if (GVAR(debugDetector) isEqualTo []) exitWith {};
|
||||
GVAR(debugDetector) params ["_detectorPointAGL", "_mines"];
|
||||
drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", [0,0,1,1], _detectorPointAGL, 1, 1, 0, "detector", 1, 0.02, "PuristaMedium"];
|
||||
{
|
||||
_name = format ["%1@%2", typeOf _x, (floor ((_x distance _detectorPointAGL) * 10)) / 10];
|
||||
if ((getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> QGVAR(detectable))) == 1) then {
|
||||
drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", [1,0,0,1], (ASLtoAGL (getPosASL _x)), 1, 1, 0, _name, 1, 0.02, "PuristaMedium"];
|
||||
} else {
|
||||
drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", [1,1,0,1], (ASLtoAGL (getPosASL _x)), 1, 1, 0, _name, 1, 0.02, "PuristaMedium"];
|
||||
};
|
||||
} forEach _mines;
|
||||
}];
|
||||
#endif
|
||||
|
@ -16,4 +16,4 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
([ACE_player] call FUNC(hasDetector)) && ([ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled));
|
||||
([ACE_player] call FUNC(hasDetector)) && {[ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled)};
|
||||
|
@ -41,7 +41,7 @@ if (ACE_player == _unit && {currentWeapon _unit == _type}) then {
|
||||
case (_distance >= 0.75): {0.7};
|
||||
default {0.5};
|
||||
};
|
||||
if (_hasDetected && (ACE_time - _lastPlayed > _distanceTiming)) then {
|
||||
if (_hasDetected && {(ACE_time - _lastPlayed > _distanceTiming)}) then {
|
||||
_args set [3, ACE_time];
|
||||
_detectorConfig params ["_type", "_radius", "_detectableTypes", "_sounds"];
|
||||
private _sound = switch (true) do {
|
||||
|
@ -25,20 +25,28 @@ _detectorConfig params ["_type", "_radius", "_detectableTypes", "_sounds"];
|
||||
private _worldPosition = _unit modelToWorld (_unit selectionPosition "granat");
|
||||
private _direction = _unit weaponDirection "Put";
|
||||
|
||||
_worldPosition params ["_posX", "_posY", "_posZ"];
|
||||
_direction params ["_dirX", "_dirY", "_dirZ"];
|
||||
private _detectorPointAGL = _worldPosition vectorAdd (_direction vectorMultiply __DR);
|
||||
|
||||
private _dPnt = [_posX + __DR * _dirX, _posY + __DR * _dirY, _posZ + __DR * _dirZ];
|
||||
private _mines = nearestObjects [_detectorPointAGL, _detectableTypes, _radius];
|
||||
|
||||
private _mines = nearestObjects [_dPnt, _detectableTypes, _radius];
|
||||
if (_mines isEqualTo []) exitwith {
|
||||
[false, objNull, -1];
|
||||
};
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(debugDetector) = [_detectorPointAGL, _mines];
|
||||
#endif
|
||||
|
||||
// guaranteed to have at least one element. Lets get the first
|
||||
private _mine = _mines select 0;
|
||||
private _distance = _dPnt distance _mine;
|
||||
private _isDetectable = false;
|
||||
private _mine = objNull;
|
||||
private _distance = -1;
|
||||
|
||||
private _isDetectable = getNumber (configFile >> "CfgVehicles" >> typeOf _mine >> QGVAR(detectable));
|
||||
{
|
||||
//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;
|
||||
|
||||
[(_isDetectable > 0), _mine, _distance];
|
||||
TRACE_3("return",_isDetectable, _mine, _distance);
|
||||
|
||||
[_isDetectable, _mine, _distance];
|
||||
|
@ -10,7 +10,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* ["example"] call ace_minedetector_fnc_playDetectorSound
|
||||
* [player, "ace_buzz_1"] call ace_minedetector_fnc_playDetectorSound
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -19,9 +19,11 @@
|
||||
|
||||
params ["_unit", "_detectorSound"];
|
||||
|
||||
if (isNull _unit) exitwith {}; // TODO log error - unit does not exist
|
||||
if (isNull _unit) exitwith {
|
||||
ACE_LOGERROR_1("unit does not exist [%1]",_unit);
|
||||
};
|
||||
if (!alive _unit) exitwith {
|
||||
// log error, unit is not alive
|
||||
ACE_LOGERROR_1("unit is not alive [%1]",_unit);
|
||||
};
|
||||
|
||||
private _helperObject = _unit getvariable [QGVAR(helperLogic), objNull];
|
||||
@ -33,4 +35,6 @@ _helperObject = "ACE_LogicDummy" createVehicleLocal (getPos _unit);
|
||||
if !(isNull _helperObject) then {
|
||||
_helperObject attachto [_unit,[0,0,-3],""];
|
||||
[_helperObject, _unit] say3D _detectorSound;
|
||||
} else {
|
||||
ACE_LOGERROR_1("helper does not exist [%1]",_helperObject);
|
||||
};
|
||||
|
@ -4,5 +4,11 @@
|
||||
<Key ID="STR_ACE_MineDetector_">
|
||||
<English>Vallon</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_MineDetector_ActivateDetector">
|
||||
<English>Activate Detector</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_MineDetector_DeactivateDetector">
|
||||
<English>Deactivate Detector</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user