jumpAssinger.sqf 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //params["personToApply"];
  2. personToApply=_this select 0;
  3. personToApply removeAllEventHandlers "HandleDamage";
  4. removeAllActions personToApply;
  5. comment "is Jumping-0
  6. last jump time-1
  7. jump counter-2
  8. cooldown-3
  9. max consecutive jumps-4";
  10. jumpData=[false,0,0,5,2];
  11. personToApply setVariable ["jumpArray", jumpData,true];
  12. _namShortJumpDistY=5;//in meters
  13. _namShortJumpDistX=10;//in meters
  14. _namShortJumpVeloY=1;//meters/second
  15. _namShortJumpVeloX=1;//meters/second
  16. _namLongJumpDistY=20;//in meters
  17. _namLongJumpDistX=40;//in meters
  18. _namLongJumpVeloY=1;//meters/second
  19. _namLongJumpVeloX=1;//meters/second
  20. //Short calculations
  21. _namShortJumpVeloY=sqrt(-2*-9.8*_namShortJumpDistY);
  22. _tShort=(-_namShortJumpDistY)/(-9.8);
  23. _namShortJumpVeloX=_namShortJumpDistX/(2*_tShort);
  24. //Long calculations
  25. _namLongJumpVeloY=sqrt(-2*-9.8*_namLongJumpDistY);
  26. _tLong=(-_namLongJumpDistY)/(-9.8);
  27. _namLongJumpVeloX=_namLongJumpDistX/(2*_tLong);
  28. jumpPhysicsData=[[_namShortJumpVeloX,_namShortJumpVeloY],[_namLongJumpVeloX,_namLongJumpVeloY]];
  29. personToApply setVariable ["jumpPhysicsArray", jumpPhysicsData,true];