Fix Spezial Jumps for players with 0, 1 and -1 Jumps

- Add some more documentation to the code
- reverted early ground jump to keep physics
This commit is contained in:
c0d3d3v 2022-05-20 21:37:05 +02:00
parent e7140caf8b
commit 9c97995679
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
3 changed files with 21 additions and 12 deletions

View file

@ -971,6 +971,7 @@ void CCharacter::DDRacePostCoreTick()
if(m_DeepFreeze && !m_Super)
Freeze();
// following jump rules can be overridden by tiles, like Refill Jumps, Stopper and Wall Jump
if(m_Core.m_Jumps == -1)
{
// The player has only one ground jump, so his feet are always dark

View file

@ -134,15 +134,6 @@ void CCharacterCore::Tick(bool UseInput)
float Accel = Grounded ? m_Tuning.m_GroundControlAccel : m_Tuning.m_AirControlAccel;
float Friction = Grounded ? m_Tuning.m_GroundFriction : m_Tuning.m_AirFriction;
// handle jumping
// 1 bit = to keep track if a jump has been made on this input (player is holding space bar)
// 2 bit = to track if all air-jumps have been used up (tee gets dark feet)
if(Grounded)
{
m_Jumped &= ~2;
m_JumpedTotal = 0;
}
// handle input
if(UseInput)
{
@ -159,12 +150,18 @@ void CCharacterCore::Tick(bool UseInput)
m_Angle = (int)(TmpAngle * 256.0f);
}
// Special jump cases:
// m_Jumps == -1: A tee may only make one ground jump. Second jumped bit is always set
// m_Jumps == 0: A tee may not make a jump. Second jumped bit is always set
// m_Jumps == 1: A tee may do either a ground jump or an air jump. Second jumped bit is set after the first jump
// The second jump bit can be overridden by special tiles so that the tee can nevertheless jump.
// handle jump
if(m_Input.m_Jump)
{
if(!(m_Jumped & 1) && m_Jumps != 0)
if(!(m_Jumped & 1))
{
if(Grounded)
if(Grounded && (!(m_Jumped & 2) || m_Jumps == -1))
{
m_TriggeredEvents |= COREEVENT_GROUND_JUMP;
m_Vel.y = -m_Tuning.m_GroundJumpImpulse;
@ -178,7 +175,7 @@ void CCharacterCore::Tick(bool UseInput)
}
m_JumpedTotal = 0;
}
else if(!(m_Jumped & 2) && m_Jumps >= 1)
else if(!(m_Jumped & 2))
{
m_TriggeredEvents |= COREEVENT_AIR_JUMP;
m_Vel.y = -m_Tuning.m_AirJumpImpulse;
@ -213,6 +210,16 @@ void CCharacterCore::Tick(bool UseInput)
}
}
// handle jumping
// 1 bit = to keep track if a jump has been made on this input (player is holding space bar)
// 2 bit = to track if all air-jumps have been used up (tee gets dark feet)
if(Grounded)
{
// A tee must touch the ground for one tick before it can jump again.
m_Jumped &= ~2;
m_JumpedTotal = 0;
}
// add the speed modification according to players wanted direction
if(m_Direction < 0)
m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel);

View file

@ -2146,6 +2146,7 @@ void CCharacter::DDRacePostCoreTick()
if(m_DeepFreeze && !m_Super)
Freeze();
// following jump rules can be overridden by tiles, like Refill Jumps, Stopper and Wall Jump
if(m_Core.m_Jumps == -1)
{
// The player has only one ground jump, so his feet are always dark