[ZScript] Ledge climbing
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
-
- Posts: 58
- Joined: Sun Sep 30, 2018 6:16 pm
Re: [ZScript] Ledge climbing
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?
-
- Posts: 113
- Joined: Tue Dec 17, 2019 5:12 am
- Graphics Processor: nVidia with Vulkan support
Re: [ZScript] Ledge climbing
Is there easy way to prevent player for climbing steep slopes?
-
- Posts: 113
- Joined: Tue Dec 17, 2019 5:12 am
- Graphics Processor: nVidia with Vulkan support
Re: [ZScript] Ledge climbing
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.
-
- Posts: 2
- Joined: Sat Nov 21, 2020 4:16 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: [ZScript] Ledge climbing
How could I put it together with the quake movement?
-
- Posts: 30
- Joined: Sat Mar 13, 2021 6:47 pm
Re: [ZScript] Ledge climbing
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
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();
}
-
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: [ZScript] Ledge climbing
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
}
}
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
}
}
-
- Posts: 115
- Joined: Sat Sep 25, 2021 11:55 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
Re: [ZScript] Ledge climbing
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
}
}