diff --git a/data/editor/entities.png b/data/editor/entities.png index 999b4122c..7f88b37e7 100644 Binary files a/data/editor/entities.png and b/data/editor/entities.png differ diff --git a/data/mapres/entities.png b/data/mapres/entities.png index 00b4256af..7f88b37e7 100644 Binary files a/data/mapres/entities.png and b/data/mapres/entities.png differ diff --git a/data/maps/Test.map b/data/maps/Test.map index cbfd3553f..bcbe1a2cf 100644 Binary files a/data/maps/Test.map and b/data/maps/Test.map differ diff --git a/src/game/collision.cpp b/src/game/collision.cpp index bce64cfcc..9ee8f5fa4 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -40,7 +40,7 @@ void CCollision::Init(class CLayers *pLayers) for(int i = 0; i < m_Width*m_Height; i++) { int Index = m_pFront[i].m_Index; - if(Index > 191) + if(Index > TILE_NPH) continue; switch(Index) @@ -49,10 +49,10 @@ void CCollision::Init(class CLayers *pLayers) m_pFront[i].m_Index = COLFLAG_DEATH; break; case TILE_SOLID: - m_pFront[i].m_Index = COLFLAG_SOLID; + m_pFront[i].m_Index = 0; break; case TILE_NOHOOK: - m_pFront[i].m_Index = COLFLAG_SOLID|COLFLAG_NOHOOK; + m_pFront[i].m_Index = 0; break; case TILE_NOLASER: m_pFront[i].m_Index = COLFLAG_NOLASER; @@ -62,7 +62,7 @@ void CCollision::Init(class CLayers *pLayers) } // DDRace tiles - if(Index >= 5 && Index<=191) + if(Index >= 6 && Index<=TILE_NPH) m_pFront[i].m_Index = Index; } } @@ -70,7 +70,7 @@ void CCollision::Init(class CLayers *pLayers) for(int i = 0; i < m_Width*m_Height; i++) { int Index = m_pTiles[i].m_Index; - if(Index > 191) + if(Index > TILE_NPH) continue; switch(Index) @@ -92,7 +92,7 @@ void CCollision::Init(class CLayers *pLayers) } // DDRace tiles - if(Index >= 5 && Index<=191) + if(Index >= 6 && Index<=TILE_NPH) m_pTiles[i].m_Index = Index; } } @@ -191,9 +191,7 @@ int CCollision::GetFTile(int x, int y) int nx = clamp(x/32, 0, m_Width-1); int ny = clamp(y/32, 0, m_Height-1); /*dbg_msg("GetFTile","m_Index %d",m_pFront[ny*m_Width+nx].m_Index);//Remove */ - if(m_pFront[ny*m_Width+nx].m_Index == COLFLAG_SOLID - || m_pFront[ny*m_Width+nx].m_Index == (COLFLAG_SOLID|COLFLAG_NOHOOK) - || m_pFront[ny*m_Width+nx].m_Index == COLFLAG_DEATH + if(m_pFront[ny*m_Width+nx].m_Index == COLFLAG_DEATH || m_pFront[ny*m_Width+nx].m_Index == COLFLAG_NOLASER) return m_pFront[ny*m_Width+nx].m_Index; else @@ -265,14 +263,13 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p vec2 Pos = mix(Pos0, Pos1, a); ix = round(Pos.x); iy = round(Pos.y); - if((CheckPoint(ix, iy) || FCheckPoint(ix, iy)) && !(AllowThrough && IsThrough(ix + dx, iy + dy))) + if(CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))) { if(pOutCollision) *pOutCollision = Pos; if(pOutBeforeCollision) *pOutBeforeCollision = Last; - if (CheckPoint(ix, iy)) return GetCollisionAt(ix, iy); - else return GetFCollisionAt(ix, iy); + return GetCollisionAt(ix, iy); } Last = Pos; } @@ -292,14 +289,14 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 { float a = f/d; vec2 Pos = mix(Pos0, Pos1, a); - if(IsSolid(round(Pos.x), round(Pos.y)) || IsFSolid(round(Pos.x), round(Pos.y)) || (IsNoLaser(round(Pos.x), round(Pos.y)) || IsFNoLaser(round(Pos.x), round(Pos.y)))) + if(IsSolid(round(Pos.x), round(Pos.y)) || (IsNoLaser(round(Pos.x), round(Pos.y)) || IsFNoLaser(round(Pos.x), round(Pos.y)))) { if(pOutCollision) *pOutCollision = Pos; if(pOutBeforeCollision) *pOutBeforeCollision = Last; - if (IsSolid(round(Pos.x), round(Pos.y)) || IsNoLaser(round(Pos.x), round(Pos.y))) return GetCollisionAt(Pos.x, Pos.y); - else return GetFCollisionAt(Pos.x, Pos.y); + if (IsFNoLaser(round(Pos.x), round(Pos.y))) return GetFCollisionAt(Pos.x, Pos.y); + else return GetCollisionAt(Pos.x, Pos.y); } Last = Pos; @@ -376,10 +373,10 @@ void CCollision::MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, i vec2 Pos = *pInoutPos; vec2 Vel = *pInoutVel; - if(CheckPoint(Pos + Vel) || FCheckPoint(Pos + Vel)) + if(CheckPoint(Pos + Vel)) { int Affected = 0; - if(CheckPoint(Pos.x + Vel.x, Pos.y) || FCheckPoint(Pos.x + Vel.x, Pos.y)) + if(CheckPoint(Pos.x + Vel.x, Pos.y)) { pInoutVel->x *= -Elasticity; if(pBounces) @@ -387,7 +384,7 @@ void CCollision::MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, i Affected++; } - if(CheckPoint(Pos.x, Pos.y + Vel.y) || FCheckPoint(Pos.x, Pos.y + Vel.y)) + if(CheckPoint(Pos.x, Pos.y + Vel.y)) { pInoutVel->y *= -Elasticity; if(pBounces) @@ -468,13 +465,13 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas bool CCollision::TestBox(vec2 Pos, vec2 Size) { Size *= 0.5f; - if(CheckPoint(Pos.x-Size.x, Pos.y-Size.y) || FCheckPoint(Pos.x-Size.x, Pos.y-Size.y)) + if(CheckPoint(Pos.x-Size.x, Pos.y-Size.y)) return true; - if(CheckPoint(Pos.x+Size.x, Pos.y-Size.y) || FCheckPoint(Pos.x+Size.x, Pos.y-Size.y)) + if(CheckPoint(Pos.x+Size.x, Pos.y-Size.y)) return true; - if(CheckPoint(Pos.x-Size.x, Pos.y+Size.y) || FCheckPoint(Pos.x-Size.x, Pos.y+Size.y)) + if(CheckPoint(Pos.x-Size.x, Pos.y+Size.y)) return true; - if(CheckPoint(Pos.x+Size.x, Pos.y+Size.y) || FCheckPoint(Pos.x+Size.x, Pos.y+Size.y)) + if(CheckPoint(Pos.x+Size.x, Pos.y+Size.y)) return true; return false; } @@ -484,11 +481,6 @@ int CCollision::IsSolid(int x, int y) return (GetTile(x,y)&COLFLAG_SOLID); } -int CCollision::IsFSolid(int x, int y) -{ - return (GetFTile(x,y)&COLFLAG_SOLID); -} - int CCollision::IsThrough(int x, int y) { int nx = clamp(x/32, 0, m_Width-1); diff --git a/src/game/collision.h b/src/game/collision.h index b4f4fe156..4d44c54e7 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -27,8 +27,6 @@ public: void Init(class CLayers *pLayers); bool CheckPoint(float x, float y) { return IsSolid(round(x), round(y)); } bool CheckPoint(vec2 p) { return CheckPoint(p.x, p.y); } - bool FCheckPoint(float x, float y) { return IsFSolid(round(x), round(y)); } - bool FCheckPoint(vec2 p) { return FCheckPoint(p.x, p.y); } void SetCollisionAt(float x, float y, int flag); int GetCollisionAt(float x, float y) { return GetTile(round(x), round(y)); } int GetFCollisionAt(float x, float y) { return GetFTile(round(x), round(y)); } @@ -55,7 +53,6 @@ public: void GetSpeedup(int x, int y, vec2 *Dir, int *Force); int IsSolid(int x, int y); - int IsFSolid(int x, int y); int IsThrough(int x, int y); int IsNoLaser(int x, int y); int IsFNoLaser(int x, int y); diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index 4f129188f..eef4e5c37 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -712,7 +712,7 @@ void CLayerFront::BrushDraw(CLayer *pBrush, float wx, float wy) continue; // dont allow tele in and out tiles... same with speedup tile in front - if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pFrontLayer && (l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_TRIGGER + ENTITY_OFFSET)|| l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET))) + if(m_pEditor->GetSelectedLayer(0) == m_pEditor->m_Map.m_pFrontLayer && (l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEIN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_TELEOUT || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_BOOST || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_TRIGGER + ENTITY_OFFSET) || l->m_pTiles[y*l->m_Width+x].m_Index == (ENTITY_DOOR + ENTITY_OFFSET)) || l->m_pTiles[y*l->m_Width+x].m_Index == (TILE_SOLID) || l->m_pTiles[y*l->m_Width+x].m_Index == (TILE_NOHOOK)) continue; m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x]; } diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 8ff6b82a2..581d587e4 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -81,9 +81,9 @@ void CCharacterCore::Tick(bool UseInput) // get ground state bool Grounded = false; - if(m_pCollision->CheckPoint(m_Pos.x+PhysSize/2, m_Pos.y+PhysSize/2+5) || m_pCollision->FCheckPoint(m_Pos.x+PhysSize/2, m_Pos.y+PhysSize/2+5)) + if(m_pCollision->CheckPoint(m_Pos.x+PhysSize/2, m_Pos.y+PhysSize/2+5)) Grounded = true; - if(m_pCollision->CheckPoint(m_Pos.x-PhysSize/2, m_Pos.y+PhysSize/2+5) || m_pCollision->FCheckPoint(m_Pos.x-PhysSize/2, m_Pos.y+PhysSize/2+5)) + if(m_pCollision->CheckPoint(m_Pos.x-PhysSize/2, m_Pos.y+PhysSize/2+5)) Grounded = true; vec2 TargetDirection = normalize(vec2(m_Input.m_TargetX, m_Input.m_TargetY)); diff --git a/src/game/mapitems.h b/src/game/mapitems.h index ee09809bb..24699b723 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -128,7 +128,7 @@ enum TILE_NPC, TILE_EHOOK, TILE_NOHIT, - TILE_NPH, + TILE_NPH,//Remeber to change this in collision.cpp if you add anymore tiles //End of higher tiles //Untouchable Elements TILEFLAG_VFLIP=1, diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 3c10f2311..9a7c376f5 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -113,9 +113,9 @@ void CCharacter::SetWeapon(int W) bool CCharacter::IsGrounded() { - if(GameServer()->Collision()->CheckPoint(m_Pos.x+m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5) || GameServer()->Collision()->FCheckPoint(m_Pos.x+m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) + if(GameServer()->Collision()->CheckPoint(m_Pos.x+m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) return true; - if(GameServer()->Collision()->CheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5) || GameServer()->Collision()->FCheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) + if(GameServer()->Collision()->CheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) return true; return false; } @@ -336,16 +336,20 @@ void CCharacter::FireWeapon() case WEAPON_GUN: { - CProjectile *Proj = new CProjectile(GameWorld(), WEAPON_GUN, - m_pPlayer->GetCID(), - ProjStartPos, - Direction, - (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime), - 0, - 0, - 0, - -1, - WEAPON_GUN); + CProjectile *Proj = new CProjectile + ( + GameWorld(), + WEAPON_GUN,//Type + m_pPlayer->GetCID(),//Owner + ProjStartPos,//Pos + Direction,//Dir + (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),//Span + 0,//Freeze + 0,//Explosive + 0,//Force + -1,//SoundImpact + WEAPON_GUN//Weapon + ); // pack the Projectile and send it to the client Directly CNetObj_Projectile p; @@ -399,15 +403,20 @@ void CCharacter::FireWeapon() case WEAPON_GRENADE: { - CProjectile *Proj = new CProjectile(GameWorld(), WEAPON_GRENADE, - m_pPlayer->GetCID(), - ProjStartPos, - Direction, - (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime), - 0, - true, - 0, - SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); + CProjectile *Proj = new CProjectile + ( + GameWorld(), + WEAPON_GRENADE,//Type + m_pPlayer->GetCID(),//Owner + ProjStartPos,//Pos + Direction,//Dir + (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime),//Span + 0,//Freeze + true,//Explosive + 0,//Force + SOUND_GRENADE_EXPLODE,//SoundImpact + WEAPON_GRENADE//Weapon + );//SoundImpact // pack the Projectile and send it to the client Directly CNetObj_Projectile p; @@ -635,8 +644,22 @@ void CCharacter::Tick() { CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController; int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos); - int TileIndex1 = GameServer()->Collision()->GetCollisionDDRace(MapIndex); - int TileIndex2 = GameServer()->Collision()->GetFCollisionDDRace(MapIndex); + int TileIndex = GameServer()->Collision()->GetCollisionDDRace(MapIndex); + int TileFIndex = GameServer()->Collision()->GetFCollisionDDRace(MapIndex); + int MapIndexL = GameServer()->Collision()->GetMapIndex(m_PrevPos, vec2(m_Pos.x + m_ProximityRadius/2,m_Pos.y)); + int MapIndexR = GameServer()->Collision()->GetMapIndex(m_PrevPos, vec2(m_Pos.x - m_ProximityRadius/2,m_Pos.y)); + int MapIndexT = GameServer()->Collision()->GetMapIndex(m_PrevPos, vec2(m_Pos.x,m_Pos.y + m_ProximityRadius/2+5)); + int MapIndexB = GameServer()->Collision()->GetMapIndex(m_PrevPos, vec2(m_Pos.x,m_Pos.y - m_ProximityRadius/2-5)); + int TileIndexL = GameServer()->Collision()->GetCollisionDDRace(MapIndexL); + int TileFIndexL = GameServer()->Collision()->GetFCollisionDDRace(MapIndexL); + int TileIndexR = GameServer()->Collision()->GetCollisionDDRace(MapIndexR); + int TileFIndexR = GameServer()->Collision()->GetFCollisionDDRace(MapIndexR); + int TileIndexT = GameServer()->Collision()->GetCollisionDDRace(MapIndexT); + int TileFIndexT = GameServer()->Collision()->GetFCollisionDDRace(MapIndexT); + int TileIndexB = GameServer()->Collision()->GetCollisionDDRace(MapIndexB); + int TileFIndexB = GameServer()->Collision()->GetFCollisionDDRace(MapIndexB); + m_CurrentTile = TileIndex; + m_CurrentFTile = TileFIndex; if(m_pPlayer->m_ForceBalanced) { @@ -679,7 +702,7 @@ void CCharacter::Tick() m_Core.m_Jumped = 1; if (m_Super && g_Config.m_SvEndlessSuperHook) m_Core.m_HookTick = 0; - /*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/ + /*dbg_msg("character","TileIndex=%d , TileFIndex=%d",TileIndex,TileFIndex); //REMOVE*/ //DDRace char aBuftime[128]; float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed()); @@ -754,156 +777,157 @@ void CCharacter::Tick() m_CpCurrent[cp] = time; m_CpTick = Server()->Tick() + Server()->TickSpeed()*2; } - if(((TileIndex1 == TILE_BEGIN) || (TileIndex2 == TILE_BEGIN)) && m_RaceState == RACE_NONE) + if(((TileIndex == TILE_BEGIN) || (TileFIndex == TILE_BEGIN)) && (m_RaceState == RACE_NONE)) { Controller->m_Teams.OnCharacterStart(m_pPlayer->GetCID()); } - if(((TileIndex1 == TILE_END) || (TileIndex2 == TILE_END)) && m_RaceState == RACE_STARTED) + if(((TileIndex == TILE_END) || (TileFIndex == TILE_END)) && m_RaceState == RACE_STARTED) { Controller->m_Teams.OnCharacterFinish(m_pPlayer->GetCID()); } - if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super) + if(((TileIndex == TILE_FREEZE) || (TileFIndex == TILE_FREEZE)) && !m_Super) { Freeze(Server()->TickSpeed()*3); } - else if((TileIndex1 == TILE_UNFREEZE) || (TileIndex2 == TILE_UNFREEZE)) + else if((TileIndex == TILE_UNFREEZE) || (TileFIndex == TILE_UNFREEZE)) { UnFreeze(); } - if(TileIndex1 == TILE_STOPL) + + if(TileIndex == TILE_STOPL || TileIndexL == TILE_STOPL) { if(m_Core.m_Vel.x > 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex1).x < (int)m_Core.m_Pos.x) + if((int)GameServer()->Collision()->GetPos(TileIndex).x < (int)m_Core.m_Pos.x) m_Core.m_Pos.x = m_PrevPos.x; m_Core.m_Vel.x = 0; } } - if(TileIndex2 == TILE_STOPL) + if(TileFIndex == TILE_STOPL || TileFIndexL == TILE_STOPL) { if(m_Core.m_Vel.x > 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex2).x < (int)m_Core.m_Pos.x) + if((int)GameServer()->Collision()->GetPos(TileFIndex).x < (int)m_Core.m_Pos.x) m_Core.m_Pos.x = m_PrevPos.x; m_Core.m_Vel.x = 0; } } - if(TileIndex1 == TILE_STOPR) + if(TileIndex == TILE_STOPR || TileIndexR == TILE_STOPR) { if(m_Core.m_Vel.x < 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex1).x > (int)m_Core.m_Pos.x) + if((int)GameServer()->Collision()->GetPos(TileIndex).x > (int)m_Core.m_Pos.x) m_Core.m_Pos.x = m_PrevPos.x; m_Core.m_Vel.x = 0; } } - if(TileIndex2 == TILE_STOPR) + if(TileFIndex == TILE_STOPR || TileFIndexR == TILE_STOPR) { if(m_Core.m_Vel.x < 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex2).x > (int)m_Core.m_Pos.x) + if((int)GameServer()->Collision()->GetPos(TileFIndex).x > (int)m_Core.m_Pos.x) m_Core.m_Pos.x = m_PrevPos.x; m_Core.m_Vel.x = 0; } } - if(TileIndex1 == TILE_STOPB) + if(TileIndex == TILE_STOPB || TileIndexB == TILE_STOPB) { if(m_Core.m_Vel.y < 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex1).y > (int)m_Core.m_Pos.y) + if((int)GameServer()->Collision()->GetPos(TileIndex).y > (int)m_Core.m_Pos.y) m_Core.m_Pos.y = m_PrevPos.y; m_Core.m_Vel.y = 0; } } - if(TileIndex2 == TILE_STOPB) + if(TileFIndex == TILE_STOPB || TileFIndexB == TILE_STOPB) { if(m_Core.m_Vel.y < 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex2).y > (int)m_Core.m_Pos.y) + if((int)GameServer()->Collision()->GetPos(TileFIndex).y > (int)m_Core.m_Pos.y) m_Core.m_Pos.y = m_PrevPos.y; m_Core.m_Vel.y = 0; } } - if(TileIndex1 == TILE_STOPT) + if(TileIndex == TILE_STOPT || TileIndexT == TILE_STOPT) { if(m_Core.m_Vel.y > 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex1).y < (int)m_Core.m_Pos.y) + if((int)GameServer()->Collision()->GetPos(TileIndex).y < (int)m_Core.m_Pos.y) m_Core.m_Pos.y = m_PrevPos.y; m_Core.m_Jumped = 0; //m_Jumped = 1; m_Core.m_Vel.y = 0; } } - if(TileIndex2 == TILE_STOPT) + if(TileFIndex == TILE_STOPT || TileFIndexT == TILE_STOPT) { if(m_Core.m_Vel.y > 0) { - if((int)GameServer()->Collision()->GetPos(TileIndex2).y < (int)m_Core.m_Pos.y) + if((int)GameServer()->Collision()->GetPos(TileFIndex).y < (int)m_Core.m_Pos.y) m_Core.m_Pos.y = m_PrevPos.y; m_Core.m_Jumped = 0; m_Core.m_Vel.y = 0; } } - if (TileIndex1 == TILE_BOOST_L || TileIndex2 == TILE_BOOST_L) + if (TileIndex == TILE_BOOST_L || TileFIndex == TILE_BOOST_L) { if(m_PrevPos.x-m_Pos.x<0) m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5; - else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2) + else if(m_LastBooster != TileIndex || m_LastFBooster != TileFIndex) m_Core.m_Vel.x += m_Core.m_Vel.x*0.5; } - if (TileIndex1 == TILE_BOOST_R || TileIndex2 == TILE_BOOST_R) + if (TileIndex == TILE_BOOST_R || TileFIndex == TILE_BOOST_R) { if(m_PrevPos.x-m_Pos.x>0) m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5; - else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2) + else if(m_LastBooster != TileIndex || m_LastFBooster != TileFIndex) m_Core.m_Vel.x += m_Core.m_Vel.x*0.5; } - if (TileIndex1 == TILE_BOOST_D || TileIndex2 == TILE_BOOST_D) + if (TileIndex == TILE_BOOST_D || TileFIndex == TILE_BOOST_D) { if(m_PrevPos.y-m_Pos.y>0) m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5; - else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2) + else if(m_LastBooster != TileIndex || m_LastFBooster != TileFIndex) m_Core.m_Vel.y += m_Core.m_Vel.y*0.5; } - if (TileIndex1 == TILE_BOOST_U || TileIndex2 == TILE_BOOST_U) + if (TileIndex == TILE_BOOST_U || TileFIndex == TILE_BOOST_U) { if(m_PrevPos.y-m_Pos.y<0) m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5; - else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2) + else if(m_LastBooster != TileIndex || m_LastFBooster != TileFIndex) m_Core.m_Vel.y += m_Core.m_Vel.y*0.5; } - if ((TileIndex1 == TILE_BOOST_L2 || TileIndex2 == TILE_BOOST_L2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)) + if ((TileIndex == TILE_BOOST_L2 || TileFIndex == TILE_BOOST_L2) && (m_LastBooster != TileIndex || m_LastFBooster != TileFIndex)) { if(m_PrevPos.x-m_Pos.x<0) m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1; else m_Core.m_Vel.x += m_Core.m_Vel.x*1.1; } - if ((TileIndex1 == TILE_BOOST_R2|| TileIndex2 == TILE_BOOST_R2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)) + if ((TileIndex == TILE_BOOST_R2|| TileFIndex == TILE_BOOST_R2) && (m_LastBooster != TileIndex || m_LastFBooster != TileFIndex)) { - if(m_PrevPos.x-m_Pos.x>0) + if(m_Core.m_Vel.x < 0) m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1; else m_Core.m_Vel.x += m_Core.m_Vel.x*1.1; } - if ((TileIndex1 == TILE_BOOST_D2 || TileIndex2 == TILE_BOOST_D2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)) + if ((TileIndex == TILE_BOOST_D2 || TileFIndex == TILE_BOOST_D2) && (m_LastBooster != TileIndex || m_LastFBooster != TileFIndex)) { if(m_PrevPos.y-m_Pos.y>0) m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1; else m_Core.m_Vel.y += m_Core.m_Vel.y*1.1; } - if ((TileIndex1 == TILE_BOOST_U2 || TileIndex2 == TILE_BOOST_U2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)) + if ((TileIndex == TILE_BOOST_U2 || TileFIndex == TILE_BOOST_U2) && (m_LastBooster != TileIndex || m_LastFBooster != TileFIndex)) { if(m_PrevPos.y-m_Pos.y<0) m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1; else m_Core.m_Vel.y += m_Core.m_Vel.y*1.1; } - m_LastBooster = TileIndex1; - m_LastFBooster = TileIndex2; + m_LastBooster = TileIndex; + m_LastFBooster = TileFIndex; // handle speedup tiles if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y)) { diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index f6d379e9e..a227e88c8 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -170,11 +170,13 @@ public: // checkpoints int m_CpTick; int m_CpActive; - float m_CpCurrent[25]; + float m_CpCurrent[25]; int m_BroadTime; int m_BroadCast; + int m_CurrentTile; + int m_CurrentFTile; // info for dead reckoning diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 63ead884c..3ab26a316 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -75,9 +75,8 @@ void CDragger::drag() } else if (length(m_Pos-target->m_Pos)>28) - { - target->m_Core.m_Vel+=normalize(m_Pos-target->m_Pos)*strength; - } + if(!((target->m_CurrentTile >= TILE_STOPL && target->m_CurrentTile <= TILE_STOPT) || (target->m_CurrentFTile >= TILE_STOPL && target->m_CurrentFTile <= TILE_STOPT))) + target->m_Core.m_Vel+=normalize(m_Pos-target->m_Pos)*strength; } } diff --git a/src/game/server/entities/plasma.cpp b/src/game/server/entities/plasma.cpp index 11b8a2d46..24f8a6ccd 100644 --- a/src/game/server/entities/plasma.cpp +++ b/src/game/server/entities/plasma.cpp @@ -31,8 +31,8 @@ bool CPlasma::HitCharacter() return false; if(m_Freeze) Hit->Freeze(Server()->TickSpeed()*3); - else - GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false); + if(!m_Freeze || (m_Freeze && m_Explosive)) + GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true); GameServer()->m_World.DestroyEntity(this); return true; } @@ -64,7 +64,7 @@ void CPlasma::Tick() if(Res) { if(m_Explosive) - GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false); + GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true); Reset(); } diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index b9a3ce27a..01ecfff37 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -99,11 +99,11 @@ void CProjectile::Tick() if(m_LifeSpan > -1) m_LifeSpan--; - if( (TargetChr && (g_Config.m_SvHit || TargetChr == OwnerChar)) || Collide)//TODO:TEAM + if( (TargetChr && ((g_Config.m_SvHit || m_Owner == -1) || TargetChr == OwnerChar)) || Collide)//TODO:TEAM { if(m_Explosive/*??*/ && (!TargetChr || (TargetChr && !m_Freeze))) { - GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, false); + GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, (m_Owner == -1)?true:false); GameServer()->CreateSound(ColPos, m_SoundImpact); } else if(TargetChr && m_Freeze) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 44e32f970..4853782b2 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -127,8 +127,8 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) ev->m_Y = (int)p.y; } - if (!NoDamage) - { + /*if (!NoDamage) + {*/ // deal damage CCharacter *apEnts[64]; float Radius = 135.0f; @@ -144,13 +144,14 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); float Dmg = 6 * l; if((int)Dmg)//TODO:TEAM - if(g_Config.m_SvHit || Owner == apEnts[i]->m_pPlayer->GetCID()) { + if((g_Config.m_SvHit||NoDamage) || Owner == apEnts[i]->m_pPlayer->GetCID()) + { apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon); - if(!g_Config.m_SvHit) break; + if(!g_Config.m_SvHit||NoDamage) break; } } - } + //} } /* @@ -1340,7 +1341,7 @@ void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData, int ci CCharacter* chr = pSelf->GetPlayerChar(cid); if(chr) { - chr->m_Core.m_Pos.x -= 32; + chr->m_Core.m_Pos.x -= 16; if(!g_Config.m_SvCheatTime) chr->m_RaceState = RACE_CHEAT; } @@ -1352,7 +1353,7 @@ void CGameContext::ConGoRight(IConsole::IResult *pResult, void *pUserData, int CCharacter* chr = pSelf->GetPlayerChar(cid); if(chr) { - chr->m_Core.m_Pos.x += 32; + chr->m_Core.m_Pos.x += 16; if(!g_Config.m_SvCheatTime) chr->m_RaceState = RACE_CHEAT; } @@ -1364,7 +1365,7 @@ void CGameContext::ConGoUp(IConsole::IResult *pResult, void *pUserData, int cid CCharacter* chr = pSelf->GetPlayerChar(cid); if(chr) { - chr->m_Core.m_Pos.y -= 32; + chr->m_Core.m_Pos.y -= 16; if(!g_Config.m_SvCheatTime) chr->m_RaceState = RACE_CHEAT; } @@ -1376,7 +1377,7 @@ void CGameContext::ConGoDown(IConsole::IResult *pResult, void *pUserData, int c CCharacter* chr = pSelf->GetPlayerChar(cid); if(chr) { - chr->m_Core.m_Pos.y += 32; + chr->m_Core.m_Pos.y += 16; if(!g_Config.m_SvCheatTime) chr->m_RaceState = RACE_CHEAT; } @@ -1980,9 +1981,30 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/) if (pSwitch) { if(Collision()->Layers()->SwitchLayer()) - for(int i = 0; i < Collision()->Layers()->SwitchLayer()->m_Width * Collision()->Layers()->SwitchLayer()->m_Height; i++) - if(Collision()->SwitchLayer()[i].m_Type == (ENTITY_DOOR + ENTITY_OFFSET)) - m_Size++; + for(int y = 0; y < pTileMap->m_Height; y++) + for(int x = 0; x < pTileMap->m_Width; x++) + { + int sides[8][2]; + sides[0][0]=pSwitch[(x)+pTileMap->m_Width*(y+1)].m_Type - ENTITY_OFFSET; + sides[1][0]=pSwitch[(x+1)+pTileMap->m_Width*(y+1)].m_Type - ENTITY_OFFSET; + sides[2][0]=pSwitch[(x+1)+pTileMap->m_Width*(y)].m_Type - ENTITY_OFFSET; + sides[3][0]=pSwitch[(x+1)+pTileMap->m_Width*(y-1)].m_Type - ENTITY_OFFSET; + sides[4][0]=pSwitch[(x)+pTileMap->m_Width*(y-1)].m_Type - ENTITY_OFFSET; + sides[5][0]=pSwitch[(x-1)+pTileMap->m_Width*(y-1)].m_Type - ENTITY_OFFSET; + sides[6][0]=pSwitch[(x-1)+pTileMap->m_Width*(y)].m_Type - ENTITY_OFFSET; + sides[7][0]=pSwitch[(x-1)+pTileMap->m_Width*(y+1)].m_Type - ENTITY_OFFSET; + sides[0][1]=pSwitch[(x)+pTileMap->m_Width*(y+1)].m_Number; + sides[1][1]=pSwitch[(x+1)+pTileMap->m_Width*(y+1)].m_Number; + sides[2][1]=pSwitch[(x+1)+pTileMap->m_Width*(y)].m_Number; + sides[3][1]=pSwitch[(x+1)+pTileMap->m_Width*(y-1)].m_Number; + sides[4][1]=pSwitch[(x)+pTileMap->m_Width*(y-1)].m_Number; + sides[5][1]=pSwitch[(x-1)+pTileMap->m_Width*(y-1)].m_Number; + sides[6][1]=pSwitch[(x-1)+pTileMap->m_Width*(y)].m_Number; + sides[7][1]=pSwitch[(x-1)+pTileMap->m_Width*(y+1)].m_Number; + for(int i=0; i<8;i++) + if ((sides[i][0] >= ENTITY_LASER_SHORT && sides[i][0] <= ENTITY_LASER_LONG) && Collision()->SwitchLayer()[y*pTileMap->m_Width+x].m_Number == sides[i][1]) + m_Size++; + } if(m_Size) { m_SDoors = new SDoors[m_Size]; diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index f8575f7e6..5b4c13016 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -163,7 +163,9 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front) if (Index - ENTITY_CRAZY_SHOTGUN_U_EX == i) { float Deg = i*(pi/2); - CProjectile *bullet = new CProjectile(&GameServer()->m_World, + CProjectile *bullet = new CProjectile + ( + &GameServer()->m_World, WEAPON_SHOTGUN, //Type -1, //Owner Pos, //Pos @@ -171,9 +173,10 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front) -2, //Span true, //Freeze true, //Explosive - 0, - (g_Config.m_SvShotgunBulletSound)?SOUND_GRENADE_EXPLODE:-1, - WEAPON_SHOTGUN); + 0,//Force + (g_Config.m_SvShotgunBulletSound)?SOUND_GRENADE_EXPLODE:-1,//SoundImpact + WEAPON_SHOTGUN//Weapon + ); bullet->SetBouncing(2 - (i % 2)); }