def predict_attacks(self, things, t, act_name, maxrange, radius, base_damage, current): attackable_positions = circle_positions(self.position, maxrange) result = [] DAMAGE = base_damage * (1 + settings.HERO_ATTACK_LEVEL_MULTIPLIER * self.level) received = still_damage(self, current, t) will_die = 0 if received >= self.life: received = self.life will_die = 1 for center in attackable_positions: action = mkaction(act_name, center, hero_kills=-will_die, damage=-received) for p in circle_positions(center, radius): for prob, item in things.get(p, ()): m = prob * multiplier(self.team, item.team) damage = m * max(min(DAMAGE, item.life), item.life-item.max_life) # Clip for damage and heal effects action['damage'] += damage if damage >= item.life: # scored a kill! if item.name == 'ancient': action['ancient_kills'] += m if item.name == 'tower': action['tower_kills'] += m if item.name == 'creep': action['creep_kills'] += m if item.team != settings.TEAM_NEUTRAL: # Must be a hero action['hero_kills'] += m result.append(action) return result
def predict_attacks(self, things, t, act_name, maxrange, radius, base_damage, current): attackable_positions = circle_positions(self.position, maxrange) result = [] DAMAGE = base_damage * (1 + settings.HERO_ATTACK_LEVEL_MULTIPLIER * self.level) received = still_damage(self, current, t) will_die = 0 if received >= self.life: received = self.life will_die = 1 for center in attackable_positions: action = mkaction(act_name, center, hero_kills=-will_die, damage=-received) for p in circle_positions(center, radius): for prob, item in things.get(p, ()): m = prob * multiplier(self.team, item.team) damage = m * max( min(DAMAGE, item.life), item.life - item.max_life) # Clip for damage and heal effects action['damage'] += damage if damage >= item.life: # scored a kill! if item.name == 'ancient': action['ancient_kills'] += m if item.name == 'tower': action['tower_kills'] += m if item.name == 'creep': action['creep_kills'] += m if item.team != settings.TEAM_NEUTRAL: # Must be a hero action['hero_kills'] += m result.append(action) return result
def fireball(thing, world, target_position): event_bits = [] affected_positions = circle_positions(target_position, settings.FIREBALL_RADIUS) for position in affected_positions: target = world.things.get(position) if target: damage = calculate_damage(thing, settings.FIREBALL_BASE_DAMAGE, settings.FIREBALL_LEVEL_MULTIPLIER) target.life -= damage event_bits.append('damaged {} with fire by {}'.format( target.name, damage)) world.effects[position] = 'fireball' return True, ', '.join(event_bits)
def fireball(thing, world, target_position): event_bits = [] affected_positions = circle_positions(target_position, settings.FIREBALL_RADIUS) for position in affected_positions: target = world.things.get(position) if target: damage = calculate_damage(thing, settings.FIREBALL_BASE_DAMAGE, settings.FIREBALL_LEVEL_MULTIPLIER) target.life -= damage event_bits.append('damaged {} with fire by {}'.format(target.name, damage)) world.effects[position] = 'fireball' return ', '.join(event_bits)
def heal(thing, world, target_position): event_bits = [] affected_positions = circle_positions(target_position, settings.HEAL_RADIUS) for position in affected_positions: target = world.things.get(position) if target: # heal avoiding health overflow heal = calculate_damage(thing, settings.HEAL_BASE_HEALING, settings.HEAL_LEVEL_MULTIPLIER) target.life = min(target.max_life, target.life + heal) event_bits.append('healed {} by {}'.format(target.name, heal)) world.effects[position] = 'heal' return True, ', '.join(event_bits)
def heal(thing, world, target_position): event_bits = [] affected_positions = circle_positions(target_position, settings.HEAL_RADIUS) for position in affected_positions: target = world.things.get(position) if target: # heal avoiding health overflow heal = calculate_damage(thing, settings.HEAL_BASE_HEALING, settings.HEAL_LEVEL_MULTIPLIER) target.life = min(target.max_life, target.life + heal) event_bits.append('healed {} by {}'.format(target.name, heal)) world.effects[position] = 'heal' return ', '.join(event_bits)