diff --git a/.hemtt/project.toml b/.hemtt/project.toml index 258b8ee..9c2563b 100644 --- a/.hemtt/project.toml +++ b/.hemtt/project.toml @@ -1,4 +1,5 @@ name = "BW_Waffenkammer" +mainprefix = "" prefix = "pbw" author = "Herr_KaLeun, Lemonberries, Timi007" @@ -22,3 +23,9 @@ preset = "Hemtt" [hemtt.release] folder = "BW_Waffenkammer" + +[hemtt.launch.default] +workshop = [ + "450814997", # CBA_A3's Workshop ID + "463939057" # ACE3's Workshop ID +] diff --git a/.vscode/settings.json b/.vscode/settings.json index ce71ff4..7d7dea9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,13 +12,8 @@ "**/release": true, }, "files.associations": { - "**/*.hpp": "ext", - // "**/*.hpp": "cpp", - "**/*.cpp": "ext", "**/XEH_PREP.hpp": "sqf", "*.rpt": "log", "init*.hpp": "sqf", }, - "sqf.enableACE3": true, - "sqf.enableCBA": true, } diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 26891d2..e6148e4 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -1,5 +1,5 @@ #include "script_version.hpp" -#define REQUIRED_VERSION 2.06 +#define REQUIRED_VERSION 2.18 #define REQUIRED_CBA_VERSION {3,18,1} #define REQUIRED_ACE_VERSION {3,19,0} diff --git a/addons/mines/CfgAmmo.hpp b/addons/mines/CfgAmmo.hpp index 57b7fe3..9e07c6f 100644 --- a/addons/mines/CfgAmmo.hpp +++ b/addons/mines/CfgAmmo.hpp @@ -16,8 +16,8 @@ class CfgAmmo { submunitionParentSpeedCoef = 0; triggerOnImpact = 1; deleteParentWhenTriggered = 0; - - model = "\A3\Weapons_F_Tank\Launchers\MRAWS\rocket_MRAWS_HEAT_F"; + + model = "\A3\Weapons_F_Tank\Launchers\MRAWS\rocket_MRAWS_HEAT_F.p3d"; hit = 2; indirectHit = 15; indirectHitRange = 4; @@ -41,11 +41,11 @@ class CfgAmmo { timeToLive = 6; maneuvrability = 0; allowAgainstInfantry = 0; - soundHit1[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_01",2.5118864,1,1800}; - soundHit2[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_02",2.5118864,1,1800}; - soundHit3[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_03",2.5118864,1,1800}; + soundHit1[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_01.wss",2.5118864,1,1800}; + soundHit2[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_02.wss",2.5118864,1,1800}; + soundHit3[] = {"A3\Sounds_F\arsenal\weapons\Launchers\Titan\Explosion_titan_missile_03.wss",2.5118864,1,1800}; multiSoundHit[] = {"soundHit1",0.34,"soundHit2",0.33,"soundHit3",0.33}; - soundFly[] = {"A3\Sounds_F\arsenal\weapons\Launchers\RPG32\Fly_RPG32",0.31622776,1.5,900}; + soundFly[] = {"A3\Sounds_F\arsenal\weapons\Launchers\RPG32\Fly_RPG32.wss",0.31622776,1.5,900}; class CamShakeExplode { power = "(55*0.2)"; @@ -74,7 +74,7 @@ class CfgAmmo { SoundSetExplosion[] = {"RocketsLight_Exp_SoundSet","RocketsLight_Tail_SoundSet","Explosion_Debris_SoundSet"}; }; - + class SLAMDirectionalMine_Wire_Ammo; class PBW_DM12_Ammo: SLAMDirectionalMine_Wire_Ammo { explosionEffects = "ATMineExplosion"; diff --git a/addons/mines/CfgEventHandlers.hpp b/addons/mines/CfgEventHandlers.hpp index 0d1669c..e8df281 100644 --- a/addons/mines/CfgEventHandlers.hpp +++ b/addons/mines/CfgEventHandlers.hpp @@ -1,12 +1,12 @@ class Extended_PostInit_EventHandlers { class pbw_mines { - init = "call compile preprocessFileLineNumbers '\pbw_mines\XEH_postInit.sqf'"; + init = "call compileScript ['\pbw_mines\XEH_postInit.sqf']"; }; }; class Extended_DisplayLoad_EventHandlers { class RscDisplayMission { - pbw_mines = "call compile preprocessFileLineNumbers '\pbw_mines\XEH_missionDisplayLoad.sqf'"; + pbw_mines = "call compileScript ['\pbw_mines\XEH_missionDisplayLoad.sqf']"; }; }; @@ -16,4 +16,4 @@ class Extended_InitPost_EventHandlers { init = "call pbw_mines_fnc_fixDM12Rotation;"; }; }; -}; \ No newline at end of file +}; diff --git a/addons/mines/CfgMagazines.hpp b/addons/mines/CfgMagazines.hpp index df78668..452d1c8 100644 --- a/addons/mines/CfgMagazines.hpp +++ b/addons/mines/CfgMagazines.hpp @@ -7,18 +7,18 @@ class CfgMagazines { displayNameShort = "$STR_pbw_mines_DM12_NameShort"; descriptionShort = "$STR_pbw_mines_DM12_Desc"; descriptionUse = "$STR_pbw_mines_DM12_Desc"; - model = "\pbw_mines\data\pbw_dm12"; + model = "\pbw_mines\data\pbw_dm12.p3d"; picture = "\pbw_mines\ui\pbw_dm12_picture_ca.paa"; ammo = "PBW_DM12_Ammo"; initSpeed = 0; type = "2 * 256"; count = 1; - mass = 80; // real mine is 9.6kg but this is too big for normal backbacks + mass = 80; // real mine is 9.6kg but this is too big for normal backpacks useAction = 0; ACE_explosives_Placeable = 1; ACE_explosives_SetupObject = "PBW_DM12_Static"; - + class ACE_Triggers { SupportedTriggers[] = {"FibreOpticCable"}; class FibreOpticCable { diff --git a/addons/mines/CfgVehicles.hpp b/addons/mines/CfgVehicles.hpp index 8263f0e..13afb26 100644 --- a/addons/mines/CfgVehicles.hpp +++ b/addons/mines/CfgVehicles.hpp @@ -1,5 +1,3 @@ -class CBA_Extended_EventHandlers_base; - class CfgVehicles { class LandVehicle; class StaticWeapon: LandVehicle { @@ -24,7 +22,7 @@ class CfgVehicles { displayName = "$STR_pbw_mines_DM12_Name"; displayNameShort = "$STR_pbw_mines_DM12_NameShort"; description = "$STR_pbw_mines_DM12_Desc"; - model = "\pbw_mines\data\pbw_dm12"; + model = "\pbw_mines\data\pbw_dm12.p3d"; picture = "\pbw_mines\ui\pbw_dm12_picture_ca.paa"; editorPreview = "\pbw_mines\editorpreview\pbw_dm12.jpg"; icon = "iconExplosiveAT"; @@ -39,11 +37,21 @@ class CfgVehicles { accuracy = 0.12; cost = 10000; + armor = 400; + + // ACE + ace_dragging_canCarry = 1; + ace_dragging_canDrag = 1; ace_dragging_dragPosition[] = {0, 1, 0}; ace_dragging_dragDirection = 0; - armor = 400; + ace_cargo_canLoad = 0; + ace_cargo_noRename = 1; + + class ace_csw { + enabled = 0; + }; class ACE_Actions: ACE_Actions { class ACE_MainActions: ACE_MainActions { @@ -106,10 +114,6 @@ class CfgVehicles { }; }; - class EventHandlers { - class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers_base {}; - }; - class Turrets: Turrets { class MainTurret: MainTurret { minTurn = -45; @@ -133,7 +137,7 @@ class CfgVehicles { weapons[] = {}; magazines[] = {}; - gunnerOpticsModel = "\A3\weapons_f\reticle\optics_empty"; + gunnerOpticsModel = "\A3\weapons_f\reticle\optics_empty.p3d"; gunnerOpticsEffect[] = {"OpticsCHAbera1","OpticsBlur2"}; gunnerOutOpticsShowCursor = 0; gunnerOpticsShowCursor = 0; diff --git a/addons/mines/XEH_postInit.sqf b/addons/mines/XEH_postInit.sqf index b42830a..67366e4 100644 --- a/addons/mines/XEH_postInit.sqf +++ b/addons/mines/XEH_postInit.sqf @@ -7,20 +7,19 @@ if (hasInterface) then { ["ace_unconscious", { params ["_unit"]; - if (player isEqualTo _unit) exitWith { + if (ACE_player isEqualTo _unit) exitWith { pbw_mines_isPlacingCable = PLACE_CANCEL; }; }] call CBA_fnc_addEventHandler; }; -["pbw_mines_lockDM12", { - params ["_dm12", "_lock"]; - - _dm12 lock ([0, 2] select _lock); +if (isServer) then { + ["pbw_mines_startSensorCheck", pbw_mines_fnc_startSensorCheck] call CBA_fnc_addEventHandler; + ["pbw_mines_detonateDM12", pbw_mines_fnc_detonateDM12] call CBA_fnc_addEventHandler; + ["pbw_mines_sensorDetectedVehicles", pbw_mines_fnc_detonateDM12] call CBA_fnc_addEventHandler; +}; - [_dm12, !_lock] call ace_dragging_fnc_setCarryable; - [_dm12, !_lock] call ace_dragging_fnc_setDraggable; +["pbw_mines_lock", { + params ["_vehicle", ["_lock", false, [false]]]; + _vehicle lock ([0, 2] select _lock); }] call CBA_fnc_addEventHandler; - -["pbw_mines_armDM12Sensor", {_this call pbw_mines_fnc_startSensorCheck}] call CBA_fnc_addEventHandler; -["pbw_mines_sensorDetectedVehicles", {_this call pbw_mines_fnc_detonateDM12}] call CBA_fnc_addEventHandler; diff --git a/addons/mines/functions/fn_armDM12.sqf b/addons/mines/functions/fn_armDM12.sqf index 0eb8033..0663438 100644 --- a/addons/mines/functions/fn_armDM12.sqf +++ b/addons/mines/functions/fn_armDM12.sqf @@ -18,15 +18,19 @@ params ["_dm12"]; -if (!(_dm12 getVariable ["pbw_mines_isTriggerSet", false]) || _dm12 getVariable ["pbw_mines_isArmed", false]) exitWith {}; +private _endPosATL = _dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]; +if ((_endPosATL isEqualTo []) || {_dm12 getVariable ["pbw_mines_isArmed", false]}) exitWith {}; _dm12 setVariable ["pbw_mines_isArmed", true, true]; -["pbw_mines_lockDM12", [_dm12, true], "pbw_mines_lockDM12"] call CBA_fnc_globalEventJIP; +["pbw_mines_lock", [_dm12, true], _dm12] call CBA_fnc_targetEvent; +[_dm12, false, nil, nil, nil, true] call ace_dragging_fnc_setCarryable; +[_dm12, false, nil, nil, nil, true] call ace_dragging_fnc_setDraggable; _dm12 animateSource ["hideCap", 1, true]; -private _endPosATL = _dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]; -private _class = _dm12 getVariable ["pbw_mines_magClass", "PBW_DM12"]; +private _magClass = _dm12 getVariable ["pbw_mines_magClass", "PBW_DM12"]; +["pbw_mines_startSensorCheck", [_dm12, _magClass, _endPosATL]] call CBA_fnc_serverEvent; -["pbw_mines_armDM12Sensor", [_dm12, _class, _endPosATL]] call CBA_fnc_serverEvent; \ No newline at end of file +// Provide hook +["pbw_mines_DM12Armed", [_dm12]] call CBA_fnc_localEvent; diff --git a/addons/mines/functions/fn_canArmDM12.sqf b/addons/mines/functions/fn_canArmDM12.sqf index 00dc70b..9e4ed54 100644 --- a/addons/mines/functions/fn_canArmDM12.sqf +++ b/addons/mines/functions/fn_canArmDM12.sqf @@ -18,7 +18,7 @@ params ["_dm12"]; -(alive _dm12) && -{count (crew _dm12) isEqualTo 0} && -{_dm12 getVariable ["pbw_mines_isTriggerSet", false]} && -{!(_dm12 getVariable ["pbw_mines_isArmed", false])} \ No newline at end of file +(alive _dm12) && +{(crew _dm12) isEqualTo []} && +{(_dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]) isNotEqualTo []} && +{!(_dm12 getVariable ["pbw_mines_isArmed", false])} diff --git a/addons/mines/functions/fn_canDefuseDM12.sqf b/addons/mines/functions/fn_canDefuseDM12.sqf index c67ce66..2eca5a5 100644 --- a/addons/mines/functions/fn_canDefuseDM12.sqf +++ b/addons/mines/functions/fn_canDefuseDM12.sqf @@ -18,5 +18,5 @@ params ["_dm12"]; -(alive _dm12) && -{_dm12 getVariable ["pbw_mines_isArmed", false]} \ No newline at end of file +(alive _dm12) && +{_dm12 getVariable ["pbw_mines_isArmed", false]} diff --git a/addons/mines/functions/fn_canPickupDM12.sqf b/addons/mines/functions/fn_canPickupDM12.sqf index cf7a666..1d2b7b5 100644 --- a/addons/mines/functions/fn_canPickupDM12.sqf +++ b/addons/mines/functions/fn_canPickupDM12.sqf @@ -15,10 +15,10 @@ * [cursorObject] call pbw_mines_fnc_canPickupDM12 * */ - + params ["_dm12"]; (alive _dm12) && -{count (crew _dm12) isEqualTo 0} && +{(crew _dm12) isEqualTo []} && {!(_dm12 getVariable ["pbw_mines_isArmed", false])} && -{!(_dm12 getVariable ["pbw_mines_blockSetTrigger", false])} \ No newline at end of file +{!(_dm12 getVariable ["pbw_mines_blockSetTrigger", false])} diff --git a/addons/mines/functions/fn_canPickupFiberOpticCable.sqf b/addons/mines/functions/fn_canPickupFiberOpticCable.sqf index 9d2a144..57b4e2b 100644 --- a/addons/mines/functions/fn_canPickupFiberOpticCable.sqf +++ b/addons/mines/functions/fn_canPickupFiberOpticCable.sqf @@ -20,4 +20,4 @@ params ["_dm12"]; (alive _dm12) && {!(_dm12 getVariable ["pbw_mines_isArmed", false])} && -{_dm12 getVariable ["pbw_mines_isTriggerSet", false]} \ No newline at end of file +{(_dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]) isNotEqualTo []} diff --git a/addons/mines/functions/fn_canSetTrigger.sqf b/addons/mines/functions/fn_canSetTrigger.sqf index 4e5bd62..e694e41 100644 --- a/addons/mines/functions/fn_canSetTrigger.sqf +++ b/addons/mines/functions/fn_canSetTrigger.sqf @@ -15,10 +15,10 @@ * [cursorObject] call pbw_mines_fnc_canSetTrigger * */ - + params ["_dm12"]; -(alive _dm12) && +(alive _dm12) && {!(_dm12 getVariable ["pbw_mines_blockSetTrigger", false])} && -{!(_dm12 getVariable ["pbw_mines_isTriggerSet", false])} && -{!(_dm12 getVariable ["pbw_mines_isArmed", false])} \ No newline at end of file +{(_dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]) isEqualTo []} && +{!(_dm12 getVariable ["pbw_mines_isArmed", false])} diff --git a/addons/mines/functions/fn_defuseDM12.sqf b/addons/mines/functions/fn_defuseDM12.sqf index f8af94b..c90f85a 100644 --- a/addons/mines/functions/fn_defuseDM12.sqf +++ b/addons/mines/functions/fn_defuseDM12.sqf @@ -15,13 +15,18 @@ * [cursorObject] call pbw_mines_fnc_defuseDM12 * */ - + params ["_dm12"]; if !(_dm12 getVariable ["pbw_mines_isArmed", false]) exitWith {}; -["pbw_mines_lockDM12", [_dm12, false], "pbw_mines_lockDM12"] call CBA_fnc_globalEventJIP; +["pbw_mines_lock", [_dm12, false], _dm12] call CBA_fnc_targetEvent; +[_dm12, true, nil, nil, nil, true] call ace_dragging_fnc_setCarryable; +[_dm12, true, nil, nil, nil, true] call ace_dragging_fnc_setDraggable; _dm12 animateSource ["hideCap", 0, true]; -_dm12 setVariable ["pbw_mines_isArmed", false, true]; \ No newline at end of file +_dm12 setVariable ["pbw_mines_isArmed", false, true]; + +// Provide hook +["pbw_mines_DM12Defused", [_dm12]] call CBA_fnc_localEvent; diff --git a/addons/mines/functions/fn_detonateDM12.sqf b/addons/mines/functions/fn_detonateDM12.sqf index 0cc145e..6f9aafa 100644 --- a/addons/mines/functions/fn_detonateDM12.sqf +++ b/addons/mines/functions/fn_detonateDM12.sqf @@ -17,24 +17,30 @@ * */ -params ["_dm12", "_magClass"]; +if (!isServer) exitWith { + ["pbw_mines_detonateDM12", _this] call CBA_fnc_serverEvent; +}; + +params [["_dm12", objNull, [objNull]], ["_magClass", "", [""]]]; + +if (isNull _dm12 || {_magClass isEqualTo ""}) exitWith {}; private _warheadBeginRelPos = _dm12 selectionPosition ["warhead_begin", "Memory"]; -private _warheadBeginPosASL = _dm12 modelToWorldVisualWorld _warheadBeginRelPos; +private _warheadBeginPosWorld = _dm12 modelToWorldWorld _warheadBeginRelPos; private _dm12Config = configFile >> "CfgMagazines" >> _magClass; private _rocketStarterClass = getText (_dm12Config >> "ammo"); private _rocketStarter = _rocketStarterClass createVehicle [0, 0, 0]; -["ace_common_hideObjectGlobal", [_rocketStarter, true]] call CBA_fnc_serverEvent; +_rocketStarter hideObjectGlobal true; -private _dir0 = getDirVisual _dm12; +private _dir0 = getDir _dm12; private _dir = _dir0 - deg (_dm12 animationSourcePhase "mainTurret"); private _pitch0 = (_dm12 call BIS_fnc_getPitchBank) select 0; private _pitch = _pitch0 + deg (_dm12 animationSourcePhase "mainGun"); deleteVehicle _dm12; -_rocketStarter setPosASL _warheadBeginPosASL; +_rocketStarter setPosWorld _warheadBeginPosWorld; _rocketStarter setDir _dir; [_rocketStarter, _pitch, 0] call BIS_fnc_setPitchBank; diff --git a/addons/mines/functions/fn_fixDM12Rotation.sqf b/addons/mines/functions/fn_fixDM12Rotation.sqf index 9eea5cb..15c634b 100644 --- a/addons/mines/functions/fn_fixDM12Rotation.sqf +++ b/addons/mines/functions/fn_fixDM12Rotation.sqf @@ -24,8 +24,8 @@ if (!local _dm12) exitWith {}; // Stupid but better than copying the whole placing system [{(_this select 0) getVariable ["ace_explosives_Direction", -1] isNotEqualTo -1}, { params ["_dm12"]; - + private _dir = _dm12 getVariable ["ace_explosives_Direction", 0]; _dm12 setDir _dir; _dm12 setVariable ["ace_explosives_Direction", _dir, true]; -}, _this, 1] call CBA_fnc_waitUntilAndExecute; \ No newline at end of file +}, _this, 1] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/mines/functions/fn_pickupDM12.sqf b/addons/mines/functions/fn_pickupDM12.sqf index 177be1c..e181c64 100644 --- a/addons/mines/functions/fn_pickupDM12.sqf +++ b/addons/mines/functions/fn_pickupDM12.sqf @@ -23,8 +23,10 @@ _player playAction "putdown"; [{((animationState (_this select 1)) select [25,7]) isEqualTo "putdown"}, { params ["_dm12", "_player"]; - + + if (isNull _dm12) exitWith {}; + + private _magClass = _dm12 getVariable ["pbw_mines_magClass", "PBW_DM12"]; deleteVehicle _dm12; - [_player, "PBW_DM12"] call ace_common_fnc_addToInventory; + [_player, _magClass] call ace_common_fnc_addToInventory; }, _this] call CBA_fnc_waitUntilAndExecute; - diff --git a/addons/mines/functions/fn_pickupFiberOpticCable.sqf b/addons/mines/functions/fn_pickupFiberOpticCable.sqf index 2cffbed..7eb1a47 100644 --- a/addons/mines/functions/fn_pickupFiberOpticCable.sqf +++ b/addons/mines/functions/fn_pickupFiberOpticCable.sqf @@ -18,8 +18,7 @@ params ["_dm12"]; -if !(_dm12 getVariable ["pbw_mines_isTriggerSet", false]) exitWith {}; +if ((_dm12 getVariable ["pbw_mines_fiberOpticCableEndPos", []]) isEqualTo []) exitWith {}; -_dm12 setVariable ["pbw_mines_isTriggerSet", false, true]; _dm12 setVariable ["pbw_mines_fiberOpticCableEndPos", nil, true]; -_dm12 setVariable ["pbw_mines_magClass", nil, true]; \ No newline at end of file +_dm12 setVariable ["pbw_mines_magClass", nil, true]; diff --git a/addons/mines/functions/fn_placeFiberOpticCable.sqf b/addons/mines/functions/fn_placeFiberOpticCable.sqf index 0de5f6e..e65655b 100644 --- a/addons/mines/functions/fn_placeFiberOpticCable.sqf +++ b/addons/mines/functions/fn_placeFiberOpticCable.sqf @@ -20,14 +20,20 @@ params ["_player", "_dm12", "_magClass"]; -private _endPointHelper = "Land_PencilGreen_F" createVehicleLocal [0,0,0]; +private _endPointHelper = ENDPOINTHELPER_CLASS createVehicleLocal [0, 0, 0]; +_endPointHelper setVectorDirAndUp [[0, 0, 1], [0, 1, 0]]; _endPointHelper enableSimulation false; pbw_mines_isPlacingCable = PLACE_WAITING; _dm12 setVariable ["pbw_mines_blockSetTrigger", true, true]; [localize "STR_pbw_mines_DM12_PlaceFiberOpticCableAction", localize "STR_pbw_mines_DM12_Cancel"] call ace_interaction_fnc_showMouseHint; -private _mouseClickID = [_player, "DefaultAction", {pbw_mines_isPlacingCable isEqualTo PLACE_WAITING}, {pbw_mines_isPlacingCable = PLACE_APPROVE}] call ace_common_fnc_addActionEventHandler; +private _mouseClickID = [ + _player, + "DefaultAction", + {pbw_mines_isPlacingCable isEqualTo PLACE_WAITING}, + {pbw_mines_isPlacingCable = PLACE_APPROVE} +] call ace_common_fnc_addActionEventHandler; private _maxCableLength = getNumber (configFile >> "CfgMagazines" >> _magClass >> "ACE_Triggers" >> "FibreOpticCable" >> "maxCableLength"); @@ -39,23 +45,21 @@ private _maxCableLength = getNumber (configFile >> "CfgMagazines" >> _magClass > pbw_mines_isPlacingCable = PLACE_CANCEL; }; - private _pos = ((eyePos _player) vectorAdd ((getCameraViewDirection _player) vectorMultiply ENDPOINTHELPER_DISTANCE)); - _pos set [2, ENDPOINTHELPER_HEIGHT]; - _endPointHelper setPosATL _pos; - _endPointHelper setVectorDirAndUp [[0,0,1], [0,1,0]]; - - private _dm12Pos = getPos _dm12; - private _endPointPos = getPos _endPointHelper; - + private _endPointPos = ((eyePos _player) vectorAdd ((getCameraViewDirection _player) vectorMultiply ENDPOINTHELPER_DISTANCE)); + _endPointPos set [2, ENDPOINTHELPER_HEIGHT]; + + _endPointHelper setPosATL _endPointPos; + + private _dm12Pos = getPosATL _dm12; private _begin = [_dm12Pos select 0, _dm12Pos select 1, CABLE_HEIGHT]; - private _end = []; - private _vec = []; - + private _cableLength = 0; private _stopExtendingLines = false; + + private ["_end"]; while {true} do { - _vec = _endPointPos vectorDiff _begin; - + private _vec = _endPointPos vectorDiff _begin; + private _segmentLength = vectorMagnitude _vec; if (_segmentLength < CABLE_SEGMENT_LENGTH) then { _stopExtendingLines = true; @@ -66,33 +70,35 @@ private _maxCableLength = getNumber (configFile >> "CfgMagazines" >> _magClass > _end = _begin vectorAdd (_vecNorm vectorMultiply CABLE_SEGMENT_LENGTH); _cableLength = _cableLength + CABLE_SEGMENT_LENGTH; }; - + private _lineStart = [_begin select 0, _begin select 1, CABLE_HEIGHT]; private _lineEnd = [_end select 0, _end select 1, CABLE_HEIGHT]; - - private _color = if (_cableLength <= _maxCableLength) then {CABLE_COLOR_GOOD} else {CABLE_COLOR_BAD}; - + + private _color = [CABLE_COLOR_BAD, CABLE_COLOR_GOOD] select (_cableLength <= _maxCableLength); + drawLine3D [_lineStart, _lineEnd, _color]; - + if (_stopExtendingLines) then {break}; - + _begin = _end; }; - + private _ctrlTextLMB = (uiNamespace getVariable ["ace_interaction_mouseHint", displayNull]) displayCtrl 2420; if (_cableLength <= _maxCableLength) then { _ctrlTextLMB ctrlSetText format [localize "STR_pbw_mines_DM12_PlaceFiberOpticCableAction", _maxCableLength - round _cableLength]; } else { _ctrlTextLMB ctrlSetText localize "STR_pbw_mines_DM12_FiberOpticCableTooShort"; }; - - if (_cableLength > _maxCableLength && {pbw_mines_isPlacingCable isEqualTo PLACE_APPROVE}) then {pbw_mines_isPlacingCable = PLACE_WAITING}; - + + if (_cableLength > _maxCableLength && {pbw_mines_isPlacingCable isEqualTo PLACE_APPROVE}) then { + pbw_mines_isPlacingCable = PLACE_WAITING; + }; + if (pbw_mines_isPlacingCable isNotEqualTo PLACE_WAITING) exitWith { [_PFHID] call CBA_fnc_removePerFrameHandler; call ace_interaction_fnc_hideMouseHint; [_player, "DefaultAction", _mouseClickID] call ace_common_removeActionEventHandler; - + _dm12 setVariable ["pbw_mines_blockSetTrigger", false, true]; if (pbw_mines_isPlacingCable isEqualTo PLACE_APPROVE) then { @@ -100,14 +106,16 @@ private _maxCableLength = getNumber (configFile >> "CfgMagazines" >> _magClass > // End position of the object _player playAction "putdown"; - + private _endPosATL = getPosATL _endPointHelper; _endPosATL set [2, 0]; deleteVehicle _endPointHelper; - - _dm12 setVariable ["pbw_mines_isTriggerSet", true, true]; + _dm12 setVariable ["pbw_mines_fiberOpticCableEndPos", _endPosATL, true]; _dm12 setVariable ["pbw_mines_magClass", _magClass, true]; + + // Provide hook + ["pbw_mines_DM12Placed", [_dm12, _magClass, _endPosATL]] call CBA_fnc_localEvent; } else { // Action is canceled deleteVehicle _endPointHelper; diff --git a/addons/mines/functions/fn_startSensorCheck.sqf b/addons/mines/functions/fn_startSensorCheck.sqf index 26ab707..4ccbce4 100644 --- a/addons/mines/functions/fn_startSensorCheck.sqf +++ b/addons/mines/functions/fn_startSensorCheck.sqf @@ -8,7 +8,7 @@ * Parameter(s): * 0: OBJECT - DM12 which was placed. * 1: STRING - DM12 magazine classname. - * 2: ARRAY - Fibre optic cable end positon ATL. + * 2: ARRAY - Fibre optic cable end position ATL. * * Returns: * Nothing. @@ -18,32 +18,38 @@ * */ +if (!isServer) exitWith { + ["pbw_mines_startSensorCheck", _this] call CBA_fnc_serverEvent; +}; + [{ params ["_PFHArgs", "_PFHID"]; _PFHArgs params ["_dm12", "_magClass", "_endPosATL"]; - if (isNull _dm12 || !(alive _dm12) || !(_dm12 getVariable ["pbw_mines_isArmed", false])) exitWith { + if (isNull _dm12 || {!alive _dm12} || {!(_dm12 getVariable ["pbw_mines_isArmed", false])}) exitWith { [_PFHID] call CBA_fnc_removePerFrameHandler; }; private _dm12PosATL = getPosATL _dm12; private _centerATL = (_dm12PosATL vectorAdd _endPosATL) vectorMultiply 0.5; - private _xAxis = 0.5; + private _nearestVehicles = nearestObjects [_centerATL, ["Car", "Tank"], SENSOR_VEHICLE_RADIUS]; + if (_nearestVehicles isEqualTo []) exitWith {}; + + private _xAxis = SENSOR_DEPTH; private _yAxis = _centerATL distance2D _dm12PosATL; - private _zAxis = 5; + private _zAxis = SENSOR_HEIGHT; private _angle = _dm12PosATL getDir _endPosATL; - private _allVehicles = vehicles select {_x isKindOf "Car" || _x isKindOf "Tank"}; // The sensor doesn't trigger in MP when the vehicles drive fast. // Probably because inAreaArray checks object pos in simulation time scope. - // Thats why we get the positions ourselfs and pass them to check if they're in the area. - private _allPositions = _allVehicles apply {getPosATLVisual _x}; - private _positionsInTriggerArea = _allPositions inAreaArray [_centerATL, _xAxis, _yAxis, _angle, true, _zAxis]; + // Thats why we get the positions ourselves and pass them to check if they're in the area. + private _positions = _nearestVehicles apply {getPosATLVisual _x}; + private _positionsInTriggerArea = _positions inAreaArray [_centerATL, _xAxis, _yAxis, _angle, true, _zAxis]; - if (count _positionsInTriggerArea > 0) exitWith { + if (_positionsInTriggerArea isNotEqualTo []) exitWith { [_PFHID] call CBA_fnc_removePerFrameHandler; - ["pbw_mines_sensorDetectedVehicles", [_dm12, _magClass], _dm12] call CBA_fnc_targetEvent; + ["pbw_mines_sensorDetectedVehicles", [_dm12, _magClass]] call CBA_fnc_serverEvent; }; }, 0, _this] call CBA_fnc_addPerFrameHandler; diff --git a/addons/mines/script_component.hpp b/addons/mines/script_component.hpp index 372d010..3006a00 100644 --- a/addons/mines/script_component.hpp +++ b/addons/mines/script_component.hpp @@ -4,6 +4,7 @@ #define PLACE_CANCEL 0 #define PLACE_APPROVE 1 +#define ENDPOINTHELPER_CLASS "Land_PencilGreen_F" #define ENDPOINTHELPER_DISTANCE 1 #define ENDPOINTHELPER_HEIGHT 0.05 @@ -12,4 +13,8 @@ #define CABLE_COLOR_GOOD [1, 1, 1, 1] #define CABLE_COLOR_BAD [1, 0, 0, 1] +#define SENSOR_VEHICLE_RADIUS 100 +#define SENSOR_HEIGHT 5 +#define SENSOR_DEPTH 0.5 + #include "\pbw_main\script_macros.hpp"