Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OP4 grapple detection #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

anzz1
Copy link
Contributor

@anzz1 anzz1 commented Jan 22, 2025

Stop creation of ladder waypoints in air while autowaypoint=1 and a player uses grapple hook in OP4

-   if(pEntity->v.movetype == MOVETYPE_FLY && players[idx].current_weapon_id == GEARBOX_WEAPON_GRAPPLE)
+   if(pEntity->v.movetype == MOVETYPE_FLY && pEntity->v.flags & FL_IMMUNE_LAVA)

Bug
The PlayerClient_Valve_CurrentWeapon function sometimes didn't correctly keep track of a player's weapon when autowaypoint=1 and this led to creation of ladder waypoints in midair while a player used the grapple hook

image

Fix
What the OP4 engine itself uses for ladder detection is the otherwise unused FL_IMMUNE_LAVA (0x80000) (1<<19) flag.
CGrapple.cpp#L168

void CGrapple::PrimaryAttack()
{
/* ... */
	if (m_pTip->GetGrappleType() > CGrappleTip::TargetClass::SMALL)
	{
		m_pPlayer->pev->movetype = MOVETYPE_FLY;
		//Tells the physics code that the player is not on a ladder - Solokiller
		m_pPlayer->pev->flags |= FL_IMMUNE_LAVA;
	}
/* ... */
}

pm_shared.cpp#L617

void PM_UpdateStepSound()
{
/* ... */
	const bool fLadder = pmove->movetype == MOVETYPE_FLY && (pmove->flags & FL_IMMUNE_LAVA) == 0; // IsOnLadder();
/* ... */
}

The halflife-op4-updated repo is a remake of the original OP4 dll so I did check with a decompiler that this functionality does indeed exist in the vanilla game (opfor.dll / opfor.so) and wasn't something that was added for the updated version
image

Artifact
Archive: jk_botti_grapple_bug.zip
Contains files: op4_bounce.bsp (the map where the bug occured) and op4_bounce.wpt + op4_bounce.matrix the bugged waypoint files
Note: You need to replace MSG_ALL:MSG_ONE with MSG_BROADCAST:MSG_ONE_UNRELIABLE in waypoint.cpp if you wish to view these ingame with show_waypoints 1 as there are so many waypoints in the file that the reliable channel will otherwise overflow.

Stop creation of ladder waypoints in air while autowaypoint=1 and a player uses grapple hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant