home *** CD-ROM | disk | FTP | other *** search
- #configure ship
- # this ship gets commands from flagship or flagshp2 and attacks whatever
- # vessel it is told to or the nearest if none is specified.
- $trp 050
- $eng 005
- $msh 070
- $rsh 020
- $pwr 050
- set a 010
- arm a
- set a 040
- prx a
- # sets up constants m=1000, n=100, s=2000, p=40, r=30, o=1, q=0, t=5
- set m 100
- set a 010
- mlt m a
- set n 100
- cpy m s
- set p 002
- mlt s p
- set p 040
- set r 030
- set o 001
- set q 000
- @loop1
- set t 005
- # make sure flagship's OK
- set v 001
- set w 005
- dam
- bne a n @cont
- set d 000
- @cont
- set v 002
- cpy d w
- bne d q @targeting
- #if not, finds nearest live enemy ship
- set f 001
- set g 000
- set w 001
- @lp1
- dam
- bgr a n @c1
- beq a n @in1
- loc
- bne g q @tmp1
- cpy a g
- @tmp1
- bgr a g @in1
- cpy w f
- cpy a g
- @in1
- add w o
- blt w t @lp1
- @c1
- cpy f w
- @targeting
- loc
- # if range>2000 (max phaser range), goto @lead
- bgr a s @lead
- # otherwise, phaser it, select movement direction, and goto @mvt
- phs
- cpy b y
- cpy c z
- cpy p x
- jmp @mvt
- #
- # this next part tries to lead the enemy ship and fire at it
- @lead
- # this gets the ship's velocity and converts it to x,y,z components
- vel
- sin b i
- cos c g
- sin c h
- mlt g i
- div g m
- mlt g a
- div g m
- mlt h i
- div h m
- mlt h a
- div h m
- cos b i
- mlt i a
- div i m
- # this part gets the relative position and converts it to X,Y,Z
- loc
- sin b l
- cos c j
- sin c k
- mlt j l
- div j m
- mlt j a
- div j m
- mlt k l
- div k m
- mlt k a
- div k m
- cos b l
- mlt l a
- div l m
- # use the formula that X=X0+Vx*T, where X is the position to shoot at, X0 is
- # the current position, Vx is the velocity in the X direction, and T is the
- # estimated time to reach the target. Here, I am letting T be Range/250.
- # (250 is the torpedo's speed).
- cpy a t
- set u 100
- div t u
- set u 006
- div t u
- mlt g t
- mlt h t
- mlt i t
- add g j
- add h k
- add i l
- # this copies the final results to X, Y, and Z, converts back to polar
- # coordinates, fires, and chooses direction.
- cpy g x
- cpy h y
- cpy i z
- pol
- cpy b y
- cpy c z
- fir
- # I add 30 degrees to the angle here, to avoid charging the target head on.
- add z r
- cpy n x
- @mvt
- # here we move
- mve
- exe
- jmp @loop1
- $end
-