jumpShort.sqf 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //Params["personToApply"];
  2. personToApply=_this select 0;
  3. personToApply addAction ["<t color='#FF66FF'>Short Jump--------U13</t>",
  4. {
  5. _namUnit=_this select 0;
  6. _namThisJumpData=_namUnit getVariable["jumpArray",[]];
  7. if((count _namThisJumpData) ==0) then
  8. {
  9. _namThisJumpData=[false,0,0,5,2];
  10. };
  11. comment "data from jump array";
  12. comment "is Jumping-0
  13. last jump time-1
  14. jump counter-2
  15. cooldown-3
  16. max consecutive jumps-4
  17. !C or (!A and B)";
  18. _namIsJumping=_namThisJumpData select 0;
  19. _namLastJumpTime=_namThisJumpData select 1;
  20. _namJumpCounter=_namThisJumpData select 2;
  21. _namJumpCooldownTime=_namThisJumpData select 3;
  22. _namMaxJump=_namThisJumpData select 4;
  23. comment "A-is jumping B-is cooled C-is over counter /// karnugh map variables";
  24. _namTimeSinceLastJump=time-_namLastJumpTime;
  25. _A=_namIsJumping;
  26. comment "true if cooled";
  27. _B=(_namTimeSinceLastJump)>_namJumpCooldownTime;
  28. comment "true if u just 'double jumped'";
  29. _C=_namJumpCounter>=_namMaxJump;
  30. if((count _namThisJumpData) !=0) then
  31. {
  32. _namIsOverCounter=_C;
  33. _namIsCool=(time-_namLastJumpTime)>=_namJumpCooldownTime;
  34. comment "if ur cooled then reset counter";
  35. if(_B)then
  36. {
  37. _namJumpCounter=0;
  38. _namUnit setVariable ["jumpArray", [_namIsJumping,_namLastJumpTime,_namJumpCounter,_namJumpCooldownTime,_namMaxJump],true];
  39. };
  40. if(!_C || {!_A && {_B}}) then
  41. {
  42. _namJumpPhysicsArray=_namUnit getVariable["jumpPhysicsArray",[[5,5],[20,40]]];
  43. _namSpeed=(_namJumpPhysicsArray select 0) select 0;
  44. _namSpeedUp=(_namJumpPhysicsArray select 0) select 1;
  45. comment "initiate jump";
  46. (_namUnit) setVelocity
  47. [
  48. ((vectordir (_namUnit)) select 0)*_namSpeed,
  49. ((vectordir (_namUnit)) select 1)*_namSpeed,
  50. (velocity (_namUnit) select 2)+_namSpeedUp
  51. ];
  52. comment "update variables";
  53. _namIsJumping=true;
  54. _namLastJumpTime=time;
  55. _namJumpCounter=_namJumpCounter+1;
  56. _namUnit setVariable ["jumpArray", [_namIsJumping,_namLastJumpTime,_namJumpCounter,_namJumpCooldownTime,_namMaxJump],true];
  57. }
  58. else
  59. {
  60. hint parseText format["Can not boost. <t color='#40e0d0'>Cooldown done in</t> <t color='#FF0000'>%1</t>",(_namJumpCooldownTime-(time-_namLastJumpTime))];
  61. if(_B || {(_namJumpCooldownTime-(time-_namLastJumpTime))<0}) then
  62. {
  63. _namJumpCounter=0;
  64. _namUnit setVariable ["jumpArray", [_namIsJumping,_namLastJumpTime,_namJumpCounter,_namJumpCooldownTime,_namMaxJump],true];
  65. };
  66. };
  67. };
  68. }
  69. ,[1],0,false,true,"User13"," driver _target == _this"];