Ejemplo n.º 1
0
 def rotateToFaceTarget(self):
    angularDistance = vectorDirection(Autolib.interceptVector(self.target))
    angularSpeed = self.ship.spin()
    
    power = Autolib.powerForSmoothApproach(angularDistance, angularSpeed,
                                      self.analysis.maxPositiveDizzy, 
                                        self.analysis.maxNegativeDizzy)
       
    self.powerEngines(power, self.analysis.positiveDizzyEngines, self.analysis.negativeDizzyEngines)
    self.currentStatus = (0.2, "acquiring target")
Ejemplo n.º 2
0
   def fireIfAble(self):
      spinSpeed = abs(self.ship.spin() * 0.51)

      for target in self.targets:
         vector = Autolib.interceptVector(target)

         direction = abs(vectorDirection(vector))

         if direction < spinSpeed:
            self.fireAtTarget()
            return
Ejemplo n.º 3
0
 def thrustToTargetRadius(self):
    if abs(vectorDirection(self.target.vector())) < 0.5:
       distance = vectorMagnitude(self.target.vector()) - (Misc.WEAPON_RANGE / 2.0)
       speed = vectorScalarProjection(self.target.velocity(), [-1, 0])
       
       maxTowardAcceleration = self.analysis.maxRemainingForwardAcceleration()
       maxAwayAcceleration = self.analysis.maxRemainingReverseAcceleration()
       
       power = Autolib.powerForSmoothApproach(distance, speed, 
                                         maxTowardAcceleration, 
                                         maxAwayAcceleration)
 
       self.powerEngines(power, self.analysis.forwardEngines, self.analysis.reverseEngines)
       self.currentStatus = (0.5, "approaching")
Ejemplo n.º 4
0
   def fireWeaponsIfPossible(self):
      intercept = Autolib.interceptVector(self.target)
      direction = abs(vectorDirection(intercept))
      range = abs(vectorMagnitude(intercept))
      
      if direction < 0.1 and range < Misc.WEAPON_RANGE:
         self.weaponsEngaged = True

      if direction > 0.3 or range > Misc.WEAPON_RANGE * 2.5:
         self.weaponsEngaged = False
         
      if self.weaponsEngaged:
         self.currentStatus = (1.0, "firing")
         self.fireAllWeapons()