Ejemplo n.º 1
0
    def start(self):
        npc = get_npc(self.session, self.parameters.npc_slug)
        direction = self.parameters.direction
        if direction not in dirs2:
            if direction == "player":
                target = self.session.player
            else:
                target = get_npc(self.session, direction)
            direction = get_direction(npc.tile_pos, target.tile_pos)

        npc.facing = direction
Ejemplo n.º 2
0
    def start(self):
        # Get the parameters to determine what direction the player will face.
        direction = self.parameters.direction
        if direction not in dirs2:
            target = get_npc(self.session, direction)
            direction = get_direction(self.session.player.tilepos,
                                      target.tilepos)

        # If we're doing a transition, only change the player's facing when we've reached the apex
        # of the transition.
        world_state = self.session.client.get_state_by_name("WorldState")
        if world_state.in_transition:
            world_state.delayed_facing = direction
        else:
            self.session.player.facing = direction
Ejemplo n.º 3
0
    def next_waypoint(self):
        """ Take the next step of the path, stop if way is blocked

        * This must be called after a path is set
        * Not needed to be called if existing path is modified
        * If the next waypoint is blocked, the waypoint will be removed

        :return: None
        """
        target = self.path[-1]
        direction = get_direction(self.tile_pos, target)
        self.facing = direction
        if self.valid_movement(target):
            # pyganim has horrible clock drift.  even after one animation
            # cycle, the time will be off.  drift causes the walking steps to not
            # align with tiles and some frames will only last one game frame.
            # using play to start each tile will reset the pyganim timer
            # and prevent the walking animation frames from coming out of sync.
            # it still occasionally happens though!
            # eventually, there will need to be a global clock for the game,
            # not based on wall time, to prevent visual glitches.
            self.moveConductor.play()
            self.path_origin = tuple(self.tile_pos)
            self.velocity3 = self.moverate * dirs3[direction]
        else:
            # the target is blocked now
            self.stop_moving()

            if self.pathfinding:
                # since we are pathfinding, just try a new path
                logger.error('{} finding new path!'.format(self.slug))
                self.pathfind(self.pathfinding)

            else:
                # give up and wait until the target is clear again
                pass