home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / game / misc / 003 / leader.src < prev    next >
Encoding:
Text File  |  1993-05-03  |  1.6 KB  |  102 lines

  1. #configure ship
  2. $trp 048
  3. $eng 002
  4. $msh 070
  5. $rsh 030
  6. $pwr 050
  7. set a 010
  8. arm a
  9. set a 040
  10. prx a
  11. # sets up constants m=1000, n=100, s=2000, p=40, r=30
  12. set m 100
  13. set a 010
  14. mlt m a
  15. set n 100
  16. cpy m s
  17. set p 002
  18. mlt s p
  19. set p 100
  20. set r 030
  21. @loop1
  22. # locate enemy ship #1
  23. set v 002
  24. set w 001
  25. loc
  26. # if range>2000 (max phaser range), goto @lead
  27. bgr a s @lead
  28. # otherwise, phaser it, select movement direction, and goto @mvt
  29. phs
  30. cpy b y
  31. cpy c z
  32. cpy p x
  33. jmp @mvt
  34. # this next part tries to lead the enemy ship and fire at it
  35. @lead
  36. # this gets the ship's velocity and converts it to x,y,z components
  37. vel
  38. sin b i
  39. cos c g
  40. sin c h
  41. mlt g i
  42. div g m
  43. mlt g a
  44. div g m
  45. mlt h i
  46. div h m
  47. mlt h a
  48. div h m
  49. cos b i
  50. mlt i a
  51. div i m
  52. # this part gets the relative position and converts it to X,Y,Z
  53. loc
  54. sin b l
  55. cos c j
  56. sin c k
  57. mlt j l
  58. div j m
  59. mlt j a
  60. div j m
  61. mlt k l
  62. div k m
  63. mlt k a
  64. div k m
  65. cos b l
  66. mlt l a
  67. div l m
  68. # use the formula that X=X0+Vx*T, where X is the position to shoot at, X0 is
  69. # the current position, Vx is the velocity in the X direction, and T is the
  70. # estimated time to reach the target.  Here, I am letting T be Range/600.
  71. # (600 is the torpedo's speed).
  72. cpy a t
  73. set u 100
  74. div t u
  75. set u 006
  76. div t u
  77. mlt g t
  78. mlt h t
  79. mlt i t
  80. add g j
  81. add h k
  82. add i l
  83. # this copies the final results to X, Y, and Z, converts back to polar
  84. # coordinates, fires, and chooses direction.
  85. cpy g x
  86. cpy h y
  87. cpy i z
  88. pol
  89. cpy b y
  90. cpy c z
  91. fir
  92. # I add 30 degrees to the angle here, to avoid charging the target head on.
  93. add z r
  94. cpy n x
  95. @mvt
  96. # here we move
  97. mve
  98. exe
  99. jmp @loop1
  100. $end
  101.