diff options
| author | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-28 00:33:40 +0100 |
|---|---|---|
| committer | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-28 00:33:40 +0100 |
| commit | 9e266f4c1dafdba5b562e46bba3eca9dfddb95f3 (patch) | |
| tree | 103759bae45803af69b6c04ea816b3e9080b7aa2 /src/game/server/gamecontext.cpp | |
| parent | 814138ac95e0f46702c02aba4bef722e08f903d3 (diff) | |
| download | zcatch-9e266f4c1dafdba5b562e46bba3eca9dfddb95f3.tar.gz zcatch-9e266f4c1dafdba5b562e46bba3eca9dfddb95f3.zip | |
anti-spray protection for some cases
Diffstat (limited to 'src/game/server/gamecontext.cpp')
| -rw-r--r-- | src/game/server/gamecontext.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 1160d56e..ba08cebb 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -121,7 +121,7 @@ void CGameContext::CreateHammerHit(vec2 Pos) } -void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage) +void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, bool limitVictims, const bool *victims) { // create the event CNetEvent_Explosion *pEvent = (CNetEvent_Explosion *)m_Events.Create(NETEVENTTYPE_EXPLOSION, sizeof(CNetEvent_Explosion)); @@ -140,15 +140,18 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); for(int i = 0; i < Num; i++) { - vec2 Diff = apEnts[i]->m_Pos - Pos; - vec2 ForceDir(0,1); - float l = length(Diff); - if(l) - ForceDir = normalize(Diff); - l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); - float Dmg = 6 * l; - if((int)Dmg) - apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon); + if(!limitVictims || victims[apEnts[i]->GetPlayer()->GetCID()]) + { + vec2 Diff = apEnts[i]->m_Pos - Pos; + vec2 ForceDir(0,1); + float l = length(Diff); + if(l) + ForceDir = normalize(Diff); + l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); + float Dmg = 6 * l; + if((int)Dmg) + apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon); + } } } } |