diff --git a/README.md b/README.md index 3bb42107..aa1958de 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ Sounds **(NEW!)** - [x] On new #1. - [x] On personal best. - [x] On map finish. +- [ ] Add support for 'sound for X map rank'. Rankings **(NEW!)** -- diff --git a/scripting/include/shavit.inc b/scripting/include/shavit.inc index 54a3a374..f4bbf483 100644 --- a/scripting/include/shavit.inc +++ b/scripting/include/shavit.inc @@ -29,7 +29,7 @@ #define PREFIX "\x04[Timer]\x01" -#define MAX_STYLES 6 +#define MAX_STYLES 7 #define MAX_ZONES 8 // game types @@ -82,6 +82,7 @@ enum ReplayStatus(+=1) #define STYLE_PRESPEED (1 << 10) // allow prespeeding regardless of the prespeed setting #define STYLE_HSW_ONLY (1 << 11) // force half-sideways #define STYLE_100AA (1 << 12) // force 100 airacclerate for the style +#define STYLE_LOWGRAV (1 << 13) // 0.6x gravity int gI_StyleProperties[MAX_STYLES] = { @@ -90,7 +91,8 @@ int gI_StyleProperties[MAX_STYLES] = STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_BLOCK_A|STYLE_BLOCK_D|STYLE_BLOCK_S, // W-Only STYLE_EASYBHOP, // Scroll STYLE_VEL_LIMIT, // 400 Velocity - STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_HSW_ONLY // HSW + STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_HSW_ONLY, // HSW + STYLE_AUTOBHOP|STYLE_EASYBHOP|STYLE_LOWGRAV|STYLE_UNRANKED // Low gravity }; #endif @@ -132,7 +134,8 @@ char gS_StyleHTMLColors[MAX_STYLES][] = "9A59F0", "279BC2", "C9BB8B", - "B54CBB" + "B54CBB", + "DB88C2" }; #endif @@ -145,7 +148,8 @@ char gS_ShortBhopStyles[MAX_STYLES][] = "W", "LEGIT", "400VEL", - "HSW" + "HSW", + "LG" }; #endif @@ -158,7 +162,8 @@ float gI_RankingMultipliers[MAX_STYLES] = 1.33, // W-Only 1.30, // Scroll 1.50, // 400 Velocity - 1.20 // HSW + 1.20, // HSW + 0.00 // Low gravity }; #endif @@ -319,9 +324,12 @@ forward void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, * @param style Style the record was done on. * @param time Record time. * @param jumps Jumps amount. + * @param strafes Amount of strafes. + * @param sync Sync percentage (0.0 to 100.0). + * @param rank Rank on map. * @noreturn */ -forward void Shavit_OnFinish_Post(int client, BhopStyle style, float time, int jumps); +forward void Shavit_OnFinish_Post(int client, BhopStyle style, float time, int jumps, int strafes, float sync, int rank); /** * Called when there's a new WR on the map. @@ -330,9 +338,11 @@ forward void Shavit_OnFinish_Post(int client, BhopStyle style, float time, int j * @param style Style the record was done on. * @param time Record time. * @param jumps Jumps amount. + * @param strafes Amount of strafes. + * @param sync Sync percentage (0.0 to 100.0). * @noreturn */ -forward void Shavit_OnWorldRecord(int client, BhopStyle style, float time, int jumps); +forward void Shavit_OnWorldRecord(int client, BhopStyle style, float time, int jumps, int strafes, float sync); /** * Called when an admin deletes a WR. diff --git a/scripting/shavit-core.sp b/scripting/shavit-core.sp index 967e5658..e85c9785 100644 --- a/scripting/shavit-core.sp +++ b/scripting/shavit-core.sp @@ -542,6 +542,11 @@ public void Player_Jump(Event event, const char[] name, bool dontBroadcast) { SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0); } + + if(gI_StyleProperties[gBS_Style[client]] & STYLE_LOWGRAV) + { + SetEntityGravity(client, 0.6); + } } public void Player_Death(Event event, const char[] name, bool dontBroadcast) @@ -725,7 +730,7 @@ public void StartTimer(int client) gF_PauseTotalTime[client] = 0.0; gB_ClientPaused[client] = false; - SetEntityGravity(client, 0.0); + SetEntityGravity(client, (gI_StyleProperties[gBS_Style[client]] & STYLE_LOWGRAV)? 0.6:0.0); SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0); } diff --git a/scripting/shavit-wr.sp b/scripting/shavit-wr.sp index 4d123b81..41d4a88b 100644 --- a/scripting/shavit-wr.sp +++ b/scripting/shavit-wr.sp @@ -111,8 +111,8 @@ public void OnPluginStart() #endif // forwards - gH_OnWorldRecord = CreateGlobalForward("Shavit_OnWorldRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); - gH_OnFinish_Post = CreateGlobalForward("Shavit_OnFinish_Post", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell); + gH_OnWorldRecord = CreateGlobalForward("Shavit_OnWorldRecord", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); + gH_OnFinish_Post = CreateGlobalForward("Shavit_OnFinish_Post", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell); gH_OnWRDeleted = CreateGlobalForward("Shavit_OnWRDeleted", ET_Event, Param_Cell, Param_Cell); // player commands @@ -336,6 +336,11 @@ public void SQL_UpdateWRCache_Callback(Database db, DBResultSet results, const c // reset cache for(int i = 0; i < MAX_STYLES; i++) { + if(gI_StyleProperties[i] & STYLE_UNRANKED) + { + continue; + } + strcopy(gS_WRName[i], MAX_NAME_LENGTH, "invalid"); gF_WRTime[i] = 0.0; gI_RecordAmount[i] = 0; @@ -1360,25 +1365,17 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, char[] sTime = new char[32]; FormatSeconds(time, sTime, 32); - // k people I made this forward so I'll use it to make cool text messages on WR (check shavit-misc soon™) EDIT: implemented into shavit-misc ages ago lmao why is this line still here :o - if(!(gI_StyleProperties[style] & STYLE_UNRANKED) && time < gF_WRTime[style] || gF_WRTime[style] == 0.0) // WR? - { - Call_StartForward(gH_OnWorldRecord); - Call_PushCell(client); - Call_PushCell(style); - Call_PushCell(time); - Call_PushCell(jumps); - Call_Finish(); - - UpdateWRCache(); - } - // 0 - no query // 1 - insert // 2 - update int overwrite = 0; - if(gF_PlayerRecord[client][style] == 0.0) + if(gI_StyleProperties[style] & STYLE_UNRANKED) + { + overwrite = 0; // ugly way of not writing to database + } + + else if(gF_PlayerRecord[client][style] == 0.0) { overwrite = 1; } @@ -1388,9 +1385,20 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, overwrite = 2; } - else if(gI_StyleProperties[style] & STYLE_UNRANKED) + int iRank = GetRankForTime(style, time); + + if(overwrite > 0 && (time < gF_WRTime[style] || gF_WRTime[style] == 0.0)) // WR? { - overwrite = 0; // ugly way of not writing to database + Call_StartForward(gH_OnWorldRecord); + Call_PushCell(client); + Call_PushCell(style); + Call_PushCell(time); + Call_PushCell(jumps); + Call_PushCell(strafes); + Call_PushCell(sync); + Call_Finish(); + + UpdateWRCache(); } float fDifference = (gF_PlayerRecord[client][style] - time) * -1.0; @@ -1411,12 +1419,12 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, { if(sGame == Game_CSS) { - Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07D490CF%s\x01 (\x077585E0#%d\x01) with %d jump%s, %d strafe%s @ \x07B590D4%.02f%%\x01.", client, gS_BhopStyles[style], sTime, GetRankForTime(style, time), jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync); + Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07D490CF%s\x01 (\x077585E0#%d\x01) with %d jump%s, %d strafe%s @ \x07B590D4%.02f%%\x01.", client, gS_BhopStyles[style], sTime, iRank, jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync); } else { - Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07%s\x01 (\x05#%d\x01) with %d jump%s, %d strafe%s @ \x06%.02f%%\x01.", client, gS_BhopStyles[style], sTime, GetRankForTime(style, time), jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync); + Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07%s\x01 (\x05#%d\x01) with %d jump%s, %d strafe%s @ \x06%.02f%%\x01.", client, gS_BhopStyles[style], sTime, iRank, jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync); } // prevent duplicate records in case there's a long enough lag for the mysql server between two map finishes @@ -1433,12 +1441,12 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, { if(sGame == Game_CSS) { - Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07D490CF%s\x01 (\x077585E0#%d\x01) with %d jump%s, %d strafe%s @ \x07B590D4%.02f%%\x01. \x07AD3BA6(%s)", client, gS_BhopStyles[style], sTime, GetRankForTime(style, time), jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync, sDifference); + Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07D490CF%s\x01 (\x077585E0#%d\x01) with %d jump%s, %d strafe%s @ \x07B590D4%.02f%%\x01. \x07AD3BA6(%s)", client, gS_BhopStyles[style], sTime, iRank, jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync, sDifference); } else { - Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07%s\x01 (\x05#%d\x01) with %d jump%s, %d strafe%s @ \x06%.02f%%\x01. \x0C(%s)", client, gS_BhopStyles[style], sTime, GetRankForTime(style, time), jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync, sDifference); + Shavit_PrintToChatAll("\x03%N\x01 finished (%s) in \x07%s\x01 (\x05#%d\x01) with %d jump%s, %d strafe%s @ \x06%.02f%%\x01. \x0C(%s)", client, gS_BhopStyles[style], sTime, iRank, jumps, (jumps != 1)? "s":"", strafes, (strafes != 1)? "s":"", sync, sDifference); } FormatEx(sQuery, 512, "UPDATE %splayertimes SET time = %.03f, jumps = %d, date = %d, strafes = %d, sync = %.02f WHERE map = '%s' AND auth = '%s' AND style = '%d';", gS_MySQLPrefix, time, jumps, GetTime(), strafes, sync, gS_Map, sAuthID, style); @@ -1458,6 +1466,9 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps, Call_PushCell(style); Call_PushCell(time); Call_PushCell(jumps); + Call_PushCell(strafes); + Call_PushCell(sync); + Call_PushCell(iRank); Call_Finish(); } @@ -1532,11 +1543,23 @@ public void SQL_UpdateLeaderboards_Callback(Database db, DBResultSet results, co while(results.FetchRow()) { - gA_LeaderBoard[results.FetchInt(0)].Push(results.FetchFloat(1)); + BhopStyle style = view_as(results.FetchInt(0)); + + if(gI_StyleProperties[style] & STYLE_UNRANKED) + { + continue; + } + + gA_LeaderBoard[style].Push(results.FetchFloat(1)); } for(int i = 0; i < MAX_STYLES; i++) { + if(gI_StyleProperties[i] & STYLE_UNRANKED) + { + continue; + } + SortADTArray(gA_LeaderBoard[i], Sort_Ascending, Sort_Float); gI_RecordAmount[i] = gA_LeaderBoard[i].Length; }