Ejemplo n.º 1
0
    def control_npc(self, game_state: GameState, npc: NonPlayerCharacter,
                    player_entity: WorldEntity, is_player_invisible: bool,
                    time_passed: Millis):

        if self.quest_timer.update_and_check_if_ready(time_passed):
            player_state = game_state.player_state
            if player_state.has_quest(QUEST_ID):
                if player_state.item_inventory.has_item_in_inventory(
                        item_id_key()):
                    npc.quest_giver_state = QuestGiverState.CAN_COMPLETE_QUEST
                else:
                    npc.quest_giver_state = QuestGiverState.WAITING_FOR_PLAYER
            elif player_state.has_completed_quest(QUEST_ID):
                npc.quest_giver_state = None
            elif _is_player_eligible_for_quest(game_state):
                npc.quest_giver_state = QuestGiverState.CAN_GIVE_NEW_QUEST
            else:
                npc.quest_giver_state = None

        if self.timer.update_and_check_if_ready(time_passed):
            if random.random() < 0.8:
                npc.world_entity.set_not_moving()
            else:
                direction = random.choice(get_all_directions())
                npc.world_entity.set_moving_in_dir(direction)
Ejemplo n.º 2
0
 def control_npc(self, game_state: GameState, npc: NonPlayerCharacter, player_entity: WorldEntity,
                 is_player_invisible: bool, time_passed: Millis):
     if self.timer.update_and_check_if_ready(time_passed):
         if random.random() < 0.8:
             npc.world_entity.set_not_moving()
         else:
             direction = random.choice(get_all_directions())
             npc.world_entity.set_moving_in_dir(direction)