def _update(self): minXDist = minYDist = minZDist = 999999 mtx, mty, mtz = (0, 0, 0) xdist = ydist = zdist = 0 ox, oy, oz = self.node.position for node in bs.getNodes(): if node.getNodeType() == 'spaz': if node.getDelegate() is None: continue if node.getDelegate().sourcePlayer in self.sourcePlayers: continue tx, ty, tz = node.position xdist = abs(tx - ox) ydist = abs(ty - oy) zdist = abs(tz - oz) if xdist < minXDist and ydist < minYDist and zdist < minZDist: minXDist, minYDist, minZDist = xdist, ydist, zdist ntx, nty, ntz = tx, ty, tz if minXDist > 8: return # Далеко((( if minYDist > 8: return # Далеко((( if minZDist > 8: return # Далеко((( self.getSourcePlayers() vel = [0, 0, 0] if ntx > ox: vel[0] = 5 else: vel[0] = -5 if nty > oy: vel[1] = 5 else: vel[1] = -5 if ntz > oz: vel[2] = 5 else: vel[2] = -5 bs.playSound(self.targetSound, position=self.node.position) bs.Blast(position=self.node.position, hitType='punch', sourcePlayer=self.sourcePlayers[0], blastRadius=1.2).autoRetain() self.node.velocity = vel
def _bUpdate(self): # update one of our bot lists each time through.. # first off, remove dead bots from the list # (we check exists() here instead of dead.. we want to keep them around even if they're just a corpse) try: botList = self._botLists[self._botUpdateList] = \ [b for b in self._botLists[self._botUpdateList] if b.exists()] except Exception: bs.printException('error updating bot list: ' + str(self._botLists[self._botUpdateList])) self._botUpdateList = (self._botUpdateList + 1) % self._botListCount # update our list of player points for the bots to use playerPts = [] try: #if player.isAlive() and not (player is self.sourcePlayer): # playerPts.append((bs.Vector(*player.actor.node.position), # bs.Vector(*player.actor.node.velocity))) for n in bs.getNodes(): if n.getNodeType() == 'spaz': s = n.getDelegate() if isinstance(s, bsSpaz.SpazBot): if not s in self.getLivingBots(): if hasattr(s, 'sourcePlayer'): if not s.sourcePlayer is self.sourcePlayer: playerPts.append((bs.Vector(*n.position), bs.Vector(*n.velocity))) else: playerPts.append((bs.Vector(*n.position), bs.Vector(*n.velocity))) elif isinstance(s, bsSpaz.PlayerSpaz): try: if not (s.getPlayer().getTeam() is self.sourcePlayer.getTeam()): playerPts.append((bs.Vector(*n.position), bs.Vector(*n.velocity))) except: pass except Exception: bs.printException('error on bot-set _update') for b in botList: b._setPlayerPts(playerPts) b._updateAI()