mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 02:18:26 +00:00
move UpdateStepSound stuff to shavit-replay
This commit is contained in:
parent
c4783eae37
commit
c33ea7c0d0
@ -137,7 +137,6 @@ Convar gCV_StopTimerWarning = null;
|
||||
Convar gCV_WRMessages = null;
|
||||
Convar gCV_BhopSounds = null;
|
||||
Convar gCV_RestrictNoclip = null;
|
||||
Convar gCV_BotFootsteps = null;
|
||||
Convar gCV_SpecScoreboardOrder = null;
|
||||
ConVar gCV_ExperimentalSegmentedEyeAngleFix = null;
|
||||
ConVar gCV_PauseMovement = null;
|
||||
@ -160,7 +159,6 @@ Handle gH_Forwards_OnCheckpointMenuMade = null;
|
||||
Handle gH_Forwards_OnCheckpointMenuSelect = null;
|
||||
|
||||
// dhooks
|
||||
DynamicHook gH_UpdateStepSound = null;
|
||||
DynamicHook gH_IsSpawnPointValid = null;
|
||||
DynamicDetour gH_CalcPlayerScore = null;
|
||||
Handle gH_PhysicsCheckForEntityUntouch;
|
||||
@ -344,7 +342,6 @@ public void OnPluginStart()
|
||||
gCV_WRMessages = new Convar("shavit_misc_wrmessages", "3", "How many \"NEW <style> WR!!!\" messages to print?\n0 - Disabled", 0, true, 0.0, true, 100.0);
|
||||
gCV_BhopSounds = new Convar("shavit_misc_bhopsounds", "1", "Should bhop (landing and jumping) sounds be muted?\n0 - Disabled\n1 - Blocked while !hide is enabled\n2 - Always blocked", 0, true, 0.0, true, 2.0);
|
||||
gCV_RestrictNoclip = new Convar("shavit_misc_restrictnoclip", "0", "Should noclip be be restricted\n0 - Disabled\n1 - No vertical velocity while in noclip in start zone\n2 - No noclip in start zone", 0, true, 0.0, true, 2.0);
|
||||
gCV_BotFootsteps = new Convar("shavit_misc_botfootsteps", "1", "Enable footstep sounds for replay bots. Only works if shavit_misc_bhopsounds is less than 2.", 0, true, 0.0, true, 1.0);
|
||||
gCV_ExperimentalSegmentedEyeAngleFix = new Convar("shavit_misc_experimental_segmented_eyeangle_fix", "1", "When teleporting to a segmented checkpoint, the player's old eye-angles persist in replay-frames for as many ticks they're behind the server in latency. This applies the teleport-position angles to the replay-frame for that many ticks.", 0, true, 0.0, true, 1.0);
|
||||
gCV_SpecScoreboardOrder = new Convar("shavit_misc_spec_scoreboard_order", "1", "Use scoreboard ordering for players when changing target when spectating.", 0, true, 0.0, true, 1.0);
|
||||
|
||||
@ -408,18 +405,6 @@ void LoadDHooks()
|
||||
}
|
||||
}
|
||||
|
||||
if ((iOffset = GameConfGetOffset(hGameData, "CBasePlayer::UpdateStepSound")) != -1)
|
||||
{
|
||||
gH_UpdateStepSound = new DynamicHook(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_ObjectPtr);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_VectorPtr);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_VectorPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError("Couldn't get the offset for \"CBasePlayer::UpdateStepSound\" - make sure your gamedata is updated!");
|
||||
}
|
||||
|
||||
if ((iOffset = GameConfGetOffset(hGameData, "CGameRules::IsSpawnPointValid")) != -1)
|
||||
{
|
||||
gH_IsSpawnPointValid = new DynamicHook(iOffset, HookType_GameRules, ReturnType_Bool, ThisPointer_Ignore);
|
||||
@ -1051,32 +1036,6 @@ public Action Command_Radio(int client, const char[] command, int args)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
// Remove flags from replay bots that cause CBasePlayer::UpdateStepSound to return without playing a footstep.
|
||||
public MRESReturn Hook_UpdateStepSound_Pre(int pThis, DHookParam hParams)
|
||||
{
|
||||
if (GetEntityMoveType(pThis) == MOVETYPE_NOCLIP)
|
||||
{
|
||||
SetEntityMoveType(pThis, MOVETYPE_WALK);
|
||||
}
|
||||
|
||||
SetEntityFlags(pThis, GetEntityFlags(pThis) & ~FL_ATCONTROLS);
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
// Readd flags to replay bots now that CBasePlayer::UpdateStepSound is done.
|
||||
public MRESReturn Hook_UpdateStepSound_Post(int pThis, DHookParam hParams)
|
||||
{
|
||||
if (GetEntityMoveType(pThis) == MOVETYPE_WALK)
|
||||
{
|
||||
SetEntityMoveType(pThis, MOVETYPE_NOCLIP);
|
||||
}
|
||||
|
||||
SetEntityFlags(pThis, GetEntityFlags(pThis) | FL_ATCONTROLS);
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
public Action Timer_Cron(Handle timer)
|
||||
{
|
||||
if(gCV_HideRadar.BoolValue && gEV_Type == Engine_CSS)
|
||||
@ -1485,11 +1444,6 @@ public void OnClientPutInServer(int client)
|
||||
|
||||
if(IsFakeClient(client))
|
||||
{
|
||||
if (gCV_BotFootsteps.BoolValue && gH_UpdateStepSound != null)
|
||||
{
|
||||
gH_UpdateStepSound.HookEntity(Hook_Pre, client, Hook_UpdateStepSound_Pre);
|
||||
gH_UpdateStepSound.HookEntity(Hook_Post, client, Hook_UpdateStepSound_Post);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -221,7 +221,8 @@ bot_info_t gA_BotInfo[MAXPLAYERS+1];
|
||||
|
||||
// hooks and sdkcall stuff
|
||||
Handle gH_BotAddCommand = INVALID_HANDLE;
|
||||
Handle gH_DoAnimationEvent = INVALID_HANDLE ;
|
||||
Handle gH_DoAnimationEvent = INVALID_HANDLE;
|
||||
DynamicHook gH_UpdateStepSound = null;
|
||||
DynamicDetour gH_MaintainBotQuota = null;
|
||||
DynamicDetour gH_TeamFull = null;
|
||||
int gI_WEAPONTYPE_UNKNOWN = 123123123;
|
||||
@ -236,6 +237,7 @@ bool gB_HideNameChange = false;
|
||||
|
||||
// plugin cvars
|
||||
Convar gCV_Enabled = null;
|
||||
Convar gCV_BotFootsteps = null;
|
||||
Convar gCV_ReplayDelay = null;
|
||||
Convar gCV_DefaultTeam = null;
|
||||
Convar gCV_CentralBot = null;
|
||||
@ -414,6 +416,7 @@ public void OnPluginStart()
|
||||
|
||||
// plugin convars
|
||||
gCV_Enabled = new Convar("shavit_replay_bot_enabled", "1", "Enable replay bot functionality?", 0, true, 0.0, true, 1.0);
|
||||
gCV_BotFootsteps = new Convar("shavit_replay_bot_footsteps", "1", "Enable footstep sounds for replay bots.", 0, true, 0.0, true, 1.0);
|
||||
gCV_ReplayDelay = new Convar("shavit_replay_delay", "2.5", "Time to wait before restarting the replay after it finishes playing.", 0, true, 0.0, true, 10.0);
|
||||
gCV_DefaultTeam = new Convar("shavit_replay_defaultteam", "3", "Default team to make the bots join, if possible.\n2 - Terrorists/RED\n3 - Counter Terrorists/BLU", 0, true, 2.0, true, 3.0);
|
||||
gCV_CentralBot = new Convar("shavit_replay_centralbot", "1", "Have one central bot instead of one bot per replay.\nTriggered with !replay.\nRestart the map for changes to take effect.\nThe disabled setting is not supported - use at your own risk.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
|
||||
@ -489,6 +492,7 @@ public void OnPluginStart()
|
||||
|
||||
void LoadDHooks()
|
||||
{
|
||||
int iOffset.
|
||||
GameData gamedata = new GameData("shavit.games");
|
||||
|
||||
if (gamedata == null)
|
||||
@ -584,6 +588,18 @@ void LoadDHooks()
|
||||
|
||||
gH_DoAnimationEvent = EndPrepSDKCall();
|
||||
|
||||
if ((iOffset = GameConfGetOffset(hGameData, "CBasePlayer::UpdateStepSound")) != -1)
|
||||
{
|
||||
gH_UpdateStepSound = new DynamicHook(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_ObjectPtr);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_VectorPtr);
|
||||
gH_UpdateStepSound.AddParam(HookParamType_VectorPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError("Couldn't get the offset for \"CBasePlayer::UpdateStepSound\" - make sure your gamedata is updated!");
|
||||
}
|
||||
|
||||
delete gamedata;
|
||||
}
|
||||
|
||||
@ -2221,6 +2237,12 @@ public void OnClientPutInServer(int client)
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
FillBotName(gA_BotInfo_Temp, sName);
|
||||
SetClientName(client, sName);
|
||||
|
||||
if (gCV_BotFootsteps.BoolValue && gH_UpdateStepSound != null)
|
||||
{
|
||||
gH_UpdateStepSound.HookEntity(Hook_Pre, client, Hook_UpdateStepSound_Pre);
|
||||
gH_UpdateStepSound.HookEntity(Hook_Post, client, Hook_UpdateStepSound_Post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2247,6 +2269,32 @@ public Action HookTriggers(int entity, int other)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
// Remove flags from replay bots that cause CBasePlayer::UpdateStepSound to return without playing a footstep.
|
||||
public MRESReturn Hook_UpdateStepSound_Pre(int pThis, DHookParam hParams)
|
||||
{
|
||||
if (GetEntityMoveType(pThis) == MOVETYPE_NOCLIP)
|
||||
{
|
||||
SetEntityMoveType(pThis, MOVETYPE_WALK);
|
||||
}
|
||||
|
||||
SetEntityFlags(pThis, GetEntityFlags(pThis) & ~FL_ATCONTROLS);
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
// Readd flags to replay bots now that CBasePlayer::UpdateStepSound is done.
|
||||
public MRESReturn Hook_UpdateStepSound_Post(int pThis, DHookParam hParams)
|
||||
{
|
||||
if (GetEntityMoveType(pThis) == MOVETYPE_WALK)
|
||||
{
|
||||
SetEntityMoveType(pThis, MOVETYPE_NOCLIP);
|
||||
}
|
||||
|
||||
SetEntityFlags(pThis, GetEntityFlags(pThis) | FL_ATCONTROLS);
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
void FormatStyle(const char[] source, int style, bool central, int track, char dest[MAX_NAME_LENGTH], bool idle, frame_cache_t aCache, int type)
|
||||
{
|
||||
char sTime[16];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user