Advertisement
Guest User

gps_init

a guest
Apr 17th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.73 KB | None | 0 0
  1. if (! isDedicated) then {
  2.     if (isnil "glt_gpsDispLevel") then {glt_gpsDispLevel = 150};
  3.     if (isnil "GLT_GPSMARKERTYPE") then {GLT_GPSMARKERTYPE = "GLT_GPSINSmarker"};
  4.     if (isnil "glt_hideGPSobject") then {
  5.         glt_hideGPSobject = {
  6.             private ["_plane"];
  7.             _plane = _this select 0;
  8.             while {(alive _plane) and ((player == (driver _plane)) or (player == (gunner _plane)))} do {
  9.                 private ["_hide"];
  10.                 if (getNumber (configFile >> "cfgWeapons" >> currentweapon _plane >> "GLT_isGPSguided") == 1) then {_hide = false} else {_hide = true};
  11.                 GLT_GPSINStarget hideObject _hide;
  12.                 sleep 0.333;
  13.             };
  14.         };
  15.     };
  16.     if (isnil "glt_initDialog") then {
  17.         glt_initDialog = {
  18.             if (local player) then {
  19.                 private ["_pos", "_display", "_mycontrol"];
  20.                 onMapSingleClick "[_pos] call glt_gpsSetMarker";
  21.                 disableSerialization;
  22.                 _display = findDisplay 3330;
  23.                 _mycontrol = _display displayCtrl 3358;
  24.                 _mycontrol ctrlsettext (str glt_gpsDispLevel);
  25.                 _mycontrol ctrlcommit 0;
  26.                 if (GLT_GPSMARKERTYPE == "GLT_GPSINSmarker") then {call glt_gpsDisplaySetDirMode} else {call glt_gpsDisplaySetDispMode};
  27.             };
  28.         };
  29.     };
  30.     if (isnil "glt_gpsDisplaySetDispMode") then {
  31.         glt_gpsDisplaySetDispMode = {
  32.             if (local player) then {
  33.                 private ["_display", "_mycontrol"];
  34.                 _display = findDisplay 3330;
  35.                 _mycontrol1 = _display displayCtrl 3355;
  36.                 _mycontrol2 = _display displayCtrl 3356;
  37.                 _mycontrol2 ctrlsettextcolor [0.1,1,0.1,0.8];
  38.                 _mycontrol1 ctrlsettextcolor [0.4,0.4,0.4,0.5];
  39.                 _mycontrol1 ctrlcommit 0;
  40.                 _mycontrol2 ctrlcommit 0;
  41.                 GLT_GPSMARKERTYPE = "GLT_GPSINSmarkerHigh";
  42.                 if (!isnil "GLT_GPSINSmarker") then {GLT_GPSINSmarker setMarkerTypeLocal "GLT_GPSINSmarkerHigh"};
  43.                 if (!isnil "GLT_GPSINStarget") then {GLT_GPSINStarget setPosATL [getPosATL GLT_GPSINStarget select 0, getPosATL GLT_GPSINStarget select 1, glt_gpsDispLevel]};
  44.             };
  45.         };
  46.     };
  47.     if (isnil "glt_gpsDisplaySetDirMode") then {
  48.         glt_gpsDisplaySetDirMode = {
  49.             if (local player) then {
  50.                 private ["_display", "_mycontrol"];
  51.                 _display = findDisplay 3330;
  52.                 _mycontrol1 = _display displayCtrl 3355;
  53.                 _mycontrol2 = _display displayCtrl 3356;
  54.                 _mycontrol1 ctrlsettextcolor [0.1,1,0.1,0.8];
  55.                 _mycontrol2 ctrlsettextcolor [0.4,0.4,0.4,0.5];
  56.                 _mycontrol1 ctrlcommit 0;
  57.                 _mycontrol2 ctrlcommit 0;
  58.                 GLT_GPSMARKERTYPE =  "GLT_GPSINSmarker";
  59.                 if (!isnil "GLT_GPSINSmarker") then {GLT_GPSINSmarker setMarkerTypeLocal "GLT_GPSINSmarker"};
  60.                 if (!isnil "GLT_GPSINStarget") then {GLT_GPSINStarget setPosATL [getPosATL GLT_GPSINStarget select 0, getPosATL GLT_GPSINStarget select 1, (random 3)]};
  61.             };
  62.         };
  63.     };
  64.     if (isnil "glt_gpsSetMarker") then {
  65.         glt_gpsSetMarker = {
  66.             private ["_pos"];
  67.             if (local player) then {
  68.                 _pos = _this select 0;
  69.                 if (count _this == 0) exitWith {};
  70.                 deleteMarkerLocal "glt_airgpsmarker";
  71.                 GLT_MapClickMarker = createMarkerLocal ["glt_airgpsmarker",_pos];
  72.                 "glt_airgpsmarker" setMarkerPosLocal _pos;
  73.                 "glt_airgpsmarker" setMarkerColorLocal "ColorBlack";
  74.                 "glt_airgpsmarker" setMarkerTypeLocal "waypoint";
  75.                 "glt_airgpsmarker" setMarkerTextLocal format ["  %1",(mapGridPosition _pos)];
  76.             };
  77.         };
  78.     };
  79.     if (isnil "glt_gpsMarkPos") then {
  80.         glt_gpsMarkPos = {
  81.             if (local player) then {
  82.                 if !(isnil "GLT_MapClickMarker") then {
  83.                     private ["_pos", "_markertype", "_zz"];
  84.                     if (!isnil "GLT_GPSINSmarker") then {deleteMarkerLocal GLT_GPSINSmarker};
  85.                     if (!isnil "GLT_GPSINStarget") then {deleteVehicle GLT_GPSINStarget};
  86.                     _pos = getMarkerPos "glt_airgpsmarker";
  87.                     deleteMarkerLocal "glt_airgpsmarker";
  88.                     GLT_GPSINSmarker = createMarkerLocal ["GLT_GPSINSmarker", _pos];
  89.                     "GLT_GPSINSmarker" setMarkerShapeLocal "ICON";
  90.                     "GLT_GPSINSmarker" setMarkerTypeLocal GLT_GPSMARKERTYPE;
  91.                     "GLT_GPSINSmarker" setMarkerColorLocal "ColorYellow";
  92.                     "GLT_GPSINSmarker" setMarkerTextLocal format [" %1", (mapGridPosition _pos)];
  93.                     if (GLT_GPSMARKERTYPE == "GLT_GPSINSmarkerHigh") then {_zz = glt_gpsDispLevel} else {_zz = random 3};
  94.                     GLT_GPSINStarget = "GLT_GPStarget" createVehicleLocal [_pos select 0, _pos select 1, _zz];
  95.                     GLT_GPSINStarget setPosATL [_pos select 0, _pos select 1, _zz];
  96.                     //player dotarget GLT_GPSINStarget;
  97.                     GLT_GPSINStarget enableSimulation false;
  98.                 };
  99.             };
  100.         };
  101.     };
  102.     if (isnil "glt_gpsCenterOnPlayer") then {
  103.         glt_gpsCenterOnPlayer = {
  104.             if (local player) then {
  105.                 disableSerialization;
  106.                 private ["_pos","_map","_zoom"];
  107.                 _pos = [];
  108.                 _pos = position player;
  109.                 _pos resize 2;
  110.                 _map = (findDisplay 3330) displayCtrl 3330;
  111.                 _zoom = ctrlMapScale _map;
  112.                 ctrlMapAnimClear _map;
  113.                 _map ctrlMapAnimAdd [0.1,_zoom,_pos];
  114.                 ctrlMapAnimCommit _map;
  115.                 waitUntil {ctrlMapAnimDone _map};
  116.                 ctrlMapAnimClear _map;
  117.             };
  118.         };
  119.     };
  120.     if (isnil "glt_gpsClear") then {
  121.         glt_gpsClear = {
  122.             if (local player) then {
  123.                 deleteMarkerLocal "glt_airgpsmarker";
  124.                 if (!isnil "GLT_GPSINSmarker") then {deleteMarkerLocal GLT_GPSINSmarker};
  125.                 if (!isnil "GLT_GPSINStarget") then {deleteVehicle GLT_GPSINStarget};
  126.                 player dowatch objNull;
  127.             };
  128.         };
  129.     };
  130.     if (isnil "glt_gpsCenterOnMarker") then {
  131.         glt_gpsCenterOnMarker = {
  132.             if (local player) then {
  133.                 disableSerialization;
  134.                 private ["_pos","_map","_zoom"];
  135.                 _pos = [];
  136.                 _pos = getMarkerPos "GLT_GPSINSmarker";
  137.                 _pos resize 2;
  138.                 _map = (findDisplay 3330) displayCtrl 3330;
  139.                 _zoom = ctrlMapScale _map;
  140.                 ctrlMapAnimClear _map;
  141.                 _map ctrlMapAnimAdd [0.1,_zoom,_pos];
  142.                 ctrlMapAnimCommit _map;
  143.                 waitUntil {ctrlMapAnimDone _map};
  144.                 ctrlMapAnimClear _map;
  145.             };
  146.         };
  147.     };
  148.     if (isnil "glt_gpsExit") then {
  149.         glt_gpsExit = {
  150.             if (local player) then {
  151.                 onMapSingleClick "";
  152.                 deleteMarkerLocal GLT_MapClickMarker;
  153.             };
  154.         };
  155.     };
  156.     if (isnil "glt_gpsSetHeight") then {
  157.         glt_gpsSetHeight = {
  158.             _toAdd = _this select 0;
  159.             _limitLow = _this select 1;
  160.             _limitHi = _this select 2;
  161.             glt_gpsDispLevel = ((glt_gpsDispLevel + _toAdd) max _limitLow) min _limitHi;
  162.             if ((!isnil "GLT_GPSINStarget") and ((getposATL GLT_GPSINStarget select 2) > 10)) then {
  163.                 GLT_GPSINStarget setPosATL [getPosATL GLT_GPSINStarget select 0, getPosATL GLT_GPSINStarget select 1, glt_gpsDispLevel];
  164.             };
  165.             _display = findDisplay 3330;
  166.             _mycontrol = _display displayCtrl 3358;
  167.             _mycontrol ctrlsettext (str glt_gpsDispLevel);
  168.             _mycontrol ctrlcommit 0;
  169.         };
  170.     };
  171.     if (isnil "GLT_createBomblets") then {
  172.         GLT_createBomblets = {
  173.             if ((getNumber (configFile >> "cfgWeapons" >> (_this select 1) >> "GLT_bomblets")) > 0) then {
  174.                 _this spawn {
  175.                     private ["_bomb", "_pos", "_vel", "_i", "_h", "_velrand", "_type", "_numb"];
  176.                     _bomb = _this select 5;
  177.                     //_bomb = nearestObject [position (_this select 0),(_this select 4)];
  178.                     _type = getText (configFile >> "cfgWeapons" >> (_this select 1) >> "GLT_bombletType");
  179.                     _numb = getNumber (configFile >> "cfgWeapons" >> (_this select 1) >> "GLT_bomblets");
  180.                     while {alive _bomb} do {
  181.                         _pos = getPosATL _bomb;
  182.                         _vel = velocity _bomb;
  183.                         sleep 0.01;
  184.                     };
  185.                     if ((_pos select 2) > 40) then {
  186.                         for [{_i=0},{_i<_numb},{_i=_i+1}] do {
  187.                             _h = createvehicle [_type,_pos,[],2,"CAN_COLLIDE"];
  188.                             _velrand = ((_vel select 0) + (_vel select 1))/5;
  189.                             _h setvelocity [(_vel select 0)+(random _velrand) -(random _velrand),(_vel select 1)+(random _velrand) -(random _velrand),(_vel select 2)+random 5.0-random 5.0];
  190.                             sleep (0.05 + (random 0.05));
  191.                         };
  192.                     };
  193.                 };
  194.             };
  195.         };
  196.     };
  197.     if (isnil "GLT_GPSAutoPilot") then {
  198.         GLT_GPSAutoPilot = {
  199.             if ((player != vehicle player) && (player == driver (vehicle player))) then {
  200.                 private ["_plane", "_vecDir", "_vecUp"];
  201.                 _plane = vehicle player;
  202.                 _vecUp = vectorUp _plane;
  203.                 GLT_AutoPilot = true;
  204.                 while {GLT_AutoPilot} do {
  205.                     if (((inputAction "heliForward") + (inputAction "heliBack") + (inputAction "heliCyclicLeft") + (inputAction "heliCyclicRight")) > 0.01) exitwith {GLT_AutoPilot = false};
  206.                     if ((_vecUp select 0) < -0.0021) then {_vecUp set [0, (_vecUp select 0) + ((abs (ln ((_vecUp select 0)+ 1)))/50)]};
  207.                     if ((_vecUp select 0) > 0.0021) then {_vecUp set [0, (_vecUp select 0) - ((abs (ln ((_vecUp select 0)+ 1)))/50)]};
  208.                     if ((_vecUp select 1) < -0.0021) then {_vecUp set [1, (_vecUp select 1) + ((abs (ln ((_vecUp select 1)+ 1)))/50)]};
  209.                     if ((_vecUp select 1) > 0.0021) then {_vecUp set [1, (_vecUp select 1) - ((abs (ln ((_vecUp select 1)+ 1)))/50)]};
  210.                     _plane setVectorUp _vecUp;
  211.                     sleep 0.025;
  212.                 };
  213.             };
  214.         };
  215.     };
  216.     waitUntil {!isNull player};
  217.     if (((vehicle player) iskindof "Air") and ((player == (driver (vehicle player))) or (player == (gunner (vehicle player))))) then {
  218.         _nul = [(vehicle player)] spawn glt_hideGPSobject;
  219.     };
  220. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement