diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 71e10ceab..dba17c527 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1223,7 +1223,7 @@ void CCharacter::Die(int Killer, int Weapon) m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - Controller->m_Teams.m_Core.Team(m_pPlayer->GetCID(), 0); + Controller->m_Teams.SetForceCharacterTeam(m_pPlayer->GetCID(), 0); // send the kill message CNetMsg_Sv_KillMsg Msg; diff --git a/src/game/server/entities/dragger.cpp b/src/game/server/entities/dragger.cpp index 740161736..78daaef3c 100644 --- a/src/game/server/entities/dragger.cpp +++ b/src/game/server/entities/dragger.cpp @@ -11,14 +11,14 @@ const int LENGTH=700; -CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW) +CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, int CatchedTeam) : CEntity(pGameWorld, NETOBJTYPE_LASER) { m_Pos = Pos; m_Strength = Strength; m_EvalTick = Server()->Tick(); m_NW = NW; - + m_CatchedTeam = CatchedTeam; GameWorld()->InsertEntity(this); } @@ -27,22 +27,19 @@ void CDragger::Move() if (m_Target) return; CCharacter *Ents[16]; - int Num = -1; - Num = GameServer()->m_World.FindEntities(m_Pos,LENGTH, (CEntity**)Ents, 16, NETOBJTYPE_CHARACTER); + int Num = GameServer()->m_World.FindEntities(m_Pos,LENGTH, (CEntity**)Ents, 16, NETOBJTYPE_CHARACTER); int Id=-1; int MinLen=0; for (int i = 0; i < Num; i++) { m_Target = Ents[i]; - int Res=0; - if (!m_NW) - Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Target->m_Pos, 0, 0); - else - Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_Target->m_Pos, 0, 0); + if(m_Target->Team() != m_CatchedTeam) continue; + int Res = m_NW ? GameServer()->Collision()->IntersectNoLaserNW(m_Pos, m_Target->m_Pos, 0, 0) : + GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Target->m_Pos, 0, 0); if (Res==0) { - int Len=length(Ents[i]->m_Pos - m_Pos); + int Len=length(m_Target->m_Pos - m_Pos); if (MinLen==0 || MinLen>Len) { MinLen=Len; @@ -50,14 +47,7 @@ void CDragger::Move() } } } - if (Id!=-1) - { - m_Target = Ents[Id]; - } - else - { - m_Target=0; - } + m_Target = Id != -1 ? Ents[Id] : 0; } void CDragger::Drag() @@ -127,7 +117,9 @@ void CDragger::Snap(int SnappingClient) return; CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient); - if(Char && m_Target && !Char->GetPlayer()->m_ShowOthers && Char->Team() != m_Target->Team()) return; + if(Char && m_Target + && !Char->GetPlayer()->m_ShowOthers + && Char->Team() != m_Target->Team()) return; CNetObj_Laser *obj = static_cast(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser))); @@ -152,5 +144,15 @@ void CDragger::Snap(int SnappingClient) StartTick = Server()->Tick(); obj->m_StartTick = StartTick; } -//я тут был -//я тоже + +CDraggerTeam::CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW) { + for(int i = 0; i < MAX_CLIENTS; ++i) { + m_Draggers[i] = new CDragger(pGameWorld, Pos, Strength, NW, i); + } +} + +//CDraggerTeam::~CDraggerTeam() { + //for(int i = 0; i < MAX_CLIENTS; ++i) { + // delete m_Draggers[i]; + //} +//} diff --git a/src/game/server/entities/dragger.h b/src/game/server/entities/dragger.h index 316b18e24..5e15a875d 100644 --- a/src/game/server/entities/dragger.h +++ b/src/game/server/entities/dragger.h @@ -4,7 +4,6 @@ #define GAME_SERVER_ENTITY_DRAGGER_H #include - class CCharacter; class CDragger : public CEntity @@ -16,14 +15,24 @@ class CDragger : public CEntity void Drag(); CCharacter * m_Target; bool m_NW; + int m_CatchedTeam; public: - CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW=false); + CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, int CatchedTeam); virtual void Reset(); virtual void Tick(); virtual void Snap(int snapping_client); }; +class CDraggerTeam { + CDragger * m_Draggers[MAX_CLIENTS]; + +public: + + CDraggerTeam(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW=false); + //~CDraggerTeam(); +}; + #endif diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index 324d3b831..4eaf80987 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -95,20 +95,23 @@ void CProjectile::Tick() if(m_LifeSpan > -1) m_LifeSpan--; + int TeamMask = -1; bool isWeaponCollide = false; if(OwnerChar && TargetChr && OwnerChar->m_Alive && TargetChr->m_Alive - && !TargetChr->CanCollide(m_Owner)) isWeaponCollide = true; - + && !TargetChr->CanCollide(m_Owner)) { + isWeaponCollide = true; + TeamMask = OwnerChar->Teams()->TeamMask( OwnerChar->Team()); + } if( ((TargetChr && (g_Config.m_SvHit || m_Owner == -1 || TargetChr == OwnerChar)) || Collide) && !isWeaponCollide)//TODO:TEAM { if(m_Explosive/*??*/ && (!TargetChr || (TargetChr && !m_Freeze))) { - GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, (m_Owner == -1)?true:false, - (m_Owner != -1)? OwnerChar->Teams()->TeamMask(OwnerChar->Team()) : -1); + GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, m_Owner == -1, + (m_Owner != -1)? TeamMask : -1); GameServer()->CreateSound(ColPos, m_SoundImpact, - (m_Owner != -1)? OwnerChar->Teams()->TeamMask(OwnerChar->Team()) : -1); + (m_Owner != -1)? TeamMask : -1); } else if(TargetChr && m_Freeze) TargetChr->Freeze(Server()->TickSpeed()*3); @@ -125,7 +128,7 @@ void CProjectile::Tick() else if (m_Weapon == WEAPON_GUN) { GameServer()->CreateDamageInd(CurPos, -atan2(m_Direction.x, m_Direction.y), 10, - (m_Owner != -1)? OwnerChar->Teams()->TeamMask(OwnerChar->Team()) : -1); + (m_Owner != -1)? TeamMask : -1); GameServer()->m_World.DestroyEntity(this); } else @@ -156,7 +159,7 @@ void CProjectile::Snap(int SnappingClient) return; CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient); if(Char && m_Owner != -1 && !Char->GetPlayer()->m_ShowOthers && - Char->Team() != GameServer()->GetPlayerChar(m_Owner)->Team()) return; + Char->CanCollide(m_Owner)) return; CNetObj_Projectile *pProj = static_cast(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_Id, sizeof(CNetObj_Projectile))); FillInfo(pProj); } diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index a953b4780..561d19481 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -289,11 +289,11 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front) } else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG) { - new CDragger(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1); + new CDraggerTeam(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1, false); } else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW) { - new CDragger(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true); + new CDraggerTeam(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true); } else if(Index==ENTITY_PLASMAE) { diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 7d93aeb1f..d7cdf2871 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -81,6 +81,23 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) { } } } + SetForceCharacterTeam(id, Team); + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team); + dbg_msg("Teams", aBuf); + //GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask()); + if(Character(id)->GetPlayer()->m_IsUsingRaceClient) + { + CNetMsg_Sv_PlayerTeam Msg; + Msg.m_Team = Team; + Msg.m_Cid = id; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); + //dbg_msg("Teams", "Sended all"); + } + return true; +} + +void CGameTeams::SetForceCharacterTeam(int id, int Team) { if(m_Core.Team(id) != TEAM_FLOCK && m_Core.Team(id) != TEAM_SUPER && m_TeamState[m_Core.Team(id)] != EMPTY) { bool NoOneInOldTeam = true; for(int i = 0; i < MAX_CLIENTS; ++i) { @@ -97,19 +114,6 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) { if(Team != TEAM_SUPER && m_TeamState[Team] == EMPTY) { ChangeTeamState(Team, OPEN); } - char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team); - dbg_msg("Teams", aBuf); - //GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask()); - if(Character(id)->GetPlayer()->m_IsUsingRaceClient) - { - CNetMsg_Sv_PlayerTeam Msg; - Msg.m_Team = Team; - Msg.m_Cid = id; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); - //dbg_msg("Teams", "Sended all"); - } - return true; } void CGameTeams::ChangeTeamState(int Team, int State) { diff --git a/src/game/server/teams.h b/src/game/server/teams.h index c2578abe4..4be6095f3 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -41,6 +41,9 @@ public: int TeamMask(int Team); void SendAllInfo(int Cid); + + //need to be very carefull using this method + void SetForceCharacterTeam(int id, int Team); }; #endif