home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-23 | 2.0 KB | 94 lines | [TEXT/?bDv] |
- !
- ! Bomber
- !
- ! This bot recognizes when it takes damage, and it tries to run
- ! away when it gets hit.
- ! Its weapon is a grenade launcher, not an ordinary gun.
-
- #DATA
-
- EQU INCR 23
- EQU MINDIST 25
-
- DEF DAMAGE
- DEF SCAN_AT
- DEF XX ! Destination coordinates
- DEF YY
- DEF GOX ! Prepared velocities for running away
- DEF GOY
- DEF TEMP
-
- #CODE ASM
-
- :INITIALIZE
- JSR CALCPOS ! Pick a point to go to
- MUL 20, GOX ! Prepare to accelerate an awful lot
- MUL 20, GOY
- MOV D0, DAMAGE ! Remember current damage level
-
- :SCANLOOP
- CMP D0, DAMAGE ! Have I been hit?
- BNE RUNAWAY ! If so, then run away.
- ADD INCR, SCAN_AT
- SCN SCAN_AT
- CMP S0, 0
- BEQ SCANLOOP
-
- MOV S1, R1 ! Set angle to target
- MOV S2, R2 ! Set distance to target
- CMP R2, MINDIST
- BGE FIRE
- MOV MINDIST, R2 ! Don't launch so close that you hit
- ! yourself!
- :FIRE
- FIR 1 ! Don't bother locking, as grenades are
- JMP SCANLOOP ! pretty slow to detonate anyway
-
- :RAWAY
- JSR CALCVEL
- MUL 2, GOX ! Move there twice as fast.
- MUL 2, GOY
- :RUNAWAY
- VEL GOX, GOY
- MOV XX, TEMP ! Is XX-X0 > 30? Then we're not there
- SUB X0, TEMP ! yet. Otherwise, continue on.
- CMP TEMP, 30
- BGT RAWAY
- NEG TEMP, TEMP ! How about X0-XX? If not, loop.
- CMP TEMP, 30
- BGT RAWAY
- MOV YY, TEMP ! YY-Y0 > 30? Same thing.
- SUB Y0, TEMP
- CMP TEMP, 30
- BGT RAWAY
- NEG TEMP, TEMP ! Y0-YY? Last one...
- CMP TEMP, 30
- BGT RAWAY
-
- ! If we got this far, we must be within 30 pixels (both X
- ! and Y) of our destination. Close enough.
-
- VEL 0, 0
- JMP INITIALIZE ! Start all over again.
-
-
- ! These are subroutines. CALCVEL calculates the new velocity
- ! for moving to point XX,YY. CALCPOS does the same, except
- ! that it also picks random numbers between 20 and 235 for
- ! XX and YY.
-
- :CALCPOS
- RND 215, XX
- RND 215, YY
- ADD 20, XX
- ADD 20, YY
- :CALCVEL
-
- MOV XX, GOX
- SUB X0, GOX
- MOV YY, GOY
- SUB Y0, GOY
- RET
-
- #END
-