Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Place a ball in editor and call it SoccerBall
- Place a trigger down with an area and call it SoccerAreaTrigger
- - This was used to determine if the player is still within the area to kick the ball
- Scroll up to increase kick force
- Scroll down to decrease kick force
- The ZKB_fnc_AddForce function is used to more easily setvelocity to an object with remoteExec
- The goal posts where a trigger that checked when the ball entered and reset it's position
- */
- ZKB_fnc_AddForce = {
- private _object = param [0,objNull,[objNull]];
- private _velArray = param [1,[0,0,0],[[]]];
- _object setVelocity _velArray;
- };
- [] spawn {
- kickforce = 2;
- private _soccerMouseZChangedEH = (findDisplay 46) displayAddEventHandler ["MouseZChanged", {
- if (_this select 1 > 0) then {
- kickforce = (kickforce + 1) min 5;
- } else {
- kickforce = (kickforce - 1) max 0;
- };
- titleText [format ["Kick Force: %1%2",((kickforce/5)*100),"%"],"PLAIN DOWN"];
- }];
- private _soccerDraw3DEH = addMissionEventHandler ["Draw3D", {
- 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];
- }];
- private _playerVel = velocity player;
- private _playerDir = direction player;
- while {true} do {
- waitUntil {player distance SoccerBall <= .5 or !(player inArea SoccerAreaTrigger)};
- if !(player inArea SoccerAreaTrigger) exitWith {};
- _playerVel = velocity player;
- _playerDir = direction player;
- [SoccerBall,[(_playervel select 0) + (sin _playerDir * kickforce), (_playervel select 1) + (cos _playerDir * kickforce), kickforce/1.5]] remoteExecCall ["ZKB_fnc_AddForce",SoccerBall,false];
- sleep .1;
- };
- (findDisplay 46) displayRemoveEventHandler ["MouseZChanged",_soccerMouseZChangedEH];
- removeMissionEventHandler ["Draw3D",_soccerDraw3DEH];
- };
Add Comment
Please, Sign In to add comment