예제 #1
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_state = game_state.player_state
    if player_state.health_resource.value <= ABILITY_HEALTH_LOSS:
        return AbilityFailedToExecute("Using this would kill you!")
    player_state.health_resource.lose(ABILITY_HEALTH_LOSS)
    player_state.gain_buff_effect(get_buff_effect(BUFF_TYPE), DURATION)
    return AbilityWasUsedSuccessfully()
예제 #2
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    rect_w = 36
    # Note: We assume that this ability is used by this specific hero
    hero_entity_size = HEROES[HeroId.WARRIOR].entity_size
    slash_pos = translate_in_direction(
        player_entity.get_center_position(),
        player_entity.direction,
        rect_w / 2 + hero_entity_size[0] * 0.25)

    slash_rect = Rect(int(slash_pos[0] - rect_w / 2), int(slash_pos[1] - rect_w / 2), rect_w, rect_w)
    affected_enemies = game_state.game_world.get_enemy_intersecting_rect(slash_rect)
    has_aoe_upgrade = game_state.player_state.has_upgrade(HeroUpgradeId.ABILITY_SLASH_AOE_BONUS_DAMAGE)
    hit_multiple_enemies = len(affected_enemies) > 1
    for enemy in affected_enemies:
        if has_aoe_upgrade and hit_multiple_enemies:
            damage: float = MAX_DMG
        else:
            damage: float = MIN_DMG + random.random() * (MAX_DMG - MIN_DMG)
        deal_player_damage_to_enemy(game_state, enemy, damage, DamageType.PHYSICAL)

    game_state.game_world.visual_effects.append(
        VisualRect((100, 0, 0), slash_pos, rect_w, int(rect_w * 0.7), Millis(200), 2, None))
    game_state.player_state.gain_buff_effect(get_buff_effect(BuffType.RECOVERING_AFTER_ABILITY), Millis(300))
    return AbilityWasUsedSuccessfully()
예제 #3
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    rect_w = 28
    slash_center_pos = translate_in_direction(
        player_entity.get_center_position(), player_entity.direction,
        rect_w / 2 + PLAYER_ENTITY_SIZE[0] * 0.25)
    slash_rect = Rect(int(slash_center_pos[0] - rect_w / 2),
                      int(slash_center_pos[1] - rect_w / 2), rect_w, rect_w)
    affected_enemies = game_state.game_world.get_enemy_intersecting_rect(
        slash_rect)
    if not affected_enemies:
        return AbilityFailedToExecute(reason="No targets")

    # Note: Dependency on other ability 'stealth'
    should_stun = game_state.player_state.has_active_buff(BuffType.STEALTHING)
    if should_stun:
        game_state.camera_shake = CameraShake(Millis(50), Millis(150), 4)
    buff_effect = get_buff_effect(DEBUFF, should_stun)
    affected_enemies[0].gain_buff_effect(buff_effect, DEBUFF_DURATION)

    game_state.game_world.visual_effects.append(
        VisualRect((150, 150, 75), slash_center_pos, rect_w, int(rect_w * 0.7),
                   Millis(200), 2, None))
    game_state.game_world.visual_effects.append(
        VisualCross((100, 100, 70), slash_center_pos, 6, Millis(100), 2))
    game_state.player_state.gain_buff_effect(
        get_buff_effect(BuffType.RECOVERING_AFTER_ABILITY), Millis(250))
    return AbilityWasUsedSuccessfully()
예제 #4
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    game_state.player_state.force_cancel_all_buffs()
    has_speed_upgrade = game_state.player_state.has_upgrade(
        HeroUpgradeId.ABILITY_STEALTH_MOVEMENT_SPEED)
    speed_decrease = MOVEMENT_SPEED_DECREASE if not has_speed_upgrade else 0
    game_state.player_state.gain_buff_effect(
        get_buff_effect(BUFF_STEALTH, speed_decrease), DURATION_STEALTH)
    return AbilityWasUsedSuccessfully()
예제 #5
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    previous_position = player_entity.get_center_position()

    used_from_stealth = game_state.player_state.has_active_buff(
        BuffType.STEALTHING)

    for distance in range(40, 200, 10):
        new_position = translate_in_direction(
            (player_entity.x, player_entity.y), player_entity.direction,
            distance)
        if game_state.game_world.is_position_within_game_world(new_position) \
                and not game_state.game_world.would_entity_collide_if_new_pos(player_entity, new_position):
            if _would_collide_with_wall(game_state, player_entity, distance):
                return AbilityFailedToExecute(reason="Wall is blocking")
            should_regain_mana_and_cd = False
            enemy_hit = _get_enemy_that_was_hit(game_state, player_entity,
                                                distance)
            if enemy_hit:
                game_state.camera_shake = CameraShake(Millis(50), Millis(150),
                                                      4)
                deal_player_damage_to_enemy(game_state, enemy_hit, DAMAGE,
                                            DamageType.MAGIC)
                has_reset_upgrade = game_state.player_state.has_upgrade(
                    HeroUpgradeId.ABILITY_DASH_KILL_RESET)
                enemy_died = enemy_hit.health_resource.is_at_or_below_zero()
                if has_reset_upgrade and enemy_died:
                    should_regain_mana_and_cd = True

            player_entity.set_position(new_position)
            new_center_position = player_entity.get_center_position()
            color = (250, 140, 80)
            game_state.game_world.visual_effects.append(
                VisualCircle(color, previous_position, 17, 35, Millis(150), 1))
            game_state.game_world.visual_effects.append(
                VisualLine(color, previous_position, new_center_position,
                           Millis(250), 2))
            game_state.game_world.visual_effects.append(
                VisualRect(color, previous_position, 37, 46, Millis(150), 1))
            game_state.game_world.visual_effects.append(
                VisualCircle(color, new_center_position, 25, 40, Millis(300),
                             1, player_entity))
            has_speed_upgrade = game_state.player_state.has_upgrade(
                HeroUpgradeId.ABILITY_DASH_MOVEMENT_SPEED)
            if has_speed_upgrade:
                game_state.player_state.gain_buff_effect(
                    get_buff_effect(BUFF_SPEED), BUFF_SPEED_DURATION)
            if used_from_stealth:
                game_state.player_state.gain_buff_effect(
                    get_buff_effect(BUFF_FROM_STEALTH),
                    BUFF_FROM_STEALTH_DURATION)
            return AbilityWasUsedSuccessfully(
                should_regain_mana_and_cd=should_regain_mana_and_cd)
    return AbilityFailedToExecute(reason="No space")
예제 #6
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    hero_center_pos = game_state.game_world.player_entity.get_center_position()
    distance = 60
    affected_enemies = game_state.game_world.get_enemies_within_x_y_distance_of(
        distance, hero_center_pos)
    game_state.game_world.visual_effects.append(
        VisualRect((50, 50, 100), hero_center_pos, distance * 2,
                   int(distance * 2.1), Millis(200), 2, None))
    game_state.game_world.visual_effects.append(
        VisualRect((150, 150, 200), hero_center_pos, distance, distance * 2,
                   Millis(150), 3, None))
    for enemy in affected_enemies:
        enemy.gain_buff_effect(get_buff_effect(BUFF_TYPE_STUNNED),
                               STUN_DURATION)
    return AbilityWasUsedSuccessfully()
예제 #7
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.player_entity
    rect_w = 28
    slash_center_pos = translate_in_direction(
        player_entity.get_center_position(), player_entity.direction,
        rect_w / 2 + PLAYER_ENTITY_SIZE[0] * 0.25)

    slash_rect = Rect(int(slash_center_pos[0] - rect_w / 2),
                      int(slash_center_pos[1] - rect_w / 2), rect_w, rect_w)
    affected_enemies = game_state.get_enemy_intersecting_rect(slash_rect)
    is_stealthed = game_state.player_state.has_active_buff(BuffType.STEALTHING)
    if is_stealthed:
        play_sound(SoundId.ABILITY_SHIV_STEALTHED)
    else:
        play_sound(SoundId.ABILITY_SHIV)
    for enemy in affected_enemies:
        damage: float = MIN_DMG + random.random() * (MAX_DMG - MIN_DMG)

        # Note: Dependency on other ability 'stealth'
        if is_stealthed:
            # Talent: increase the damage bonus that Shiv gets from being used while stealthing
            has_damage_upgrade = game_state.player_state.has_upgrade(
                HeroUpgradeId.ABILITY_SHIV_SNEAK_BONUS_DAMAGE)
            damage *= SHIV_UPGRADED_STEALTH_DAMAGE_MULTIPLIER if has_damage_upgrade else SHIV_STEALTH_DAMAGE_MULTIPLIER
            game_state.camera_shake = CameraShake(Millis(50), Millis(150), 4)
        else:
            # Talent: if attacking an enemy that's at 100% health while not stealthing, deal bonus damage
            has_damage_upgrade = game_state.player_state.has_upgrade(
                HeroUpgradeId.ABILITY_SHIV_FULL_HEALTH_BONUS_DAMAGE)
            if has_damage_upgrade and enemy.health_resource.is_at_max():
                damage *= SHIV_TALENT_FULL_HEALTH_DAMAGE_MULTIPLIER

        deal_player_damage_to_enemy(game_state,
                                    enemy,
                                    damage,
                                    DamageType.PHYSICAL,
                                    visual_emphasis=is_stealthed)
        break

    game_state.visual_effects.append(
        VisualRect((150, 150, 75), slash_center_pos, rect_w, int(rect_w * 0.7),
                   Millis(200), 2, None))
    game_state.visual_effects.append(
        VisualCross((100, 100, 70), slash_center_pos, 6, Millis(100), 2))

    game_state.player_state.gain_buff_effect(
        get_buff_effect(BuffType.RECOVERING_AFTER_ABILITY), Millis(250))
    return AbilityWasUsedSuccessfully()
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    distance_from_player = 35
    projectile_pos = translate_in_direction(
        get_position_from_center_position(player_entity.get_center_position(), PROJECTILE_SIZE),
        player_entity.direction,
        distance_from_player)
    projectile_speed = 0.2
    entity = WorldEntity(projectile_pos, PROJECTILE_SIZE, PROJECTILE_SPRITE, player_entity.direction,
                         projectile_speed)
    projectile = Projectile(entity, create_projectile_controller(PROJECTILE_TYPE))
    game_state.game_world.projectile_entities.append(projectile)
    effect_position = (projectile_pos[0] + PROJECTILE_SIZE[0] // 2,
                       projectile_pos[1] + PROJECTILE_SIZE[1] // 2)
    game_state.game_world.visual_effects.append(VisualCircle((250, 150, 50), effect_position, 9, 18, Millis(80), 0))
    return AbilityWasUsedSuccessfully()
예제 #9
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity

    player_center_pos = player_entity.get_center_position()
    game_state.game_world.visual_effects.append(
        VisualCircle((150, 150, 250), player_center_pos, 95, 190, Millis(200), 3))
    affected_enemies = game_state.game_world.get_enemies_within_x_y_distance_of(180, player_center_pos)
    effect_position = get_position_from_center_position(player_center_pos, EFFECT_SPRITE_SIZE)
    game_state.game_world.visual_effects.append(
        VisualSprite(Sprite.EFFECT_ABILITY_FROST_NOVA, effect_position, Millis(200), player_entity))
    for enemy in affected_enemies:
        damage_was_dealt = deal_player_damage_to_enemy(game_state, enemy, 5, DamageType.MAGIC
                                                       )
        if damage_was_dealt:
            enemy.gain_buff_effect(get_buff_effect(BuffType.REDUCED_MOVEMENT_SPEED), Millis(4000))
    return AbilityWasUsedSuccessfully()
예제 #10
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    aoe_center_pos = translate_in_direction(
        player_entity.get_center_position(), player_entity.direction, 60)
    aoe_pos = get_position_from_center_position(aoe_center_pos,
                                                PROJECTILE_SIZE)
    projectile_speed = 0.1
    entity = WorldEntity(aoe_pos, PROJECTILE_SIZE, PROJECTILE_SPRITE,
                         player_entity.direction, projectile_speed)
    projectile = Projectile(entity,
                            create_projectile_controller(PROJECTILE_TYPE))
    game_state.game_world.projectile_entities.append(projectile)
    has_lightfooted_upgrade = game_state.player_state.has_upgrade(
        HeroUpgradeId.MAGE_LIGHT_FOOTED)
    if not has_lightfooted_upgrade:
        game_state.player_state.gain_buff_effect(
            get_buff_effect(BuffType.RECOVERING_AFTER_ABILITY), Millis(300))
    return AbilityWasUsedSuccessfully()
예제 #11
0
def _apply_teleport(game_state: GameState) -> AbilityResult:
    player_entity = game_state.player_entity
    previous_position = player_entity.get_center_position()
    new_position = translate_in_direction((player_entity.x, player_entity.y),
                                          player_entity.direction, 140)
    player_entity.set_position(new_position)
    new_center_position = player_entity.get_center_position()

    color = (140, 140, 230)
    game_state.visual_effects.append(
        VisualCircle(color, previous_position, 17, 35, Millis(150), 1))
    game_state.visual_effects.append(
        VisualRect(color, previous_position, 37, 50, Millis(150), 1))
    game_state.visual_effects.append(
        VisualLine(color, previous_position, new_center_position, Millis(200),
                   1))
    game_state.visual_effects.append(
        VisualCircle(color, new_center_position, 25, 50, Millis(300), 2,
                     player_entity))
    return AbilityWasUsedSuccessfully()
예제 #12
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.player_entity
    distance_from_player = 35
    projectile_pos = translate_in_direction(
        get_position_from_center_position(player_entity.get_center_position(),
                                          PROJECTILE_SIZE),
        player_entity.direction, distance_from_player)
    projectile_speed = 0.3
    entity = WorldEntity(projectile_pos, PROJECTILE_SIZE,
                         Sprite.PROJECTILE_PLAYER_FIREBALL,
                         player_entity.direction, projectile_speed)
    projectile = Projectile(
        entity, create_projectile_controller(ProjectileType.PLAYER_FIREBALL))
    game_state.projectile_entities.append(projectile)
    effect_position = (projectile_pos[0] + PROJECTILE_SIZE[0] // 2,
                       projectile_pos[1] + PROJECTILE_SIZE[1] // 2)
    game_state.visual_effects.append(
        VisualCircle((250, 150, 50), effect_position, 15, 5, Millis(300), 0))
    has_lightfooted_upgrade = game_state.player_state.has_upgrade(
        HeroUpgradeId.MAGE_LIGHT_FOOTED)
    if not has_lightfooted_upgrade:
        game_state.player_state.gain_buff_effect(
            get_buff_effect(BuffType.RECOVERING_AFTER_ABILITY), Millis(300))
    return AbilityWasUsedSuccessfully()
예제 #13
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    game_state.player_state.gain_buff_effect(get_buff_effect(BUFF_TYPE_CHARGING), CHARGE_DURATION)
    return AbilityWasUsedSuccessfully()
예제 #14
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    strike_enemies(game_state, ABILITY_NUM_TARGETS)
    return AbilityWasUsedSuccessfully()
예제 #15
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    game_state.player_state.mana_resource.gain(ABILITY_MANA_AMOUNT)
    return AbilityWasUsedSuccessfully()
예제 #16
0
def _apply_channel_attack(game_state: GameState) -> AbilityResult:
    game_state.player_state.gain_buff_effect(
        get_buff_effect(BuffType.CHANNELING_ARCANE_FIRE), CHANNEL_DURATION)
    return AbilityWasUsedSuccessfully()
예제 #17
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    player_entity = game_state.game_world.player_entity
    for enemy in game_state.game_world.get_enemies_within_x_y_distance_of(
            400, player_entity.get_center_position()):
        enemy.health_resource.set_zero()
    return AbilityWasUsedSuccessfully()
예제 #18
0
def _apply_ability(game_state: GameState) -> AbilityResult:
    game_state.player_state.gain_buff_effect(get_buff_effect(CHANNELING_STOMP),
                                             Millis(500))
    return AbilityWasUsedSuccessfully()
예제 #19
0
def _apply_heal(game_state: GameState) -> AbilityResult:
    game_state.player_state.gain_buff_effect(
        get_buff_effect(BuffType.HEALING_OVER_TIME), Millis(3500))
    return AbilityWasUsedSuccessfully()