diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index ca4437e1e..0aa8758fd 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1614,7 +1614,7 @@ void CGameClient::OnPredict() vec2 Temp = pTarget->m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f; - pTarget->LimitVel(&Temp); + pTarget->LimitForce(&Temp); Temp -= pTarget->m_Vel; pTarget->ApplyForce((vec2(0.f, -1.0f) + Temp) * Strength); diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 029c56404..8920fa73c 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -14,27 +14,6 @@ #include -vec2 ClampVel(int MoveRestriction, vec2 Vel) -{ - if(Vel.x > 0 && (MoveRestriction&CANTMOVE_RIGHT)) - { - Vel.x = 0; - } - if(Vel.x < 0 && (MoveRestriction&CANTMOVE_LEFT)) - { - Vel.x = 0; - } - if(Vel.y > 0 && (MoveRestriction&CANTMOVE_DOWN)) - { - Vel.y = 0; - } - if(Vel.y < 0 && (MoveRestriction&CANTMOVE_UP)) - { - Vel.y = 0; - } - return Vel; -} - CCollision::CCollision() { m_pTiles = 0; @@ -150,119 +129,6 @@ void CCollision::Init(class CLayers *pLayers) } } -enum -{ - MR_DIR_HERE=0, - MR_DIR_RIGHT, - MR_DIR_DOWN, - MR_DIR_LEFT, - MR_DIR_UP, - NUM_MR_DIRS -}; - -static int GetMoveRestrictionsRaw(int Direction, int Tile, int Flags) -{ - switch(Tile) - { - case TILE_STOP: - switch(Flags) - { - case ROTATION_0: return CANTMOVE_DOWN; - case ROTATION_90: return CANTMOVE_LEFT; - case ROTATION_180: return CANTMOVE_UP; - case ROTATION_270: return CANTMOVE_RIGHT; - } - break; - case TILE_STOPS: - switch(Flags) - { - case ROTATION_0: - case ROTATION_180: - return CANTMOVE_DOWN|CANTMOVE_UP; - case ROTATION_90: - case ROTATION_270: - return CANTMOVE_LEFT|CANTMOVE_RIGHT; - } - break; - case TILE_STOPA: - return CANTMOVE_LEFT|CANTMOVE_RIGHT|CANTMOVE_UP|CANTMOVE_DOWN; - } - return 0; -} - -static int GetMoveRestrictionsMask(int Direction) -{ - switch(Direction) - { - case MR_DIR_HERE: return 0; - case MR_DIR_RIGHT: return CANTMOVE_RIGHT; - case MR_DIR_DOWN: return CANTMOVE_DOWN; - case MR_DIR_LEFT: return CANTMOVE_LEFT; - case MR_DIR_UP: return CANTMOVE_UP; - default: dbg_assert(false, "invalid dir"); - } - return 0; -} - -static int GetMoveRestrictions(int Direction, int Tile, int Flags) -{ - int Result = GetMoveRestrictionsRaw(Direction, Tile, Flags); - // Generally, stoppers only have an effect if they block us from moving - // *onto* them. The one exception is one-way blockers, they can also - // block us from moving if we're on top of them. - if(Direction == MR_DIR_HERE && Tile == TILE_STOP) - { - return Result; - } - return Result&GetMoveRestrictionsMask(Direction); -} - -int CCollision::GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance) -{ - static const vec2 DIRECTIONS[NUM_MR_DIRS] = - { - vec2(0, 0), - vec2(1, 0), - vec2(0, 1), - vec2(-1, 0), - vec2(0, -1) - }; - dbg_assert(0.0f <= Distance && Distance <= 32.0f, "invalid distance"); - int Restrictions = 0; - for(int d = 0; d < NUM_MR_DIRS; d++) - { - vec2 ModPos = Pos + DIRECTIONS[d] * Distance; - int ModMapIndex = GetPureMapIndex(ModPos); - for(int Front = 0; Front < 2; Front++) - { - int Tile; - int Flags; - if(!Front) - { - Tile = GetTileIndex(ModMapIndex); - Flags = GetTileFlags(ModMapIndex); - } - else - { - Tile = GetFTileIndex(ModMapIndex); - Flags = GetFTileFlags(ModMapIndex); - } - Restrictions |= ::GetMoveRestrictions(d, Tile, Flags); - } - if(pfnSwitchActive) - { - int TeleNumber = GetDTileNumber(ModMapIndex); - if(pfnSwitchActive(TeleNumber, pUser)) - { - int Tile = GetDTileIndex(ModMapIndex); - int Flags = GetDTileFlags(ModMapIndex); - Restrictions |= ::GetMoveRestrictions(d, Tile, Flags); - } - } - } - return Restrictions; -} - int CCollision::GetTile(int x, int y) { if(!m_pTiles) diff --git a/src/game/collision.h b/src/game/collision.h index 7c772ec7a..518b3a9c3 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -8,18 +8,6 @@ #include -enum -{ - CANTMOVE_LEFT=1<<0, - CANTMOVE_RIGHT=1<<1, - CANTMOVE_UP=1<<2, - CANTMOVE_DOWN=1<<3, -}; - -vec2 ClampVel(int MoveRestriction, vec2 Vel); - -typedef bool (*CALLBACK_SWITCHACTIVE)(int Number, void *pUser); - class CCollision { class CTile *m_pTiles; @@ -60,12 +48,6 @@ public: int GetIndex(vec2 PrevPos, vec2 Pos); int GetFIndex(int x, int y); - int GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance = 18.0f); - int GetMoveRestrictions(vec2 Pos, float Distance = 18.0f) - { - return GetMoveRestrictions(0, 0, Pos, Distance); - } - int GetTile(int x, int y); int GetFTile(int x, int y); int Entity(int x, int y, int Layer); diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 6fd5acb9b..81745be1e 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -106,9 +106,45 @@ void CCharacterCore::Reset() void CCharacterCore::Tick(bool UseInput, bool IsClient) { float PhysSize = 28.0f; - m_MoveRestrictions = m_pCollision->GetMoveRestrictions(UseInput ? IsSwitchActiveCb : 0, this, m_Pos); + int MapIndex = Collision()->GetPureMapIndex(m_Pos); + int MapIndexL = Collision()->GetPureMapIndex(vec2(m_Pos.x + (28/2)+4,m_Pos.y)); + int MapIndexR = Collision()->GetPureMapIndex(vec2(m_Pos.x - (28/2)-4,m_Pos.y)); + int MapIndexT = Collision()->GetPureMapIndex(vec2(m_Pos.x,m_Pos.y + (28/2)+4)); + int MapIndexB = Collision()->GetPureMapIndex(vec2(m_Pos.x,m_Pos.y - (28/2)-4)); + m_TileIndex = Collision()->GetTileIndex(MapIndex); + m_TileFlags = Collision()->GetTileFlags(MapIndex); + m_TileIndexL = Collision()->GetTileIndex(MapIndexL); + m_TileFlagsL = Collision()->GetTileFlags(MapIndexL); + m_TileIndexR = Collision()->GetTileIndex(MapIndexR); + m_TileFlagsR = Collision()->GetTileFlags(MapIndexR); + m_TileIndexB = Collision()->GetTileIndex(MapIndexB); + m_TileFlagsB = Collision()->GetTileFlags(MapIndexB); + m_TileIndexT = Collision()->GetTileIndex(MapIndexT); + m_TileFlagsT = Collision()->GetTileFlags(MapIndexT); + m_TileFIndex = Collision()->GetFTileIndex(MapIndex); + m_TileFFlags = Collision()->GetFTileFlags(MapIndex); + m_TileFIndexL = Collision()->GetFTileIndex(MapIndexL); + m_TileFFlagsL = Collision()->GetFTileFlags(MapIndexL); + m_TileFIndexR = Collision()->GetFTileIndex(MapIndexR); + m_TileFFlagsR = Collision()->GetFTileFlags(MapIndexR); + m_TileFIndexB = Collision()->GetFTileIndex(MapIndexB); + m_TileFFlagsB = Collision()->GetFTileFlags(MapIndexB); + m_TileFIndexT = Collision()->GetFTileIndex(MapIndexT); + m_TileFFlagsT = Collision()->GetFTileFlags(MapIndexT); + m_TileSIndex = (UseInput && IsRightTeam(MapIndex))?Collision()->GetDTileIndex(MapIndex):0; + m_TileSFlags = (UseInput && IsRightTeam(MapIndex))?Collision()->GetDTileFlags(MapIndex):0; + m_TileSIndexL = (UseInput && IsRightTeam(MapIndexL))?Collision()->GetDTileIndex(MapIndexL):0; + m_TileSFlagsL = (UseInput && IsRightTeam(MapIndexL))?Collision()->GetDTileFlags(MapIndexL):0; + m_TileSIndexR = (UseInput && IsRightTeam(MapIndexR))?Collision()->GetDTileIndex(MapIndexR):0; + m_TileSFlagsR = (UseInput && IsRightTeam(MapIndexR))?Collision()->GetDTileFlags(MapIndexR):0; + m_TileSIndexB = (UseInput && IsRightTeam(MapIndexB))?Collision()->GetDTileIndex(MapIndexB):0; + m_TileSFlagsB = (UseInput && IsRightTeam(MapIndexB))?Collision()->GetDTileFlags(MapIndexB):0; + m_TileSIndexT = (UseInput && IsRightTeam(MapIndexT))?Collision()->GetDTileIndex(MapIndexT):0; + m_TileSFlagsT = (UseInput && IsRightTeam(MapIndexT))?Collision()->GetDTileFlags(MapIndexT):0; m_TriggeredEvents = 0; + vec2 PrevPos = m_Pos; + // get ground state bool Grounded = false; if(m_pCollision->CheckPoint(m_Pos.x+PhysSize/2, m_Pos.y+PhysSize/2+5)) @@ -400,15 +436,32 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) float Accel = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragAccel * (Distance/m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookLength); float DragSpeed = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragSpeed; - vec2 Temp; // add force to the hooked player + vec2 Temp = pCharCore->m_Vel; Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, Accel*Dir.x*1.5f); Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y, Accel*Dir.y*1.5f); - pCharCore->m_Vel = ClampVel(pCharCore->m_MoveRestrictions, Temp); + if(Temp.x > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOP && pCharCore->m_TileFlagsL == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOPS && (pCharCore->m_TileFlagsL == ROTATION_90 || pCharCore->m_TileFlagsL ==ROTATION_270)) || (pCharCore->m_TileIndexL == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOP && pCharCore->m_TileFFlagsL == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOPS && (pCharCore->m_TileFFlagsL == ROTATION_90 || pCharCore->m_TileFFlagsL == ROTATION_270)) || (pCharCore->m_TileFIndexL == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOP && pCharCore->m_TileSFlagsL == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOPS && (pCharCore->m_TileSFlagsL == ROTATION_90 || pCharCore->m_TileSFlagsL == ROTATION_270)) || (pCharCore->m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOP && pCharCore->m_TileFlagsR == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOPS && (pCharCore->m_TileFlagsR == ROTATION_90 || pCharCore->m_TileFlagsR == ROTATION_270)) || (pCharCore->m_TileIndexR == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOP && pCharCore->m_TileFFlagsR == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOPS && (pCharCore->m_TileFFlagsR == ROTATION_90 || pCharCore->m_TileFFlagsR == ROTATION_270)) || (pCharCore->m_TileFIndexR == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOP && pCharCore->m_TileSFlagsR == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOPS && (pCharCore->m_TileSFlagsR == ROTATION_90 || pCharCore->m_TileSFlagsR == ROTATION_270)) || (pCharCore->m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_180) || (pCharCore->m_TileIndexB == TILE_STOP && pCharCore->m_TileFlagsB == ROTATION_180) || (pCharCore->m_TileIndexB == TILE_STOPS && (pCharCore->m_TileFlagsB == ROTATION_0 || pCharCore->m_TileFlagsB == ROTATION_180)) || (pCharCore->m_TileIndexB == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_180) || (pCharCore->m_TileFIndexB == TILE_STOP && pCharCore->m_TileFFlagsB == ROTATION_180) || (pCharCore->m_TileFIndexB == TILE_STOPS && (pCharCore->m_TileFFlagsB == ROTATION_0 || pCharCore->m_TileFFlagsB == ROTATION_180)) || (pCharCore->m_TileFIndexB == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_180) || (pCharCore->m_TileSIndexB == TILE_STOP && pCharCore->m_TileSFlagsB == ROTATION_180) || (pCharCore->m_TileSIndexB == TILE_STOPS && (pCharCore->m_TileSFlagsB == ROTATION_0 || pCharCore->m_TileSFlagsB == ROTATION_180)) || (pCharCore->m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOP && pCharCore->m_TileFlagsT == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOPS && (pCharCore->m_TileFlagsT == ROTATION_0 || pCharCore->m_TileFlagsT == ROTATION_180)) || (pCharCore->m_TileIndexT == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOP && pCharCore->m_TileFFlagsT == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOPS && (pCharCore->m_TileFFlagsT == ROTATION_0 || pCharCore->m_TileFFlagsT == ROTATION_180)) || (pCharCore->m_TileFIndexT == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOP && pCharCore->m_TileSFlagsT == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOPS && (pCharCore->m_TileSFlagsT == ROTATION_0 || pCharCore->m_TileSFlagsT == ROTATION_180)) || (pCharCore->m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + // add a little bit force to the guy who has the grip + pCharCore->m_Vel = Temp; Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -Accel*Dir.x*0.25f); Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -Accel*Dir.y*0.25f); - m_Vel = ClampVel(m_MoveRestrictions, Temp); + if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + m_Vel = Temp; } } } @@ -418,7 +471,7 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) m_NewHook = false; } - int Index = m_pCollision->GetPureMapIndex(m_Pos); + int Index = MapIndex; if(g_Config.m_ClPredictDDRace && IsClient && m_pCollision->IsSpeedup(Index)) { vec2 Direction, MaxVel, TempVel = m_Vel; @@ -472,7 +525,18 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) else TempVel += Direction * Force; - m_Vel = ClampVel(m_MoveRestrictions, TempVel); + + if(TempVel.x > 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_270) || (this->m_TileIndexL == TILE_STOP && this->m_TileFlagsL == ROTATION_270) || (this->m_TileIndexL == TILE_STOPS && (this->m_TileFlagsL == ROTATION_90 || this->m_TileFlagsL ==ROTATION_270)) || (this->m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + TempVel.x = 0; + if(TempVel.x < 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_90) || (this->m_TileIndexR == TILE_STOP && this->m_TileFlagsR == ROTATION_90) || (this->m_TileIndexR == TILE_STOPS && (this->m_TileFlagsR == ROTATION_90 || this->m_TileFlagsR == ROTATION_270)) || (this->m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + TempVel.x = 0; + if(TempVel.y < 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_180) || (this->m_TileIndexB == TILE_STOP && this->m_TileFlagsB == ROTATION_180) || (this->m_TileIndexB == TILE_STOPS && (this->m_TileFlagsB == ROTATION_0 || this->m_TileFlagsB == ROTATION_180)) || (this->m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + TempVel.y = 0; + if(TempVel.y > 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_0) || (this->m_TileIndexT == TILE_STOP && this->m_TileFlagsT == ROTATION_0) || (this->m_TileIndexT == TILE_STOPS && (this->m_TileFlagsT == ROTATION_0 || this->m_TileFlagsT == ROTATION_180)) || (this->m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + TempVel.y = 0; + + + m_Vel = TempVel; } } @@ -483,9 +547,32 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) if(g_Config.m_ClPredictDDRace && IsClient) { - m_Vel = ClampVel(m_MoveRestrictions, m_Vel); - if(m_MoveRestrictions&CANTMOVE_DOWN) + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)) && m_Vel.x > 0) { + if((int)m_pCollision->GetPos(MapIndexL).x < (int)m_Pos.x) + m_Pos = PrevPos; + m_Vel.x = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)) && m_Vel.x < 0) + { + if((int)m_pCollision->GetPos(MapIndexR).x) + if((int)m_pCollision->GetPos(MapIndexR).x < (int)m_Pos.x) + m_Pos = PrevPos; + m_Vel.x = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)) && m_Vel.y < 0) + { + if((int)m_pCollision->GetPos(MapIndexB).y) + if((int)m_pCollision->GetPos(MapIndexB).y < (int)m_Pos.y) + m_Pos = PrevPos; + m_Vel.y = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)) && m_Vel.y > 0) + { + if((int)m_pCollision->GetPos(MapIndexT).y) + if((int)m_pCollision->GetPos(MapIndexT).y < (int)m_Pos.y) + m_Pos = PrevPos; + m_Vel.y = 0; m_Jumped = 0; m_JumpedTotal = 0; } @@ -607,23 +694,31 @@ void CCharacterCore::Quantize() // DDRace -bool CCharacterCore::IsSwitchActiveCb(int Number, void *pUser) +bool CCharacterCore::IsRightTeam(int MapIndex) { - CCharacterCore *pThis = (CCharacterCore *)pUser; - if(pThis->Collision()->m_pSwitchers) - if(pThis->m_pTeams->Team(pThis->m_Id) != (pThis->m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER)) - return pThis->Collision()->m_pSwitchers[Number].m_Status[pThis->m_pTeams->Team(pThis->m_Id)]; + if(Collision()->m_pSwitchers) + if(m_pTeams->Team(m_Id) != (m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER)) + return Collision()->m_pSwitchers[Collision()->GetDTileNumber(MapIndex)].m_Status[m_pTeams->Team(m_Id)]; return false; } -void CCharacterCore::LimitVel(vec2 *pVel) +void CCharacterCore::LimitForce(vec2 *Force) { - *pVel = ClampVel(m_MoveRestrictions, *pVel); + vec2 Temp = *Force; + if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + *Force = Temp; } void CCharacterCore::ApplyForce(vec2 Force) { vec2 Temp = m_Vel + Force; - LimitVel(&Temp); + LimitForce(&Temp); m_Vel = Temp; } diff --git a/src/game/gamecore.h b/src/game/gamecore.h index cd34ca763..bbd10a0bf 100644 --- a/src/game/gamecore.h +++ b/src/game/gamecore.h @@ -231,7 +231,7 @@ public: int m_Colliding; bool m_LeftWall; - void LimitVel(vec2 *pVel); + void LimitForce(vec2 *Force); void ApplyForce(vec2 Force); private: @@ -239,8 +239,35 @@ private: CTeamsCore *m_pTeams; int m_TileIndex; int m_TileFlags; - int m_MoveRestrictions; - static bool IsSwitchActiveCb(int Number, void *pUser); + int m_TileFIndex; + int m_TileFFlags; + int m_TileSIndex; + int m_TileSFlags; + int m_TileIndexL; + int m_TileFlagsL; + int m_TileFIndexL; + int m_TileFFlagsL; + int m_TileSIndexL; + int m_TileSFlagsL; + int m_TileIndexR; + int m_TileFlagsR; + int m_TileFIndexR; + int m_TileFFlagsR; + int m_TileSIndexR; + int m_TileSFlagsR; + int m_TileIndexT; + int m_TileFlagsT; + int m_TileFIndexT; + int m_TileFFlagsT; + int m_TileSIndexT; + int m_TileSFlagsT; + int m_TileIndexB; + int m_TileFlagsB; + int m_TileFIndexB; + int m_TileFFlagsB; + int m_TileSIndexB; + int m_TileSFlagsB; + bool IsRightTeam(int MapIndex); }; //input count diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index c2c5b6a0b..ab06274c9 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -119,11 +119,15 @@ bool CCharacter::IsGrounded() if(GameServer()->Collision()->CheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) return true; - int MoveRestrictionsBelow = GameServer()->Collision()->GetMoveRestrictions(m_Pos + vec2(0, m_ProximityRadius / 2 + 4), 0.0f); - if(MoveRestrictionsBelow&CANTMOVE_DOWN) - { + int index = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x, m_Pos.y+m_ProximityRadius/2+4)); + int tile = GameServer()->Collision()->GetTileIndex(index); + int flags = GameServer()->Collision()->GetTileFlags(index); + if(tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile ==TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) + return true; + tile = GameServer()->Collision()->GetFTileIndex(index); + flags = GameServer()->Collision()->GetFTileFlags(index); + if(tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile ==TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) return true; - } return false; } @@ -416,9 +420,15 @@ void CCharacter::FireWeapon() else Strength = GameServer()->TuningList()[m_TuneZone].m_HammerStrength; - vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, - -1.1f)) * 10.0f; - Temp = ClampVel(pTarget->m_MoveRestrictions, Temp); + vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f; + if(Temp.x > 0 && ((pTarget->m_TileIndex == TILE_STOP && pTarget->m_TileFlags == ROTATION_270) || (pTarget->m_TileIndexL == TILE_STOP && pTarget->m_TileFlagsL == ROTATION_270) || (pTarget->m_TileIndexL == TILE_STOPS && (pTarget->m_TileFlagsL == ROTATION_90 || pTarget->m_TileFlagsL ==ROTATION_270)) || (pTarget->m_TileIndexL == TILE_STOPA) || (pTarget->m_TileFIndex == TILE_STOP && pTarget->m_TileFFlags == ROTATION_270) || (pTarget->m_TileFIndexL == TILE_STOP && pTarget->m_TileFFlagsL == ROTATION_270) || (pTarget->m_TileFIndexL == TILE_STOPS && (pTarget->m_TileFFlagsL == ROTATION_90 || pTarget->m_TileFFlagsL == ROTATION_270)) || (pTarget->m_TileFIndexL == TILE_STOPA) || (pTarget->m_TileSIndex == TILE_STOP && pTarget->m_TileSFlags == ROTATION_270) || (pTarget->m_TileSIndexL == TILE_STOP && pTarget->m_TileSFlagsL == ROTATION_270) || (pTarget->m_TileSIndexL == TILE_STOPS && (pTarget->m_TileSFlagsL == ROTATION_90 || pTarget->m_TileSFlagsL == ROTATION_270)) || (pTarget->m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((pTarget->m_TileIndex == TILE_STOP && pTarget->m_TileFlags == ROTATION_90) || (pTarget->m_TileIndexR == TILE_STOP && pTarget->m_TileFlagsR == ROTATION_90) || (pTarget->m_TileIndexR == TILE_STOPS && (pTarget->m_TileFlagsR == ROTATION_90 || pTarget->m_TileFlagsR == ROTATION_270)) || (pTarget->m_TileIndexR == TILE_STOPA) || (pTarget->m_TileFIndex == TILE_STOP && pTarget->m_TileFFlags == ROTATION_90) || (pTarget->m_TileFIndexR == TILE_STOP && pTarget->m_TileFFlagsR == ROTATION_90) || (pTarget->m_TileFIndexR == TILE_STOPS && (pTarget->m_TileFFlagsR == ROTATION_90 || pTarget->m_TileFFlagsR == ROTATION_270)) || (pTarget->m_TileFIndexR == TILE_STOPA) || (pTarget->m_TileSIndex == TILE_STOP && pTarget->m_TileSFlags == ROTATION_90) || (pTarget->m_TileSIndexR == TILE_STOP && pTarget->m_TileSFlagsR == ROTATION_90) || (pTarget->m_TileSIndexR == TILE_STOPS && (pTarget->m_TileSFlagsR == ROTATION_90 || pTarget->m_TileSFlagsR == ROTATION_270)) || (pTarget->m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((pTarget->m_TileIndex == TILE_STOP && pTarget->m_TileFlags == ROTATION_180) || (pTarget->m_TileIndexB == TILE_STOP && pTarget->m_TileFlagsB == ROTATION_180) || (pTarget->m_TileIndexB == TILE_STOPS && (pTarget->m_TileFlagsB == ROTATION_0 || pTarget->m_TileFlagsB == ROTATION_180)) || (pTarget->m_TileIndexB == TILE_STOPA) || (pTarget->m_TileFIndex == TILE_STOP && pTarget->m_TileFFlags == ROTATION_180) || (pTarget->m_TileFIndexB == TILE_STOP && pTarget->m_TileFFlagsB == ROTATION_180) || (pTarget->m_TileFIndexB == TILE_STOPS && (pTarget->m_TileFFlagsB == ROTATION_0 || pTarget->m_TileFFlagsB == ROTATION_180)) || (pTarget->m_TileFIndexB == TILE_STOPA) || (pTarget->m_TileSIndex == TILE_STOP && pTarget->m_TileSFlags == ROTATION_180) || (pTarget->m_TileSIndexB == TILE_STOP && pTarget->m_TileSFlagsB == ROTATION_180) || (pTarget->m_TileSIndexB == TILE_STOPS && (pTarget->m_TileSFlagsB == ROTATION_0 || pTarget->m_TileSFlagsB == ROTATION_180)) || (pTarget->m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((pTarget->m_TileIndex == TILE_STOP && pTarget->m_TileFlags == ROTATION_0) || (pTarget->m_TileIndexT == TILE_STOP && pTarget->m_TileFlagsT == ROTATION_0) || (pTarget->m_TileIndexT == TILE_STOPS && (pTarget->m_TileFlagsT == ROTATION_0 || pTarget->m_TileFlagsT == ROTATION_180)) || (pTarget->m_TileIndexT == TILE_STOPA) || (pTarget->m_TileFIndex == TILE_STOP && pTarget->m_TileFFlags == ROTATION_0) || (pTarget->m_TileFIndexT == TILE_STOP && pTarget->m_TileFFlagsT == ROTATION_0) || (pTarget->m_TileFIndexT == TILE_STOPS && (pTarget->m_TileFFlagsT == ROTATION_0 || pTarget->m_TileFFlagsT == ROTATION_180)) || (pTarget->m_TileFIndexT == TILE_STOPA) || (pTarget->m_TileSIndex == TILE_STOP && pTarget->m_TileSFlags == ROTATION_0) || (pTarget->m_TileSIndexT == TILE_STOP && pTarget->m_TileSFlagsT == ROTATION_0) || (pTarget->m_TileSIndexT == TILE_STOPS && (pTarget->m_TileSFlagsT == ROTATION_0 || pTarget->m_TileSFlagsT == ROTATION_180)) || (pTarget->m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; Temp -= pTarget->m_Core.m_Vel; pTarget->TakeDamage((vec2(0.f, -1.0f) + Temp) * Strength, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_Core.m_ActiveWeapon); @@ -992,7 +1002,15 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) } vec2 Temp = m_Core.m_Vel + Force; - m_Core.m_Vel = ClampVel(m_MoveRestrictions, Temp); + if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + m_Core.m_Vel = Temp; return true; } @@ -1293,26 +1311,59 @@ void CCharacter::HandleSkippableTiles(int Index) else TempVel += Direction * Force; - m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel); + if(TempVel.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + TempVel.x = 0; + if(TempVel.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + TempVel.x = 0; + if(TempVel.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + TempVel.y = 0; + if(TempVel.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + TempVel.y = 0; + m_Core.m_Vel = TempVel; } } } -bool CCharacter::IsSwitchActiveCb(int Number, void *pUser) -{ - CCharacter *pThis = (CCharacter *)pUser; - CCollision *pCollision = pThis->GameServer()->Collision(); - return pCollision->m_pSwitchers && pCollision->m_pSwitchers[Number].m_Status[pThis->Team()] && pThis->Team() != TEAM_SUPER; -} - void CCharacter::HandleTiles(int Index) { CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController; int MapIndex = Index; //int PureMapIndex = GameServer()->Collision()->GetPureMapIndex(m_Pos); + float Offset = 4.0f; + int MapIndexL = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + (m_ProximityRadius / 2) + Offset, m_Pos.y)); + int MapIndexR = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x - (m_ProximityRadius / 2) - Offset, m_Pos.y)); + int MapIndexT = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x, m_Pos.y + (m_ProximityRadius / 2) + Offset)); + int MapIndexB = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x, m_Pos.y - (m_ProximityRadius / 2) - Offset)); m_TileIndex = GameServer()->Collision()->GetTileIndex(MapIndex); m_TileFlags = GameServer()->Collision()->GetTileFlags(MapIndex); - m_MoveRestrictions = GameServer()->Collision()->GetMoveRestrictions(IsSwitchActiveCb, this, m_Pos); + m_TileIndexL = GameServer()->Collision()->GetTileIndex(MapIndexL); + m_TileFlagsL = GameServer()->Collision()->GetTileFlags(MapIndexL); + m_TileIndexR = GameServer()->Collision()->GetTileIndex(MapIndexR); + m_TileFlagsR = GameServer()->Collision()->GetTileFlags(MapIndexR); + m_TileIndexB = GameServer()->Collision()->GetTileIndex(MapIndexB); + m_TileFlagsB = GameServer()->Collision()->GetTileFlags(MapIndexB); + m_TileIndexT = GameServer()->Collision()->GetTileIndex(MapIndexT); + m_TileFlagsT = GameServer()->Collision()->GetTileFlags(MapIndexT); + m_TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex); + m_TileFFlags = GameServer()->Collision()->GetFTileFlags(MapIndex); + m_TileFIndexL = GameServer()->Collision()->GetFTileIndex(MapIndexL); + m_TileFFlagsL = GameServer()->Collision()->GetFTileFlags(MapIndexL); + m_TileFIndexR = GameServer()->Collision()->GetFTileIndex(MapIndexR); + m_TileFFlagsR = GameServer()->Collision()->GetFTileFlags(MapIndexR); + m_TileFIndexB = GameServer()->Collision()->GetFTileIndex(MapIndexB); + m_TileFFlagsB = GameServer()->Collision()->GetFTileFlags(MapIndexB); + m_TileFIndexT = GameServer()->Collision()->GetFTileIndex(MapIndexT); + m_TileFFlagsT = GameServer()->Collision()->GetFTileFlags(MapIndexT);// + m_TileSIndex = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndex)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileIndex(MapIndex) : 0 : 0; + m_TileSFlags = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndex)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileFlags(MapIndex) : 0 : 0; + m_TileSIndexL = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexL)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileIndex(MapIndexL) : 0 : 0; + m_TileSFlagsL = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexL)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileFlags(MapIndexL) : 0 : 0; + m_TileSIndexR = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexR)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileIndex(MapIndexR) : 0 : 0; + m_TileSFlagsR = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexR)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileFlags(MapIndexR) : 0 : 0; + m_TileSIndexB = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexB)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileIndex(MapIndexB) : 0 : 0; + m_TileSFlagsB = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexB)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileFlags(MapIndexB) : 0 : 0; + m_TileSIndexT = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexT)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileIndex(MapIndexT) : 0 : 0; + m_TileSFlagsT = (GameServer()->Collision()->m_pSwitchers && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetDTileNumber(MapIndexT)].m_Status[Team()])?(Team() != TEAM_SUPER)? GameServer()->Collision()->GetDTileFlags(MapIndexT) : 0 : 0; //Sensitivity int S1 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f)); int S2 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f)); @@ -1611,9 +1662,33 @@ void CCharacter::HandleTiles(int Index) } // stopper - m_Core.m_Vel = ClampVel(m_MoveRestrictions, m_Core.m_Vel); - if(m_MoveRestrictions&CANTMOVE_DOWN) + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)) && m_Core.m_Vel.x > 0) { + if((int)GameServer()->Collision()->GetPos(MapIndexL).x) + if((int)GameServer()->Collision()->GetPos(MapIndexL).x < (int)m_Core.m_Pos.x) + m_Core.m_Pos = m_PrevPos; + m_Core.m_Vel.x = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)) && m_Core.m_Vel.x < 0) + { + if((int)GameServer()->Collision()->GetPos(MapIndexR).x) + if((int)GameServer()->Collision()->GetPos(MapIndexR).x > (int)m_Core.m_Pos.x) + m_Core.m_Pos = m_PrevPos; + m_Core.m_Vel.x = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)) && m_Core.m_Vel.y < 0) + { + if((int)GameServer()->Collision()->GetPos(MapIndexB).y) + if((int)GameServer()->Collision()->GetPos(MapIndexB).y > (int)m_Core.m_Pos.y) + m_Core.m_Pos = m_PrevPos; + m_Core.m_Vel.y = 0; + } + if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)) && m_Core.m_Vel.y > 0) + { + if((int)GameServer()->Collision()->GetPos(MapIndexT).y) + if((int)GameServer()->Collision()->GetPos(MapIndexT).y < (int)m_Core.m_Pos.y) + m_Core.m_Pos = m_PrevPos; + m_Core.m_Vel.y = 0; m_Core.m_Jumped = 0; m_Core.m_JumpedTotal = 0; } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 42e5dfe48..85aeb3218 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -159,7 +159,7 @@ private: // DDRace - static bool IsSwitchActiveCb(int Number, void *pUser); + void HandleTiles(int Index); float m_Time; int m_LastBroadcast; @@ -219,9 +219,32 @@ public: int m_TileFlags; int m_TileFIndex; int m_TileFFlags; - - int m_MoveRestrictions; - + int m_TileSIndex; + int m_TileSFlags; + int m_TileIndexL; + int m_TileFlagsL; + int m_TileFIndexL; + int m_TileFFlagsL; + int m_TileSIndexL; + int m_TileSFlagsL; + int m_TileIndexR; + int m_TileFlagsR; + int m_TileFIndexR; + int m_TileFFlagsR; + int m_TileSIndexR; + int m_TileSFlagsR; + int m_TileIndexT; + int m_TileFlagsT; + int m_TileFIndexT; + int m_TileFFlagsT; + int m_TileSIndexT; + int m_TileSFlagsT; + int m_TileIndexB; + int m_TileFlagsB; + int m_TileFIndexB; + int m_TileFFlagsB; + int m_TileSIndexB; + int m_TileSFlagsB; vec2 m_Intersection; int64 m_LastStartWarning; int64 m_LastRescue; diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 3555e4620..1102a8d0c 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -127,8 +127,125 @@ void CDragger::Drag() } else if (length(m_Pos - Target->m_Pos) > 28) { - vec2 Temp = Target->Core()->m_Vel + (normalize(m_Pos - Target->m_Pos) * m_Strength); - Target->Core()->m_Vel = ClampVel(Target->m_MoveRestrictions, Temp); + vec2 Temp = Target->Core()->m_Vel + + (normalize(m_Pos - Target->m_Pos) * m_Strength); + if (Temp.x > 0 + && ((Target->m_TileIndex == TILE_STOP + && Target->m_TileFlags == ROTATION_270) + || (Target->m_TileIndexL == TILE_STOP + && Target->m_TileFlagsL == ROTATION_270) + || (Target->m_TileIndexL == TILE_STOPS + && (Target->m_TileFlagsL == ROTATION_90 + || Target->m_TileFlagsL + == ROTATION_270)) + || (Target->m_TileIndexL == TILE_STOPA) + || (Target->m_TileFIndex == TILE_STOP + && Target->m_TileFFlags == ROTATION_270) + || (Target->m_TileFIndexL == TILE_STOP + && Target->m_TileFFlagsL == ROTATION_270) + || (Target->m_TileFIndexL == TILE_STOPS + && (Target->m_TileFFlagsL == ROTATION_90 + || Target->m_TileFFlagsL + == ROTATION_270)) + || (Target->m_TileFIndexL == TILE_STOPA) + || (Target->m_TileSIndex == TILE_STOP + && Target->m_TileSFlags == ROTATION_270) + || (Target->m_TileSIndexL == TILE_STOP + && Target->m_TileSFlagsL == ROTATION_270) + || (Target->m_TileSIndexL == TILE_STOPS + && (Target->m_TileSFlagsL == ROTATION_90 + || Target->m_TileSFlagsL + == ROTATION_270)) + || (Target->m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if (Temp.x < 0 + && ((Target->m_TileIndex == TILE_STOP + && Target->m_TileFlags == ROTATION_90) + || (Target->m_TileIndexR == TILE_STOP + && Target->m_TileFlagsR == ROTATION_90) + || (Target->m_TileIndexR == TILE_STOPS + && (Target->m_TileFlagsR == ROTATION_90 + || Target->m_TileFlagsR + == ROTATION_270)) + || (Target->m_TileIndexR == TILE_STOPA) + || (Target->m_TileFIndex == TILE_STOP + && Target->m_TileFFlags == ROTATION_90) + || (Target->m_TileFIndexR == TILE_STOP + && Target->m_TileFFlagsR == ROTATION_90) + || (Target->m_TileFIndexR == TILE_STOPS + && (Target->m_TileFFlagsR == ROTATION_90 + || Target->m_TileFFlagsR + == ROTATION_270)) + || (Target->m_TileFIndexR == TILE_STOPA) + || (Target->m_TileSIndex == TILE_STOP + && Target->m_TileSFlags == ROTATION_90) + || (Target->m_TileSIndexR == TILE_STOP + && Target->m_TileSFlagsR == ROTATION_90) + || (Target->m_TileSIndexR == TILE_STOPS + && (Target->m_TileSFlagsR == ROTATION_90 + || Target->m_TileSFlagsR + == ROTATION_270)) + || (Target->m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if (Temp.y < 0 + && ((Target->m_TileIndex == TILE_STOP + && Target->m_TileFlags == ROTATION_180) + || (Target->m_TileIndexB == TILE_STOP + && Target->m_TileFlagsB == ROTATION_180) + || (Target->m_TileIndexB == TILE_STOPS + && (Target->m_TileFlagsB == ROTATION_0 + || Target->m_TileFlagsB + == ROTATION_180)) + || (Target->m_TileIndexB == TILE_STOPA) + || (Target->m_TileFIndex == TILE_STOP + && Target->m_TileFFlags == ROTATION_180) + || (Target->m_TileFIndexB == TILE_STOP + && Target->m_TileFFlagsB == ROTATION_180) + || (Target->m_TileFIndexB == TILE_STOPS + && (Target->m_TileFFlagsB == ROTATION_0 + || Target->m_TileFFlagsB + == ROTATION_180)) + || (Target->m_TileFIndexB == TILE_STOPA) + || (Target->m_TileSIndex == TILE_STOP + && Target->m_TileSFlags == ROTATION_180) + || (Target->m_TileSIndexB == TILE_STOP + && Target->m_TileSFlagsB == ROTATION_180) + || (Target->m_TileSIndexB == TILE_STOPS + && (Target->m_TileSFlagsB == ROTATION_0 + || Target->m_TileSFlagsB + == ROTATION_180)) + || (Target->m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if (Temp.y > 0 + && ((Target->m_TileIndex == TILE_STOP + && Target->m_TileFlags == ROTATION_0) + || (Target->m_TileIndexT == TILE_STOP + && Target->m_TileFlagsT == ROTATION_0) + || (Target->m_TileIndexT == TILE_STOPS + && (Target->m_TileFlagsT == ROTATION_0 + || Target->m_TileFlagsT + == ROTATION_180)) + || (Target->m_TileIndexT == TILE_STOPA) + || (Target->m_TileFIndex == TILE_STOP + && Target->m_TileFFlags == ROTATION_0) + || (Target->m_TileFIndexT == TILE_STOP + && Target->m_TileFFlagsT == ROTATION_0) + || (Target->m_TileFIndexT == TILE_STOPS + && (Target->m_TileFFlagsT == ROTATION_0 + || Target->m_TileFFlagsT + == ROTATION_180)) + || (Target->m_TileFIndexT == TILE_STOPA) + || (Target->m_TileSIndex == TILE_STOP + && Target->m_TileSFlags == ROTATION_0) + || (Target->m_TileSIndexT == TILE_STOP + && Target->m_TileSFlagsT == ROTATION_0) + || (Target->m_TileSIndexT == TILE_STOPS + && (Target->m_TileSFlagsT == ROTATION_0 + || Target->m_TileSFlagsT + == ROTATION_180)) + || (Target->m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + Target->Core()->m_Vel = Temp; } } } diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 56e0582d7..64dde9499 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -61,7 +61,15 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) Temp = pHit->Core()->m_Vel + normalize(pOwnerChar->Core()->m_Pos - pHit->Core()->m_Pos) * Strength; else Temp = pHit->Core()->m_Vel; - pHit->Core()->m_Vel = ClampVel(pHit->m_MoveRestrictions, Temp); + if(Temp.x > 0 && ((pHit->m_TileIndex == TILE_STOP && pHit->m_TileFlags == ROTATION_270) || (pHit->m_TileIndexL == TILE_STOP && pHit->m_TileFlagsL == ROTATION_270) || (pHit->m_TileIndexL == TILE_STOPS && (pHit->m_TileFlagsL == ROTATION_90 || pHit->m_TileFlagsL ==ROTATION_270)) || (pHit->m_TileIndexL == TILE_STOPA) || (pHit->m_TileFIndex == TILE_STOP && pHit->m_TileFFlags == ROTATION_270) || (pHit->m_TileFIndexL == TILE_STOP && pHit->m_TileFFlagsL == ROTATION_270) || (pHit->m_TileFIndexL == TILE_STOPS && (pHit->m_TileFFlagsL == ROTATION_90 || pHit->m_TileFFlagsL == ROTATION_270)) || (pHit->m_TileFIndexL == TILE_STOPA) || (pHit->m_TileSIndex == TILE_STOP && pHit->m_TileSFlags == ROTATION_270) || (pHit->m_TileSIndexL == TILE_STOP && pHit->m_TileSFlagsL == ROTATION_270) || (pHit->m_TileSIndexL == TILE_STOPS && (pHit->m_TileSFlagsL == ROTATION_90 || pHit->m_TileSFlagsL == ROTATION_270)) || (pHit->m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((pHit->m_TileIndex == TILE_STOP && pHit->m_TileFlags == ROTATION_90) || (pHit->m_TileIndexR == TILE_STOP && pHit->m_TileFlagsR == ROTATION_90) || (pHit->m_TileIndexR == TILE_STOPS && (pHit->m_TileFlagsR == ROTATION_90 || pHit->m_TileFlagsR == ROTATION_270)) || (pHit->m_TileIndexR == TILE_STOPA) || (pHit->m_TileFIndex == TILE_STOP && pHit->m_TileFFlags == ROTATION_90) || (pHit->m_TileFIndexR == TILE_STOP && pHit->m_TileFFlagsR == ROTATION_90) || (pHit->m_TileFIndexR == TILE_STOPS && (pHit->m_TileFFlagsR == ROTATION_90 || pHit->m_TileFFlagsR == ROTATION_270)) || (pHit->m_TileFIndexR == TILE_STOPA) || (pHit->m_TileSIndex == TILE_STOP && pHit->m_TileSFlags == ROTATION_90) || (pHit->m_TileSIndexR == TILE_STOP && pHit->m_TileSFlagsR == ROTATION_90) || (pHit->m_TileSIndexR == TILE_STOPS && (pHit->m_TileSFlagsR == ROTATION_90 || pHit->m_TileSFlagsR == ROTATION_270)) || (pHit->m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((pHit->m_TileIndex == TILE_STOP && pHit->m_TileFlags == ROTATION_180) || (pHit->m_TileIndexB == TILE_STOP && pHit->m_TileFlagsB == ROTATION_180) || (pHit->m_TileIndexB == TILE_STOPS && (pHit->m_TileFlagsB == ROTATION_0 || pHit->m_TileFlagsB == ROTATION_180)) || (pHit->m_TileIndexB == TILE_STOPA) || (pHit->m_TileFIndex == TILE_STOP && pHit->m_TileFFlags == ROTATION_180) || (pHit->m_TileFIndexB == TILE_STOP && pHit->m_TileFFlagsB == ROTATION_180) || (pHit->m_TileFIndexB == TILE_STOPS && (pHit->m_TileFFlagsB == ROTATION_0 || pHit->m_TileFFlagsB == ROTATION_180)) || (pHit->m_TileFIndexB == TILE_STOPA) || (pHit->m_TileSIndex == TILE_STOP && pHit->m_TileSFlags == ROTATION_180) || (pHit->m_TileSIndexB == TILE_STOP && pHit->m_TileSFlagsB == ROTATION_180) || (pHit->m_TileSIndexB == TILE_STOPS && (pHit->m_TileSFlagsB == ROTATION_0 || pHit->m_TileSFlagsB == ROTATION_180)) || (pHit->m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((pHit->m_TileIndex == TILE_STOP && pHit->m_TileFlags == ROTATION_0) || (pHit->m_TileIndexT == TILE_STOP && pHit->m_TileFlagsT == ROTATION_0) || (pHit->m_TileIndexT == TILE_STOPS && (pHit->m_TileFlagsT == ROTATION_0 || pHit->m_TileFlagsT == ROTATION_180)) || (pHit->m_TileIndexT == TILE_STOPA) || (pHit->m_TileFIndex == TILE_STOP && pHit->m_TileFFlags == ROTATION_0) || (pHit->m_TileFIndexT == TILE_STOP && pHit->m_TileFFlagsT == ROTATION_0) || (pHit->m_TileFIndexT == TILE_STOPS && (pHit->m_TileFFlagsT == ROTATION_0 || pHit->m_TileFFlagsT == ROTATION_180)) || (pHit->m_TileFIndexT == TILE_STOPA) || (pHit->m_TileSIndex == TILE_STOP && pHit->m_TileSFlags == ROTATION_0) || (pHit->m_TileSIndexT == TILE_STOP && pHit->m_TileSFlagsT == ROTATION_0) || (pHit->m_TileSIndexT == TILE_STOPS && (pHit->m_TileSFlagsT == ROTATION_0 || pHit->m_TileSFlagsT == ROTATION_180)) || (pHit->m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + pHit->Core()->m_Vel = Temp; } else if (m_Type == WEAPON_RIFLE) {