mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
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:
parent
e7140caf8b
commit
9c97995679
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue