Fix wall jumps

This commit is contained in:
def 2014-06-22 00:50:11 +02:00
parent d768eb4908
commit 99c74b5311
8 changed files with 68 additions and 56 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 KiB

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 KiB

After

Width:  |  Height:  |  Size: 306 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 301 KiB

View file

@ -410,8 +410,6 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
vec2 NewPos = Pos + Vel*Fraction; // TODO: this row is not nice
m_Colliding = 0;
if(TestBox(vec2(NewPos.x, NewPos.y), Size))
{
int Hits = 0;
@ -425,10 +423,6 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
if(TestBox(vec2(NewPos.x, Pos.y), Size))
{
if(NewPos.x > Pos.x)
m_Colliding = 1;
else if(NewPos.x < Pos.x)
m_Colliding = 2;
NewPos.x = Pos.x;
Vel.x *= -Elasticity;
Hits++;
@ -442,10 +436,6 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
Vel.y *= -Elasticity;
NewPos.x = Pos.x;
Vel.x *= -Elasticity;
if(NewPos.x > Pos.x)
m_Colliding = 1;
else if(NewPos.x < Pos.x)
m_Colliding = 2;
}
}

View file

@ -108,7 +108,6 @@ public:
class CTuneTile *TuneLayer() { return m_pTune; }
class CLayers *Layers() { return m_pLayers; }
int m_NumSwitchers;
int m_Colliding;
private:

View file

@ -594,8 +594,26 @@ void CCharacterCore::Move()
m_Vel.x = m_Vel.x*RampValue;
vec2 NewPos = m_Pos;
if((m_Vel.x < 0 && m_LastVel.x >= 0) || (m_Vel.x > 0 && m_LastVel.x <= 0))
{
m_DirectionChanged = true;
m_LastVel = m_Vel;
}
vec2 OldVel = m_Vel;
m_pCollision->MoveBox(&NewPos, &m_Vel, vec2(28.0f, 28.0f), 0);
if(m_Vel.x < 0.001 && m_Vel.x > -0.001)
{
if(OldVel.x > 0)
m_Colliding = 1;
else if(OldVel.x < 0)
m_Colliding = 2;
else
m_Colliding = 0;
}
m_Vel.x = m_Vel.x*(1.0f/RampValue);
if(m_pWorld && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision && this->m_Collision)

View file

@ -229,6 +229,10 @@ public:
bool m_pReset;
class CCollision *Collision() { return m_pCollision; }
vec2 m_LastVel;
int m_Colliding;
bool m_DirectionChanged;
private:
CTeamsCore* m_pTeams;

View file

@ -1508,6 +1508,15 @@ void CCharacter::HandleTiles(int Index)
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
}
}
else if((m_TileIndex == TILE_WALLJUMP) || (m_TileFIndex == TILE_WALLJUMP))
{
if(m_Core.m_Jumps == m_Core.m_JumpedTotal + 1 && m_Core.m_Vel.y > 0 && m_Core.m_Colliding && m_Core.m_DirectionChanged)
{
m_Core.m_DirectionChanged = false;
m_Core.m_JumpedTotal--;
m_Core.m_Jumped = 1;
}
}
else if(((m_TileIndex == TILE_JETPACK_END) || (m_TileFIndex == TILE_JETPACK_END)) && m_Jetpack)
{
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You lost your jetpack gun");
@ -1699,14 +1708,6 @@ void CCharacter::HandleTiles(int Index)
m_LastPenalty = false;
}
if((m_Jumped & 1) && m_Core.m_Vel.x > 0
&& ((GameServer()->Collision()->IsWallJump(MapIndex-1) && GameServer()->Collision()->m_Colliding & 1)
|| (GameServer()->Collision()->IsWallJump(MapIndex+1) && GameServer()->Collision()->m_Colliding & 2)))
{
m_Core.m_JumpedTotal++;
m_Core.m_Jumped |= 3;
}
int z = GameServer()->Collision()->IsTeleport(MapIndex);
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size())
{
@ -1904,46 +1905,46 @@ void CCharacter::DDRacePostCoreTick()
m_Time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
if (m_pPlayer->m_DefEmoteReset >= 0 && m_pPlayer->m_DefEmoteReset <= Server()->Tick())
{
m_pPlayer->m_DefEmoteReset = -1;
m_EmoteType = m_pPlayer->m_DefEmote = EMOTE_NORMAL;
m_EmoteStop = -1;
}
if (m_EndlessHook || (m_Super && g_Config.m_SvEndlessSuperHook))
m_Core.m_HookTick = 0;
if (m_DeepFreeze && !m_Super)
Freeze();
if (m_Core.m_Jumps == 0 && !m_Super)
m_Core.m_Jumped = 3;
else if (m_Core.m_Jumps == 1 && m_Core.m_Jumped > 0)
m_Core.m_Jumped = 3;
else if (m_Core.m_JumpedTotal < m_Core.m_Jumps - 1 && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
if ((m_Super || m_SuperJump) && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
int CurrentIndex = GameServer()->Collision()->GetMapIndex(m_Pos);
HandleSkippableTiles(CurrentIndex);
// handle Anti-Skip tiles
std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos);
if(!Indices.empty())
for(std::list < int >::iterator i = Indices.begin(); i != Indices.end(); i++)
{
m_pPlayer->m_DefEmoteReset = -1;
m_EmoteType = m_pPlayer->m_DefEmote = EMOTE_NORMAL;
m_EmoteStop = -1;
HandleTiles(*i);
//dbg_msg("Running","%d", *i);
}
else
{
HandleTiles(CurrentIndex);
//dbg_msg("Running","%d", CurrentIndex);
}
if (m_EndlessHook || (m_Super && g_Config.m_SvEndlessSuperHook))
m_Core.m_HookTick = 0;
if (m_DeepFreeze && !m_Super)
Freeze();
if (m_Core.m_Jumps == 0 && !m_Super)
m_Core.m_Jumped = 3;
else if (m_Core.m_Jumps == 1 && m_Core.m_Jumped > 0)
m_Core.m_Jumped = 3;
else if (m_Core.m_JumpedTotal < m_Core.m_Jumps - 1 && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
if ((m_Super || m_SuperJump) && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
int CurrentIndex = GameServer()->Collision()->GetMapIndex(m_Pos);
HandleSkippableTiles(CurrentIndex);
// handle Anti-Skip tiles
std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos);
if(!Indices.empty())
for(std::list < int >::iterator i = Indices.begin(); i != Indices.end(); i++)
{
HandleTiles(*i);
//dbg_msg("Running","%d", *i);
}
else
{
HandleTiles(CurrentIndex);
//dbg_msg("Running","%d", CurrentIndex);
}
HandleBroadcast();
HandleBroadcast();
}
bool CCharacter::Freeze(int Seconds)