add Shavit_GetReplayEntityFlags & have scroll count work for replay bots (non-prop) #1125

This commit is contained in:
rtldg 2022-02-24 06:23:01 +00:00
parent 4e89fb60d9
commit 80e8480b7a
4 changed files with 49 additions and 10 deletions

View File

@ -110,7 +110,17 @@ public void Bhopstats_PostThinkPost(int client)
int buttons = GetClientButtons(client);
bool bOldOnGround = gB_OnGround[client];
int iGroundEntity = GetEntPropEnt(client, Prop_Send, "m_hGroundEntity");
int iGroundEntity;
if (gB_ReplayPlayback && IsFakeClient(client))
{
iGroundEntity = (Shavit_GetReplayEntityFlags(client) & FL_ONGROUND) ? 0 : -1;
}
else
{
iGroundEntity = GetEntPropEnt(client, Prop_Send, "m_hGroundEntity");
}
bool bOnLadder = (GetEntityMoveType(client) == MOVETYPE_LADDER);
gB_OnGround[client] = (iGroundEntity != -1 || GetEntProp(client, Prop_Send, "m_nWaterLevel") >= 2 || bOnLadder);

View File

@ -158,6 +158,13 @@ native int Shavit_GetReplayStarter(int ent);
*/
native int Shavit_GetReplayButtons(int ent, float& anglediff);
/**
* Retrieves the replay's entity flags for its current tick.
* @param Replay entity.
* @return Entity flags
*/
native int Shavit_GetReplayEntityFlags(int ent);
/**
* Retrieves a replay's frame count.
*
@ -473,6 +480,7 @@ public void __pl_shavit_replay_playback_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetClosestReplayVelocityDifference");
MarkNativeAsOptional("Shavit_IsReplayEntity");
MarkNativeAsOptional("Shavit_GetReplayButtons");
MarkNativeAsOptional("Shavit_GetReplayEntityFlags");
MarkNativeAsOptional("Shavit_GetClosestReplayStyle");
MarkNativeAsOptional("Shavit_SetClosestReplayStyle");
MarkNativeAsOptional("Shavit_GetReplayCacheFrameCount");

View File

@ -29,7 +29,6 @@
#define DEBUG 0
#include <shavit/core>
#include <shavit/bhopstats-timerified.sp>
#undef REQUIRE_PLUGIN
#include <shavit/hud>
@ -161,6 +160,10 @@ float gF_ZoneSpeedLimit[MAXPLAYERS+1];
// kz support
bool gB_KZMap[TRACKS_SIZE];
#include <shavit/bhopstats-timerified.sp> // down here to get includes from replay-playback & to inherit gB_ReplayPlayback
public Plugin myinfo =
{
name = "[shavit] Core",
@ -344,6 +347,7 @@ public void OnPluginStart()
// admin
RegAdminCmd("sm_deletemap", Command_DeleteMap, ADMFLAG_ROOT, "Deletes all map data. Usage: sm_deletemap <map>");
RegAdminCmd("sm_wipeplayer", Command_WipePlayer, ADMFLAG_BAN, "Wipes all bhoptimer data for specified player. Usage: sm_wipeplayer <steamid3>");
RegAdminCmd("sm_wipetrack", Command_WipeTrack, ADMFLAG_ROOT, "Deletes all runs on a track.");
RegAdminCmd("sm_migration", Command_Migration, ADMFLAG_ROOT, "Force a database migration to run. Usage: sm_migration <migration id> or \"all\" to run all migrations.");
// commands END
@ -1091,6 +1095,12 @@ public Action Command_WipePlayer(int client, int args)
return Plugin_Handled;
}
public Action Command_WipeTrack(int client, int args)
{
return Plugin_Handled;
}
public void Trans_DeleteRestOfUserSuccess(Database db, DataPack hPack, int numQueries, DBResultSet[] results, any[] queryData)
{
hPack.Reset();
@ -2502,14 +2512,13 @@ public void OnClientCookiesCached(int client)
public void OnClientPutInServer(int client)
{
StopTimer(client);
Bhopstats_OnClientPutInServer(client);
if(!IsClientConnected(client) || IsFakeClient(client))
{
return;
}
Bhopstats_OnClientPutInServer(client);
gB_Auto[client] = true;
gA_Timers[client].fStrafeWarning = 0.0;
gA_Timers[client].bPracticeMode = false;

View File

@ -179,6 +179,7 @@ int gI_DynamicBots = 0;
// Replay_Prop: index with starter/watcher
// Replay_ANYTHINGELSE: index with fakeclient index
bot_info_t gA_BotInfo[MAXPLAYERS+1];
frame_t gA_CachedFrames[MAXPLAYERS+1][2]; // I know it kind of overlaps with the frame_cache_t name stuff...
// hooks and sdkcall stuff
Handle gH_BotAddCommand = INVALID_HANDLE;
@ -260,6 +261,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetReplayBotType", Native_GetReplayBotType);
CreateNative("Shavit_GetReplayStarter", Native_GetReplayStarter);
CreateNative("Shavit_GetReplayButtons", Native_GetReplayButtons);
CreateNative("Shavit_GetReplayEntityFlags", Native_GetReplayEntityFlags);
CreateNative("Shavit_GetReplayFrames", Native_GetReplayFrames);
CreateNative("Shavit_GetReplayFrameCount", Native_GetReplayFrameCount);
CreateNative("Shavit_GetReplayPreFrames", Native_GetReplayPreFrames);
@ -1281,13 +1283,20 @@ public int Native_GetReplayButtons(Handle handler, int numParams)
return 0;
}
frame_t aFrame;
gA_BotInfo[bot].aCache.aFrames.GetArray(gA_BotInfo[bot].iTick ? gA_BotInfo[bot].iTick-1 : 0, aFrame, 6);
float prevAngle = aFrame.ang[1];
gA_BotInfo[bot].aCache.aFrames.GetArray(gA_BotInfo[bot].iTick, aFrame, 6);
SetNativeCellRef(2, GetAngleDiff(gA_CachedFrames[bot][0].ang[1], gA_CachedFrames[bot][1].ang[1]));
return gA_CachedFrames[bot][0].buttons;
}
SetNativeCellRef(2, GetAngleDiff(aFrame.ang[1], prevAngle));
return aFrame.buttons;
public int Native_GetReplayEntityFlags(Handle plugin, int numParams)
{
int bot = GetBotInfoIndex(GetNativeCell(1));
if (gA_BotInfo[bot].iStatus != Replay_Running)
{
return 0;
}
return gA_CachedFrames[bot][0].flags;
}
public int Native_Replay_DeleteMap(Handle handler, int numParams)
@ -2399,6 +2408,9 @@ Action ReplayOnPlayerRunCmd(bot_info_t info, int &buttons, int &impulse, float v
info.aCache.aFrames.GetArray(info.iTick, aFrame, (info.aCache.iReplayVersion >= 0x02) ? 8 : 6);
buttons = aFrame.buttons;
gA_CachedFrames[info.iEnt][1] = gA_CachedFrames[info.iEnt][0];
gA_CachedFrames[info.iEnt][0] = aFrame;
if (!isClient)
{
aFrame.pos[2] += (aFrame.buttons & IN_DUCK) ? gF_EyeOffsetDuck : gF_EyeOffset;