about summary refs log tree commit diff
path: root/src/game/server/gamecontext.cpp
diff options
context:
space:
mode:
authorMarius "Teelevision" Neugebauer <marius@teele.eu>2014-03-30 05:54:51 +0200
committerMarius "Teelevision" Neugebauer <marius@teele.eu>2014-03-30 05:54:51 +0200
commitfa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181 (patch)
tree216f70fbaf6cf3fa80295c6be5a2cb06b3d24c61 /src/game/server/gamecontext.cpp
parente799504cb2655bb3aa3a25c2a69ddc80558f9e99 (diff)
downloadzcatch-fa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181.tar.gz
zcatch-fa7c5cf7fa1d4e8a0fbcd49c776bf4fb92e0d181.zip
when limited ammo: return ammo when hitting someone or rocketjumping
Diffstat (limited to 'src/game/server/gamecontext.cpp')
-rw-r--r--src/game/server/gamecontext.cpp11
1 files changed, 11 insertions, 0 deletions
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);
+		}
 	}
 }