Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-945] Fix auto aim targeting invisible players inside bushes #947

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading