Esempio n. 1
0
def get_target(agent_entity: WorldEntity, game_state: GameState) -> EnemyTarget:
    # Enemies should prioritize attacking a summon over attacking the player
    player_summons = [npc for npc in game_state.non_player_characters
                      if npc.npc_category == NpcCategory.PLAYER_SUMMON]
    if player_summons:
        player_summon = player_summons[0]
        agent_position = agent_entity.get_position()
        distance_to_npc_target = get_manhattan_distance(player_summon.world_entity.get_position(),
                                                        agent_position)
        distance_to_player = get_manhattan_distance(game_state.player_entity.get_position(), agent_position)
        if distance_to_npc_target < distance_to_player:
            return EnemyTarget.npc(player_summon.world_entity, player_summon)
    return EnemyTarget.player(game_state.player_entity)
 def control_npc(self, game_state: GameState, npc: NonPlayerCharacter, player_entity: WorldEntity,
                 is_player_invisible: bool, time_passed: Millis):
     super().control_npc(game_state, npc, player_entity, is_player_invisible, time_passed)
     self.sprint_cooldown_remaining -= time_passed
     sprint_distance_limit = 250
     if self.sprint_cooldown_remaining <= 0:
         is_far_away = get_manhattan_distance(
             npc.world_entity.get_position(), player_entity.get_position()) > sprint_distance_limit
         if is_far_away:
             npc.gain_buff_effect(get_buff_effect(BuffType.ENEMY_GOBLIN_SPEARMAN_SPRINT), Millis(2500))
             self.sprint_cooldown_remaining = self.random_cooldown()