예제 #1
0
    def do_tactics(self):
        if self.actor.can_see_entity(
                self.actor.tile.board.world.player) and dice.one_chance_in(3):
            raise events.SeeHostileEvent()

        if not self.destination:
            self.choose_destination()
            self.compute_path()

        if self.actor.tile.pos == self.destination:
            if not self.should_stop():
                # let's wander somewhere else
                self.choose_destination()
                self.compute_path()

            else:
                # nah, let's ask the strategy what to do.
                raise events.TacticsCompleteEvent()

        # try to move:
        if not self.path:
            self.destination = None
            return wait.WaitAction(self.actor)
        try:
            result = self.smart_move(self.path)
            # reset our wait timer:
            if self.wait_timer == 0:
                self.wait_timer = dice.d(1, self.max_wait)

            return result

        except PathBlockedException:
            # logger.debug('path blocked')
            # wait and see if the blocker clears
            if self.wait_timer > 0:
                # logger.debug('waiting: {timer} more turns'.format(timer=self.wait_timer))
                self.wait_timer -= 1
                return wait.WaitAction(self.actor)

            else:
                # logger.debug('trying to repath')
                # ok, let's recompute the path, or go somewhere else
                path_found = self.recompute_path(ab=True, md=10)
                if not path_found:
                    # logger.debug('no path found, going somewhere else')
                    dest = self.nearby_reachable_destination()
                    if dest:
                        # logger.debug('nearby destination found!')
                        self.destination = dest
                        self.compute_path()

                return wait.WaitAction(self.actor)
예제 #2
0
    def do_tactics(self):
        # logger.debug('Hunting tactics: start')

        if self.actor.can_see_entity(self.target):
            # logger.debug('Hunting tactics: see target')
            raise events.SeeHostileEvent()

        elif self.actor.tile.pos == self.target_last_seen:
            # logger.debug('Hunting tactics: found target position, no target seen')
            # we've hit where the target was and haven't found him, oh well
            raise events.InterestLostEvent()

        else:
            # logger.debug('Hunting tactics: finding path to target position')
            path = search.find_path(
                self.board,
                self.actor.tile.pos,
                self.target_last_seen,
                actors_block=False,
                doors_block=(not self.actor.can_open_doors),
                max_depth=20)

            if path:
                # logger.debug('Hunting tactics: path found')
                try:
                    # logger.debug('Hunting tactics: trying to move.')
                    return self.smart_move(path)
                except PathBlockedException:
                    # logger.debug('Hunting tactics: path blocked')
                    return wait.WaitAction(self.actor)

            else:
                # logger.debug('Hunting tactics: no path found')
                raise events.InterestLostEvent()
예제 #3
0
 def do_tactics(self):
     if self.actor.can_see_entity(self.actor.tile.board.world.player) and dice.one_chance_in(6):
         raise events.SeeHostileEvent()
     
     self.turns_to_sleep -= 1
     if self.turns_to_sleep == 0:
         raise events.TacticsCompleteEvent()
         
     return wait.WaitAction(self.actor)
예제 #4
0
    def do_tactics(self):
        # logger.debug('Pursue tactics: start')
        self.target_pos = self.target.tile.pos

        ax, ay = self.actor.tile.pos
        tx, ty = self.target.tile.pos

        if abs(ax - tx) <= 1 and abs(ay - ty) <= 1:
            # logger.debug('Pursue tactics: target in range')
            # we're close enough to attack!
            raise events.TacticsCompleteEvent()

        elif not self.actor.can_see_entity(self.target):
            # logger.debug('Pursue tactics: target lost')
            raise events.TargetLostEvent()

        else:
            # logger.debug('Pursue tactics: finding path to target')
            # logger.debug('self_pos: {self_pos}'.format(self_pos=self.actor.tile.pos))
            # logger.debug('target_pos: {target_pos}'.format(target_pos=self.target.tile.pos))
            path = search.find_path(self.board,
                                    self.actor.tile.pos,
                                    self.target.tile.pos,
                                    actors_block=False,
                                    doors_block=not self.actor.can_open_doors,
                                    max_depth=20)

            if path:
                # logger.debug('Pursue tactics: path found')
                try:
                    # logger.debug('Pursue tactics: trying to move')
                    return self.smart_move(path)
                except PathBlockedException:
                    # logger.debug('Pursue tactics: path blocked')
                    return wait.WaitAction(self.actor)

            else:
                # logger.debug('Pursue tactics: no path found')
                return wait.WaitAction(self.actor)
예제 #5
0
 def process(self):
     return wait.WaitAction(self.player)