Page 2 of 2

Re: [ZScript] Ledge climbing

Posted: Sun Oct 28, 2018 9:41 pm
by atarumoroboshi18
I'm wondering, is there any way to modify the script so you actually can hold onto the ledge and move left and right while holding? Kind of a like a shimmying system?

Re: [ZScript] Ledge climbing

Posted: Fri Oct 30, 2020 3:45 am
by Jaska
Is there easy way to prevent player for climbing steep slopes?

Re: [ZScript] Ledge climbing

Posted: Wed Nov 11, 2020 9:15 am
by Jaska
Or is there easy way to climb on things. Like I add custom flag on an actor you can then climb on. Or use like skill8 to determine that object can be climbed on.

Re: [ZScript] Ledge climbing

Posted: Sun Nov 22, 2020 1:48 pm
by Blastphemybeats
How could I put it together with the quake movement?

Re: [ZScript] Ledge climbing

Posted: Sat Mar 13, 2021 6:59 pm
by 7Soul
Hi there, thanks for the script. I ran into some issues using it so I made a few fixes:

GetZAt() is a bit weird and doesn't work well when facing a solid wall. You could be facing a wall and the function will say the point in front of you is a sector adjacent to that wall, and you'll fruitlessly attempt to climb it if you jump. I've added a IsPointInLevel() check to make sure that the linedef has a sector behind it

I also fixed a problem with trying to climb in a situation where your hitbox is partially blocked on either your left or right. I made the function check at a 30 degree angle from what you're trying to climb and it nudges you to the side before climbing so you don't fail the jump

Code: Select all

override void CheckJump()
	{
		let player = self.player;

		double ledgeHeight;
		{
			vector3 oldPos = pos;

			SetXyz(pos + (0, 0, maxLedgeHeight));   // Account for thin 3D floors
			ledgeHeight = GetZAt(radius + climbReach, 0) - oldPos.z;
			SetXyz(oldPos);
		}

		bool inLevel = level.IsPointInLevel( Vec3Angle(64, angle, maxLedgeHeight) ); // Prevents game from thinking the void is a sector
		bool jump = (player.cmd.buttons & BT_JUMP) && inLevel && (pos.z != floorz);
		double clearance = GetZAt(radius + climbReach, 0, 0, GZF_CEILING) - GetZAt(radius + climbReach, 0);

		// Start/stop climbing
		if (!climbing)
		{
			if (jump && ledgeHeight > maxStepHeight && ledgeHeight <= maxLedgeHeight)
			{
				climbing = true;
				A_PlaySound("*Climb", CHAN_BODY);
				viewBob = 0.0;

				// Nudge player out of the way if there's a wall
				bool leftValid  = level.IsPointInLevel( Vec3Angle(radius+climbReach, angle + 30, 48) );
				bool rightValid = level.IsPointInLevel( Vec3Angle(radius+climbReach, angle - 30, 48) );
				if (leftValid && !rightValid) 
				{
					SetOrigin(pos + AngleToVector(angle + 90, radius+2), true);
				} 
				else if (rightValid && !leftValid) 
				{
					SetOrigin(pos + AngleToVector(angle - 90, radius+2), true);
				}
			}
		}
		else
		{
			if (ledgeHeight > maxLedgeHeight)  // Drop down/get knocked down from ledge
			{
				climbing = false;
			}
			else if (ledgeHeight <= maxStepHeight && clearance >= 0.5 * height)	// Reach top of ledge
			{
				climbing = false;

				// Crouch, so player can fit into small spaces
				player.crouchFactor = 0.5;
				SetOrigin(pos + (0, 0, 0.5 * fullHeight), false);   // Keep view from jerking
				player.viewHeight *= 0.5;

				VelFromAngle(thrustSpeed, angle);  // Thrust player onto ledge
			}

			if (!climbing)  // Exit climbing state
			{
				viewBob = 1.0;
				player.SetPsprite(PSP_WEAPON, player.readyWeapon.GetUpState());
				player.jumpTics = -1;
			}
		}

		if (climbing)
		{
			// Weapon will reset to Ready state, so we need to set it to Down state every tic
			player.SetPsprite(PSP_WEAPON, player.readyWeapon.GetDownState());

			let psp = player.GetPsprite(PSP_WEAPON);
			if (psp.y == WEAPONTOP) // Keep weapon down
			{
				psp.y = WEAPONBOTTOM;
			}
			else	// Lower weapon twice as fast
			{
				psp.y += 6;
			}

			if (ledgeHeight <= maxStepHeight) // Hold onto ledge at top, if player can't get on it
			{
				vel = (0, 0, 0);
			}
			else	// Climb ledge
			{
				vel = (0, 0, climbSpeed);
			}
		}

		Super.CheckJump();
	}

Re: [ZScript] Ledge climbing

Posted: Tue Dec 14, 2021 1:33 pm
by WARCHILD_89
Some people (like me) might want the player to be temporarily totally unarmed in certain situations. If you climb a ledge then, you get a fatal error.

So I made a useless, invisible dummy "weapon" to create the illusion of being unarmed to prevent crashes.

This way you can walk around and most importantly climb around unarmed until you get an actual weapon.

Sadly I have no hand animations for this. But it works.


//------------------------------ a fake weapon of no use to prevent fatal error when ledge climbing (added by warchild) ----------
ACTOR nohands : ModWeapon
{
//$Category weapons/LEDsGUNS
Weapon.SelectionOrder 1001
Weapon.SlotNumber 1
Decal None
DamageType Melee
Tag "Brass Knuckle"
+WEAPON.WIMPY_WEAPON
+WEAPON.NOALERT
+WEAPON.MELEEWEAPON
States
{
Select:
deselect:
Ready:
Fire:
Spawn:
TNT1 A -1
Stop
}
}

Re: [ZScript] Ledge climbing

Posted: Wed Dec 15, 2021 12:00 pm
by Plasmazippo
TO complement the post above:

Code: Select all

//------------------------------ a fake weapon of no use to prevent fatal error when ledge climbing (added by warchild) ----------
ACTOR nohands : ModWeapon
{
//$Category weapons/LEDsGUNS
Weapon.SelectionOrder 1001
Weapon.SlotNumber 1
Decal None
DamageType Melee
Tag "Brass Knuckle"
+WEAPON.WIMPY_WEAPON
+WEAPON.NOALERT
+WEAPON.MELEEWEAPON
States
{
Select:
deselect:
Ready:
Fire:
Spawn:
TNT1 A -1
Stop
}
}