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

  1. $trp 100
  2. $eng 010
  3. $msh 060
  4. $rsh 020
  5. $pwr 010
  6. set l 000
  7. set m 000
  8. set n 000
  9. set o 000
  10. # sets up constants u=1000, s=2000, r=30, t=6000, q=90, p=180
  11. set u 100
  12. set a 010
  13. mlt u a
  14. cpy u s
  15. set s 002
  16. mlt s u
  17. set r 030
  18. set t 006
  19. mlt t u
  20. set q 090
  21. set p 180
  22. @loop
  23. set a 003
  24. arm a
  25. set a 040
  26. prx a
  27. set v 002
  28. set w 001
  29. loc
  30. # if range>2000 (max phaser range), goto @lead
  31. bgr a s @lead
  32. # otherwise, phaser it, then fire a torp.
  33. phs
  34. set a 001
  35. arm a
  36. set a 015
  37. prx a
  38. # this next part tries to lead the enemy ship and fire at it
  39. @lead
  40. # this part corrects for acceleration
  41. tim
  42. cpy a j
  43. sub j l
  44. cpy a l
  45. vel
  46. cpy a g
  47. cpy b h
  48. cpy c i
  49. sub g m
  50. sub h n
  51. sub i o
  52. cpy a m
  53. cpy b n
  54. cpy c o
  55. div g j
  56. div h j
  57. div i j
  58. loc
  59. set j 200
  60. div a j
  61. mlt g a
  62. mlt h a
  63. mlt i a
  64. vel
  65. add a g
  66. add b h
  67. add c i
  68. # this gets the ship's velocity and converts it to x,y,z components
  69. sin b z
  70. cos c x
  71. sin c y
  72. mlt x z
  73. div x u
  74. mlt x a
  75. div x u
  76. mlt y z
  77. div y u
  78. mlt y a
  79. div y u
  80. cos b z
  81. mlt z a
  82. div z u
  83. # this part gets the relative position and converts it to X,Y,Z
  84. loc
  85. cpy a k
  86. sin b i
  87. cos c g
  88. sin c h
  89. mlt g i
  90. div g u
  91. mlt g a
  92. div g u
  93. mlt h i
  94. div h u
  95. mlt h a
  96. div h u
  97. cos b i
  98. mlt i a
  99. div i u
  100. # use the formula that X=X0+Vx*T, where X is the position to shoot at, X0 is
  101. # the current position, Vx is the velocity in the X direction, and T is the
  102. # estimated time to reach the target.  Here, I am letting T be Range/600.
  103. # (600 is the torpedo's speed).
  104. set j 100
  105. div a j
  106. set j 006
  107. div a j
  108. mlt x a
  109. mlt y a
  110. mlt z a
  111. add x g
  112. add y h
  113. add z i
  114. # this copies the final results to X, Y, and Z, converts back to polar
  115. # coordinates, fires, and chooses direction.
  116. pol
  117. cpy b y
  118. cpy c z
  119. fir
  120. blt k t @near
  121. # I add 30 degrees to the angle here, to avoid charging the target head on.
  122. set g 150
  123. bgr y g @f2
  124. add y r
  125. set x 100
  126. mve
  127. exe
  128. jmp @loop
  129. @f2
  130. set g 150
  131. add g p
  132. sub g y
  133. cpy g y
  134. add z p
  135. mve
  136. exe
  137. jmp @loop
  138. # keep distance if nearby (r<4000)
  139. @near
  140. blt y r @n2
  141. set x 100
  142. add z p
  143. set g 090
  144. sub g y
  145. cpy g y
  146. add y r
  147. mve
  148. exe
  149. jmp @loop
  150. @n2
  151. set x 100
  152. add y q
  153. sub y r
  154. mve
  155. exe
  156. jmp @loop
  157. $end
  158.  
  159.