Advertisement
Guest User

fn__mainLoop - d_finger

a guest
May 20th, 2015
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. #include "addon.hpp"
  2. #include "main.hpp"
  3.  
  4. LOG("Starting");
  5.  
  6. while {isNull (findDisplay 46)} do {sleep 1;};
  7.  
  8. GVAR(lastFPTime) = -FP_ACTION_TIMEOUT;
  9.  
  10. if (isNil {GVAR(cba_mode)}) then
  11. {
  12.  
  13.  
  14.  
  15. (findDisplay 46) displayAddEventHandler["KeyUp",
  16. {
  17. PV(_keycomb) = _this select [1, 4];
  18. LOGV(_keycomb);
  19.  
  20. PV(_rv) = false;
  21.  
  22. if (_keycomb isEqualTo GVAR(FP_keyComb) && alive player) then
  23. {
  24. if (!(
  25. (player == vehicle player ||
  26. (vehicle player) isKindOf "StaticWeapon") &&
  27. cameraView in ["INTERNAL", "EXTERNAL"]
  28. )) exitWith {};
  29.  
  30. _rv = true;
  31.  
  32. if (diag_tickTime < GVAR(lastFPTime) + FP_ACTION_TIMEOUT)
  33. exitWith {};
  34.  
  35.  
  36. PV(_pos_prec) = positionCameraToWorld [0, 0, FP_DISTANCE];
  37. PV(_pos) = positionCameraToWorld [
  38. random (2*FP_RANDOMIZATION_X) - FP_RANDOMIZATION_X,
  39. random (2*FP_RANDOMIZATION_Y) - FP_RANDOMIZATION_Y,
  40. FP_DISTANCE
  41. ];
  42.  
  43.  
  44. PV(_dest_players) = [];
  45.  
  46. PV(_pep) = eyePos player;
  47. {
  48. if (isPlayer _x && _x != player && alive _x &&
  49. {(_x == vehicle _x || (vehicle _x) isKindOf "StaticWeapon") && {
  50. ((eyePos _x) vectorDistance _pep) < MAX_DIST_TO_OTHER_PLAYERS
  51. }}) then
  52. {
  53. _dest_players pushBack _x;
  54. };
  55. } forEach playableUnits;
  56.  
  57. GVAR(pv_fpToServer) = [player, _pos, _dest_players];
  58.  
  59. LOGV(GVAR(pv_fpToServer));
  60.  
  61. if (isServer) then
  62. {
  63. [0, GVAR(pv_fpToServer)] call GVAR(fnc_pv_fpToServer);
  64. }
  65. else
  66. {
  67. publicVariableServer 'GVAR(pv_fpToServer)';
  68. };
  69.  
  70.  
  71. if (GVAR(FP_indicator_for_self)) then
  72. {
  73. [0, [player, _pos_prec]] call GVAR(fnc_pv_fpToClient);
  74. };
  75.  
  76. player playActionNow "GestureGo";
  77. GVAR(lastFPTime) = diag_tickTime;
  78.  
  79. _rv = true;
  80. };
  81.  
  82. _rv;
  83. }
  84. ];
  85.  
  86. (findDisplay 46) displayAddEventHandler["KeyDown",
  87. {
  88. PV(_keycomb) = _this select [1, 4];
  89. LOGV(_keycomb);
  90.  
  91. PV(_rv) = false;
  92.  
  93. if (_keycomb isEqualTo GVAR(FP_keyComb) && alive player) then
  94. {
  95. if (!(
  96. (player == vehicle player ||
  97. (vehicle player) isKindOf "StaticWeapon") &&
  98. cameraView in ["INTERNAL", "EXTERNAL"]
  99. )) exitWith {};
  100.  
  101. _rv = true;
  102. };
  103.  
  104. _rv;
  105. }
  106. ];
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. } //////////////////////////////////////////////////////////////////////////////
  115. else // cba mode ///////////////////////////////////////////////////////////////
  116. { //////////////////////////////////////////////////////////////////////////////
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. ["Finger addon ",
  124. "point_finger_at",
  125. [localize "STR_Addons__d_finger__uac_keyComb", localize "STR_Addons__d_finger__uac_keyComb"],
  126. {
  127.  
  128. PV(_rv) = false;
  129. if (alive player) then
  130. {
  131. if (!(
  132. (player == vehicle player ||
  133. (vehicle player) isKindOf "StaticWeapon" ||
  134. (vehicle player) isKindOf "Ship"|| //BUM #1 Added Boat/Car
  135. (vehicle player) isKindOf "Car") &&
  136. cameraView in ["INTERNAL", "EXTERNAL"]
  137. )) exitWith {};
  138.  
  139. _rv = true;
  140.  
  141. if (diag_tickTime < GVAR(lastFPTime) + FP_ACTION_TIMEOUT)
  142. exitWith {};
  143.  
  144.  
  145. PV(_pos_prec) = positionCameraToWorld [0, 0, FP_DISTANCE];
  146. PV(_pos) = positionCameraToWorld [
  147. random (2*FP_RANDOMIZATION_X) - FP_RANDOMIZATION_X,
  148. random (2*FP_RANDOMIZATION_Y) - FP_RANDOMIZATION_Y,
  149. FP_DISTANCE
  150. ];
  151.  
  152.  
  153. PV(_dest_players) = [];
  154.  
  155. PV(_pep) = eyePos player;
  156. {
  157. if (isPlayer _x && _x != player && alive _x &&
  158. {(_x == vehicle _x || (vehicle _x) isKindOf "StaticWeapon" || (vehicle _x) isKindOf "Car" || (vehicle _x) isKindOf "Ship") && //BUM #2: added car/boat here
  159. {((eyePos _x) vectorDistance _pep) < MAX_DIST_TO_OTHER_PLAYERS
  160. }}) then {
  161. _dest_players pushBack _x;
  162. };
  163. } forEach playableUnits;
  164.  
  165. //BUM EDIT #3 START
  166.  
  167. if (true) Then {
  168. _unitsToCheck = _dest_players;
  169. {
  170. if (lineIntersects [eyepos player, eyepos _x, player, _x]) Then {
  171. _dest_players deleteAt _forEachIndex;
  172. };
  173. } forEach _unitsToCheck;
  174. };
  175.  
  176. //BUM EDIT #3 END
  177.  
  178. GVAR(pv_fpToServer) = [player, _pos, _dest_players];
  179.  
  180. LOGV(GVAR(pv_fpToServer));
  181.  
  182. if (isServer) then
  183. {
  184. [0, GVAR(pv_fpToServer)] call GVAR(fnc_pv_fpToServer);
  185. }
  186. else
  187. {
  188. publicVariableServer 'GVAR(pv_fpToServer)';
  189. };
  190.  
  191.  
  192. if (GVAR(FP_indicator_for_self)) then
  193. {
  194. [0, [player, _pos_prec]] call GVAR(fnc_pv_fpToClient);
  195. };
  196.  
  197. player playActionNow "GestureGo";
  198. GVAR(lastFPTime) = diag_tickTime;
  199.  
  200. _rv = true;
  201. };
  202.  
  203. _rv;
  204. },
  205. "",
  206. [GVAR(FP_keyComb) select 0,
  207. [GVAR(FP_keyComb) select 1, GVAR(FP_keyComb) select 2, GVAR(FP_keyComb) select 3]]
  208. ] call cba_fnc_addKeybind;
  209.  
  210.  
  211.  
  212. };
  213.  
  214.  
  215. LOG("Done");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement