home *** CD-ROM | disk | FTP | other *** search
/ Más de 2,500 Juegos / CD1.iso / ZIPDAT / 0951 / 0951.ZIP / SNIPER.AT2 < prev    next >
Encoding:
Text File  |  1997-02-23  |  6.1 KB  |  221 lines

  1. ; Sniper                    Ed T. Toton III, 02/09/92
  2. ;
  3. ; Converted to ATR2, and vastly improved, on 02/04/97
  4. ;                                          & 02/12/97
  5. ;                                 #MSG added 02/23/97
  6. ; This robot looks for a wall to sit against, and shoot its
  7. ; enemies from afar. If it gets hit, it may pick up and move
  8. ; to the other side of the arena and start blasting again.
  9. ; The best way to defeat this one is to get in close.
  10.  
  11. ; define vars
  12. #def speed
  13. #def shoot
  14. #def move
  15. #def armor
  16. #def hitcheck
  17. #def hit
  18. #def accuracy
  19. #def turn
  20. #def start
  21.  
  22. #msg Get back!
  23.  
  24. ;        mov     ax,     1
  25. ;        int     4               ; Overburn ON!
  26.  
  27. ; set some label-remembering variables.
  28.         set     shoot   1000
  29.         set     move    2000
  30.         set     hitcheck  50
  31.  
  32. ;First order of business... Get the robot moving...
  33. ;must find a nice safe wall.
  34.         mov     start,    1
  35.         gsb     move
  36.         mov     start,    0
  37.  
  38.  
  39. ;MAIN (settings)
  40. :1
  41. ; set speed=0, arc-wdth=3, turn-speed=+6
  42.         opo     11      0
  43.         opo     17      3
  44.         set     turn    6
  45.  
  46. ; Get random number... 50% chance of setting turn-speed to -6.
  47.         ipo     10      ax
  48.         cmp     ax      0
  49.         jls     2
  50.         set     turn    -6
  51.  
  52. ; MAIN loop..
  53. :2
  54.  
  55.        ;turn
  56.         opo     12      turn
  57.  
  58.        ;scan & shoot
  59.         ipo     7       ax
  60.         cmp     ax      1500
  61.         jgr     3
  62.         gsb     shoot
  63. :3
  64.        ;check to see if damaged since last check.
  65.         mov     hit     0
  66.         gsb     hitcheck
  67.  
  68.        ;if damaged then MOVE.
  69.         cmp     hit     0
  70.         je      4
  71.         gsb     move
  72. :4
  73.         jmp 2
  74. ; if a "JMP 10" is called, the settings can be repeated.
  75. :10
  76.         jmp 1
  77.  
  78.  
  79. ;Hitcheck
  80. :50
  81.        ;read and compare armor
  82.         ipo     6       ax
  83.         cmp     ax      armor
  84.  
  85.        ;if no damage then simply exit.
  86.         je      51
  87.  
  88.        ;if hit, then say so!
  89.         set     armor   ax
  90.         set     hit     1
  91. :51
  92. ret
  93.  
  94.  
  95. ;Shoot
  96. :1000
  97.        ;read accuracy setting.
  98.         ipo     8       accuracy
  99. ;        mpy     accuracy        2
  100.  
  101.        ;check heat, skip firing if too hot.
  102.         ipo     2,      ax
  103.         cmp     ax,     100
  104.         ja      1002
  105.  
  106.        ;fire using accuracy
  107.         opo     15      accuracy
  108. :1002
  109.        ;turn using accuracy (to try to continue to face target)
  110.         opo     12      accuracy
  111.  
  112.        ;scan again. If there then repeat, else exit.
  113.         ipo     7       ax
  114.         cmp     ax      1500    ; Find a target?
  115.         ja      1003            ; if not, we lost 'em, so skip along.
  116.         cmp     ax      50      ; if we did, is he real close?
  117.         jls     1004            ; if so, let's book it.
  118.         jmp     shoot           ; if not, let's shoot again!
  119. :1004
  120.         call    move            ; book it.
  121. :1003
  122.  
  123.        ;before exiting, change turn rate and direction to match last scan.
  124.         cmp     accuracy,       0
  125.         je      1001
  126.         mov     turn,   accuracy
  127.         mpy     turn,   3
  128. :1001
  129. ret
  130.  
  131.  
  132. ;Move
  133. :2000
  134.        ;read a random number, make it so it's 
  135.        ;in range of 0-255, then turn that way.
  136.         ipo     10      ax
  137.         and     ax      255
  138.  
  139.         int     2               ; get x,y coordinates into EX,FX.
  140.  
  141.         cmp     ex,     20      ; x<=20?
  142.         ja      2001
  143.         shr     ax,     1       ; if so, heading will be 0-79h
  144.         jmp     2004
  145. :2001
  146.         cmp     ex,     980     ; x>=980?
  147.         jb      2002
  148.         shr     ax,     1       ; 
  149.         add     ax,     80h     ; if so, heading will be 80h-FFh
  150.         jmp     2004
  151. :2002
  152.         cmp     fx,     20      ; y<=20?
  153.         ja      2003
  154.         shr     ax,     1       ; 
  155.         add     ax,     40h     ; if so, heading will be 40h-BFh
  156.         jmp     2004
  157. :2003
  158.         cmp     fx,     980     ; y>=980?
  159.         jb      2004
  160.         shr     ax,     1       ; 
  161.         add     ax,     80h     ; if so, heading will be C0h-3Fh
  162. :2004
  163.         cmp     start,  0       ; At the beginning, we want a nearby wall
  164.         je      2005            ; otherwise driving across arena is fine.
  165.         add     ax,     0x80    ; add 80h to heading.
  166. :2005
  167.         and     ax,     255
  168.         err     ax               ; report our course to the screen-display.
  169.         call    3000             ; set course
  170.  
  171.        ;Set speed to 100, then delay
  172.         opo     11      100
  173.  
  174.        ;keep going until speed reaches zero.
  175.         opo     13      0        ; set turret to face forward.
  176.         mov     ax,     1
  177.         int     4                ; turn on overburn to get there quickly.
  178. :2100
  179.         ipo     2,      ax       ; read heat into AX
  180.         cmp     ax,     30       ; is heat above 30? (try to keep cool)
  181.         ja      2101             ; if so, skip along.
  182.         opo     15,     0        ; FIRE! (just in case someone is in the way)
  183. :2101
  184.         ipo     1       ax       ; read speed into AX
  185.         cmp     ax      0        ; is AX 0?
  186.         ja      2100             ; if not, we're still moving.
  187.  
  188.         xor     ax,     ax       ; AX=0
  189.         int     4                ; turn overburn off, to conserve heat.
  190.  
  191.        ;set armor so that the HITCHECK doesn't think 
  192.        ;we've been shot. (we take damage when we hit walls).
  193.         ipo     6       armor
  194.  
  195.        ;Set speed to 0.
  196.         opo     11      0
  197.  
  198.        ; Set turret to prepare for a quick scan.
  199.         cmp     turn    0        ; are we set to scan left or right?
  200.         jls     2102             ; choose turret facing
  201.         opo     13      0C0h     ; set turret to face 192 degrees.
  202.         jmp     2103
  203. :2102
  204.         opo     13      040h     ; set turret to face 64 degrees.
  205. :2103
  206.        ;turn all the way 'round
  207.         opo     14      80h      ; turn 80h degrees (128, or a half-circle)
  208. ret
  209.  
  210.  
  211.  
  212. ;course-setting subroutine
  213. ;set course to heading in AX.
  214. :3000
  215.         mov     bx,     @1      ; get current desired heading
  216.                                 ; (not actual heading)
  217.         sub     ax,     bx      ; get number of degrees to turn.
  218.         opo     14,     ax      ; turn!
  219.  
  220.         ret
  221.