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

  1. #configure ship
  2. # this ship gets commands from flagship or flagshp2 and attacks whatever
  3. # vessel it is told to or the nearest if none is specified.
  4. $trp 050
  5. $eng 005
  6. $msh 070
  7. $rsh 020
  8. $pwr 050
  9. set a 010
  10. arm a
  11. set a 040
  12. prx a
  13. # sets up constants m=1000, n=100, s=2000, p=40, r=30, o=1, q=0, t=5
  14. set m 100
  15. set a 010
  16. mlt m a
  17. set n 100
  18. cpy m s
  19. set p 002
  20. mlt s p
  21. set p 040
  22. set r 030
  23. set o 001
  24. set q 000
  25. @loop1
  26. set t 005
  27. # make sure flagship's OK
  28. set v 001
  29. set w 005
  30. dam
  31. bne a n @cont
  32. set d 000
  33. @cont
  34. set v 002
  35. cpy d w
  36. bne d q @targeting
  37. #if not, finds nearest live enemy ship
  38. set f 001
  39. set g 000
  40. set w 001
  41. @lp1
  42. dam
  43. bgr a n @c1
  44. beq a n @in1
  45. loc
  46. bne g q @tmp1
  47. cpy a g
  48. @tmp1
  49. bgr a g @in1
  50. cpy w f
  51. cpy a g
  52. @in1
  53. add w o
  54. blt w t @lp1
  55. @c1
  56. cpy f w
  57. @targeting
  58. loc
  59. # if range>2000 (max phaser range), goto @lead
  60. bgr a s @lead
  61. # otherwise, phaser it, select movement direction, and goto @mvt
  62. phs
  63. cpy b y
  64. cpy c z
  65. cpy p x
  66. jmp @mvt
  67. # this next part tries to lead the enemy ship and fire at it
  68. @lead
  69. # this gets the ship's velocity and converts it to x,y,z components
  70. vel
  71. sin b i
  72. cos c g
  73. sin c h
  74. mlt g i
  75. div g m
  76. mlt g a
  77. div g m
  78. mlt h i
  79. div h m
  80. mlt h a
  81. div h m
  82. cos b i
  83. mlt i a
  84. div i m
  85. # this part gets the relative position and converts it to X,Y,Z
  86. loc
  87. sin b l
  88. cos c j
  89. sin c k
  90. mlt j l
  91. div j m
  92. mlt j a
  93. div j m
  94. mlt k l
  95. div k m
  96. mlt k a
  97. div k m
  98. cos b l
  99. mlt l a
  100. div l m
  101. # use the formula that X=X0+Vx*T, where X is the position to shoot at, X0 is
  102. # the current position, Vx is the velocity in the X direction, and T is the
  103. # estimated time to reach the target.  Here, I am letting T be Range/250.
  104. # (250 is the torpedo's speed).
  105. cpy a t
  106. set u 100
  107. div t u
  108. set u 006
  109. div t u
  110. mlt g t
  111. mlt h t
  112. mlt i t
  113. add g j
  114. add h k
  115. add i l
  116. # this copies the final results to X, Y, and Z, converts back to polar
  117. # coordinates, fires, and chooses direction.
  118. cpy g x
  119. cpy h y
  120. cpy i z
  121. pol
  122. cpy b y
  123. cpy c z
  124. fir
  125. # I add 30 degrees to the angle here, to avoid charging the target head on.
  126. add z r
  127. cpy n x
  128. @mvt
  129. # here we move
  130. mve
  131. exe
  132. jmp @loop1
  133. $end
  134.