[ZScript] Ledge climbing

Post your example zscripts/ACS scripts/etc here.

Re: [ZScript] Ledge climbing

Postby atarumoroboshi18 » Sun Oct 28, 2018 9:41 pm

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?
atarumoroboshi18
 
Joined: 30 Sep 2018

Re: [ZScript] Ledge climbing

Postby Jaska » Fri Oct 30, 2020 3:45 am

Is there easy way to prevent player for climbing steep slopes?
Jaska
 
Joined: 17 Dec 2019
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Ledge climbing

Postby Jaska » Wed Nov 11, 2020 9:15 am

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.
Jaska
 
Joined: 17 Dec 2019
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Ledge climbing

Postby Blastphemybeats » Sun Nov 22, 2020 1:48 pm

How could I put it together with the quake movement?
Blastphemybeats
 
Joined: 21 Nov 2020
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: [ZScript] Ledge climbing

Postby 7Soul » Sat Mar 13, 2021 6:59 pm

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 allExpand view
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();
   }
7Soul
 
Joined: 13 Mar 2021

Previous

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests