diff --git a/.gitignore b/.gitignore index d0f585ee2..c00acad61 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ apps/*/_build/* # Ignore google fetched certificates apps/gateway/priv/google.oauth2.certificates.json +.vscode/settings.json diff --git a/apps/arena/lib/arena/entities.ex b/apps/arena/lib/arena/entities.ex index 687da3ff3..b1f27a340 100644 --- a/apps/arena/lib/arena/entities.ex +++ b/apps/arena/lib/arena/entities.ex @@ -334,7 +334,8 @@ defmodule Arena.Entities do inventory: entity.aditional_info.inventory, cooldowns: entity.aditional_info.cooldowns, visible_players: entity.aditional_info.visible_players, - on_bush: entity.aditional_info.on_bush + on_bush: entity.aditional_info.on_bush, + forced_movement: entity.aditional_info.forced_movement }} end diff --git a/apps/arena/lib/arena/game/player.ex b/apps/arena/lib/arena/game/player.ex index 44800eac3..411615cf7 100644 --- a/apps/arena/lib/arena/game/player.ex +++ b/apps/arena/lib/arena/game/player.ex @@ -444,8 +444,7 @@ defmodule Arena.Game.Player do y: position.y + direction.y } - ## TODO: Magic number needs to be replaced with state.game_config.game.tick_rate_ms - Physics.calculate_duration(position, target_position, leap.speed) * 30 + Physics.calculate_duration(position, target_position, leap.speed) end defp calculate_duration(%{mechanics: [_]} = skill, _, _, _) do diff --git a/apps/arena/lib/arena/game_updater.ex b/apps/arena/lib/arena/game_updater.ex index 0c3c5d4d5..d2d2f1039 100644 --- a/apps/arena/lib/arena/game_updater.ex +++ b/apps/arena/lib/arena/game_updater.ex @@ -195,12 +195,11 @@ defmodule Arena.GameUpdater do def handle_info(:update_game, %{game_state: game_state} = state) do Process.send_after(self(), :update_game, state.game_config.game.tick_rate_ms) now = DateTime.utc_now() |> DateTime.to_unix(:millisecond) - time_diff = now - game_state.server_timestamp - ticks_to_move = time_diff / state.game_config.game.tick_rate_ms + delta_time = now - game_state.server_timestamp game_state = game_state - |> Map.put(:ticks_to_move, ticks_to_move) + |> Map.put(:delta_time, delta_time / 1) # Effects |> remove_expired_effects() |> remove_effects_on_action() @@ -208,7 +207,7 @@ defmodule Arena.GameUpdater do |> Effect.apply_effect_mechanic_to_entities() # Players |> move_players() - |> reduce_players_cooldowns(time_diff) + |> reduce_players_cooldowns(delta_time) |> resolve_players_collisions_with_power_ups() |> resolve_players_collisions_with_items() |> resolve_projectiles_effects_on_collisions(state.game_config) @@ -894,7 +893,7 @@ defmodule Arena.GameUpdater do defp move_players( %{ players: players, - ticks_to_move: ticks_to_move, + delta_time: delta_time, external_wall: external_wall, obstacles: obstacles, bushes: bushes, @@ -911,7 +910,7 @@ defmodule Arena.GameUpdater do moved_players = players |> Physics.move_entities( - ticks_to_move, + delta_time, external_wall, obstacles ) @@ -947,7 +946,7 @@ defmodule Arena.GameUpdater do obstacles: obstacles, crates: crates, external_wall: external_wall, - ticks_to_move: ticks_to_move, + delta_time: delta_time, pools: pools } = game_state ) do @@ -967,7 +966,7 @@ defmodule Arena.GameUpdater do moved_projectiles = alive_projectiles - |> Physics.move_entities(ticks_to_move, external_wall, %{}) + |> Physics.move_entities(delta_time, external_wall, %{}) |> update_collisions( projectiles, entities_to_collide_with diff --git a/apps/arena/lib/arena/serialization/messages.pb.ex b/apps/arena/lib/arena/serialization/messages.pb.ex index dd260cf9e..020e6d325 100644 --- a/apps/arena/lib/arena/serialization/messages.pb.ex +++ b/apps/arena/lib/arena/serialization/messages.pb.ex @@ -498,6 +498,7 @@ defmodule Arena.Serialization.Player do field(:cooldowns, 12, repeated: true, type: Arena.Serialization.Player.CooldownsEntry, map: true) field(:visible_players, 13, repeated: true, type: :uint64, json_name: "visiblePlayers") field(:on_bush, 14, type: :bool, json_name: "onBush") + field(:forced_movement, 15, type: :bool, json_name: "forcedMovement") end defmodule Arena.Serialization.Effect do diff --git a/apps/arena/lib/physics.ex b/apps/arena/lib/physics.ex index d382b1980..e32cdf215 100644 --- a/apps/arena/lib/physics.ex +++ b/apps/arena/lib/physics.ex @@ -11,13 +11,13 @@ defmodule Physics do def add(_arg1, _arg2), do: :erlang.nif_error(:nif_not_loaded) def check_collisions(_entity, _entities), do: :erlang.nif_error(:nif_not_loaded) - def move_entities(_entities, _ticks_to_move, _external_wall, _obstacles), + def move_entities(_entities, _delta_time, _external_wall, _obstacles), do: :erlang.nif_error(:nif_not_loaded) - def move_entity(_entity, _ticks_to_move, _external_wall, _obstacles), + def move_entity(_entity, _delta_time, _external_wall, _obstacles), do: :erlang.nif_error(:nif_not_loaded) - def move_entity(_entity, _ticks_to_move, _external_wall), do: :erlang.nif_error(:nif_not_loaded) + def move_entity(_entity, _delta_time, _external_wall), do: :erlang.nif_error(:nif_not_loaded) def get_closest_available_position(_entity, _new_position, _external_wall, _obstacles), do: :erlang.nif_error(:nif_not_loaded) diff --git a/apps/arena/native/physics/src/lib.rs b/apps/arena/native/physics/src/lib.rs index 2852dbe3c..647d91428 100644 --- a/apps/arena/native/physics/src/lib.rs +++ b/apps/arena/native/physics/src/lib.rs @@ -15,7 +15,7 @@ fn add(a: i64, b: i64) -> i64 { #[rustler::nif()] fn move_entities( entities: HashMap, - ticks_to_move: f32, + delta_time: f32, external_wall: Entity, obstacles: HashMap, ) -> HashMap { @@ -23,7 +23,7 @@ fn move_entities( for entity in entities.values_mut() { if entity.is_moving { - entity.move_entity(ticks_to_move); + entity.move_entity(delta_time); move_entity_to_closest_available_position(entity, &external_wall, &obstacles); } @@ -35,13 +35,13 @@ fn move_entities( #[rustler::nif()] fn move_entity( entity: Entity, - ticks_to_move: f32, + delta_time: f32, external_wall: Entity, obstacles: HashMap, ) -> Entity { let mut entity: Entity = entity; if entity.is_moving { - entity.move_entity(ticks_to_move); + entity.move_entity(delta_time); move_entity_to_closest_available_position(&mut entity, &external_wall, &obstacles); } diff --git a/apps/arena/native/physics/src/map.rs b/apps/arena/native/physics/src/map.rs index 9d1cc0c23..e33d7e43d 100644 --- a/apps/arena/native/physics/src/map.rs +++ b/apps/arena/native/physics/src/map.rs @@ -197,14 +197,14 @@ impl Entity { result } - pub fn move_entity(&mut self, ticks_to_move: f32) { - self.position = self.next_position(ticks_to_move); + pub fn move_entity(&mut self, delta_time: f32) { + self.position = self.next_position(delta_time); } - pub fn next_position(&mut self, ticks_to_move: f32) -> Position { + pub fn next_position(&mut self, delta_time: f32) -> Position { Position { - x: self.position.x + self.direction.x * self.speed * ticks_to_move, - y: self.position.y + self.direction.y * self.speed * ticks_to_move, + x: self.position.x + self.direction.x * self.speed * delta_time, + y: self.position.y + self.direction.y * self.speed * delta_time, } } diff --git a/apps/arena/priv/config.json b/apps/arena/priv/config.json index b68179876..1eac37124 100644 --- a/apps/arena/priv/config.json +++ b/apps/arena/priv/config.json @@ -921,7 +921,7 @@ { "leap": { "range": 1300.0, - "speed": 50.0, + "speed": 1.7, "radius": 600, "on_arrival_mechanic": { "circle_hit": { @@ -976,7 +976,7 @@ "multi_shoot": { "angle_between": 22.0, "amount": 3, - "speed": 53.0, + "speed": 1.1, "duration_ms": 1000, "remove_on_collision": true, "projectile_offset": 100, @@ -1001,7 +1001,7 @@ "mechanics": [ { "dash": { - "speed": 90.0, + "speed": 4.0, "duration": 250 } } @@ -1021,7 +1021,7 @@ "mechanics": [ { "dash": { - "speed": 80.0, + "speed": 3.3, "duration": 330 } } @@ -1090,7 +1090,7 @@ "mechanics": [ { "dash": { - "speed": 95.0, + "speed": 4.0, "duration": 250 } } @@ -1134,7 +1134,7 @@ "mechanics": [ { "simple_shoot": { - "speed": 45.0, + "speed": 1.8, "duration_ms": 1100, "remove_on_collision": true, "projectile_offset": 100, @@ -1291,7 +1291,7 @@ "one_time_application": true, "effect_mechanics": { "speed_boost": { - "modifier": 0.5, + "modifier": 0.02, "effect_delay_ms": 0, "execute_multiple_times": false } @@ -1338,7 +1338,7 @@ "execute_multiple_times": true }, "speed_boost": { - "modifier": -0.25, + "modifier": -0.009, "effect_delay_ms": 0, "execute_multiple_times": false }, diff --git a/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex b/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex index f41e8a16b..976c7408c 100644 --- a/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex +++ b/apps/arena_load_test/lib/arena_load_test/serialization/messages.pb.ex @@ -545,6 +545,7 @@ defmodule ArenaLoadTest.Serialization.Player do field(:visible_players, 13, repeated: true, type: :uint64, json_name: "visiblePlayers") field(:on_bush, 14, type: :bool, json_name: "onBush") + field(:forced_movement, 15, type: :bool, json_name: "forcedMovement") end defmodule ArenaLoadTest.Serialization.Effect do diff --git a/apps/bot_manager/lib/protobuf/messages.pb.ex b/apps/bot_manager/lib/protobuf/messages.pb.ex index cf8ef5e3a..7c0256e5c 100644 --- a/apps/bot_manager/lib/protobuf/messages.pb.ex +++ b/apps/bot_manager/lib/protobuf/messages.pb.ex @@ -498,6 +498,7 @@ defmodule BotManager.Protobuf.Player do field(:cooldowns, 12, repeated: true, type: BotManager.Protobuf.Player.CooldownsEntry, map: true) field(:visible_players, 13, repeated: true, type: :uint64, json_name: "visiblePlayers") field(:on_bush, 14, type: :bool, json_name: "onBush") + field(:forced_movement, 15, type: :bool, json_name: "forcedMovement") end defmodule BotManager.Protobuf.Effect do diff --git a/apps/game_backend/priv/characters_config.json b/apps/game_backend/priv/characters_config.json index 81a23135b..a848f9738 100644 --- a/apps/game_backend/priv/characters_config.json +++ b/apps/game_backend/priv/characters_config.json @@ -3,7 +3,7 @@ { "name": "muflus", "active": true, - "base_speed": 17.5, + "base_speed": 0.63, "base_size": 110.0, "base_health": 440, "base_stamina": 3, @@ -20,7 +20,7 @@ { "name": "h4ck", "active": true, - "base_speed": 22.5, + "base_speed": 0.7, "base_size": 90.0, "base_health": 400, "base_stamina": 3, @@ -37,7 +37,7 @@ { "name": "uma", "active": true, - "base_speed": 20.0, + "base_speed": 0.67, "base_size": 95.0, "base_health": 400, "base_stamina": 3, @@ -54,7 +54,7 @@ { "name": "valtimer", "active": false, - "base_speed": 20.0, + "base_speed": 0.68, "base_size": 100.0, "base_health": 400, "base_stamina": 3, diff --git a/apps/game_client/assets/js/protobuf/messages_pb.js b/apps/game_client/assets/js/protobuf/messages_pb.js index f21dc548b..70070b8d9 100644 --- a/apps/game_client/assets/js/protobuf/messages_pb.js +++ b/apps/game_client/assets/js/protobuf/messages_pb.js @@ -6368,7 +6368,8 @@ proto.Player.toObject = function(includeInstance, msg) { inventory: (f = msg.getInventory()) && proto.Item.toObject(includeInstance, f), cooldownsMap: (f = msg.getCooldownsMap()) ? f.toObject(includeInstance, undefined) : [], visiblePlayersList: (f = jspb.Message.getRepeatedField(msg, 13)) == null ? undefined : f, - onBush: jspb.Message.getBooleanFieldWithDefault(msg, 14, false) + onBush: jspb.Message.getBooleanFieldWithDefault(msg, 14, false), + forcedMovement: jspb.Message.getBooleanFieldWithDefault(msg, 15, false) }; if (includeInstance) { @@ -6468,6 +6469,10 @@ proto.Player.deserializeBinaryFromReader = function(msg, reader) { var value = /** @type {boolean} */ (reader.readBool()); msg.setOnBush(value); break; + case 15: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setForcedMovement(value); + break; default: reader.skipField(); break; @@ -6595,6 +6600,13 @@ proto.Player.serializeBinaryToWriter = function(message, writer) { f ); } + f = message.getForcedMovement(); + if (f) { + writer.writeBool( + 15, + f + ); + } }; @@ -6933,6 +6945,24 @@ proto.Player.prototype.setOnBush = function(value) { }; +/** + * optional bool forced_movement = 15; + * @return {boolean} + */ +proto.Player.prototype.getForcedMovement = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 15, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.Player} returns this + */ +proto.Player.prototype.setForcedMovement = function(value) { + return jspb.Message.setProto3BooleanField(this, 15, value); +}; + + diff --git a/apps/game_client/lib/game_client/protobuf/messages.pb.ex b/apps/game_client/lib/game_client/protobuf/messages.pb.ex index 9052e9e1d..132de1635 100644 --- a/apps/game_client/lib/game_client/protobuf/messages.pb.ex +++ b/apps/game_client/lib/game_client/protobuf/messages.pb.ex @@ -498,6 +498,7 @@ defmodule GameClient.Protobuf.Player do field(:cooldowns, 12, repeated: true, type: GameClient.Protobuf.Player.CooldownsEntry, map: true) field(:visible_players, 13, repeated: true, type: :uint64, json_name: "visiblePlayers") field(:on_bush, 14, type: :bool, json_name: "onBush") + field(:forced_movement, 15, type: :bool, json_name: "forcedMovement") end defmodule GameClient.Protobuf.Effect do diff --git a/apps/serialization/messages.proto b/apps/serialization/messages.proto index 3970f1c32..7d219099b 100644 --- a/apps/serialization/messages.proto +++ b/apps/serialization/messages.proto @@ -193,7 +193,8 @@ message Player { Item inventory = 11; map cooldowns = 12; repeated uint64 visible_players = 13; - bool on_bush = 14; + bool on_bush = 14; + bool forced_movement = 15; } message Effect {