Add "bonus_velocity" to the style settings

This commit is contained in:
Unknown 2017-07-18 16:56:20 +02:00
parent c69508700a
commit 7b9a96909a
3 changed files with 34 additions and 2 deletions

View File

@ -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

View File

@ -95,6 +95,7 @@ enum
fSpeedMultiplier,
bHalftime,
fVelocity,
fBonusVelocity,
fMinVelocity,
bBlockW,
bBlockA,

View File

@ -715,6 +715,11 @@ public void Player_Jump(Event event, const char[] name, bool dontBroadcast)
{
RequestFrame(MinimumVelocity, GetClientSerial(client));
}
if(view_as<float>(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<float>(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);