diff options
| -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 | ||||
| -rw-r--r-- | src/game/variables.h | 2 |
4 files changed, 19 insertions, 1 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); + } } } diff --git a/src/game/variables.h b/src/game/variables.h index 3a1fb419..8ff96676 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -110,7 +110,7 @@ MACRO_CONFIG_INT(SvAnticamperRange, sv_anticamper_range, 200, 0, 1000, CFGFLAG_S MACRO_CONFIG_INT(SvGrenadeMinDamage, sv_grenade_min_damage, 4, 1, 6, CFGFLAG_SERVER, "How much damage the grenade must do to kill the player (depends how far away it explodes)") MACRO_CONFIG_INT(SvGrenadeEndlessAmmo, sv_grenade_endless_ammo, 1, 0, 1, CFGFLAG_SERVER, "Endless ammo for grenade (only mode 4). If not zero, set sv_grenade_bullets for the number of bullets") -MACRO_CONFIG_INT(SvWeaponsAmmo, sv_weapons_ammo, 7, 5, 10, CFGFLAG_SERVER, "Default amount of ammo for all weapons in mode 2 or grenade in mode 4. Your ammo will regenerate after some while") +MACRO_CONFIG_INT(SvWeaponsAmmo, sv_weapons_ammo, 4, 1, 10, CFGFLAG_SERVER, "Default amount of ammo for all weapons in mode 2 or grenade in mode 4. Your ammo will regenerate after some while") MACRO_CONFIG_INT(SvVoteForceReason, sv_vote_forcereason, 1, 0, 1, CFGFLAG_SERVER, "Allow only votes with a reason (except settings)") MACRO_CONFIG_INT(SvSuicideTime, sv_suicide_time, 15, 0, 60, CFGFLAG_SERVER, "Minimum time between suicides. 0 to forbid suicides completely") |