home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 5 / PCFORMAT5.iso / ZIPS / CZONE.ZIP / CZONE / ROBOTS / TRIGGER.ROB < prev   
Encoding:
Text File  |  1993-12-14  |  1.9 KB  |  76 lines

  1. { ****** TRIGGER ******}
  2. { This robot wanders around in a random direction (increments of 45'),
  3. { like AIMLESS, but when it finds a tank, it attempts to lock on. }
  4.  
  5.  
  6. REPEAT
  7.  
  8.   {** Pick a random starting direction **}
  9.   a=rnd(8)
  10.   a:=a*45
  11.   SHIELD OFF
  12.   RADAR(a)
  13.  
  14.   {** Have we found a tank **}
  15.   IF object=tank THEN
  16.  
  17.     TURRET(a)    {** Yes, so turn to face it **}
  18.  
  19.     {**  While we can still see the tank **}
  20.     REPEAT
  21.       RADAR gunheading    {** Check the tank is still there **}
  22.       IF object=tank THEN   {** IF the tank is in the sights ....**}
  23.         {** Only FIRE at it IF it's further away than the explsosion radius, otherwise FIRE just beyond it **}
  24.         IF distance>explode THEN
  25.           FIRE distance
  26.         ELSE
  27.           FIRE explode+5
  28.         ENDIF
  29.  
  30.      ELSE
  31.         {** Damn, lost the tank, so sheck 5' clockwise to see IF it's there **} 
  32.         RADAR(gunheading+5)
  33.         {** IF it's there THEN blast it again **}
  34.         IF object=tank THEN
  35.           TURRET gunheading+5
  36.           IF distance>explode THEN
  37.             FIRE distance
  38.           ELSE
  39.             FIRE explode+5
  40.           ENDIF
  41.  
  42.         ELSE
  43.  
  44.           {** Damn, still not there so try 5' anticlockwise **}
  45.           RADAR(gunheading+355)
  46.           {** IF it's there than blast it yet again **}
  47.           IF object=tank THEN
  48.             TURRET gunheading+355
  49.             IF distance>explode THEN
  50.               FIRE distance
  51.             ELSE
  52.               FIRE explode+5
  53.             ENDIF
  54.           ENDIF
  55.  
  56.         ENDIF
  57.  
  58.       ENDIF
  59.  
  60.     UNTIL object<>tank
  61.  
  62.   ELSE
  63.     {** We didn't spot a tank, what about a missile **}
  64.     IF object=missile THEN
  65.       DO 10
  66.         SHIELD ON    {** OHMYGOSH...Shiled on for while **}
  67.       LOOP
  68.     ENDIF
  69.   ENDIF
  70.  
  71.   {** It wasn't a tank so turn towards it and charge **}
  72.   ROTATE(a)
  73.   MOVE(distance-20)
  74.  
  75. FOREVER
  76.