Advertisement
kajacx

CRPL move predictor

Apr 30th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. # TeleportTest.crpl
  2. # Created on: 4/30/2018 1:22:12 PM
  3. # ------------------------------------------
  4.  
  5.  
  6. once
  7. ShowTraceLog
  8. ClearTraceLog
  9.  
  10. Self CONST_COUNTSFORVICTORY 0 SetUnitAttribute
  11. Self CONST_CREATEPZ 0 SetUnitAttribute
  12. Self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute
  13. Self CONST_TAKEMAPSPACE 0 SetUnitAttribute
  14.  
  15. #CurrentCoords 1 sub GetUnitAt ->unit
  16. 1084 ->unit
  17. <-unit Trace
  18.  
  19. <-unit CONST_PIXELCOORDX GetUnitAttribute ->lastPostionX
  20. <-unit CONST_PIXELCOORDY GetUnitAttribute ->lastPostionY
  21.  
  22. 0 ->done
  23.  
  24. endonce
  25.  
  26. <-done if
  27. return
  28. endif
  29.  
  30. <-unit CONST_PIXELCOORDX GetUnitAttribute ->currentPostionX
  31. <-unit CONST_PIXELCOORDY GetUnitAttribute ->currentPostionY
  32.  
  33. <-currentPostionX <-lastPostionX neq or ( <-currentPostionY <-lastPostionY neq ) if
  34. "MOVING" Trace
  35. <-currentPostionX ->x1
  36. <-currentPostionY ->y1
  37. <-currentPostionY <-lastPostionY sub <-currentPostionX <-lastPostionX sub atan2 ->a1
  38.  
  39. <-a1 PI 2 div add ->angleOffset
  40.  
  41. <-x1 <-angleOffset cos 8 mul add ->xNew
  42. <-y1 <-angleOffset sin 8 mul add ->yNew
  43.  
  44. <-unit CONST_PIXELCOORDX <-xNew SetUnitAttribute
  45. <-unit CONST_PIXELCOORDY <-yNew SetUnitAttribute
  46.  
  47. 1 Delay
  48.  
  49. <-xNew ->lastPostionX
  50. <-yNew ->lastPostionY
  51.  
  52. <-unit CONST_PIXELCOORDX GetUnitAttribute ->currentPostionX
  53. <-unit CONST_PIXELCOORDY GetUnitAttribute ->currentPostionY
  54.  
  55. <-currentPostionX ->x2
  56. <-currentPostionY ->y2
  57. <-currentPostionY <-lastPostionY sub <-currentPostionX <-lastPostionX sub atan2 ->a2
  58.  
  59. #use matrix magic
  60. <-a1 cos ->m1
  61. <-a2 cos neg ->m2
  62. <-x2 <-x1 sub ->m3
  63. <-a1 sin ->m4
  64. <-a2 sin neg ->m5
  65. <-y2 <-y1 sub ->m6
  66.  
  67. <-m3 <-m2 <-m6 <-m5 @Determinant div ( <-m1 <-m2 <-m4 <-m5 @Determinant ) ->t
  68.  
  69. <-x1 <-a1 cos <-t mul add ->targetX
  70. <-y1 <-a1 sin <-t mul add ->targetY
  71.  
  72. "Target:" <-targetX <-targetY PixelToCell Trace3
  73. "MORTAR" <-targetX <-targetY PixelToCell CreateUnit pop
  74.  
  75. <-unit CONST_PIXELCOORDX <-x1 SetUnitAttribute
  76. <-unit CONST_PIXELCOORDY <-y1 SetUnitAttribute
  77.  
  78. 1 ->done
  79. endif
  80.  
  81. <-unit CONST_PIXELCOORDX GetUnitAttribute ->lastPostionX
  82. <-unit CONST_PIXELCOORDY GetUnitAttribute ->lastPostionY
  83.  
  84.  
  85. :Determinant # f f f f - f
  86. ->v4 ->v3 ->v2 ->v1
  87. <-v1 <-v4 mul sub ( <-v2 <-v3 mul )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement