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

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