def apply_player_summon_collision(self, npc: NonPlayerCharacter, game_state: GameState, projectile: Projectile): damage = random.randint(self._min_damage, self._max_damage) deal_npc_damage_to_npc(game_state, npc, damage) game_state.game_world.visual_effects.append( VisualCircle(self._color, npc.world_entity.get_center_position(), 25, 35, Millis(100), 0)) projectile.has_collided_and_should_be_removed = True
def apply_player_summon_collision(self, npc: NonPlayerCharacter, game_state: GameState, projectile: Projectile): deal_npc_damage_to_npc(game_state, npc, 1) npc.gain_buff_effect( get_buff_effect(BuffType.ENEMY_GOBLIN_WARLOCK_BURNT), Millis(5000)) game_state.visual_effects.append( VisualCircle((180, 50, 50), npc.world_entity.get_center_position(), 25, 50, Millis(100), 0)) projectile.has_collided_and_should_be_removed = True
def apply_middle_effect(self, game_state: GameState, buffed_entity: WorldEntity, buffed_npc: NonPlayerCharacter, time_passed: Millis): self._time_since_graphics += time_passed if self._time_since_graphics > 500: self._time_since_graphics = 0 if buffed_npc: deal_npc_damage_to_npc(game_state, buffed_npc, 2) game_state.visual_effects.append( VisualCircle((180, 50, 50), buffed_npc.world_entity.get_center_position(), 10, 20, Millis(50), 0, buffed_entity)) else: deal_damage_to_player(game_state, 2, DamageType.MAGIC, None) game_state.visual_effects.append( VisualCircle((180, 50, 50), game_state.player_entity.get_center_position(), 10, 20, Millis(50), 0, buffed_entity))
def control_npc(self, game_state: GameState, npc: NonPlayerCharacter, player_entity: WorldEntity, is_player_invisible: bool, time_passed: Millis): self._time_since_updated_path += time_passed self._time_since_reevaluated += time_passed self._time_since_attack += time_passed summon_entity = npc.world_entity if self._time_since_updated_path > self._update_path_interval: self._time_since_updated_path = 0 nearby_enemies = game_state.game_world.get_enemies_within_x_y_distance_of(300, npc.world_entity.get_position()) if nearby_enemies: target_entity = nearby_enemies[0].world_entity else: target_entity = game_state.game_world.player_entity self.pathfinder.update_path_towards_target(summon_entity, game_state, target_entity) new_next_waypoint = self.pathfinder.get_next_waypoint_along_path(summon_entity) should_update_waypoint = self.next_waypoint != new_next_waypoint if self._time_since_reevaluated > self._reevaluate_next_waypoint_direction_interval: self._time_since_reevaluated = 0 should_update_waypoint = True if should_update_waypoint: self.next_waypoint = new_next_waypoint if self.next_waypoint: direction = self.pathfinder.get_dir_towards_considering_collisions( game_state, summon_entity, self.next_waypoint) _move_in_dir(summon_entity, direction) else: summon_entity.set_not_moving() if self._time_since_attack > self._attack_interval: self._time_since_attack = 0 nearby_enemies = game_state.game_world.get_enemies_within_x_y_distance_of(100, summon_entity.get_position()) if nearby_enemies: damage_amount = 3 target = nearby_enemies[0] deal_npc_damage_to_npc(game_state, target, damage_amount) game_state.game_world.visual_effects.append( VisualLine((220, 0, 0), summon_entity.get_center_position(), target.world_entity.get_center_position(), Millis(100), damage_amount))