def fire(agent, arena, target):
    agent.moves = 0
    agent.ammo -= 1
    cover = 0
    if ((agent.pos[0] + 1) > target.pos[0]):
        if (arena.arena[((target.pos[0] - 1), target.pos[1])] == 3):
            cover = 20
    if ((agent.pos[0] - 1) < target.pos[0]):
        if (arena.arena[((target.pos[0] + 1), target.pos[1])] == 3):
            cover = 20
    if ((agent.pos[1] + 1) > target.pos[1]):
        if (arena.arena[(target.pos[0], (target.pos[1] - 1))] == 3):
            cover = 20
    if ((agent.pos[1] - 1) < target.pos[1]):
        if (arena.arena[(target.pos[0], (target.pos[1] + 1))] == 3):
            cover = 20
    diff = [(agent.pos[0] - target.pos[0]), (agent.pos[1] - target.pos[1])]
    distance_chance = (42 - (4.5 * np.linalg.norm(diff)))
    to_hit = ((agent.aim - cover) + distance_chance)
    if (np.random.randint(100) >= to_hit):
        arena.time += 1
        return (agent, arena, target)
    else:
        flanking = 0
        crit_modifier = 1
        if (cover == 0):
            flanking = 50
        crit_chance = (agent.base_crit + flanking)
        if (np.random.randint(100) < crit_chance):
            crit_modifier = 1.5
        damage = math.floor((crit_modifier * (np.random.randint((- 1), 2) + agent.damage)))
        target.health -= damage
        (arena, target) = check_death_enemy(arena, target)
        arena.time += 1
        return (agent, arena, target)
def fire(agent, arena, target):
    agent.moves = 0
    agent.ammo -= 1
    cover = 0
    if ((agent.pos[0] + 1) > target.pos[0]):
        if (arena.arena[((target.pos[0] - 1), target.pos[1])] == 3):
            cover = 20
    if ((agent.pos[0] - 1) < target.pos[0]):
        if (arena.arena[((target.pos[0] + 1), target.pos[1])] == 3):
            cover = 20
    if ((agent.pos[1] + 1) > target.pos[1]):
        if (arena.arena[(target.pos[0], (target.pos[1] - 1))] == 3):
            cover = 20
    if ((agent.pos[1] - 1) < target.pos[1]):
        if (arena.arena[(target.pos[0], (target.pos[1] + 1))] == 3):
            cover = 20
    diff = [(agent.pos[0] - target.pos[0]), (agent.pos[1] - target.pos[1])]
    distance_chance = (42 - (4.5 * np.linalg.norm(diff)))
    to_hit = ((agent.aim - cover) + distance_chance)
    if (np.random.randint(100) >= to_hit):
        arena.time += 1
        return (agent, arena, target)
    else:
        flanking = 0
        crit_modifier = 1
        if (cover == 0):
            flanking = 50
        crit_chance = (agent.base_crit + flanking)
        if (np.random.randint(100) < crit_chance):
            crit_modifier = 1.5
        damage = math.floor((crit_modifier * (np.random.randint((- 1), 2) + agent.damage)))
        target.health -= damage
        (arena, target) = check_death_enemy(arena, target)
        arena.time += 1
        return (agent, arena, target)