From 7b9a96909a32b9c8ca8c23389d317c21a34c31e8 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 18 Jul 2017 16:56:20 +0200 Subject: [PATCH] Add "bonus_velocity" to the style settings --- configs/shavit-styles.cfg | 5 +++-- scripting/include/shavit.inc | 1 + scripting/shavit-core.sp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/configs/shavit-styles.cfg b/configs/shavit-styles.cfg index 273f2fcc..f1f1ed1b 100644 --- a/configs/shavit-styles.cfg +++ b/configs/shavit-styles.cfg @@ -26,8 +26,9 @@ "gravity" "1.0" // gravity setting, 1.0 for default. standard for low gravity styles is 0.6 "speed" "1.0" // speed multiplier, 1.0 for default. standard for slowmo styles is 0.5 "halftime" "0" // calculation of times will be halved, replays WILL NOT function properly - "velocity" "1.0" // % of horizontal velocity to keep per jump. a value 0.9 will make the player lose 10% of their velocity per jump. likewise, values above 1 will result in speed gains. - "min_velocity" "0.0" // minimum amount of horizontal velocity to keep per jump. if set to 600.0 , the player can't have less than 600 velocity per jump + "velocity" "1.0" // % of horizontal velocity to keep per jump. a value 0.9 will make the player lose 10% of their velocity per jump. likewise, values above 1 will result in speed gains + "bonus_velocity" "0.0" // bonus velocity to gain per jump. if set to e.g. 100.0 , the player will gain 100 bonus velocity for every jump + "min_velocity" "0.0" // minimum amount of horizontal velocity to keep per jump. if set to e.g. 600.0 , the player can't have less than 600 velocity per jump // mode settings "block_w" "0" // block +forward diff --git a/scripting/include/shavit.inc b/scripting/include/shavit.inc index 4e1d493c..3c70b77e 100644 --- a/scripting/include/shavit.inc +++ b/scripting/include/shavit.inc @@ -95,6 +95,7 @@ enum fSpeedMultiplier, bHalftime, fVelocity, + fBonusVelocity, fMinVelocity, bBlockW, bBlockA, diff --git a/scripting/shavit-core.sp b/scripting/shavit-core.sp index d4671837..9355340f 100644 --- a/scripting/shavit-core.sp +++ b/scripting/shavit-core.sp @@ -715,6 +715,11 @@ public void Player_Jump(Event event, const char[] name, bool dontBroadcast) { RequestFrame(MinimumVelocity, GetClientSerial(client)); } + + if(view_as(gA_StyleSettings[gBS_Style[client]][fBonusVelocity]) != 0.0) + { + RequestFrame(AddBonusVelocity, GetClientSerial(client)); + } } void ApplyNewVelocity(int data) @@ -731,6 +736,30 @@ void ApplyNewVelocity(int data) } } +void AddBonusVelocity(int data) +{ + int client = GetClientFromSerial(data); + + if(data != 0) + { + float fAbsVelocity[3]; + GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fAbsVelocity); + + float currentspeed = (SquareRoot(Pow(fAbsVelocity[0], 2.0) + Pow(fAbsVelocity[1], 2.0))); + + if(currentspeed > 0.0) + { + float fBonus = view_as(gA_StyleSettings[gBS_Style[client]][fBonusVelocity]); + + float x = currentspeed / (currentspeed + fBonus); + fAbsVelocity[0] /= x; + fAbsVelocity[1] /= x; + + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fAbsVelocity); + } + } +} + void MinimumVelocity(int data) { int client = GetClientFromSerial(data); @@ -1300,6 +1329,7 @@ bool LoadStyles() gA_StyleSettings[i][fSpeedMultiplier] = dStyle.GetFloat("speed", 1.0); gA_StyleSettings[i][bHalftime] = dStyle.GetBool("halftime", false); gA_StyleSettings[i][fVelocity] = dStyle.GetFloat("velocity", 1.0); + gA_StyleSettings[i][fBonusVelocity] = dStyle.GetFloat("bonus_velocity", 0.0); gA_StyleSettings[i][fMinVelocity] = dStyle.GetFloat("min_velocity", 0.0); gA_StyleSettings[i][bBlockW] = dStyle.GetBool("block_w", false); gA_StyleSettings[i][bBlockA] = dStyle.GetBool("block_a", false);