mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3755 from acemod/add-mine-detector
Add mine detector port from ACE2
This commit is contained in:
commit
66450ad36a
1
addons/minedetector/$PBOPREFIX$
Normal file
1
addons/minedetector/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\minedetector
|
12
addons/minedetector/ACE_detector.hpp
Normal file
12
addons/minedetector/ACE_detector.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
class ACE_detector {
|
||||
class detectableObjects {
|
||||
};
|
||||
class detectors {
|
||||
class ACE_VMM3 {
|
||||
radius = 2.5;
|
||||
sounds[] = {"ace_detector_1", "ace_detector_2", "ace_detector_3", "ace_detector_4"};
|
||||
};
|
||||
class ACE_VMH3: ACE_VMM3 {
|
||||
};
|
||||
};
|
||||
};
|
10
addons/minedetector/CfgEventHandlers.hpp
Normal file
10
addons/minedetector/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
|
||||
};
|
||||
};
|
22
addons/minedetector/CfgSounds.hpp
Normal file
22
addons/minedetector/CfgSounds.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
class CfgSounds {
|
||||
class ace_detector_1 {
|
||||
name = "ace_detector_1";
|
||||
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wav)), "db+1", 1};
|
||||
titles[] = {};
|
||||
};
|
||||
class ace_detector_2 {
|
||||
name = "ace_detector_2";
|
||||
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wav)), "db+1", 0.9};
|
||||
titles[] = {};
|
||||
};
|
||||
class ace_detector_3 {
|
||||
name = "ace_detector_3";
|
||||
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wav)), "db+1", 0.8};
|
||||
titles[] = {};
|
||||
};
|
||||
class ace_detector_4 {
|
||||
name = "ace_detector_4";
|
||||
sound[] = {QUOTE(PATHTOF(sounds\metal_detector.wav)), "db+1", 0.7};
|
||||
titles[] = {};
|
||||
};
|
||||
};
|
51
addons/minedetector/CfgVehicles.hpp
Normal file
51
addons/minedetector/CfgVehicles.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
class CfgVehicles {
|
||||
class Box_NATO_Support_F;
|
||||
class ACE_Box_Misc: Box_NATO_Support_F {
|
||||
class TransportItems {
|
||||
MACRO_ADDITEM(ACE_VMM3,4);
|
||||
MACRO_ADDITEM(ACE_VMH3,4);
|
||||
};
|
||||
};
|
||||
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class GVAR(activate) {
|
||||
displayName = CSTRING(ActivateDetector);
|
||||
condition = QUOTE(call FUNC(canActivateDetector));
|
||||
statement = QUOTE(call FUNC(activateDetector));
|
||||
showDisabled = 0;
|
||||
priority = 0.1;
|
||||
icon = ""; // TODO add icon
|
||||
exceptions[] = {};
|
||||
};
|
||||
class GVAR(deactivate) {
|
||||
displayName = CSTRING(DeactivateDetector);
|
||||
condition = QUOTE(call FUNC(canDeactivateDetector));
|
||||
statement = QUOTE(call FUNC(deactivateDetector));
|
||||
showDisabled = 0;
|
||||
priority = 0.1;
|
||||
icon = ""; // TODO add icon
|
||||
exceptions[] = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
class Items_base_F;
|
||||
class ACE_Explosives_Place: Items_base_F {
|
||||
GVAR(detectable) = 1;
|
||||
};
|
||||
|
||||
// Editor placed mines
|
||||
class Static;
|
||||
class MineBase: Static {
|
||||
GVAR(detectable) = 1;
|
||||
};
|
||||
|
||||
// Zeus placed mines
|
||||
class ModuleEmpty_F;
|
||||
class ModuleMine_F: ModuleEmpty_F {
|
||||
GVAR(detectable) = 1;
|
||||
};
|
||||
};
|
50
addons/minedetector/CfgWeapons.hpp
Normal file
50
addons/minedetector/CfgWeapons.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
class Mode_SemiAuto;
|
||||
|
||||
class CfgWeapons {
|
||||
class Pistol;
|
||||
class Pistol_Base_F: Pistol {
|
||||
class WeaponSlotsInfo;
|
||||
};
|
||||
class ACE_VMM3: Pistol_Base_F {
|
||||
scope = 2;
|
||||
author = ECSTRING(common,ACETeam);
|
||||
displayName = "VMM3";
|
||||
descriptionShort = CSTRING(VMM3_Description);
|
||||
model = QUOTE(PATHTOF(ace_wallon_vmm3.p3d));
|
||||
picture = QUOTE(PATHTOF(data\equip\w_vmm3_ca.paa));
|
||||
magazines[] = { };
|
||||
modes[] = { "Single" };
|
||||
class Single: Mode_SemiAuto {
|
||||
displayName = "";
|
||||
sounds[] = {};
|
||||
begin1[] = { "", 1.77828, 1, 1000 };
|
||||
soundBegin[] = { "begin1", 1 };
|
||||
reloadTime = 0.075;
|
||||
recoil = "recoil_pistol_light";
|
||||
recoilProne = "recoil_prone_pistol_light";
|
||||
dispersion = 0.001;
|
||||
minRange = 2;
|
||||
minRangeProbab = 0.3;
|
||||
midRange = 250;
|
||||
midRangeProbab = 0.7;
|
||||
maxRange = 400;
|
||||
maxRangeProbab = 0.05;
|
||||
};
|
||||
class WeaponSlotsInfo: WeaponSlotsInfo {
|
||||
holsterScale = 0;
|
||||
mass = 77;
|
||||
class CowsSlot {};
|
||||
class MuzzleSlot {};
|
||||
};
|
||||
};
|
||||
class ACE_VMH3: ACE_VMM3 {
|
||||
scope = 2;
|
||||
displayName = "VMH3";
|
||||
author = ECSTRING(common,ACETeam);
|
||||
model = QUOTE(PATHTOF(ace_wallon_vmh3.p3d));
|
||||
picture = QUOTE(PATHTOF(data\equip\w_vmh3_ca.paa));
|
||||
class WeaponSlotsInfo: WeaponSlotsInfo {
|
||||
mass = 55;
|
||||
};
|
||||
};
|
||||
};
|
11
addons/minedetector/README.md
Normal file
11
addons/minedetector/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
ace_minedetector
|
||||
===========
|
||||
|
||||
Add mine detectors
|
||||
|
||||
## Maintainers
|
||||
|
||||
The people responsible for merging changes to this component or answering potential questions.
|
||||
|
||||
- [Glowbal](https://github.com/Glowbal)
|
||||
- [Grey](https://github.com/Grey-Soldierman)
|
13
addons/minedetector/XEH_PREP.hpp
Normal file
13
addons/minedetector/XEH_PREP.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
PREP(canActivateDetector);
|
||||
PREP(canDeactivateDetector);
|
||||
PREP(activateDetector);
|
||||
PREP(deactivateDetector);
|
||||
PREP(hasDetector);
|
||||
PREP(detectorLoop);
|
||||
PREP(disableDetector);
|
||||
PREP(enableDetector);
|
||||
PREP(getDetectedObject);
|
||||
PREP(isDetectorEnabled);
|
||||
PREP(playDetectorSound);
|
||||
PREP(getDetectorConfig);
|
40
addons/minedetector/XEH_clientInit.sqf
Normal file
40
addons/minedetector/XEH_clientInit.sqf
Normal file
@ -0,0 +1,40 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
||||
[QGVAR(detectorEnabled), {
|
||||
params ["_unit", "_type"];
|
||||
private _config = [_type] call FUNC(getDetectorConfig);
|
||||
|
||||
private _helperObject = "ACE_LogicDummy" createVehicleLocal (getPos _unit);
|
||||
_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];
|
||||
if !(isNull _helperObject) then {
|
||||
deleteVehicle _helperObject;
|
||||
};
|
||||
}] call CBA_fnc_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
|
10
addons/minedetector/XEH_preInit.sqf
Normal file
10
addons/minedetector/XEH_preInit.sqf
Normal file
@ -0,0 +1,10 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
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"];
|
||||
|
||||
ADDON = true;
|
BIN
addons/minedetector/ace_wallon_vmh3.p3d
Normal file
BIN
addons/minedetector/ace_wallon_vmh3.p3d
Normal file
Binary file not shown.
BIN
addons/minedetector/ace_wallon_vmm3.p3d
Normal file
BIN
addons/minedetector/ace_wallon_vmm3.p3d
Normal file
Binary file not shown.
20
addons/minedetector/config.cpp
Normal file
20
addons/minedetector/config.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
units[] = {};
|
||||
weapons[] = {"ACE_VMH3","ACE_VMM3"};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_explosives"};
|
||||
author = ECSTRING(common,ACETeam);
|
||||
authors[] = {"Grey", "Glowbal", "Rocko"};
|
||||
url = ECSTRING(main,URL);
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgSounds.hpp"
|
||||
#include "ACE_detector.hpp"
|
92
addons/minedetector/data/ace_vmh3.rvmat
Normal file
92
addons/minedetector/data/ace_vmh3.rvmat
Normal file
@ -0,0 +1,92 @@
|
||||
ambient[] = {1.0, 1.0, 1.0, 1.0};
|
||||
diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
||||
forcedDiffuse[] = {0.0, 0.0, 0.0, 0.0};
|
||||
emmisive[] = {0.0, 0.0, 0.0, 1.0};
|
||||
specular[] = {0.93, 0.93, 0.93, 1.0};
|
||||
specularPower = 200.0;
|
||||
PixelShaderID = "Super";
|
||||
VertexShaderID = "Super";
|
||||
|
||||
class Stage1 {
|
||||
texture="z\ace\addons\minedetector\data\ace_vmh3_nohq.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage2 {
|
||||
texture = "a3\weapons_f\data\detailmaps\metal_detail_dt.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {6.0, 0.0, 0.0};
|
||||
up[] = {0.0, 3.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage3 {
|
||||
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage4 {
|
||||
texture = "#(argb,8,8,3)color(1,0,0,1,AS)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage5 {
|
||||
texture="z\ace\addons\minedetector\data\ace_vmh3_smdi.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage6 {
|
||||
texture = "#(ai,64,64,1)fresnel(1.29,0.5)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage7 {
|
||||
texture = "a3\data_f\env_land_co.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
BIN
addons/minedetector/data/ace_vmh3_co.paa
Normal file
BIN
addons/minedetector/data/ace_vmh3_co.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/ace_vmh3_nohq.paa
Normal file
BIN
addons/minedetector/data/ace_vmh3_nohq.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/ace_vmh3_smdi.paa
Normal file
BIN
addons/minedetector/data/ace_vmh3_smdi.paa
Normal file
Binary file not shown.
92
addons/minedetector/data/ace_vmm3.rvmat
Normal file
92
addons/minedetector/data/ace_vmm3.rvmat
Normal file
@ -0,0 +1,92 @@
|
||||
ambient[] = {1.0, 1.0, 1.0, 1.0};
|
||||
diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
||||
forcedDiffuse[] = {0.0, 0.0, 0.0, 0.0};
|
||||
emmisive[] = {0.0, 0.0, 0.0, 1.0};
|
||||
specular[] = {0.93, 0.93, 0.93, 1.0};
|
||||
specularPower = 200.0;
|
||||
PixelShaderID = "Super";
|
||||
VertexShaderID = "Super";
|
||||
|
||||
class Stage1 {
|
||||
texture="z\ace\addons\minedetector\data\ace_vmm3_nohq.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage2 {
|
||||
texture = "a3\weapons_f\data\detailmaps\metal_detail_dt.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {6.0, 0.0, 0.0};
|
||||
up[] = {0.0, 3.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage3 {
|
||||
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage4 {
|
||||
texture = "#(argb,8,8,3)color(1,0,0,1,AS)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage5 {
|
||||
texture="z\ace\addons\minedetector\data\ace_vmm3_smdi.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage6 {
|
||||
texture = "#(ai,64,64,1)fresnel(1.29,0.5)";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
||||
|
||||
class Stage7 {
|
||||
texture = "a3\data_f\env_land_co.paa";
|
||||
uvSource = "tex";
|
||||
|
||||
class uvTransform {
|
||||
aside[] = {1.0, 0.0, 0.0};
|
||||
up[] = {0.0, 1.0, 0.0};
|
||||
dir[] = {0.0, 0.0, 0.0};
|
||||
pos[] = {0.0, 0.0, 0.0};
|
||||
};
|
||||
};
|
BIN
addons/minedetector/data/ace_vmm3_co.paa
Normal file
BIN
addons/minedetector/data/ace_vmm3_co.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/ace_vmm3_nohq.paa
Normal file
BIN
addons/minedetector/data/ace_vmm3_nohq.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/ace_vmm3_smdi.paa
Normal file
BIN
addons/minedetector/data/ace_vmm3_smdi.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/equip/w_vmh3_ca.paa
Normal file
BIN
addons/minedetector/data/equip/w_vmh3_ca.paa
Normal file
Binary file not shown.
BIN
addons/minedetector/data/equip/w_vmm3_ca.paa
Normal file
BIN
addons/minedetector/data/equip/w_vmm3_ca.paa
Normal file
Binary file not shown.
21
addons/minedetector/functions/fnc_activateDetector.sqf
Normal file
21
addons/minedetector/functions/fnc_activateDetector.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Activate the mine detector
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_minedetector_fnc_activateDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (call FUNC(canActivateDetector)) then {
|
||||
[ACE_player, currentWeapon ACE_player] call FUNC(enableDetector);
|
||||
};
|
19
addons/minedetector/functions/fnc_canActivateDetector.sqf
Normal file
19
addons/minedetector/functions/fnc_canActivateDetector.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if the mine detector can be activated
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Can be activated <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_minedetector_fnc_canActivateDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
([ACE_player] call FUNC(hasDetector)) && !([ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled));
|
19
addons/minedetector/functions/fnc_canDeactivateDetector.sqf
Normal file
19
addons/minedetector/functions/fnc_canDeactivateDetector.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if the mine detector can be deactivated
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Can be deactivated <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_minedetector_fnc_canDeactivateDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
([ACE_player] call FUNC(hasDetector)) && {[ACE_player, currentWeapon ACE_player] call FUNC(isDetectorEnabled)};
|
21
addons/minedetector/functions/fnc_deactivateDetector.sqf
Normal file
21
addons/minedetector/functions/fnc_deactivateDetector.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Deactivate the mine detector
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_minedetector_fnc_deactivateDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (call FUNC(canDeactivateDetector)) then {
|
||||
[ACE_player, currentWeapon ACE_player] call FUNC(disableDetector);
|
||||
};
|
55
addons/minedetector/functions/fnc_detectorLoop.sqf
Normal file
55
addons/minedetector/functions/fnc_detectorLoop.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Handle mine detection in a PFH loop
|
||||
*
|
||||
* Arguments:
|
||||
* 0: args <ARRAY>
|
||||
* 1: PHD Id <PFH_ID>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit", "_type", "_detectorConfig", "_lastPlayed"];
|
||||
|
||||
if !([_unit, _type] call FUNC(hasDetectorType)) exitwith {
|
||||
// disable detector type
|
||||
[_unit, _type] call FUNC(disableDetector);
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
if (!alive _unit) exitwith {
|
||||
[_unit, _type] call FUNC(disableDetector);
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
if !([_unit, _type] call FUNC(isDetectorEnabled)) exitwith {
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
if (ACE_player == _unit && {currentWeapon _unit == _type}) then {
|
||||
private _detected = [_unit, _detectorConfig] call FUNC(getDetectedObject);
|
||||
_detected params ["_hasDetected", "_object", "_distance"];
|
||||
private _distanceTiming = switch (true) do {
|
||||
case (_distance >= 2): {1};
|
||||
case (_distance >= 1.25): {0.85};
|
||||
case (_distance >= 0.75): {0.7};
|
||||
default {0.5};
|
||||
};
|
||||
if (_hasDetected && {(CBA_missionTime - _lastPlayed > _distanceTiming)}) then {
|
||||
_args set [3, CBA_missionTime];
|
||||
_detectorConfig params ["_type", "_radius", "_detectableTypes", "_sounds"];
|
||||
private _sound = switch (true) do {
|
||||
case (_distance >= 2): {_sounds select 3};
|
||||
case (_distance >= 1.25): {_sounds select 2};
|
||||
case (_distance >= 0.5): {_sounds select 1};
|
||||
default {_sounds select 0};
|
||||
};
|
||||
[_unit, _sound, true] call FUNC(playDetectorSound);
|
||||
};
|
||||
};
|
24
addons/minedetector/functions/fnc_disableDetector.sqf
Normal file
24
addons/minedetector/functions/fnc_disableDetector.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Disables the mine detector
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: detecter type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [UNIT, DETECTOR_CLASS_NAME] call ace_minedetector_fnc_disableDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_detectorType"];
|
||||
|
||||
_unit setvariable [format[QGVAR(enable_%1), _detectorType], false];
|
||||
|
||||
[QGVAR(detectorDisabled), [_unit, _detectorType]] call CBA_fnc_localEvent;
|
24
addons/minedetector/functions/fnc_enableDetector.sqf
Normal file
24
addons/minedetector/functions/fnc_enableDetector.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Enables the mine detector
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: detecter type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [UNIT, DETECTOR_CLASS_NAME] call ace_minedetector_fnc_enableDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_detectorType"];
|
||||
|
||||
_unit setvariable [format[QGVAR(enable_%1), _detectorType], true];
|
||||
|
||||
[QGVAR(detectorEnabled), [_unit, _detectorType]] call CBA_fnc_localEvent;
|
52
addons/minedetector/functions/fnc_getDetectedObject.sqf
Normal file
52
addons/minedetector/functions/fnc_getDetectedObject.sqf
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Enables the mine detector
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Configuration <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* [isDetected <BOOL>, mine <OBJECT>, distance <NUMBER>] <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [ace_player, DETECTOR_CONFIG] call ace_minedetector_fnc_getDetectedObject
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#define __DR 1.3
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_detectorConfig"];
|
||||
_detectorConfig params ["_type", "_radius", "_detectableTypes", "_sounds"];
|
||||
|
||||
private _worldPosition = _unit modelToWorld (_unit selectionPosition "granat");
|
||||
private _direction = _unit weaponDirection "Put";
|
||||
|
||||
private _detectorPointAGL = _worldPosition vectorAdd (_direction vectorMultiply __DR);
|
||||
|
||||
private _mines = nearestObjects [_detectorPointAGL, _detectableTypes, _radius];
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
GVAR(debugDetector) = [_detectorPointAGL, _mines];
|
||||
#endif
|
||||
|
||||
private _isDetectable = false;
|
||||
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;
|
||||
|
||||
TRACE_3("return",_isDetectable, _mine, _distance);
|
||||
|
||||
[_isDetectable, _mine, _distance];
|
31
addons/minedetector/functions/fnc_getDetectorConfig.sqf
Normal file
31
addons/minedetector/functions/fnc_getDetectorConfig.sqf
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Get the mine detector configuration from the config file
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Detector class name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Detector configuration or empty array if invalid <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* ["my_detector"] call ace_minedetector_fnc_getDetectorConfig
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_detectorType"];
|
||||
|
||||
private _config = (configFile >> "ACE_detector" >> "detectors" >> _detectorType);
|
||||
if (isClass _config) then {
|
||||
[
|
||||
_detectorType,
|
||||
getNumber (_config >> "radius"),
|
||||
GVAR(ALL_DETECTABLE_TYPES), // TODO read from config and use this as a back up value instead
|
||||
getArray (_config >> "sounds")
|
||||
];
|
||||
} else {
|
||||
[];
|
||||
};
|
21
addons/minedetector/functions/fnc_hasDetector.sqf
Normal file
21
addons/minedetector/functions/fnc_hasDetector.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if unit has a mine detector in hands
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Current weapon is a mine detector <BOOLEAN>
|
||||
*
|
||||
* Example:
|
||||
* [ace_player] call ace_minedetector_fnc_hasDetector
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
!(([currentWeapon _unit] call FUNC(getDetectorConfig)) isEqualTo []);
|
21
addons/minedetector/functions/fnc_isDetectorEnabled.sqf
Normal file
21
addons/minedetector/functions/fnc_isDetectorEnabled.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Check if the mine detector is enabled
|
||||
*
|
||||
* Arguments:
|
||||
* 0: detecter type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* ["example"] call ace_minedetector_fnc_[functionName]
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_detectorType"];
|
||||
|
||||
alive _unit && {(_unit getvariable [format[QGVAR(enable_%1), _detectorType], false])};
|
42
addons/minedetector/functions/fnc_playDetectorSound.sqf
Normal file
42
addons/minedetector/functions/fnc_playDetectorSound.sqf
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Play the detector sound
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Sound class name <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, "ace_buzz_1"] call ace_minedetector_fnc_playDetectorSound
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit", "_detectorSound"];
|
||||
|
||||
if (isNull _unit) exitwith {
|
||||
ACE_LOGERROR_1("unit does not exist [%1]",_unit);
|
||||
};
|
||||
if (!alive _unit) exitwith {
|
||||
ACE_LOGERROR_1("unit is not alive [%1]",_unit);
|
||||
};
|
||||
|
||||
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, _unit] say3D _detectorSound;
|
||||
} else {
|
||||
ACE_LOGERROR_1("helper does not exist [%1]",_helperObject);
|
||||
};
|
1
addons/minedetector/functions/script_component.hpp
Normal file
1
addons/minedetector/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\minedetector\script_component.hpp"
|
12
addons/minedetector/script_component.hpp
Normal file
12
addons/minedetector/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#define COMPONENT minedetector
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_MINEDETECTOR
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_MINEDETECTOR
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_MINEDETECTOR
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
BIN
addons/minedetector/sounds/metal_detector.wav
Normal file
BIN
addons/minedetector/sounds/metal_detector.wav
Normal file
Binary file not shown.
14
addons/minedetector/stringtable.xml
Normal file
14
addons/minedetector/stringtable.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="MineDetector">
|
||||
<Key ID="STR_ACE_MineDetector_VMM3_Description">
|
||||
<English>Metal detector</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