def __init__(self, player): AbilityInstance.__init__(self, player) self.type = "FireRingOfFireInstance" self.time_to_live = self.duration self.ring_of_fire = objects.ProjectileObject(self.player, self.radius, self.duration) self.ring_of_fire.position = self.player.position self.ring_of_fire.bounding_shape = collision.BoundingCircle(self.radius, True) self.ring_of_fire.outer_bounding_circle = collision.BoundingCircle(self.radius + self.ring_thickness, True) self.ring_of_fire.inner_bounding_circle = collision.BoundingCircle(self.radius - self.ring_thickness, True) self.ring_of_fire.move_speed = 0 self.ring_of_fire.is_moving = False
def run(self): AbilityInstance.run(self) bounding_circle = collision.BoundingCircle(self.range) # find a target colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) if len(colliders) == 0: # no targets in range return self.target = colliders[0] min_distance = self._square_of_distance(self.player, colliders[0]) for collider in colliders: distance_to_collider = self._square_of_distance(self.player, collider) if distance_to_collider < min_distance: min_distance = distance_to_collider self.target = collider # target found, cast spell # @todo: apply damage to self.target here if self.player.world.is_master: self.master(self.target)
def update(self, dt): # Regen health & power. self.health += self.health_regen * dt self.power += self.power_regen * dt if self.is_charging: # If the player is charging then force movement. self.is_moving = True if self.is_hooked: if collision.CollisionDetector.check_collision( collision.BoundingCircle(8), self.hooked_by_player.position, self.bounding_shape, self.position): self.is_hooked = False self.hooked_by_player = None else: self.is_moving = False distance = 200 * dt dx = self.hooked_by_player.position[0] - self.position[0] dz = self.hooked_by_player.position[1] - self.position[1] move_direction = math.atan2(dz, dx) move_vector = (distance * math.cos(move_direction), distance * math.sin(move_direction)) self._move(move_vector) if self.is_immobilized: self.is_moving = False MobileObject.update(self, dt) for ability in self.active_abilities: ability.update(dt)
def __init__(self, player): AbilityInstance.__init__(self, player) self.type = "EarthEarthQuakeInstance" self.position = self.player.position self.bounding_circle = collision.BoundingCircle(self.radius) self.time_lived = 0 self.ticks_done = 0 self.slowed_players = [] self.player.world.world_updated += self.update_slowed_players
def __init__(self, player, projectile_radius, duration): MobileObject.__init__(self, player.world) self.time_to_live = duration self.owner = player self.bounding_shape = collision.BoundingCircle(projectile_radius) self.duration = duration self.expired = Event() self.type = "projectile" player.world.add_object(self)
def master(self): bounding_circle = collision.BoundingCircle(self.shard_radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects for player in colliders: player.apply_damage(self.shard_damage, self.player, 404) print "Ice Burst collided with another player!"
def run(self): AbilityInstance.run(self) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects if self.player.world.is_master: self.master(colliders) # end the effect self.expire()
def run(self): AbilityInstance.run(self) # get a list of players that were hit by the earthquake self.bounding_circle = collision.BoundingCircle(self.hitRadius) colliders = self.player.world.get_colliders(self.bounding_circle, self.player.position, [self.player], objects.Player) # apply effects for player in colliders: # @todo: apply slow effects, etc print "Earthquake collided with another player!" self.expire()
def create_shard_explosion(self): bounding_circle = collision.BoundingCircle(self.shard_radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects for player in colliders: # @todo: apply damage print "Ice Burst collided with another player!" # end the effect self.expire()
def run(self): AbilityInstance.run(self) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects for player in colliders: # @todo: apply damage print "Lava Splash collided with another player!" # end the effect self.expire()
def run(self): AbilityInstance.run(self) #make the projectile's projectileobject self.hook_projectile = objects.ProjectileObject(self.player, self.projectile_radius, self.projectile_duration) self.hook_projectile.position = self.start_position self.hook_projectile.bounding_shape = collision.BoundingCircle(self.projectile_radius) self.hook_projectile.rotation = self.start_rotation self.hook_projectile.move_speed = self.projectile_velocity self.hook_projectile.is_moving = True self.player.world.add_object(self.hook_projectile) self.hook_projectile.collided += self.on_collided # throw event self.hook_projectile_created(self.hook_projectile)
def on_player_collided(self, object): if not self.is_active: return False if not object.isPassable or object.type == "player": self.collided(self.player) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects if self.player.world.is_master: self.master(colliders) self.expire() return False
def __init__(self, world): MobileObject.__init__(self, world) self.power = 100 self.health = 100 self.bounding_shape = collision.BoundingCircle(6) self.type = "player" self._is_charging = False self.is_charging_changed = Event() # Create an Element and pass it a reference to this player make it our # current active element. # @todo: don't hardcode this self.element = elements.FireElement(self) self.active_abilities = [] self.last_ability_time = 0 self.ability_used = Event()
def update(self, dt): AbilityInstance.update(self, dt) if self.player.world.is_master: if self.player_hooked is None: return if collision.CollisionDetector.check_collision(collision.BoundingCircle(8), self.player_hooked.position, self.player.bounding_shape, self.player.position): self.player_hooked.is_hooked = False self.player_hooked.force_vector = (0, 0) self.expire() else: fv = (self.player.position[0] - self.player_hooked.position[0], self.player.position[1] - self.player_hooked.position[1]) fv = CollisionDetector.normalise_vector(fv) fv = (fv[0] * self.retraction_speed, fv[1] * self.retraction_speed) self.player_hooked.force_vector = fv
def __init__(self, world): MobileObject.__init__(self, world) self.bounding_shape = collision.BoundingCircle(6) self.type = "player" self.name = "" self.move_speed = 100 self.is_invulnerable = False self.is_immobilized = False self.last_damage_code = 0 self.last_damage_player = None self.teleported = Event() self.last_position = None self.last_combat_time = 0 self._health = 100 self._power = 100 self.max_power = 100 self.max_health = 100 self.health_regen = 2 self.power_regen = 8 self.regen_last_time = 0 self.health_changed = Event() self.power_changed = Event() self._score = 0 self.score_changed = Event() self._is_dead = False self.is_dead_changed = Event() self._is_charging = False self.is_charging_changed = Event() self._is_hooked = False self.is_hooked_changed = Event() # Create an Element and pass it a reference to this player make it our # current active element. # @todo: don't hardcode this self.element = elements.EarthElement(self) self.element_changed = Event() self.active_abilities = [] self.last_ability_time = 0 self.ability_used = Event() self.ability_instance_created = Event() self.ability_requested = Event()
def on_player_collided(self, object): if not self.is_active: return False if not object.isPassable: self.collided(self.player) # create the bounding circle to check collision against bounding_circle = collision.BoundingCircle(self.radius) # get a list of colliding players colliders = self.player.world.get_colliders(bounding_circle, self.player.position, [self.player], objects.Player) # for each player, apply effects for player in colliders: # @todo: apply damage print "Flame Rush collided with some other object!" self.expire() return False
def __init__(self, world): MobileObject.__init__(self, world) self.power = 100 self.health = 100 self.bounding_shape = collision.BoundingCircle(6) self.type = "player"