KZGlobalTeam / gokz

GOKZ SourceMod Plugins
https://gokz.org
GNU General Public License v3.0
64 stars 15 forks source link

Jump beam stops working if SetVelocity is called #169

Open zealain opened 3 years ago

zealain commented 3 years ago

Original report by zer0.k (Bitbucket: zer0k_z, ).


This only happens on several servers. SetVelocity is called whenever you hit a SKZ perf or you perf with maxspeed over 380 in KZT.

zealain commented 3 years ago

Original comment by zer0.k (Bitbucket: zer0k_z, ).


For more information, jump beam doesn’t draw if the jump is “invalid”. This value is set to invalid because of OnTeleport_ValidJump and OnPlayerRunCmdPost_ValidJump, which both invalidate the jump when gB_VelocityTeleported is true. This value is changed in DHooks_OnTeleport which hooks onto CBaseEntity::Teleport.

In order to change a player’s velocity, SetVelocity uses TeleportEntity which also uses CBaseEntity::Teleport. Ultimately, it makes sense that jump beam is invalidated every time you perf over 250 speed in SKZ, but this doesn’t happen in some servers (GOKZeal and HoC GOKZ servers afaik).

Also, I am not sure what DHookAddParam(gH_DHooks_OnTeleport, HookParamType_Bool) does since there’s no boolean in the CBaseEntity::Teleport. It only has 3 parameters: a vector, an object (QAngle) and another vector. (Edit: nevermind that, according to the sourcemod discord it does have a boolean, but the leaked source code said otherwise)

zealain commented 3 years ago

Original comment by zer0.k (Bitbucket: zer0k_z, ).


I think I figured out why it behaves this way. 2 events happen:

  1. You get a perf. SetVelocity is called. DHooks_OnTeleport is called. OnTeleport_ValidJump and OnPlayerRunCmdPost_ValidJump are called, see that gB_VelocityTeleported is true, so the jumps gets invalidated.
  2. You leave the ground as you perf. Movement_OnStopTouchGround is called when you leave the ground. OnStopTouchGround_ValidJump is called. The player move type is MOVETYPE_WALK, so the jump gets validated.

The problem is they both happen on the same tick and the order of these two events are not consistent across all operating systems (and maybe even in the same OS itself). So some servers have jump beam working normally, some don’t.

zer0k-z commented 2 years ago

This is already resolved, most likely.