home *** CD-ROM | disk | FTP | other *** search
- $trp 100
- $eng 005
- $msh 070
- $rsh 000
- $pwr 025
- set l 000
- set m 000
- set n 000
- set o 000
- # sets up constants u=1000, s=2000, r=30, t=6000, q=90, p=180
- set u 100
- set a 010
- mlt u a
- cpy u s
- set s 002
- mlt s u
- set r 030
- set t 006
- mlt t u
- set q 090
- set p 180
- @loop
- set a 003
- arm a
- set a 040
- prx a
- set v 002
- set w 001
- loc
- # if range>2000 (max phaser range), goto @lead
- bgr a s @lead
- # otherwise, phaser it, then fire a torp.
- phs
- set a 001
- arm a
- set a 015
- prx a
- #
- # 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 z
- cos c x
- sin c y
- mlt x z
- div x u
- mlt x a
- div x u
- mlt y z
- div y u
- mlt y a
- div y u
- cos b z
- mlt z a
- div z u
- cpy x g
- cpy y h
- cpy z i
- sub g m
- sub h n
- sub i o
- cpy x m
- cpy y n
- cpy z o
- loc
- set j 200
- div a j
- mlt g a
- mlt h a
- mlt i a
- tim
- cpy a j
- sub j l
- cpy a l
- div g j
- div h j
- div i j
- add x g
- add y h
- add z i
- # this part gets the relative position and converts it to X,Y,Z
- loc
- cpy a k
- sin b i
- cos c g
- sin c h
- mlt g i
- div g u
- mlt g a
- div g u
- mlt h i
- div h u
- mlt h a
- div h u
- cos b i
- mlt i a
- div i u
- # 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/600.
- # (600 is the torpedo's speed).
- set j 100
- div a j
- set j 006
- div a j
- mlt x a
- mlt y a
- mlt z a
- add x g
- add y h
- add z i
- # this copies the final results to X, Y, and Z, converts back to polar
- # coordinates, fires, and chooses direction.
- pol
- cpy b y
- cpy c z
- fir
- blt k t @near
- # I add 30 degrees to the angle here, to avoid charging the target head on.
- set g 150
- bgr y g @f2
- add y r
- set x 100
- mve
- exe
- jmp @loop
- @f2
- set g 150
- add g p
- sub g y
- cpy g y
- add z p
- mve
- exe
- jmp @loop
- # keep distance if nearby (r<4000)
- @near
- blt y r @n2
- set x 100
- add z p
- set g 090
- sub g y
- cpy g y
- add y r
- mve
- exe
- jmp @loop
- @n2
- set x 100
- add y q
- sub y r
- mve
- exe
- jmp @loop
- $end
-
-