Skip to content

Commit

Permalink
Merge pull request #404 from Nickelony/master
Browse files Browse the repository at this point in the history
Add "bonus_velocity" to the style settings
  • Loading branch information
shavitush committed Jul 19, 2017
2 parents fa68629 + ae579f1 commit 3d5bfce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 3 additions & 2 deletions configs/shavit-styles.cfg
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions scripting/include/shavit.inc
Expand Up @@ -95,6 +95,7 @@ enum
fSpeedMultiplier,
bHalftime,
fVelocity,
fBonusVelocity,
fMinVelocity,
bBlockW,
bBlockA,
Expand Down
30 changes: 30 additions & 0 deletions scripting/shavit-core.sp
Expand Up @@ -710,6 +710,11 @@ public void Player_Jump(Event event, const char[] name, bool dontBroadcast)
{
RequestFrame(ApplyNewVelocity, GetClientSerial(client));
}

if(view_as<float>(gA_StyleSettings[gBS_Style[client]][fBonusVelocity]) != 0.0)
{
RequestFrame(AddBonusVelocity, GetClientSerial(client));
}

if(view_as<float>(gA_StyleSettings[gBS_Style[client]][fMinVelocity]) != 0.0)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3d5bfce

Please sign in to comment.