diff options
| author | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-30 05:54:51 +0200 |
|---|---|---|
| committer | Marius "Teelevision" Neugebauer <marius@teele.eu> | 2014-03-30 05:54:51 +0200 |
| commit | fa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181 (patch) | |
| tree | 216f70fbaf6cf3fa80295c6be5a2cb06b3d24c61 /src/game/server | |
| parent | e799504cb2655bb3aa3a25c2a69ddc80558f9e99 (diff) | |
| download | zcatch-fa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181.tar.gz zcatch-fa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181.zip | |
when limited ammo: return ammo when hitting someone or rocketjumping
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/entities/character.cpp | 6 | ||||
| -rw-r--r-- | src/game/server/entities/character.h | 1 | ||||
| -rw-r--r-- | src/game/server/gamecontext.cpp | 11 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index ee6b1019..01ed8693 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -532,6 +532,12 @@ void CCharacter::GiveNinja() GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA); } +void CCharacter::GiveAmmo(int Weapon, int Ammo) +{ + if(m_aWeapons[Weapon].m_Got && m_aWeapons[Weapon].m_Ammo > -1) + m_aWeapons[Weapon].m_Ammo = min(m_aWeapons[Weapon].m_Ammo + Ammo, min(g_Config.m_SvWeaponsAmmo, g_pData->m_Weapons.m_aId[Weapon].m_Maxammo)); +} + void CCharacter::SetEmote(int Emote, int Tick) { m_EmoteType = Emote; diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 8bd1d3da..ece33e45 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -58,6 +58,7 @@ public: bool GiveWeapon(int Weapon, int Ammo); void GiveNinja(); + void GiveAmmo(int Weapon, int Ammo); void SetEmote(int Emote, int Tick); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 6f983855..fa36187b 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -138,6 +138,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag float Radius = 135.0f; float InnerRadius = 48.0f; int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); + bool someoneWasHit = false; for(int i = 0; i < Num; i++) { if(!limitVictims || victims[apEnts[i]->GetPlayer()->GetCID()]) @@ -150,9 +151,19 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag 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); + someoneWasHit = true; + } } } + // give the owner the ammo back if he hit someone else or himself (like rocketjump) + if(someoneWasHit) + { + CCharacter *ownerChar = GetPlayerChar(Owner); + if(ownerChar) + ownerChar->GiveAmmo(Weapon, 1); + } } } |