zkb1325

Arma 3 Soccer

Apr 26th, 2021 (edited)
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.87 KB | None | 0 0
  1. /*
  2.     Place a ball in editor and call it SoccerBall
  3.     Place a trigger down with an area and call it SoccerAreaTrigger
  4.         - This was used to determine if the player is still within the area to kick the ball
  5.  
  6.     Scroll up to increase kick force
  7.     Scroll down to decrease kick force
  8.  
  9.     The ZKB_fnc_AddForce function is used to more easily setvelocity to an object with remoteExec
  10.     The goal posts where a trigger that checked when the ball entered and reset it's position
  11. */
  12. ZKB_fnc_AddForce = {
  13.     private _object = param [0,objNull,[objNull]];
  14.     private _velArray = param [1,[0,0,0],[[]]];
  15.     _object setVelocity _velArray;
  16. };
  17.  
  18. [] spawn {
  19.     kickforce = 2;
  20.     private _soccerMouseZChangedEH = (findDisplay 46) displayAddEventHandler ["MouseZChanged", {
  21.         if (_this select 1 > 0) then {
  22.             kickforce = (kickforce + 1) min 5;
  23.         } else {
  24.             kickforce = (kickforce - 1) max 0;
  25.         };
  26.         titleText [format ["Kick Force: %1%2",((kickforce/5)*100),"%"],"PLAIN DOWN"];
  27.     }];
  28.        
  29.     private _soccerDraw3DEH = addMissionEventHandler ["Draw3D", {
  30.         drawIcon3D ["", [0,0,1,1], [((getposATL SoccerBall) select 0), ((getposATL SoccerBall) select 1), ((getposATL SoccerBall) select 2) + .25], 1.5, 1.5, 0, "Ball", 0, 0.04, "PuristaMedium","center",true];
  31.     }];
  32.    
  33.     private _playerVel = velocity player;
  34.     private _playerDir = direction player;
  35.     while {true} do {
  36.         waitUntil {player distance SoccerBall <= .5 or !(player inArea SoccerAreaTrigger)};
  37.         if !(player inArea SoccerAreaTrigger) exitWith {};
  38.         _playerVel = velocity player;
  39.         _playerDir = direction player;
  40.         [SoccerBall,[(_playervel select 0) + (sin _playerDir * kickforce), (_playervel select 1) + (cos _playerDir * kickforce), kickforce/1.5]] remoteExecCall ["ZKB_fnc_AddForce",SoccerBall,false];
  41.         sleep .1;
  42.     };
  43.     (findDisplay 46) displayRemoveEventHandler ["MouseZChanged",_soccerMouseZChangedEH];
  44.     removeMissionEventHandler ["Draw3D",_soccerDraw3DEH];
  45. };
Add Comment
Please, Sign In to add comment