def act(self): angle = ai.enemyHeadingDeg(self.idE) pos = np.array([ai.screenEnemyXId(self.idE), ai.screenEnemyYId(self.idE)]) vel = ai.enemySpeedId(self.idE) * np.array([np.cos(angle), np.sin(angle)]) self.target = pos - vel * self.K self.open_fire() # Put up shield if no good enemy. XOR operation: if id_valid(self.idE) == ai.selfShield(): ai.shield()
def __init__(self, idE=None, gain=FIRE_GAIN): if idE is None: print("FireEnemy: No enemy selected! Exiting now.") ai.quitAI() sys.exit(1) print("Open fire to:", ai.enemyNameId(idE)) if ai.selfShield(): ai.shield() self.idE = idE self.K = gain
def __init__(self, target=None): self.name = "fire" if target is None: print("Fire: Target not specified!!") ai.quitAI() sys.exit(1) else: self.target = target if ai.selfShield(): ai.shield()
def act(self): angle = ai.enemyHeadingDeg(self.idE) pos = np.array( [ai.screenEnemyXId(self.idE), ai.screenEnemyYId(self.idE)]) vel = ai.enemySpeedId(self.idE) * np.array( [np.cos(angle), np.sin(angle)]) self.target = pos - vel * self.K self.open_fire() # Put up shield if no good enemy. XOR operation: if id_valid(self.idE) == ai.selfShield(): ai.shield()
def act(self): """ Act according to the current action """ if self.was_dead: for _ in range(2): ai.shield() self.was_dead = False elif self.was_dead_before: if not ai.selfShield(): ai.shield() self.was_dead_before = False try: self.action.act() except AttributeError: if not self.warned: print("Action not yet initialised!") self.warned = True
def preempt(self): if not ai.selfShield(): ai.shield()