diff --git a/src/game/server/entities/gun.cpp b/src/game/server/entities/gun.cpp index 209ac1af0..a5d99efef 100644 --- a/src/game/server/entities/gun.cpp +++ b/src/game/server/entities/gun.cpp @@ -28,10 +28,16 @@ CGun::CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive) void CGun::Fire() { CCharacter *Ents[16]; + int IdInTeam[16]; + int LenInTeam[16]; + for (int i = 0; i < 16; i++) { + IdInTeam[i] = -1; + LenInTeam[i] = 0; + } + int Num = -1; Num = GameServer()->m_World.FindEntities(m_Pos,RANGE, (CEntity**)Ents, 16, NETOBJTYPE_CHARACTER); - int Id=-1; - int MinLen=0; + for (int i = 0; i < Num; i++) { CCharacter *Target = Ents[i]; @@ -40,24 +46,31 @@ void CGun::Fire() res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0,false); if (!res) { - int Len=length(Ents[i]->m_Pos - m_Pos); - if (MinLen==0) + int Len=length(Target->m_Pos - m_Pos); + if (LenInTeam[Target->Team()] == 0) { - MinLen=Len; - Id=i; + LenInTeam[Target->Team()] = Len; + IdInTeam[Target->Team()] = i; } - else if(MinLen>Len) + else if(LenInTeam[Target->Team()] > Len) { - MinLen=Len; - Id=i; + LenInTeam[Target->Team()] = Len; + IdInTeam[Target->Team()] = i; } } } - if (Id!=-1) - { - CCharacter *Target = Ents[Id]; - vec2 Fdir = normalize(Target->m_Pos - m_Pos); - new CPlasma(&GameServer()->m_World, m_Pos, Fdir, m_Freeze, m_Explosive); + //if (Id!=-1) + //{ + // CCharacter *Target = Ents[Id]; + // vec2 Fdir = normalize(Target->m_Pos - m_Pos); + // new CPlasma(&GameServer()->m_World, m_Pos, Fdir, m_Freeze, m_Explosive); + //} + for (int i = 0; i < 16; i++) { + if(IdInTeam[i] != -1) { + CCharacter *Target = Ents[IdInTeam[i]]; + vec2 Fdir = normalize(Target->m_Pos - m_Pos); + new CPlasma(&GameServer()->m_World, m_Pos, Fdir, m_Freeze, m_Explosive); + } } } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 32c3a20f8..4ae65ee61 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -146,7 +146,7 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage) if((int)Dmg) if((g_Config.m_SvHit||NoDamage) || Owner == apEnts[i]->m_pPlayer->GetCID()) { - if(apEnts[i]->Team() != GetPlayerChar(Owner)->Team()) continue; + if(Owner != -1 && apEnts[i]->m_Alive && apEnts[i]->Team() != GetPlayerChar(Owner)->Team()) continue; apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon); if(!g_Config.m_SvHit||NoDamage) break; }