jumpDecider.sqf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Params["namUnit"];
  2. _namUnit=_this select 0;
  3. _namThisJumpData=_namUnit getVariable["jumpArray",[]];
  4. _result=false;
  5. if((count _namThisJumpData) ==0) then
  6. {
  7. _namThisJumpData=[false,0,0,5,2];
  8. };
  9. comment "data from jump array";
  10. comment "is Jumping-0
  11. last jump time-1
  12. jump counter-2
  13. cooldown-3
  14. max consecutive jumps-4
  15. !C or (!A and B)";
  16. _namIsJumping=_namThisJumpData select 0;
  17. _namLastJumpTime=_namThisJumpData select 1;
  18. _namJumpCounter=_namThisJumpData select 2;
  19. _namJumpCooldownTime=_namThisJumpData select 3;
  20. _namMaxJump=_namThisJumpData select 4;
  21. comment "A-is jumping B-is cooled C-is over counter /// karnugh map variables";
  22. _namTimeSinceLastJump=time-_namLastJumpTime;
  23. _A=_namIsJumping;
  24. comment "true if cooled";
  25. _B=(_namTimeSinceLastJump)>_namJumpCooldownTime;
  26. comment "true if u just 'double jumped'";
  27. _C=_namJumpCounter>=_namMaxJump;
  28. if((count _namThisJumpData) !=0) then
  29. {
  30. _namIsOverCounter=_C;
  31. _namIsCool=(time-_namLastJumpTime)>=_namJumpCooldownTime;
  32. comment "if ur cooled then reset counter";
  33. if(_B)then
  34. {
  35. _namJumpCounter=0;
  36. _namUnit setVariable ["jumpArray", [_namIsJumping,_namLastJumpTime,_namJumpCounter,_namJumpCooldownTime,_namMaxJump],true];
  37. };
  38. if(!_C || {!_A && {_B}}) then //true if u can jump
  39. {
  40. _result=true;
  41. _result
  42. }
  43. else
  44. {
  45. hint parseText format["Can not boost. <t color='#40e0d0'>Cooldown done in</t> <t color='#FF0000'>%1</t>",(_namJumpCooldownTime-(time-_namLastJumpTime))];
  46. if(_B || {(_namJumpCooldownTime-(time-_namLastJumpTime))<0}) then
  47. {
  48. _namJumpCounter=0;
  49. _namUnit setVariable ["jumpArray", [_namIsJumping,_namLastJumpTime,_namJumpCounter,_namJumpCooldownTime,_namMaxJump],true];
  50. };
  51. _result=false;
  52. };
  53. _result//return value
  54. };