jumpDecider.sqf 1.8 KB

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