-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include "stdafx.hpp" | ||
#ifndef OE | ||
|
||
#include "..\feature.hpp" | ||
#include "..\sptlib-wrapper.hpp" | ||
#include "playerio.hpp" | ||
#include "shadow.hpp" | ||
#include "signals.hpp" | ||
|
||
ConVar spt_qc_cmd("spt_qc_cmd", | ||
"", | ||
FCVAR_CHEAT, | ||
"Execute command when quickclip occurs. " | ||
"This is detected by the difference between " | ||
"the quake position and the shadow position " | ||
"rising above some threshold " | ||
"and then teleporting to the same position\n"); | ||
|
||
ConVar spt_qc_threshold("spt_qc_threshold", | ||
"32", | ||
FCVAR_CHEAT, | ||
"Threshold for quickclip detection, the distance between the quake hitbox and havok hitbox must exceed this before the teleport.\n"); | ||
|
||
ConVar spt_qc_maxdist_to_prev("spt_qc_maxdist_to_prev", | ||
"200", | ||
FCVAR_CHEAT | FCVAR_HIDDEN, | ||
"Max distance to previous shadow position. This is to prevent loading a save with a havok hitbox differential causing the qc command to trigger.\n"); | ||
|
||
ConVar spt_qc_teleport_eps("spt_qc_teleport_eps", | ||
"1", | ||
FCVAR_CHEAT | FCVAR_HIDDEN, | ||
"Quake hitbox needs to be within this many units to be considered teleported.\n"); | ||
|
||
// Execute command on quickclip | ||
class QcCmdFeature : public FeatureWrapper<QcCmdFeature> | ||
{ | ||
public: | ||
Vector previousShadowPosition; | ||
float previousShadowDiff; | ||
protected: | ||
virtual bool ShouldLoadFeature() override; | ||
|
||
virtual void InitHooks() override; | ||
|
||
virtual void LoadFeature() override; | ||
|
||
virtual void UnloadFeature() override; | ||
|
||
}; | ||
|
||
static QcCmdFeature qc_cmd; | ||
|
||
static void Tick() | ||
{ | ||
if (spt_qc_cmd.GetString()[0] == '\0') | ||
{ | ||
return; | ||
} | ||
|
||
Vector playerPos = spt_playerio.m_vecAbsOrigin.GetValue(); | ||
Vector havokPos; | ||
spt_player_shadow.GetPlayerHavokPos(&havokPos, nullptr); | ||
float diffToCurrent = playerPos.DistTo(havokPos); | ||
float diffToPrev = playerPos.DistTo(qc_cmd.previousShadowPosition); | ||
|
||
if(qc_cmd.previousShadowDiff > spt_qc_threshold.GetFloat() && | ||
diffToCurrent < spt_qc_teleport_eps.GetFloat() && | ||
diffToPrev < spt_qc_maxdist_to_prev.GetFloat()) | ||
{ | ||
EngineConCmd(spt_qc_cmd.GetString()); | ||
spt_qc_cmd.SetValue(""); | ||
} | ||
|
||
qc_cmd.previousShadowDiff = diffToCurrent; | ||
qc_cmd.previousShadowPosition = havokPos; | ||
} | ||
|
||
bool QcCmdFeature::ShouldLoadFeature() | ||
{ | ||
return true; | ||
} | ||
|
||
void QcCmdFeature::InitHooks() {} | ||
|
||
void QcCmdFeature::LoadFeature() | ||
{ | ||
if (spt_player_shadow.ORIG_GetShadowPosition) | ||
{ | ||
previousShadowDiff = 0.0f; | ||
previousShadowPosition.Zero(); | ||
InitConcommandBase(spt_qc_cmd); | ||
InitConcommandBase(spt_qc_threshold); | ||
InitConcommandBase(spt_qc_maxdist_to_prev); | ||
TickSignal.Connect(Tick); | ||
} | ||
} | ||
|
||
void QcCmdFeature::UnloadFeature() {} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters