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-591] Allow movement while executing skills #592

Merged
merged 13 commits into from
May 21, 2024

Conversation

agustinesco
Copy link
Contributor

@agustinesco agustinesco commented May 10, 2024

Motivation

Some skills should be able to be cast while moving

Merge alongside This client pr

Closes #591

Disclaimer

Even tho you can move while you execute a skill and we don't stop this in the backend the unity client still blocks the inputs in the game while executing the skill, this will be addressed in a future PR in the client repo. The game configuration will be the same

Summary of changes

Refactored the block of actions while executing actions to block movement depending on a configuration

How to test it?

Change any skill block_movement configuration to false, and you should keep moving while this action is being executed. This pr is meant to be used for the h4ck basic but you should be able to change other abilities

Start a match and use the h4ck basic and you should be able to move while shooting

Checklist

  • Tested the changes locally.
  • Reviewed the changes on GitHub, line by line.
  • This change requires new documentation.
    • Documentation has been added/updated.

@lotuuu lotuuu added the champions MOBA game label May 13, 2024
@agustinesco agustinesco marked this pull request as ready for review May 20, 2024 15:11
Copy link
Collaborator

@Nico-Sanchez Nico-Sanchez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a leap with muflus and got the following error

** (FunctionClauseError) no function clause matching in Arena.Game.Skill.do_mechanic/4
    (arena 0.1.0) lib/arena/game/skill.ex:10: Arena.Game.Skill.do_mechanic(%{status: :RUNNING, items: %{62 => %{id: 62, name: "Item62", position: %{y: 470.0, x: -5182.0}, speed: 0.0, category: :item, vertices: [], direction: %{y: 0.0, x: 0.0}, radius: 200.0, aditional_info: %{name: "golden_clock", effects: ["golden_clock_effect"], pull_immunity: true}, shape: :circle, is_moving: false}}, pools: %{}, players: %{1 => %{id: 1, name: "nico", position: %{y: 1365.7877197265625, x: -985.8231811523438}, speed: 50.0, category: :player, vertices: [], direction: %{y: 1.0, x: 0.0}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 316, forced_movement: false, bonus_damage: 0, available_stamina: 2, visible_players: [10, 9, 8, 7, 6, 5, 4, 3, 2], inventory: nil, kill_count: 0, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true}}, on_bush: false, last_damage_received: -576459642824, current_actions: [%{action: :MOVING, duration: 0}], max_health: 440, bonus_defense: 0, last_natural_healing_update: -576459637972, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{"2" => 6884}, last_skill_triggered: -576459634924, base_health: 440, damage_immunity: false, stamina_interval: 2000, character_name: "muflus", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 27.0, recharging_stamina: true, pull_immunity: false, base_radius: 110.0}, shape: :circle, is_moving: false, collides_with: []}, 2 => %{id: 2, name: "SlashJava", position: %{y: -751.69873046875, x: -5074.1796875}, speed: 28.0, category: :player, vertices: [], direction: %{y: 0.09065249562263489, x: -0.9958825707435608}, radius: 95.0, aditional_info: %{max_stamina: 3, health: 0, forced_movement: false, bonus_damage: 0, available_stamina: 1, visible_players: [10, 9, 8, 7, 6, 5, 4, 3, 1], inventory: nil, kill_count: 0, skills: %{"1" => %{name: "uma_avenge", cooldown_mechanism: "stamina", mechanics: [multi_circle_hit: %{offset: 200.0, range: 280.0, amount: 3, damage: 21, interval_ms: 200, move_by: 200.0}], stamina_cost: 1, execution_duration_ms: 500, activation_delay_ms: 0, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "uma_veil_radiance", cooldown_mechanism: "time", cooldown_ms: 9000, mechanics: [circle_hit: %{offset: 0, range: 800.0, damage: 68}], execution_duration_ms: 400, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 0, can_pick_destination: false, block_movement: true, effects_to_apply: ["invisible"]}, "3" => %{name: "uma_sneak", cooldown_mechanism: "time", cooldown_ms: 5000, mechanics: [dash: %{speed: 120.0, duration: 250}], execution_duration_ms: 250, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true, effects_to_apply: []}}, on_bush: false, last_damage_received: -576459635775, current_actions: [%{action: :MOVING, duration: 0}], max_health: 400, bonus_defense: 0, last_natural_healing_update: -576459645200, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{}, last_skill_triggered: -576459636299, base_health: 400, damage_immunity: false, stamina_interval: 2000, character_name: "uma", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 28.0, recharging_stamina: true, pull_immunity: false, base_radius: 95.0}, shape: :circle, is_moving: false, collides_with: ~c"A"}, 3 => %{id: 3, name: "SteelBallRun", position: %{y: 2356.38916015625, x: -3440.233154296875}, speed: 27.0, category: :player, vertices: [], direction: %{y: 0.7144173383712769, x: 0.6997198462486267}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 0, forced_movement: false, bonus_damage: 0, available_stamina: 0, visible_players: [10, 9, 8, 7, 6, 5, 4, 2, 1], inventory: nil, kill_count: 1, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true}}, on_bush: false, last_damage_received: -576459635184, current_actions: [%{action: :MOVING, duration: 0}], max_health: 440, bonus_defense: 0, last_natural_healing_update: -576459643996, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{}, last_skill_triggered: -576459635337, base_health: 440, damage_immunity: false, stamina_interval: 2000, character_name: "muflus", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 27.0, recharging_stamina: true, pull_immunity: false, base_radius: 110.0}, shape: :circle, is_moving: false, collides_with: ~c"CB"}, 4 => %{id: 4, name: "Jeff", position: %{y: -241.84249877929688, x: 2833.686279296875}, speed: 27.0, category: :player, vertices: [], direction: %{y: 0.3664489686489105, x: -0.9304381608963013}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 204, forced_movement: false, bonus_damage: 0, available_stamina: 0, visible_players: [10, 9, 8, 7, 6, 5, 3, 2, 1], inventory: nil, kill_count: 1, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, (truncated)

@agustinesco
Copy link
Contributor Author

Did a leap with muflus and got the following error

** (FunctionClauseError) no function clause matching in Arena.Game.Skill.do_mechanic/4
    (arena 0.1.0) lib/arena/game/skill.ex:10: Arena.Game.Skill.do_mechanic(%{status: :RUNNING, items: %{62 => %{id: 62, name: "Item62", position: %{y: 470.0, x: -5182.0}, speed: 0.0, category: :item, vertices: [], direction: %{y: 0.0, x: 0.0}, radius: 200.0, aditional_info: %{name: "golden_clock", effects: ["golden_clock_effect"], pull_immunity: true}, shape: :circle, is_moving: false}}, pools: %{}, players: %{1 => %{id: 1, name: "nico", position: %{y: 1365.7877197265625, x: -985.8231811523438}, speed: 50.0, category: :player, vertices: [], direction: %{y: 1.0, x: 0.0}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 316, forced_movement: false, bonus_damage: 0, available_stamina: 2, visible_players: [10, 9, 8, 7, 6, 5, 4, 3, 2], inventory: nil, kill_count: 0, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true}}, on_bush: false, last_damage_received: -576459642824, current_actions: [%{action: :MOVING, duration: 0}], max_health: 440, bonus_defense: 0, last_natural_healing_update: -576459637972, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{"2" => 6884}, last_skill_triggered: -576459634924, base_health: 440, damage_immunity: false, stamina_interval: 2000, character_name: "muflus", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 27.0, recharging_stamina: true, pull_immunity: false, base_radius: 110.0}, shape: :circle, is_moving: false, collides_with: []}, 2 => %{id: 2, name: "SlashJava", position: %{y: -751.69873046875, x: -5074.1796875}, speed: 28.0, category: :player, vertices: [], direction: %{y: 0.09065249562263489, x: -0.9958825707435608}, radius: 95.0, aditional_info: %{max_stamina: 3, health: 0, forced_movement: false, bonus_damage: 0, available_stamina: 1, visible_players: [10, 9, 8, 7, 6, 5, 4, 3, 1], inventory: nil, kill_count: 0, skills: %{"1" => %{name: "uma_avenge", cooldown_mechanism: "stamina", mechanics: [multi_circle_hit: %{offset: 200.0, range: 280.0, amount: 3, damage: 21, interval_ms: 200, move_by: 200.0}], stamina_cost: 1, execution_duration_ms: 500, activation_delay_ms: 0, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "uma_veil_radiance", cooldown_mechanism: "time", cooldown_ms: 9000, mechanics: [circle_hit: %{offset: 0, range: 800.0, damage: 68}], execution_duration_ms: 400, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 0, can_pick_destination: false, block_movement: true, effects_to_apply: ["invisible"]}, "3" => %{name: "uma_sneak", cooldown_mechanism: "time", cooldown_ms: 5000, mechanics: [dash: %{speed: 120.0, duration: 250}], execution_duration_ms: 250, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true, effects_to_apply: []}}, on_bush: false, last_damage_received: -576459635775, current_actions: [%{action: :MOVING, duration: 0}], max_health: 400, bonus_defense: 0, last_natural_healing_update: -576459645200, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{}, last_skill_triggered: -576459636299, base_health: 400, damage_immunity: false, stamina_interval: 2000, character_name: "uma", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 28.0, recharging_stamina: true, pull_immunity: false, base_radius: 95.0}, shape: :circle, is_moving: false, collides_with: ~c"A"}, 3 => %{id: 3, name: "SteelBallRun", position: %{y: 2356.38916015625, x: -3440.233154296875}, speed: 27.0, category: :player, vertices: [], direction: %{y: 0.7144173383712769, x: 0.6997198462486267}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 0, forced_movement: false, bonus_damage: 0, available_stamina: 0, visible_players: [10, 9, 8, 7, 6, 5, 4, 2, 1], inventory: nil, kill_count: 1, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, activation_delay_ms: 0, is_passive: false, autoaim: false, max_autoaim_range: 0, can_pick_destination: false, block_movement: true}}, on_bush: false, last_damage_received: -576459635184, current_actions: [%{action: :MOVING, duration: 0}], max_health: 440, bonus_defense: 0, last_natural_healing_update: -576459643996, cooldown_multiplier: 1, natural_healing_interval: 1000, cooldowns: %{}, last_skill_triggered: -576459635337, base_health: 440, damage_immunity: false, stamina_interval: 2000, character_name: "muflus", effects: [], base_stamina_interval: 2000, power_ups: 0, base_cooldown_multiplier: 1, power_up_damage_modifier: 0.1, natural_healing_damage_interval: 3500, base_speed: 27.0, recharging_stamina: true, pull_immunity: false, base_radius: 110.0}, shape: :circle, is_moving: false, collides_with: ~c"CB"}, 4 => %{id: 4, name: "Jeff", position: %{y: -241.84249877929688, x: 2833.686279296875}, speed: 27.0, category: :player, vertices: [], direction: %{y: 0.3664489686489105, x: -0.9304381608963013}, radius: 110.0, aditional_info: %{max_stamina: 3, health: 204, forced_movement: false, bonus_damage: 0, available_stamina: 0, visible_players: [10, 9, 8, 7, 6, 5, 3, 2, 1], inventory: nil, kill_count: 1, skills: %{"1" => %{name: "muflus_crush", cooldown_mechanism: "stamina", mechanics: [circle_hit: %{offset: 400, range: 380.0, damage: 64}], stamina_cost: 1, execution_duration_ms: 450, activation_delay_ms: 150, is_passive: false, autoaim: true, max_autoaim_range: 800, can_pick_destination: false, block_movement: true, effects_to_apply: []}, "2" => %{name: "muflus_leap", cooldown_mechanism: "time", cooldown_ms: 8000, mechanics: [leap: %{speed: 50.0, range: 1500.0, radius: 650, on_arrival_mechanic: {:circle_hit, %{offset: 0, range: 650.0, damage: 92}}}], execution_duration_ms: 800, activation_delay_ms: 200, is_passive: false, autoaim: true, max_autoaim_range: 1500, can_pick_destination: true, block_movement: true}, "3" => %{name: "muflus_dash", cooldown_mechanism: "time", cooldown_ms: 4500, mechanics: [dash: %{speed: 100.0, duration: 330}], execution_duration_ms: 330, (truncated)

Fixed! it was a pattern match error since the do_mechanic now requires the direction in the skill_params map

Copy link
Collaborator

@Nico-Sanchez Nico-Sanchez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine with projectiles, but there are a few bugs with other skills.
I think we should iterate over this because it doesn't seem right to let valtimer teleport while moving, but it's worth the mention.
Proof:

Untitled.2.mov

apps/arena/lib/arena/game/player.ex Show resolved Hide resolved
apps/arena/lib/arena/game/player.ex Outdated Show resolved Hide resolved
@agustinesco
Copy link
Contributor Author

Works fine with projectiles, but there are a few bugs with other skills. I think we should iterate over this because it doesn't seem right to let valtimer teleport while moving, but it's worth the mention. Proof:

Untitled.2.mov

I would merge this and if we need another pr to move while executing we can see if that case bugs out, also using projectiles while movings seems so broken lol

@@ -13,8 +13,8 @@ defmodule Arena.Game.Skill do
end)
end

def do_mechanic(game_state, entity, {:circle_hit, circle_hit}, _skill_params) do
circle_center_position = get_position_with_offset(entity.position, entity.direction, circle_hit.offset)
def do_mechanic(game_state, entity, {:circle_hit, circle_hit}, %{skill_direction: skill_direction} = _skill_params) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will potentially break the traps feature, since we do not have the attacks logic isolated from the skills, lets create an issue to refactor this

Copy link
Contributor

@tvillegas98 tvillegas98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! the feature seems to work as intended

@tvillegas98 tvillegas98 merged commit b04170c into main May 21, 2024
1 check passed
@tvillegas98 tvillegas98 deleted the allow-movement-while-executing-skills branch May 21, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
champions MOBA game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Allow abilities to be executed while walking
4 participants