Try wall jumps

This commit is contained in:
def 2014-06-21 18:14:22 +02:00
parent 7430af00eb
commit d768eb4908
4 changed files with 32 additions and 3 deletions

View file

@ -131,7 +131,7 @@ void CCollision::Init(class CLayers *pLayers)
} }
// DDRace tiles // DDRace tiles
if(Index == TILE_THROUGH || (Index >= TILE_FREEZE && Index <= TILE_UNFREEZE) || (Index >= TILE_SWITCHOPEN && Index <= TILE_TELECHECKIN) || (Index >= TILE_BEGIN && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH_START) || (Index >= TILE_EHOOK_START && Index <= TILE_SOLO_END) || (Index >= TILE_DFREEZE && Index <= TILE_DUNFREEZE)) if(Index == TILE_THROUGH || Index == TILE_WALLJUMP || (Index >= TILE_FREEZE && Index <= TILE_UNFREEZE) || (Index >= TILE_SWITCHOPEN && Index <= TILE_TELECHECKIN) || (Index >= TILE_BEGIN && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH_START) || (Index >= TILE_EHOOK_START && Index <= TILE_SOLO_END) || (Index >= TILE_DFREEZE && Index <= TILE_DUNFREEZE))
m_pFront[i].m_Index = Index; m_pFront[i].m_Index = Index;
} }
} }
@ -157,7 +157,7 @@ void CCollision::Init(class CLayers *pLayers)
} }
// DDRace tiles // DDRace tiles
if(Index == TILE_THROUGH || (Index >= TILE_FREEZE && Index <= TILE_UNFREEZE) || (Index >= TILE_SWITCHOPEN && Index <= TILE_TELECHECKIN) || (Index >= TILE_BEGIN && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH_START) || (Index >= TILE_EHOOK_START && Index <= TILE_SOLO_END) || (Index >= TILE_DFREEZE && Index <= TILE_DUNFREEZE)) if(Index == TILE_THROUGH || Index == TILE_WALLJUMP || (Index >= TILE_FREEZE && Index <= TILE_UNFREEZE) || (Index >= TILE_SWITCHOPEN && Index <= TILE_TELECHECKIN) || (Index >= TILE_BEGIN && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH_START) || (Index >= TILE_EHOOK_START && Index <= TILE_SOLO_END) || (Index >= TILE_DFREEZE && Index <= TILE_DUNFREEZE))
m_pTiles[i].m_Index = Index; m_pTiles[i].m_Index = Index;
} }
} }
@ -410,6 +410,8 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
vec2 NewPos = Pos + Vel*Fraction; // TODO: this row is not nice vec2 NewPos = Pos + Vel*Fraction; // TODO: this row is not nice
m_Colliding = 0;
if(TestBox(vec2(NewPos.x, NewPos.y), Size)) if(TestBox(vec2(NewPos.x, NewPos.y), Size))
{ {
int Hits = 0; int Hits = 0;
@ -423,6 +425,10 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
if(TestBox(vec2(NewPos.x, Pos.y), Size)) 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; NewPos.x = Pos.x;
Vel.x *= -Elasticity; Vel.x *= -Elasticity;
Hits++; Hits++;
@ -436,6 +442,10 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
Vel.y *= -Elasticity; Vel.y *= -Elasticity;
NewPos.x = Pos.x; NewPos.x = Pos.x;
Vel.x *= -Elasticity; Vel.x *= -Elasticity;
if(NewPos.x > Pos.x)
m_Colliding = 1;
else if(NewPos.x < Pos.x)
m_Colliding = 2;
} }
} }
@ -488,6 +498,14 @@ int CCollision::IsThrough(int x, int y)
return 0; return 0;
} }
int CCollision::IsWallJump(int Index)
{
if(Index < 0)
return 0;
return m_pTiles[Index].m_Index == TILE_WALLJUMP;
}
int CCollision::IsNoLaser(int x, int y) int CCollision::IsNoLaser(int x, int y)
{ {
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER); return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);

View file

@ -92,6 +92,7 @@ public:
int IsSolid(int x, int y); int IsSolid(int x, int y);
int IsThrough(int x, int y); int IsThrough(int x, int y);
int IsWallJump(int Index);
int IsNoLaser(int x, int y); int IsNoLaser(int x, int y);
int IsFNoLaser(int x, int y); int IsFNoLaser(int x, int y);
@ -107,6 +108,7 @@ public:
class CTuneTile *TuneLayer() { return m_pTune; } class CTuneTile *TuneLayer() { return m_pTune; }
class CLayers *Layers() { return m_pLayers; } class CLayers *Layers() { return m_pLayers; }
int m_NumSwitchers; int m_NumSwitchers;
int m_Colliding;
private: private:

View file

@ -103,7 +103,8 @@ enum
TILE_DUNFREEZE, TILE_DUNFREEZE,
TILE_TELEINWEAPON, TILE_TELEINWEAPON,
TILE_TELEINHOOK, TILE_TELEINHOOK,
TILE_EHOOK_START = 17, TILE_WALLJUMP = 16,
TILE_EHOOK_START,
TILE_EHOOK_END, TILE_EHOOK_END,
TILE_HIT_START, TILE_HIT_START,
TILE_HIT_END, TILE_HIT_END,

View file

@ -1699,6 +1699,14 @@ void CCharacter::HandleTiles(int Index)
m_LastPenalty = false; 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); int z = GameServer()->Collision()->IsTeleport(MapIndex);
if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size()) if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size())
{ {