Skip to content

Commit

Permalink
add some more semi-tested ladder stuff to checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Apr 12, 2022
1 parent b090743 commit 1802f99
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
24 changes: 24 additions & 0 deletions addons/sourcemod/gamedata/shavit.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@
"windows" "104"
"linux" "104"
}
// find in CCSGameMovement::CheckForLadders which references CCSPlayer::CanGrabLadder
"CCSPlayer::m_lastStandingPos"
{
"windows" "5688"
"linux" "5704"
}
// find CCSPlayer::CanGrabLadder via 4096.0f or symbols on linux...
"CCSPlayer::m_ladderSurpressionTimer"
{
"windows" "5700"
"linux" "5720" // +20 wow that's easy!
}
// find CCSPlayer::CanGrabLadder via 4096.0f or symbols on linux...
"CCSPlayer::m_lastLadderNormal"
{
"windows" "5712"
"linux" "5732" // +20 wow that's easy!
}
// find CCSPlayer::CanGrabLadder via 4096.0f or symbols on linux...
"CCSPlayer::m_lastLadderPos"
{
"windows" "5724"
"linux" "5744" // +20 wow that's easy!
}
}

"Signatures"
Expand Down
8 changes: 8 additions & 0 deletions addons/sourcemod/scripting/include/shavit/checkpoints.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ enum struct cp_cache_t
ArrayList aOutputWaits;
float vecLadderNormal[3];
StringMap customdata;

bool m_bHasWalkMovedSinceLastJump; // csgo only
float m_ignoreLadderJumpTime; // csgo only

float m_lastStandingPos[3]; // css only
float m_ladderSurpressionTimer[2]; // css only // 0 = duration, 1 = remaining
float m_lastLadderNormal[3]; // css only
float m_lastLadderPos[3]; // css only
}

/**
Expand Down
55 changes: 54 additions & 1 deletion addons/sourcemod/scripting/shavit-checkpoints.sp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ bool gB_ReplayRecorder = false;
DynamicHook gH_CommitSuicide = null;
float gF_NextSuicide[MAXPLAYERS+1];

int gI_Offset_m_lastStandingPos = 0;
int gI_Offset_m_ladderSurpressionTimer = 0;
int gI_Offset_m_lastLadderNormal = 0;
int gI_Offset_m_lastLadderPos = 0;

public Plugin myinfo =
{
name = "[shavit] Checkpoints",
Expand Down Expand Up @@ -225,6 +230,29 @@ void LoadDHooks()

LoadPhysicsUntouch(hGameData);

if (gEV_Type == Engine_CSS)
{
if ((gI_Offset_m_lastStandingPos = GameConfGetOffset(hGameData, "CCSPlayer::m_lastStandingPos")) == -1)
{
SetFailState("Couldn't get the offset for \"CCSPlayer::m_lastStandingPos\"!");
}

if ((gI_Offset_m_ladderSurpressionTimer = GameConfGetOffset(hGameData, "CCSPlayer::m_ladderSurpressionTimer")) == -1)
{
SetFailState("Couldn't get the offset for \"CCSPlayer::m_ladderSurpressionTimer\"!");
}

if ((gI_Offset_m_lastLadderNormal = GameConfGetOffset(hGameData, "CCSPlayer::m_lastLadderNormal")) == -1)
{
SetFailState("Couldn't get the offset for \"CCSPlayer::m_lastLadderNormal\"!");
}

if ((gI_Offset_m_lastLadderPos = GameConfGetOffset(hGameData, "CCSPlayer::m_lastLadderPos")) == -1)
{
SetFailState("Couldn't get the offset for \"CCSPlayer::m_lastLadderPos\"!");
}
}

delete hGameData;

int iOffset;
Expand Down Expand Up @@ -1376,7 +1404,25 @@ void SaveCheckpointCache(int saver, int target, cp_cache_t cpcache, int index, H
GetClientAbsOrigin(target, cpcache.fPosition);
GetClientEyeAngles(target, cpcache.fAngles);
GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", cpcache.fVelocity);
GetEntPropVector(target, Prop_Data, "m_vecLadderNormal", cpcache.vecLadderNormal);

if (gEV_Type != Engine_TF2)
{
GetEntPropVector(target, Prop_Data, "m_vecLadderNormal", cpcache.vecLadderNormal);
}

if (gEV_Type == Engine_CSS)
{
GetEntDataVector(target, gI_Offset_m_lastStandingPos, cpcache.m_lastStandingPos);
cpcache.m_ladderSurpressionTimer[0] = GetEntDataFloat(target, gI_Offset_m_ladderSurpressionTimer + 4);
cpcache.m_ladderSurpressionTimer[1] = GetEntDataFloat(target, gI_Offset_m_ladderSurpressionTimer + 8) - GetGameTime();
GetEntDataVector(target, gI_Offset_m_lastLadderNormal, cpcache.m_lastLadderNormal);
GetEntDataVector(target, gI_Offset_m_lastLadderPos, cpcache.m_lastLadderPos);
}
else if (gEV_Type == Engine_CSGO)
{
cpcache.m_bHasWalkMovedSinceLastJump = 0 != GetEntProp(target, Prop_Data, "m_bHasWalkMovedSinceLastJump", 1);
cpcache.m_ignoreLadderJumpTime = GetEntPropFloat(target, Prop_Data, "m_ignoreLadderJumpTime") - GetGameTime();
}

cpcache.iMoveType = GetEntityMoveType(target);
cpcache.fGravity = GetEntityGravity(target);
Expand Down Expand Up @@ -1642,10 +1688,17 @@ bool LoadCheckpointCache(int client, cp_cache_t cpcache, int index, bool force =

if(gEV_Type == Engine_CSS)
{
SetEntDataVector(client, gI_Offset_m_lastStandingPos, cpcache.m_lastStandingPos);
SetEntDataFloat(client, gI_Offset_m_ladderSurpressionTimer + 4, cpcache.m_ladderSurpressionTimer[0]);
SetEntDataFloat(client, gI_Offset_m_ladderSurpressionTimer + 8, cpcache.m_ladderSurpressionTimer[1] + GetGameTime());
SetEntDataVector(client, gI_Offset_m_lastLadderNormal, cpcache.m_lastLadderNormal);
SetEntDataVector(client, gI_Offset_m_lastLadderPos, cpcache.m_lastLadderPos);
SetEntPropFloat(client, Prop_Send, "m_flDucktime", cpcache.fDucktime);
}
else if(gEV_Type == Engine_CSGO)
{
SetEntProp(client, Prop_Data, "m_bHasWalkMovedSinceLastJump", cpcache.m_bHasWalkMovedSinceLastJump, 1);
SetEntPropFloat(client, Prop_Data, "m_ignoreLadderJumpTime", cpcache.m_ignoreLadderJumpTime + GetGameTime());
SetEntPropFloat(client, Prop_Send, "m_flDuckAmount", cpcache.fDucktime);
SetEntPropFloat(client, Prop_Send, "m_flDuckSpeed", cpcache.fDuckSpeed);
}
Expand Down

0 comments on commit 1802f99

Please sign in to comment.