home *** CD-ROM | disk | FTP | other *** search
- #configure ship
- $trp 048
- $eng 002
- $msh 100
- $rsh 000
- $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
- 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
- @loop1
- # locate enemy ship #1
- set w 000
- @select
- set v 002
- add w o
- dam
- beq a n @select
- 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
-