From be027b06792c278a407687e22cddde59430faa36 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 26 Jan 2022 15:12:37 +0100 Subject: [PATCH] rework battle royale dropping even further, drop velocity is no longer constant --- gamemodes-server.cfg | 5 +- qcsrc/common/gamemodes/gamemode/br/sv_br.qc | 54 ++++++++++++--------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index e87733b35..cefeb158d 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -592,9 +592,10 @@ set g_br_dropship_scale 3 "dropship scale" set g_br_dropship_speed 200 "dropship speed" set g_br_drop_damage 0.5 "multiplier of damage taken while dropping" set g_br_drop_speed_max 2 "max air speed multiplier while dropping" +set g_br_drop_speed_min 1.25 "min air speed multiplier while dropping" set g_br_drop_speed_vertical_min 0.1 "minimum vertical speed portion while dropping" -set g_br_drop_accel_dive 600 "dive acceleration while dropping" -set g_br_drop_accel_turn 1500 "turn acceleration while dropping" +set g_br_drop_accel_dive 50 "dive acceleration while dropping" +set g_br_drop_accel_turn 600 "turn acceleration while dropping" set g_br_drop_distance_force 500 "minimum distance to the end of the dropship path before players are force dropped" set g_br_ring_alpha 0.5 "ring transparency" set g_br_ring_color "1 0 0" "ring color" diff --git a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc index e64ee1a70..2f5e944fd 100644 --- a/qcsrc/common/gamemodes/gamemode/br/sv_br.qc +++ b/qcsrc/common/gamemodes/gamemode/br/sv_br.qc @@ -36,10 +36,11 @@ float autocvar_g_br_revive_health = 0.25; float autocvar_g_br_bleeding_health = 0.5; float autocvar_g_br_drop_damage = 0.5; float autocvar_g_br_drop_speed_max = 2; +float autocvar_g_br_drop_speed_min = 1.25; float autocvar_g_br_drop_speed_vertical_min = 0.1; bool autocvar_g_br_squad_colors = true; -float autocvar_g_br_drop_accel_dive = 600; -float autocvar_g_br_drop_accel_turn = 1500; +float autocvar_g_br_drop_accel_dive = 50; +float autocvar_g_br_drop_accel_turn = 600; bool autocvar_g_br_startweapons = false; bool autocvar_g_br_ring_exitvehicle = false; @@ -429,10 +430,16 @@ MUTATOR_HOOKFUNCTION(br, PM_Physics) bool player_is_drop_leader = has_drop_leader && (player == player.br_squad.br_squad_drop_leader); if(player_is_drop_leader || !has_drop_leader) { + const float vertical_max = 0.9; float maxairspeed = PHYS_MAXAIRSPEED(player) * max(maxspeed_mod, 1); float maxdropspeed = maxairspeed * max(autocvar_g_br_drop_speed_max, 0); - float mindropspeed_z = maxdropspeed * bound(0, autocvar_g_br_drop_speed_vertical_min, 1); - float maxdropspeed_z = maxdropspeed * 0.9; // moving straight down is glitchy + float mindropspeed = maxairspeed * max(autocvar_g_br_drop_speed_min, 0); + float maxdropspeed_ratio = vertical_max; // moving straight down is glitchy + float mindropspeed_ratio = bound(0, autocvar_g_br_drop_speed_vertical_min, vertical_max); + float accel_dive = max(autocvar_g_br_drop_accel_dive, 0); + float accel_turn = max(autocvar_g_br_drop_accel_turn, 0); + float dropspeed = vlen(player.br_drop_velocity); + float dropspeed_xy = vlen(vec2(player.br_drop_velocity)); float pitch_current = br_CalculatePlayerDropAngle(player); float pitch_view = player.v_angle.x; @@ -464,34 +471,37 @@ MUTATOR_HOOKFUNCTION(br, PM_Physics) wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspeed); // vertical wishvel using forward movement and the previously calculated ratio wishvel.z = pitch_ratio * bound(0, CS(player).movement.x / maxairspeed, 1); - // apply turn acceleration to the horizontal portion of the wishvel - wishvel.x *= max(autocvar_g_br_drop_accel_turn, 0); - wishvel.y *= max(autocvar_g_br_drop_accel_turn, 0); - // apply dive acceleration to the vertical portion of the wishvel - wishvel.z *= max(autocvar_g_br_drop_accel_dive, 0); + // apply turn acceleration to wishvel + wishvel.x *= accel_turn; + wishvel.y *= accel_turn; + wishvel.z *= accel_turn; player.br_drop_velocity += wishvel * dt; + player.br_drop_velocity = normalize(eZ * player.br_drop_velocity.z + normalize(vec2(player.br_drop_velocity)) * dropspeed_xy); - // modify mindropspeed_z and maxdropspeed_z so that the player does not rotate beyond the view angle + // if there is no horizontal movement point the horizontal vector towards the view direction + if(vlen(vec2(player.br_drop_velocity)) == 0) + player.br_drop_velocity += (eX * cos(player.angles.y * DEG2RAD) + eY * sin(player.angles.y * DEG2RAD)) * sqrt(1 - pow(maxdropspeed_ratio, 2)); + + // modify mindropspeed_ratio and maxdropspeed_ratio so that the player does not rotate beyond the view angle float vpitch_ratio = sin(pitch_view * DEG2RAD); if(pitch_ratio > 0) - mindropspeed_z = bound(mindropspeed_z, vpitch_ratio * maxdropspeed, maxdropspeed_z); + mindropspeed_ratio = bound(mindropspeed_ratio, vpitch_ratio, maxdropspeed_ratio); else if(pitch_ratio < 0) - maxdropspeed_z = bound(mindropspeed_z, vpitch_ratio * maxdropspeed, maxdropspeed_z); + maxdropspeed_ratio = bound(mindropspeed_ratio, vpitch_ratio, maxdropspeed_ratio); // constrain to vertical min/maxdropspeed - if(player.br_drop_velocity.z > -mindropspeed_z) - player.br_drop_velocity.z = -mindropspeed_z; - if(player.br_drop_velocity.z < -maxdropspeed_z) - player.br_drop_velocity.z = -maxdropspeed_z; - - // if there is no horizontal movement point the horizontal vector towards the view direction - if(vlen(vec2(player.br_drop_velocity)) == 0) - player.br_drop_velocity += eX * cos(player.angles.y * DEG2RAD) + eY * sin(player.angles.y * DEG2RAD); + if(player.br_drop_velocity.z > -mindropspeed_ratio) + player.br_drop_velocity.z = -mindropspeed_ratio; + if(player.br_drop_velocity.z < -maxdropspeed_ratio) + player.br_drop_velocity.z = -maxdropspeed_ratio; // adjust horizontal speed so that vertical speed + horizontal speed = maxdropspeed - player.br_drop_velocity = eZ * player.br_drop_velocity.z + normalize(vec2(player.br_drop_velocity)) * sqrt(pow(maxdropspeed, 2) - pow(player.br_drop_velocity.z, 2)); + float dropangle = br_CalculatePlayerDropAngle(player); + const float accelangle = 20; + dropspeed = bound(mindropspeed, dropspeed + accel_dive * (dropangle - accelangle) / accelangle * dt, maxdropspeed); + player.br_drop_velocity = normalize(player.br_drop_velocity) * dropspeed; - player.br_drop_angles.x = br_CalculatePlayerDropAngle(player) - 90; + player.br_drop_angles.x = dropangle - 90; player.br_drop_angles.y = vectoangles(vec2(player.br_drop_velocity)).y + 180; player.br_drop_angles.z = 180; -- 2.39.2