Skip to content

Commit

Permalink
Use visible players to filter auto aim (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
agustinesco authored Sep 12, 2024
1 parent 97143ec commit cf5f035
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions apps/arena/lib/arena/game/player.ex
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ defmodule Arena.Game.Player do
Map.filter(players, fn {_, player} -> alive?(player) end)
end

def targetable_players(players) do
Map.filter(players, fn {_, player} -> alive?(player) and not invisible?(player) end)
def targetable_players(current_player, players) do
Map.filter(players, fn {_, player} -> alive?(player) and visible?(current_player, player) end)
end

def stamina_full?(player) do
Expand Down Expand Up @@ -225,7 +225,7 @@ defmodule Arena.Game.Player do

{auto_aim?, skill_direction} =
skill_params.target
|> Skill.maybe_auto_aim(skill, player, targetable_players(game_state.players))
|> Skill.maybe_auto_aim(skill, player, targetable_players(player, game_state.players))
|> case do
{false, _} ->
Skill.maybe_auto_aim(skill_params.target, skill, player, Crate.alive_crates(game_state.crates))
Expand Down Expand Up @@ -380,11 +380,8 @@ defmodule Arena.Game.Player do
end
end

def invisible?(player) do
get_in(player, [:aditional_info, :effects])
|> Enum.any?(fn effect ->
Enum.any?(effect.effect_mechanics, fn {mechanic, _} -> mechanic == :invisible end)
end)
def visible?(current_player, candidate_player) do
candidate_player.id in current_player.aditional_info.visible_players
end

def remove_expired_effects(player) do
Expand Down

0 comments on commit cf5f035

Please sign in to comment.