mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 10:28:26 +00:00
add strafe counter (sync soon™)
This commit is contained in:
parent
1d133feb3f
commit
28da693457
@ -86,6 +86,7 @@ Core
|
||||
- [x] Add a setting to not start timer if Z axis velocity is a thing (non-prespeed styles).
|
||||
- [x] Add speed reset at timer start.
|
||||
- [x] Add support for 100AA styles.
|
||||
- [ ] Add low gravity styles (0.6)
|
||||
- [ ] Measure strafe count/sync, also have it in the Shavit_OnFinish forward.
|
||||
- [ ] Add a native that will execute threaded MySQL queries and allow callbacks.
|
||||
- [ ] Add bonus timer.
|
||||
@ -115,6 +116,7 @@ Replay
|
||||
- [x] Make replay bots dead if there's no replay data loaded.
|
||||
- [x] Clear player cache on spawn/death.
|
||||
- [x] Add admin interface. (delete replay data, `sm_deletereplay` for RCON admins.)
|
||||
- [ ] Save first/last frame per style globally instead of calling Get() every time.
|
||||
- [ ] Add a setting so there are two modes: one is that bots always play, and the other is that there are X bots (defined by server admin) and players can start their playback with a command. (`sm_replay`)
|
||||
|
||||
Stats
|
||||
|
||||
@ -513,6 +513,15 @@ native BhopStyle Shavit_GetBhopStyle(int client);
|
||||
*/
|
||||
native TimerStatus Shavit_GetTimerStatus(int client);
|
||||
|
||||
/**
|
||||
* Retrieve the amount of strafes done since the timer started.
|
||||
* Will return 0 if timer isn't running.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return Amount of strafes since timer start.
|
||||
*/
|
||||
native int Shavit_GetStrafeCount(int client);
|
||||
|
||||
/**
|
||||
* Saves the WR time for the current map on a variable.
|
||||
*
|
||||
@ -766,36 +775,37 @@ public SharedPlugin __pl_shavit =
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_shavit_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("Shavit_StartTimer");
|
||||
MarkNativeAsOptional("Shavit_StopTimer");
|
||||
MarkNativeAsOptional("Shavit_CalculatePoints");
|
||||
MarkNativeAsOptional("Shavit_FinishMap");
|
||||
MarkNativeAsOptional("Shavit_GetTimer");
|
||||
MarkNativeAsOptional("Shavit_GetClientTime");
|
||||
MarkNativeAsOptional("Shavit_GetBhopStyle");
|
||||
MarkNativeAsOptional("Shavit_GetTimerStatus");
|
||||
MarkNativeAsOptional("Shavit_PauseTimer");
|
||||
MarkNativeAsOptional("Shavit_ResumeTimer");
|
||||
MarkNativeAsOptional("Shavit_PrintToChat");
|
||||
MarkNativeAsOptional("Shavit_RestartTimer");
|
||||
MarkNativeAsOptional("Shavit_ForceHUDUpdate");
|
||||
MarkNativeAsOptional("Shavit_FormatChat");
|
||||
MarkNativeAsOptional("Shavit_GetBhopStyle");
|
||||
MarkNativeAsOptional("Shavit_GetClientTime");
|
||||
MarkNativeAsOptional("Shavit_GetGivenMapValues");
|
||||
MarkNativeAsOptional("Shavit_GetMapValues");
|
||||
MarkNativeAsOptional("Shavit_GetPlayerPB");
|
||||
MarkNativeAsOptional("Shavit_GetPoints");
|
||||
MarkNativeAsOptional("Shavit_GetRank");
|
||||
MarkNativeAsOptional("Shavit_GetMapValues");
|
||||
MarkNativeAsOptional("Shavit_GetRankedPlayers");
|
||||
MarkNativeAsOptional("Shavit_CalculatePoints");
|
||||
MarkNativeAsOptional("Shavit_GetWRTime");
|
||||
MarkNativeAsOptional("Shavit_GetWRRecordID");
|
||||
MarkNativeAsOptional("Shavit_GetWRName");
|
||||
MarkNativeAsOptional("Shavit_GetPlayerPB");
|
||||
MarkNativeAsOptional("Shavit_GetRankForTime");
|
||||
MarkNativeAsOptional("Shavit_ZoneExists");
|
||||
MarkNativeAsOptional("Shavit_InsideZone");
|
||||
MarkNativeAsOptional("Shavit_IsClientCreatingZone");
|
||||
MarkNativeAsOptional("Shavit_GetRankedPlayers");
|
||||
MarkNativeAsOptional("Shavit_GetReplayBotCurrentFrame");
|
||||
MarkNativeAsOptional("Shavit_GetReplayBotFirstFrame");
|
||||
MarkNativeAsOptional("Shavit_GetReplayBotIndex");
|
||||
MarkNativeAsOptional("Shavit_GetReplayBotCurrentFrame");
|
||||
MarkNativeAsOptional("Shavit_GetStrafeCount");
|
||||
MarkNativeAsOptional("Shavit_GetTimer");
|
||||
MarkNativeAsOptional("Shavit_GetTimerStatus");
|
||||
MarkNativeAsOptional("Shavit_GetWRName");
|
||||
MarkNativeAsOptional("Shavit_GetWRRecordID");
|
||||
MarkNativeAsOptional("Shavit_GetWRTime");
|
||||
MarkNativeAsOptional("Shavit_InsideZone");
|
||||
MarkNativeAsOptional("Shavit_IsClientCreatingZone");
|
||||
MarkNativeAsOptional("Shavit_IsReplayDataLoaded");
|
||||
MarkNativeAsOptional("Shavit_FormatChat");
|
||||
MarkNativeAsOptional("Shavit_GetGivenMapValues");
|
||||
MarkNativeAsOptional("Shavit_PauseTimer");
|
||||
MarkNativeAsOptional("Shavit_PrintToChat");
|
||||
MarkNativeAsOptional("Shavit_RestartTimer");
|
||||
MarkNativeAsOptional("Shavit_ResumeTimer");
|
||||
MarkNativeAsOptional("Shavit_StartTimer");
|
||||
MarkNativeAsOptional("Shavit_StopTimer");
|
||||
MarkNativeAsOptional("Shavit_ZoneExists");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -63,6 +63,7 @@ BhopStyle gBS_Style[MAXPLAYERS+1];
|
||||
bool gB_Auto[MAXPLAYERS+1];
|
||||
bool gB_OnGround[MAXPLAYERS+1];
|
||||
int gI_ButtonCache[MAXPLAYERS+1];
|
||||
int gI_Strafes[MAXPLAYERS+1];
|
||||
float gF_HSW_Requirement = 0.0;
|
||||
|
||||
// late load
|
||||
@ -119,6 +120,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
CreateNative("Shavit_ResumeTimer", Native_ResumeTimer);
|
||||
CreateNative("Shavit_PrintToChat", Native_PrintToChat);
|
||||
CreateNative("Shavit_RestartTimer", Native_RestartTimer);
|
||||
CreateNative("Shavit_GetStrafeCount", Native_GetStrafeCount);
|
||||
|
||||
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
|
||||
RegPluginLibrary("shavit");
|
||||
@ -678,6 +680,11 @@ public int Native_RestartTimer(Handle handler, int numParams)
|
||||
return;
|
||||
}
|
||||
|
||||
public int Native_GetStrafeCount(Handle handler, int numParams)
|
||||
{
|
||||
return gI_Strafes[GetNativeCell(1)];
|
||||
}
|
||||
|
||||
public void StartTimer(int client)
|
||||
{
|
||||
if(!IsValidClient(client, true) || GetClientTeam(client) < 2 || IsFakeClient(client))
|
||||
@ -692,13 +699,14 @@ public void StartTimer(int client)
|
||||
{
|
||||
gF_StartTime[client] = GetEngineTime();
|
||||
gB_TimerEnabled[client] = true;
|
||||
gI_Strafes[client] = 0;
|
||||
gI_Jumps[client] = 0;
|
||||
|
||||
Call_StartForward(gH_Forwards_Start);
|
||||
Call_PushCell(client);
|
||||
Call_Finish();
|
||||
}
|
||||
|
||||
gI_Jumps[client] = 0;
|
||||
gF_PauseTotalTime[client] = 0.0;
|
||||
gB_ClientPaused[client] = false;
|
||||
|
||||
@ -718,6 +726,7 @@ public void StopTimer(int client)
|
||||
gF_StartTime[client] = 0.0;
|
||||
gF_PauseTotalTime[client] = 0.0;
|
||||
gB_ClientPaused[client] = false;
|
||||
gI_Strafes[client] = 0;
|
||||
}
|
||||
|
||||
public void PauseTimer(int client)
|
||||
@ -913,17 +922,28 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if(gB_HUD)
|
||||
if(!(gI_ButtonCache[client] & IN_FORWARD) && buttons & IN_FORWARD)
|
||||
{
|
||||
if(gI_ButtonCache[client] != buttons)
|
||||
{
|
||||
Shavit_ForceHUDUpdate(client, true);
|
||||
}
|
||||
gI_Strafes[client]++;
|
||||
}
|
||||
|
||||
gI_ButtonCache[client] = buttons;
|
||||
if(!(gI_ButtonCache[client] & IN_MOVELEFT) && buttons & IN_MOVELEFT)
|
||||
{
|
||||
gI_Strafes[client]++;
|
||||
}
|
||||
|
||||
if(!(gI_ButtonCache[client] & IN_BACK) && buttons & IN_BACK)
|
||||
{
|
||||
gI_Strafes[client]++;
|
||||
}
|
||||
|
||||
if(!(gI_ButtonCache[client] & IN_MOVERIGHT) && buttons & IN_MOVERIGHT)
|
||||
{
|
||||
gI_Strafes[client]++;
|
||||
}
|
||||
|
||||
bool bOnLadder = (GetEntityMoveType(client) == MOVETYPE_LADDER);
|
||||
bool bOnGround = (GetEntityFlags(client) & FL_ONGROUND || bOnLadder);
|
||||
bool bInStart = Shavit_InsideZone(client, Zone_Start);
|
||||
|
||||
if(gCV_LeftRight.BoolValue && gB_TimerEnabled[client] && (!gB_Zones || !bInStart && (buttons & IN_LEFT || buttons & IN_RIGHT)))
|
||||
@ -932,8 +952,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
Shavit_PrintToChat(client, "I've stopped your timer for using +left/+right. No cheating!");
|
||||
}
|
||||
|
||||
bool bOnGround = GetEntityFlags(client) & FL_ONGROUND || bOnLadder;
|
||||
|
||||
// key blocking
|
||||
if(!Shavit_InsideZone(client, Zone_Freestyle))
|
||||
{
|
||||
@ -945,25 +963,25 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
|
||||
if(!bOnGround)
|
||||
{
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_W && (vel[0] > 0 || buttons & IN_FORWARD))
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_W && (buttons & IN_FORWARD || vel[0] > 0.0))
|
||||
{
|
||||
vel[0] = 0.0;
|
||||
buttons &= ~IN_FORWARD;
|
||||
}
|
||||
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_A && (vel[1] < 0 || buttons & IN_MOVELEFT))
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_A && (buttons & IN_MOVELEFT || vel[1] < 0.0))
|
||||
{
|
||||
vel[1] = 0.0;
|
||||
buttons &= ~IN_MOVELEFT;
|
||||
}
|
||||
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_S && (vel[0] < 0 || buttons & IN_BACK))
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_S && (buttons & IN_BACK || vel[0] < 0.0))
|
||||
{
|
||||
vel[0] = 0.0;
|
||||
buttons &= ~IN_BACK;
|
||||
}
|
||||
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_D && (vel[1] > 0 || buttons & IN_MOVERIGHT))
|
||||
if(gI_StyleProperties[gBS_Style[client]] & STYLE_BLOCK_D && (buttons & IN_MOVERIGHT || vel[1] > 0.0))
|
||||
{
|
||||
vel[1] = 0.0;
|
||||
buttons &= ~IN_MOVERIGHT;
|
||||
@ -994,6 +1012,11 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
buttons &= ~IN_JUMP;
|
||||
}
|
||||
|
||||
if(gB_HUD && gI_ButtonCache[client] != buttons)
|
||||
{
|
||||
Shavit_ForceHUDUpdate(client, true);
|
||||
}
|
||||
|
||||
// velocity limit
|
||||
if(bOnGround && gI_StyleProperties[gBS_Style[client]] & STYLE_VEL_LIMIT && gF_VelocityLimit[gBS_Style[client]] != VELOCITY_UNLIMITED && (!gB_Zones || !Shavit_InsideZone(client, Zone_NoVelLimit)))
|
||||
{
|
||||
@ -1023,5 +1046,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
vel = view_as<float>({0.0, 0.0, 0.0});
|
||||
}
|
||||
|
||||
gI_ButtonCache[client] = buttons;
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ public void UpdateHUD(int client)
|
||||
Format(sHintText, 512, "%s\tJumps: %d", sHintText, iJumps);
|
||||
}
|
||||
|
||||
Format(sHintText, 512, "%s\nPlayer: <font color='#BF6821'>%N</font>", sHintText, target);
|
||||
Format(sHintText, 512, "%s\nStrafes: <font color='#BF6821'>%d</font>", sHintText, Shavit_GetStrafeCount(target));
|
||||
Format(sHintText, 512, "%s</font>", sHintText);
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ public void UpdateHUD(int client)
|
||||
{
|
||||
if(Shavit_GetTimerStatus(target) == Timer_Running)
|
||||
{
|
||||
FormatEx(sHintText, 512, "%s\nTime: %s (%d)\nJumps: %d\nSpeed: %d", gS_BhopStyles[bsStyle], sTime, Shavit_GetRankForTime(bsStyle, fTime), iJumps, RoundToZero(fSpeed_New));
|
||||
FormatEx(sHintText, 512, "%s\nTime: %s (%d)\nJumps: %d\nStrafes: %d\nSpeed: %d", gS_BhopStyles[bsStyle], sTime, Shavit_GetRankForTime(bsStyle, fTime), iJumps, Shavit_GetStrafeCount(target), RoundToZero(fSpeed_New));
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user