Skip to content

Commit

Permalink
Use start zone data field for prestrafe limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesomerly committed Oct 12, 2024
1 parent a51140d commit ae64972
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
21 changes: 18 additions & 3 deletions addons/sourcemod/scripting/shavit-core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ char gS_Verification[MAXPLAYERS+1][8];
bool gB_CookiesRetrieved[MAXPLAYERS+1];
float gF_ZoneAiraccelerate[MAXPLAYERS+1];
float gF_ZoneSpeedLimit[MAXPLAYERS+1];
float gF_ZoneStartSpeedLimit[MAXPLAYERS+1];
int gI_LastPrintedSteamID[MAXPLAYERS+1];

// kz support
Expand Down Expand Up @@ -2511,7 +2512,18 @@ bool CanStartTimer(int client, int track, bool skipGroundCheck)
return true;

float cfgMax = GetStyleSettingFloat(style, "maxprestrafe");
float prestrafe = cfgMax > 0.0 ? cfgMax : StyleMaxPrestrafe(style);
float zoneMax = gF_ZoneStartSpeedLimit[client];
// float prestrafe = cfgMax > 0.0 ? cfgMax : StyleMaxPrestrafe(style);
float prestrafe;
if (zoneMax > 0.0) {
prestrafe = zoneMax;
}
else if (cfgMax > 0.0) {
prestrafe = cfgMax;
} else {
prestrafe = StyleMaxPrestrafe(style);
}

if (curVel > prestrafe)
return false;

Expand Down Expand Up @@ -2899,7 +2911,10 @@ void SQL_DBConnect()

public void Shavit_OnEnterZone(int client, int type, int track, int id, int entity, int data)
{
if (type == Zone_Airaccelerate && track == gA_Timers[client].iTimerTrack)
if (type == Zone_Start && track == gA_Timers[client].iTimerTrack) {
gF_ZoneStartSpeedLimit[client] = float(data);
}
else if (type == Zone_Airaccelerate && track == gA_Timers[client].iTimerTrack)
{
gF_ZoneAiraccelerate[client] = float(data);
}
Expand All @@ -2921,7 +2936,7 @@ public void Shavit_OnLeaveZone(int client, int type, int track, int id, int enti
// Probably so very niche that it doesn't matter.
if (track != gA_Timers[client].iTimerTrack)
return;
if (type != Zone_Airaccelerate && type != Zone_CustomSpeedLimit)
if (type != Zone_Airaccelerate && type != Zone_CustomSpeedLimit && type != Zone_Start)
return;

UpdateStyleSettings(client);
Expand Down
30 changes: 26 additions & 4 deletions addons/sourcemod/scripting/shavit-misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1357,10 +1357,21 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float

float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue);
float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe");

int zoneid;
Shavit_InsideZoneGetID(client, Zone_Start, track, zoneid);
float zoneLimit = float(Shavit_GetZoneData(zoneid));

float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]);
if (cfgLimit > 0.0) {
if (zoneLimit > 0.0)
{
fLimit = zoneLimit;
}
else if (cfgLimit > 0.0)
{
fLimit = cfgLimit;
} else if (fLimit > maxPrestrafe) {
}
else if (fLimit > maxPrestrafe){
fLimit = maxPrestrafe;
}

Expand Down Expand Up @@ -2294,10 +2305,21 @@ public Action Shavit_OnStartPre(int client, int track, bool& skipGroundTimer)

float fLimit = (Shavit_GetStyleSettingFloat(gI_Style[client], "runspeed") + gCV_PrestrafeLimit.FloatValue);
float cfgLimit = Shavit_GetStyleSettingFloat(gI_Style[client], "maxprestrafe");

int zoneid;
Shavit_InsideZoneGetID(client, Zone_Start, track, zoneid);
float zoneLimit = float(Shavit_GetZoneData(zoneid));

float maxPrestrafe = StyleMaxPrestrafe(gI_Style[client]);
if (cfgLimit > 0.0) {
if (zoneLimit > 0.0)
{
fLimit = zoneLimit;
}
else if (cfgLimit > 0.0)
{
fLimit = cfgLimit;
} else if (fLimit > maxPrestrafe) {
}
else if (fLimit > maxPrestrafe){
fLimit = maxPrestrafe;
}

Expand Down

0 comments on commit ae64972

Please sign in to comment.