#side Megadont
#author Matt Burkholder
#date 5 April 2002
#color 555
#type Megadont
#color f00 
#hardware 
   processor 20
   engine 0.15
   constructor 1.25
   energy 210 20
   solar-cells .5
   eater 1.25
   robot-sensor 40 15
   food-sensor 12 50
   armor 1000
   repair-rate 1
   grenades 50 40 31
     
#code 

#var destx 0
#var desty 0
#var targetx 50
#var targety 50
#var targetDirection 0
       random-angle targetDirection!
       do
         energy 140 / constructor-rate!
         1 constructor-type!
         armor max-armor < energy 20 > and max-repair-rate 0 ifev repair-rate!
         robot-sensor-cooldown grenades-cooldown or nif
            robot-sensor-range random-angle fire-robot-sensor sync
            robot-found if
                   ;robot-distance robot-position position v- angle fire-grenade
                   robot-position position v-
                   robot-velocity 0.75 vs* velocity v- 
                   robot-distance grenades-speed / vs* v+ 
                   rect-to-polar fire-grenade
                   robot-position targety! targetx!
                   robot-direction targetDirection!
         then then
         destx speed and food-sensor-cooldown or nif
            destx if
                  0 0 fire-food-sensor
            else
                  food-sensor-range targetDirection fire-food-sensor
            then sync
            food-found if
               food-position else
               0 0 then
            desty! destx!
         then
         destx if
            destx desty seek-location
         else
            targetx targety seek-location
            speed nif
                   30 70 random targetx!
                   30 70 random targety!
          then then
       forever
    
#end
