Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector3, bool QA_CheckIfJumpable(double maxPitch = double.max)
- {
- // gimpy-ass PM_SlideMove wannabe let's go
- if (floorsector)
- {
- double fas_floorz;
- Sector fas_sector;
- [fas_floorz, fas_sector] = floorsector.NextLowestFloorAt(pos.x, pos.y, pos.z, FFCF_3DRESTRICT, MaxStepHeight);
- vector3 normal = fas_sector.floorplane.Normal;
- double floorPitch = 90 - atan2(normal.z, (normal.x, normal.y).length());
- if (pos.z <= fas_floorz)
- {
- return normal, floorPitch < maxPitch;
- }
- }
- return (0, 0, 1), false;
- }
- bool QA_CheckJump()
- {
- UserCmd cmd = player.cmd;
- if (player.onGround && (cmd.buttons & BT_JUMP) && level.IsJumpingAllowed() && !Q_BlockJump)
- {
- double jumpvelz = (JumpZ * 35) / TICRATE;
- double jumpfac = 0;
- // [BC] If the player has the high jump power, double his jump velocity.
- // (actually, pick the best factors from all active items.)
- //
- // I would modify this to add the effective jump bonuses together,
- // but that'd lead to serious jump height sequence breaks
- for (let p = Inv; p != null; p = p.Inv)
- {
- let pp = PowerHighJump(p);
- if (pp)
- {
- double f = pp.Strength;
- jumpfac = max(jumpfac, f);
- }
- }
- if (jumpfac > 0) { jumpvelz *= jumpfac; }
- vector3 floornormal;
- bool canjump;
- [floornormal, canjump] = QA_CheckIfJumpable(MAXSLOPEPITCH);
- if (!canjump) { return false; }
- vector3 newvel = vel;
- // Disgusting hack to get what our Z velocity should be
- // Breaks with teleporters, although I guess you could say it's
- // kinda like portal jumping
- if (Q_GroundTime <= 1)
- {
- newvel.z = Q_LastVel.z - GetGravity();
- }
- double speedIntoFloor = -newvel dot floornormal;
- vector3 alignedvel = newvel + (floornormal * speedIntoFloor);
- vector3 jumpvector = (0, 0, jumpvelz);
- // Going into floor, align velocity to floor
- if ((Q_GroundTime <= 1 && newvel.z <= 0) || speedIntoFloor > 0)
- {
- newvel = alignedvel;
- // Angle jump off floor too since we're bunnyhopping
- if (Q_GroundTime <= 1)
- {
- jumpvector = floornormal * jumpvelz;
- }
- }
- newvel = alignedvel + (newvel - alignedvel) * Q_DoubleJumpFactor;
- vel = newvel + jumpvector;
- // XY changes always apply to ramp jumps, but Z changes can be disabled
- if (!Q_RampJump)
- {
- vel.z = newvel.z + jumpvelz;
- }
- if (!Q_Autohop) { Q_BlockJump = true; }
- if (!(player.cheats & CF_PREDICTING)) { A_PlaySound("*jump", CHAN_BODY); }
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement