From c055d44dcdb87e8db49fb23e632fc086aa44cce6 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:53:22 +0300 Subject: init --- Client/Module/UAV/uav.sqf | 136 +++++++++++++++ Client/Module/UAV/uav_interface.sqf | 304 +++++++++++++++++++++++++++++++++ Client/Module/UAV/uav_interface_oa.sqf | 162 ++++++++++++++++++ Client/Module/UAV/uav_spotter.sqf | 28 +++ 4 files changed, 630 insertions(+) create mode 100644 Client/Module/UAV/uav.sqf create mode 100644 Client/Module/UAV/uav_interface.sqf create mode 100644 Client/Module/UAV/uav_interface_oa.sqf create mode 100644 Client/Module/UAV/uav_spotter.sqf (limited to 'Client/Module/UAV') diff --git a/Client/Module/UAV/uav.sqf b/Client/Module/UAV/uav.sqf new file mode 100644 index 0000000..840ffbe --- /dev/null +++ b/Client/Module/UAV/uav.sqf @@ -0,0 +1,136 @@ +Private ['_add','_buildings','_built','_checks','_closest','_cw','_d','_dir','_driver','_group','_gunner','_id','_lastWP','_lastWPpos','_logic','_logicMARTA','_pos','_radius','_sorted','_spawn','_step','_uav','_varname','_waypoints','_wp','_wpcount']; +_logic = UAVL; + +if (!isNull playerUAV) then {if (!alive playerUAV) then {playerUAV = objNull}}; +if (!isNull playerUAV) exitWith { + if (WF_A2_Vanilla) then { + ExecVM "Client\Module\UAV\uav_interface.sqf"; + } else { + ExecVM "Client\Module\UAV\uav_interface_oa.sqf"; + }; +}; + +//--- Logic ID +if (isnil "BIS_uavlastID") then {BIS_uav_lastID = -1}; +BIS_uav_lastID = BIS_uav_lastID + 1; +_id = BIS_uav_lastID; +_varname = ""; +call compile format ["BIS_uav_%1 = _logic; _logic setvehiclevarname 'BIS_uav_%1'; _varname = 'BIS_uav_%1'; publicvariable 'BIS_uav_%1'",BIS_uav_lastID]; +_logic setVariable ["ID",BIS_uav_lastID]; + +//--- First call +if (BIS_uav_lastID == 0) then { + //--- Execute MARTA + if (isnil "bis_marta_mainscope") then { + (group _logic) createunit ["MartaManager",position player,[],0,"none"]; + }; +}; + +_buildings = (sideJoinedText) Call GetSideStructures; +_checks = [sideJoined,Format ["WFBE_%1COMMANDCENTERTYPE",sideJoinedText] Call GetNamespace,_buildings] Call GetFactories; +_closest = objNull; +if (count _checks > 0) then { + _sorted = [player,_checks] Call SortByDistance; + _closest = _sorted select 0; +}; + +if (isNull _closest) exitWith {}; + +_uav = createVehicle [Format ["WFBE_%1UAV",sideJoinedText] Call GetNamespace,getPos _closest, [], 0, "FLY"]; +playerUAV = _uav; +Call Compile Format ["_uav addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",sideJoined]; +_uav SetVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",sideJoined]; +processInitCommands; + +//--- Remove weapons if air restriction is enabled. +if (('WFBE_RESTRICTIONADVAIR' Call GetNamespace) == 2) then {removeAllWeapons _uav}; + +_group = createGroup sideJoined; +_driver = [Format ["WFBE_%1SOLDIER",sideJoinedText] Call GetNamespace,_group,getPos _uav,sideJoined] Call CreateMan; +_driver MoveInDriver _uav; + +_built = 1; +//--- OPFOR Uav has no gunner slot. +if (sideJoined == west) then { + _gunner = [Format ["WFBE_%1SOLDIER",sideJoinedText] Call GetNamespace,_group,getPos _uav,sideJoined] Call CreateMan; + _gunner MoveInGunner _uav; + _built = _built + 1; +}; +[sideJoinedText,'UnitsCreated',_built] Call UpdateStatistics; +[sideJoinedText,'VehiclesCreated',1] Call UpdateStatistics; + +-12500 Call ChangePlayerFunds; + +WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',["uav",sideJoined,_uav,clientTeam]]; +publicVariable 'WFBE_RequestSpecial'; +if (isHostedServer) then {['SRVFNCREQUESTSPECIAL',["uav",sideJoined,_uav,clientTeam]] Spawn HandleSPVF}; + +sleep 0.02; + +if ((count units _uav) > 1) then {[driver _uav] join grpnull}; + +_radius = 1000; +_wpcount = 4; +_step = 360 / _wpcount; +_add = 0; +_cw = true; +_dir = 0; +if !(isNil "_lastWP") then {deletewaypoint _lastWP}; + +//--- No need to preprocess those. +if (WF_A2_Vanilla) then { + ExecVM "Client\Module\UAV\uav_interface.sqf"; +} else { + ExecVM "Client\Module\UAV\uav_interface_oa.sqf"; +}; +[_uav] ExecVM 'Client\Module\UAV\uav_spotter.sqf'; + +_spawn = [] spawn {}; //--- Empty spawn +while {alive _uav} do { + waituntil {waypointdescription [group _uav,currentwaypoint group _uav] != ' ' || !alive _uav}; + terminate _spawn; //--- Terminate spawn from previous loop + if (!(alive _uav)||isNull _uav) exitwith {}; + + _waypoints = waypoints _uav; + _lastWP = _waypoints select (count _waypoints - 1); + _lastWPpos = waypointposition _lastWP; + deletewaypoint _lastWP; + for "_d" from 0 to (360-_step) step _step do + { + _add = _d; + if !(_cw) then {_add = -_d}; + _pos = [_lastWPpos, _radius, _dir+_add] call bis_fnc_relPos; + _wp = (group _uav) addwaypoint [_pos,0]; + _wp setWaypointType "MOVE"; + _wp setwaypointdescription ' '; + _wp setwaypointcompletionradius (1000/_wpcount); + }; + + _spawn = [_uav,_add,_step,_lastWPpos,_radius,_dir] spawn { + Private ['_add','_currentWP','_dir','_lastWPpos','_pos','_radius','_step','_uav','_wp']; + scriptname "UAV Route planning"; + _uav = _this select 0; + _add = _this select 1; + _step = _this select 2; + _lastWPpos = _this select 3; + _radius = _this select 4; + _dir = _this select 5; + _currentWP = currentwaypoint group _uav; + while {alive _uav} do { + waituntil {_currentWP != currentwaypoint group _uav}; + sleep .01; + _add = _add + _step; + if !(_cw) then {_add = -_add}; + _pos = [_lastWPpos, _radius, _dir+_add] call bis_fnc_relPos; + _wp = (group _uav) addwaypoint [_pos,0]; + _wp setWaypointType "MOVE"; + _wp setwaypointdescription ' '; + _wp setwaypointcompletionradius (1000/_wpcount); + _currentWP = currentwaypoint group _uav; + }; + }; + + _wpcount = count waypoints _uav; + waituntil {waypointdescription [group _uav,currentwaypoint group _uav] == ' ' || _wpcount != count waypoints _uav || !alive _uav}; + if (!(alive _uav)||isNull _uav) exitwith {}; +}; diff --git a/Client/Module/UAV/uav_interface.sqf b/Client/Module/UAV/uav_interface.sqf new file mode 100644 index 0000000..873b026 --- /dev/null +++ b/Client/Module/UAV/uav_interface.sqf @@ -0,0 +1,304 @@ +Private ['_IGUI_update','_alt','_defaultTeamswitch','_defaultvalue','_displayEH_keydown','_displayEH_mousebuttondown','_displayEH_mousezchanged','_locked','_logic','_mapEH_mousebttondown','_newalt','_newspeed','_ppBlur','_ppColor','_ppGrain','_ppInversion','_speed','_uav']; +_defaultTeamswitch = teamswitchenabled; + +startLoadingScreen ["UAV","RscDisplayLoadMission"]; + +_uav = playerUAV; + +//--- UAV destroyed +if (isnull _uav) exitwith {endLoadingScreen;hintc format [localize "strwfbasestructuredestroyed",localize "str_uav_action"]}; + +//--- Switch view +gunner _uav removeweapon "nvgoggles"; +_uav switchcamera "internal"; +player remoteControl gunner _uav; +_locked = locked _uav; +_uav lock true; +_uav selectweapon (weapons _uav select 0); +enableteamswitch false; +titletext ["","black in"]; +BIS_UAV_TIME = 0; +BIS_UAV_PLANE = _uav; +_ppInversion = 0; + +//--- Disable HC +hcshowbar false; + +//--- Show MARTA icons +if (isnil "BIS_UAV_visible") then {BIS_UAV_visible = groupiconsvisible}; +setGroupIconsVisible [true,true]; +(group _uav) setvariable ["MARTA_waypoint",[true,[-1,-1,-1,-1]]]; + +//--- Postprocess effects +_ppColor = ppEffectCreate ["ColorCorrections", 1999]; +_ppColor ppEffectEnable true; +_ppColor ppEffectAdjust [1, 1, 0, [1, 1, 1, 0], [1, 1, 1, 0.0], [1, 1, 1, 1.0]]; +_ppColor ppEffectCommit 0; +_ppBlur = ppEffectCreate ["dynamicBlur", 505]; +_ppBlur ppEffectEnable true; +_ppBlur ppEffectAdjust [.5]; +_ppBlur ppEffectCommit 0; +_ppGrain = ppEffectCreate ["filmGrain", 2005]; +_ppGrain ppEffectEnable true; +_ppGrain ppEffectAdjust [0.02, 1, 1, 0, 1]; +_ppGrain ppEffectCommit 0; + +//--- RSC +1124 cutrsc ["RscUnitInfoUAV","plain"]; +waituntil {!isnil {uinamespace getvariable "BIS_UAV_DISPLAY"}}; +progressLoadingScreen 0.5; + +//--- Minimap update +((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl 112410) mapcenteroncamera true; + +//--- Default aperture +if (isnil {BIS_UAV_PLANE getvariable 'BIS_UAV_aperture'}) then { + _defaultvalue = if (daytime > 5 && daytime < 19) then {24} else {0.07}; + BIS_UAV_PLANE setvariable ['BIS_UAV_aperture',_defaultValue]; + setaperture _defaultvalue; +} else { + setaperture (BIS_UAV_PLANE getvariable 'BIS_UAV_aperture'); +}; + +//--- Default height +_newalt = BIS_UAV_PLANE getvariable 'BIS_UAV_height'; +if (isnil "_newalt") then { + _alt = position _uav select 2; + _newalt = (round (_alt / 50)) * 50; + if (_newalt < 100) then {_newalt = 100}; + _uav flyinheight _newalt; + _uav setvariable ['BIS_UAV_height',_newalt]; +}; +((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlsettext str (_newalt); +((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlcommit 0; + +//--- Default speed +_newspeed = BIS_UAV_PLANE getvariable 'BIS_UAV_speed'; +if (isnil "_newspeed") then { + _speed = speed _uav; + _newspeed = (round (_speed / 50)) * 50; + if (_newalt < 200) then {_newalt = 200}; + driver _uav forcespeed _newspeed;; + _uav setvariable ['BIS_UAV_speed',_newspeed]; +}; +((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlsettext str (_newspeed); +((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlcommit 0; + +BIS_UAV_GUIinit = { +private ["_control","_display","_controls","_controlHint"]; +scriptName "UAV\data\scripts\uav_interface.sqf: GUI Init"; + disableserialization; + Private ['_control','_controlHint','_controls','_display']; + _display = uinamespace getvariable "BIS_UAV_DISPLAY"; + _controls = [112401,112402,112403,112404]; + { + _control = _display displayctrl _x; + _control ctrlshow false; + _control ctrlcommit 0; + } foreach _controls; + _controlHint = _display displayctrl 112414; + _controlHint ctrlsettext ( + localize "str_coin_exit" + " " + localize "str_input_device_mouse_1" + "\n\n" + + localize "str_disp_opt_bright" + " " + localize "str_input_device_mouse_axis_z" + "\n" + + localize "str_arcmark_title1" + ": " + call compile actionkeysnames ["Binocular",2] + ); + _controlHint ctrlcommit 0; +}; +[] spawn BIS_UAV_GUIinit; + +_IGUI_update = [] spawn {scriptName "UAV\data\scripts\uav_interface.sqf: IGUI Update"; + Private ['_uav']; + _uav = BIS_UAV_PLANE; + while {cameraon == BIS_UAV_PLANE} do { + if (isnull (uinamespace getvariable "BIS_UAV_DISPLAY")) then {bis_uav_terminate = true; + ExecVM "ca\modules\uav\data\scripts\uav_interface.sqf"; + }; + if (visiblemap) then { + if (ctrlshown ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl 112411)) then { + { + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl _x) ctrlshow false; + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl _x) ctrlcommit 0; + } foreach [112410,112411,112412,112413,112414]; + }; + } else { + if !(ctrlshown ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl 112411)) then { + { + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl _x) ctrlshow true; + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl _x) ctrlcommit 0; + } foreach [112410,112411,112412,112413,112414]; + }; + }; + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl 112411) ctrlsettext str (round speed _uav); + ((uinamespace getvariable "BIS_UAV_DISPLAY") displayctrl 112411) ctrlcommit 0; + sleep 0.01; + }; +}; + +//--- Detect pressed keys (temporary solution) +_displayEH_keydown = (finddisplay 46) displayaddeventhandler ["keydown"," + Private ['_id','_key','_level','_marker','_markertime','_ppInversion','_uav','_worldpos']; + _key = _this select 1; + + comment '--- END'; + if (_key in (actionkeys 'menuback')) then {bis_uav_terminate = true}; + + comment '--- NVG'; + if (_key in (actionkeys 'NightVision')) then { + _uav = BIS_UAV_PLANE; + if (isnil {_uav getvariable 'BIS_UAV_pp_NVG'}) then { + _ppInversion = ppEffectCreate ['colorInversion', 2555]; + _ppInversion ppEffectEnable true; + _ppInversion ppEffectAdjust [1,1,1]; + _ppInversion ppEffectCommit 0; + _uav setvariable ['BIS_UAV_pp_NVG',_ppInversion]; + } else { + ppEffectDestroy (_uav getvariable 'BIS_UAV_pp_NVG'); + _uav setvariable ['BIS_UAV_pp_NVG',nil]; + }; + }; + + comment '--- MARKER'; + if (_key in (actionkeys 'binocular') && !visiblemap) then { + _id = 1; + while {markertype format ['_user_defined_UAV_MARKER_%1',_id] != ''} do { + _id = _id + 1; + }; + _worldpos = screentoworld [0.5,0.5]; + _marker = createmarker [format ['_user_defined_UAV_MARKER_%1',_id],_worldpos]; + _marker setmarkertype 'mil_destroy'; + _marker setmarkercolor 'colorred'; + _marker setmarkersize [0.5,0.5]; + _markertime = [daytime] call bis_fnc_timetostring; + _marker setmarkertext format ['UAV %1: %2',_id,_markertime]; + }; + + comment '--- UP'; + if (_key in (actionkeys 'HeliUp')) then { + _uav = BIS_UAV_PLANE; + _level = _uav getvariable 'BIS_UAV_height'; + _level = _level + 50; + if (_level > 1000) then {_level = 1000}; + _uav flyinheight _level; + _uav setvariable ['BIS_UAV_height',_level]; + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlsettext str (_level); + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlcommit 0; + }; + + comment '--- DOWN'; + if (_key in (actionkeys 'HeliDown')) then { + _uav = BIS_UAV_PLANE; + _level = _uav getvariable 'BIS_UAV_height'; + _level = _level - 50; + if (_level < 100) then {_level = 100}; + _uav flyinheight _level; + _uav setvariable ['BIS_UAV_height',_level]; + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlsettext str (_level); + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112413) ctrlcommit 0; + }; + + comment '--- FORWARD'; + if (_key in (actionkeys 'HeliForward')) then { + _uav = BIS_UAV_PLANE; + _level = _uav getvariable 'BIS_UAV_speed'; + _level = _level + 50; + if (_level > 500) then {_level = 500}; + if (_level < 200) then {_level = 200}; + driver _uav forcespeed (_level / 3.6); + _uav setvariable ['BIS_UAV_speed',_level]; + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlsettext str (_level); + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlcommit 0; + }; + + comment '--- BACK'; + if (_key in (actionkeys 'HeliBack')) then { + _uav = BIS_UAV_PLANE; + _level = _uav getvariable 'BIS_UAV_speed'; + _level = _level - 50; + if (_level > 500) then {_level = 500}; + if (_level < 200) then {_level = 200}; + driver _uav forcespeed (_level / 3.6); + _uav setvariable ['BIS_UAV_speed',_level]; + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlsettext str (_level); + ((uinamespace getvariable 'BIS_UAV_DISPLAY') displayctrl 112412) ctrlcommit 0; + }; +"]; + +//--- Detect pressed mouse buttons +_displayEH_mousebuttondown = (finddisplay 46) displayaddeventhandler ["mousebuttondown"," + disableserialization; + Private ['_button','_control','_controls','_display']; + _button = _this select 1; + if (_button == 007 && !visiblemap) then {comment 'DISABLED'; + _display = uinamespace getvariable 'BIS_UAV_DISPLAY'; + _controls = [112401,112402,112403,112404]; + { + _control = _display displayctrl _x; + _control ctrlshow !(ctrlshown _control); + _control ctrlcommit 0; + } foreach _controls; + }; + if (_button == 1 && !visiblemap && 65665 in (actionkeys 'menuback')) then {bis_uav_terminate = true}; +"]; + +//--- Detect mouse wheel rotation +_displayEH_mousezchanged = (finddisplay 46) displayaddeventhandler ["mousezchanged"," + Private ['_aperture','_oldAperture','_zChangeFinal','_zchange']; + _zchange = _this select 1; + _oldAperture = BIS_UAV_PLANE getvariable 'BIS_UAV_aperture'; + _zChangeFinal = _zChange / 2; + if (_oldAperture <= 1.0) then {_zChangeFinal = _zChange / 10}; + if (_oldAperture <= 0.1) then {_zChangeFinal = _zChange / 1000}; + _aperture = _oldAperture + _zchangeFinal; + if (_oldaperture > 1.0 && _aperture < 1.0) then {_aperture = 1.0}; + if (_oldaperture > 0.1 && _aperture < 0.1) then {_aperture = 0.1}; + if (_aperture < 0.001) then {_aperture = 0.001}; + BIS_UAV_PLANE setvariable ['BIS_UAV_aperture',_aperture]; + setaperture _aperture; +"]; + +_mapEH_mousebttondown = ((findDisplay 12) displayCtrl 51) ctrladdeventhandler ["mousebuttondown", " + Private ['_button','_uav','_worldpos','_wp']; + _button = _this select 1; + if (_button == 0) then { + _uav = BIS_UAV_PLANE; + + while {count (waypoints _uav) > 0} do {deletewaypoint ((waypoints _uav) select 0)}; + + _worldpos = (_this select 0) posscreentoworld [_this select 2,_this select 3]; + _wp = (group _uav) addwaypoint [_worldpos,0]; + _wp setWaypointType 'MOVE'; + (group _uav) setcurrentwaypoint _wp; + }; +"]; + +endLoadingScreen; + +//--- TERMINATE +waituntil {!isnil "bis_uav_terminate" || !alive _uav || !alive player}; +if (!alive _uav) then { + hintc format [localize "strwfbasestructuredestroyed",localize "str_uav_action"]; +}; +_uav lock _locked; +titletext ["","black in"]; +bis_uav_terminate = nil; +BIS_UAV_TIME = nil; +BIS_UAV_PLANE = nil; +objnull remoteControl gunner _uav; +player switchcamera "internal"; +enableteamswitch _defaultTeamswitch; + +setGroupIconsVisible BIS_UAV_visible; +BIS_UAV_visible = nil; +(group _uav) setvariable ["MARTA_waypoint",[false,[-1,-1,-1,-1]]]; + +setaperture -1; +ppEffectDestroy _ppColor; +ppEffectDestroy _ppBlur; +ppEffectDestroy (_uav getvariable 'BIS_UAV_pp_NVG'); //--- Color Invert Fix. +ppEffectDestroy _ppGrain; + +1124 cuttext ["","plain"]; +(finddisplay 46) displayremoveeventhandler ["keydown",_displayEH_keydown]; +(finddisplay 46) displayremoveeventhandler ["mousebuttondown",_displayEH_mousebuttondown]; +(finddisplay 46) displayremoveeventhandler ["mousezchanged",_displayEH_mousezchanged]; +((findDisplay 12) displayCtrl 51) ctrlremoveeventhandler ["mousebuttondown",_mapEH_mousebttondown]; \ No newline at end of file diff --git a/Client/Module/UAV/uav_interface_oa.sqf b/Client/Module/UAV/uav_interface_oa.sqf new file mode 100644 index 0000000..5c4e229 --- /dev/null +++ b/Client/Module/UAV/uav_interface_oa.sqf @@ -0,0 +1,162 @@ +Private ['_action_leave','_defaultTeamswitch','_displayEH_keydown','_displayEH_mousebuttondown','_locked','_logic','_mapEH_mousebttondown','_ppColor','_uav']; +_defaultTeamswitch = teamswitchenabled; + +startLoadingScreen ["UAV","RscDisplayLoadMission"]; + +_uav = playerUAV; + +//--- UAV destroyed +if (isnull _uav) exitwith {endLoadingScreen;hint format [localize "strwfbasestructuredestroyed",localize "str_uav_action"]}; + +//--- Switch view +gunner _uav removeweapon "nvgoggles"; +_uav switchcamera "internal"; +player remoteControl gunner _uav; +_locked = locked _uav; +_uav lock true; +_uav selectweapon (weapons _uav select 0); +enableteamswitch false; +titletext ["","black in"]; +BIS_UAV_TIME = 0; +BIS_UAV_PLANE = _uav; + +//--- Action! +_action_leave = _uav addaction [ + localize "STR_EP1_UAV_action_exit", + "ca\modules_e\uav\data\scripts\uav_actionCommit.sqf", + [0], + 1, + false, + true, + "PersonView", + "isnil 'BIS_UAV_noExit'" +]; + +//--- Disable HC +if (hcShownBar) then {hcshowbar false}; + +//--- Show MARTA icons +if (isnil "BIS_UAV_visible") then {BIS_UAV_visible = groupiconsvisible}; +setGroupIconsVisible [true,true]; +(group _uav) setvariable ["MARTA_waypoint",[true,[-1,-1,-1,-1]]]; + +//--- Prostprocess effects +//setaperture 24; +_ppColor = ppEffectCreate ["ColorCorrections", 1999]; +_ppColor ppEffectEnable true; +_ppColor ppEffectAdjust [1, 1, 0, [1, 1, 1, 0], [1, 1, 1, 0.0], [0.2, 0.2, 0.2, 0]]; +_ppColor ppEffectCommit 0; + + +//--- RSC +progressLoadingScreen 0.5; + +//--- Detect pressed keys (temporary solution) +BIS_UAV_HELI_keydown = { + Private ['_id','_key','_marker','_markertime','_newHeight','_uav','_worldpos']; + _key = _this select 1; + _uav = BIS_UAV_PLANE; + + //--- END + //if (_key in (actionkeys 'menuback') && isnil 'BIS_UAV_noExit') then {bis_uav_terminate = true}; + + //--- MARKER + if (_key in (actionkeys 'binocular') && !visiblemap) then { + _id = 1; + while {markertype format ['_user_defined_UAV_MARKER_%1',_id] != ''} do { + _id = _id + 1; + }; + _worldpos = screentoworld [0.5,0.5]; + _marker = createmarker [format ['_user_defined_UAV_MARKER_%1',_id],_worldpos]; + _marker setmarkertype 'mil_destroy'; + _marker setmarkercolor 'colorred'; + _marker setmarkersize [0.5,0.5]; + _markertime = [daytime] call bis_fnc_timetostring; + _marker setmarkertext format ['UAV %1: %2',_id,_markertime]; + }; + + //--- UP + if (_key in (actionkeys 'HeliUp')) then { + _newHeight = (position _uav select 2) + 50; + if (_newHeight > 1000) then {_newHeight = 1000}; + if (speed _uav < 1) then {_uav domove position _uav;}; + _uav land 'none'; + _uav flyinheight _newHeight; + }; + + //--- DOWN + if (_key in (actionkeys 'HeliDown')) then { + _newHeight = (position _uav select 2) - 50; + if (_newHeight < 100) then {_newHeight = 100}; + _uav land 'none'; + _uav flyinheight _newHeight; + }; +}; +_displayEH_keydown = (finddisplay 46) displayaddeventhandler ["keydown","Private['_sqf']; _sqf = _this spawn BIS_UAV_HELI_keydown"]; + +//--- Detect pressed mouse buttons +_displayEH_mousebuttondown = (finddisplay 46) displayaddeventhandler ["mousebuttondown"," + disableserialization; + Private ['_button','_control','_controls','_display']; + _button = _this select 1; + if (_button == 007 && !visiblemap) then {comment 'DISABLED'; + _display = uinamespace getvariable 'BIS_UAV_DISPLAY'; + _controls = [112401,112402,112403,112404]; + { + _control = _display displayctrl _x; + _control ctrlshow !(ctrlshown _control); + _control ctrlcommit 0; + } foreach _controls; + }; +"]; + + +//_display = findDisplay 12; +//_map = _display displayCtrl 51; +_mapEH_mousebttondown = ((findDisplay 12) displayCtrl 51) ctrladdeventhandler ["mousebuttondown", " + Private ['_button','_uav','_worldpos','_wp']; + _button = _this select 1; + if (_button == 0) then { + _uav = BIS_UAV_PLANE; + + while {count (waypoints _uav) > 0} do {deletewaypoint ((waypoints _uav) select 0)}; + + _worldpos = (_this select 0) posscreentoworld [_this select 2,_this select 3]; + _wp = (group _uav) addwaypoint [_worldpos,0]; + _wp setWaypointType 'MOVE'; + (group _uav) setcurrentwaypoint _wp; + }; +"]; + +////////////////////////////////////////////////// +endLoadingScreen; +////////////////////////////////////////////////// + + +//--- TERMINATE +waituntil {!isnil "bis_uav_terminate" || !alive _uav || !alive player}; +if (!alive _uav) then { + hint format [localize "strwfbasestructuredestroyed",localize "str_uav_action"]; +}; +_uav lock _locked; +titletext ["","black in"]; +bis_uav_terminate = nil; +BIS_UAV_TIME = nil; +BIS_UAV_PLANE = nil; +objnull remoteControl gunner _uav; +player switchcamera "internal"; +enableteamswitch _defaultTeamswitch; + +_uav removeaction _action_leave; + +setGroupIconsVisible BIS_UAV_visible; +BIS_UAV_visible = nil; +(group _uav) setvariable ["MARTA_waypoint",[false,[-1,-1,-1,-1]]]; + +ppEffectDestroy _ppColor; + +//1124 cuttext ["","plain"]; +(finddisplay 46) displayremoveeventhandler ["keydown",_displayEH_keydown]; +(finddisplay 46) displayremoveeventhandler ["mousebuttondown",_displayEH_mousebuttondown]; +//(finddisplay 46) displayremoveeventhandler ["mousezchanged",_displayEH_mousezchanged]; +((findDisplay 12) displayCtrl 51) ctrlremoveeventhandler ["mousebuttondown",_mapEH_mousebttondown]; \ No newline at end of file diff --git a/Client/Module/UAV/uav_spotter.sqf b/Client/Module/UAV/uav_spotter.sqf new file mode 100644 index 0000000..b1b0b17 --- /dev/null +++ b/Client/Module/UAV/uav_spotter.sqf @@ -0,0 +1,28 @@ +/* + Author: Benny + Name: uav_spotter.sqf + Parameters: + 0 - UAV + Description: + This file handle the UAV 'spotting' ability. If the UAV knows about an hostile unit, it'll reveal it's average location on the map. +*/ + +Private ['_delay','_range','_sensitivity','_uav']; +_uav = _this select 0; +_delay = 'WFBE_UAVSPOTTINGDELAY' Call GetNamespace; +_range = 'WFBE_UAVSPOTTINGRANGE' Call GetNamespace; +_sensitivity = 'WFBE_UAVSPOTTINGDETECTION' Call GetNamespace; + +while {true} do { + sleep _delay; + if (!alive _uav || isNull _uav) exitWith {}; + + { + if (_uav knowsAbout _x > _sensitivity && side _x != sideJoined && side _x != civilian) then { + sleep (0.05 + random 0.05); + WFBE_UAV_Reveal = [sideJoined,'CLTFNCUAV_REVEAL',[_uav,_x]]; + publicVariable 'WFBE_UAV_Reveal'; + if (isHostedServer) then {[sideJoined,'CLTFNCUAV_REVEAL',[_uav,_x]] Spawn HandlePVF}; + }; + } forEach (_uav nearEntities _range); +}; -- cgit v1.3.1