From c9bdc32fc086be241f4be420566d7a02a49f203f Mon Sep 17 00:00:00 2001 From: Speedy Consoles Date: Sat, 14 Sep 2013 21:33:52 +0200 Subject: [PATCH] cleaned up weapon value locations removed laser damage tuning added explosion values in content.py made explosion force independent from damage linked all weapon damage values to content.py linked all weapon max ammo values to content.py stopped regenerating infinite ammo removed m_Ammocost in CCharacter --- datasrc/content.py | 13 ++++++++++++- src/game/server/entities/character.cpp | 11 ++++++----- src/game/server/entities/character.h | 1 - src/game/server/entities/laser.cpp | 3 ++- src/game/server/entities/pickup.cpp | 6 +++--- src/game/server/gamecontext.cpp | 19 ++++++++++++------- src/game/tuning.h | 1 - 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/datasrc/content.py b/datasrc/content.py index 3298f927f..128c38254 100644 --- a/datasrc/content.py +++ b/datasrc/content.py @@ -157,6 +157,13 @@ class Weapons(Struct): self.ninja = Weapon_Ninja() self.id = Array(WeaponSpec()) +class Explosion(Struct): + def __init__(self): + Struct.__init__(self, "CDataExplosion") + self.max_damage = Int(6) + self.radius = Float(135) + self.max_force = Float(12) + class DataContainer(Struct): def __init__(self): Struct.__init__(self, "CDataContainer") @@ -167,6 +174,7 @@ class DataContainer(Struct): self.sprites = Array(Sprite()) self.animations = Array(Animation()) self.weapons = Weapons() + self.explosion = Explosion() def FileList(format, num): return [format%(x+1) for x in range(0,num)] @@ -532,6 +540,7 @@ container.weapons.id.Add(weapon) weapon = WeaponSpec(container, "gun") weapon.firedelay.Set(125) +weapon.damage.Set(1) weapon.ammoregentime.Set(500) weapon.visual_size.Set(64) weapon.offsetx.Set(32) @@ -543,6 +552,7 @@ container.weapons.id.Add(weapon) weapon = WeaponSpec(container, "shotgun") weapon.firedelay.Set(500) +weapon.damage.Set(1) weapon.visual_size.Set(96) weapon.offsetx.Set(24) weapon.offsety.Set(-2) @@ -553,6 +563,7 @@ container.weapons.id.Add(weapon) weapon = WeaponSpec(container, "grenade") weapon.firedelay.Set(500) # TODO: fix this +weapon.damage.Set(0) weapon.visual_size.Set(96) weapon.offsetx.Set(24) weapon.offsety.Set(-2) @@ -561,8 +572,8 @@ container.weapons.id.Add(weapon) weapon = WeaponSpec(container, "laser") weapon.firedelay.Set(800) -weapon.visual_size.Set(92) weapon.damage.Set(5) +weapon.visual_size.Set(92) weapon.offsetx.Set(24) weapon.offsety.Set(-2) container.weapons.laser.base.Set(weapon) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0919c4089..8b15e8304 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -334,7 +334,7 @@ void CCharacter::FireWeapon() ProjStartPos, Direction, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime), - 1, 0, 0, -1, WEAPON_GUN); + g_pData->m_Weapons.m_Gun.m_pBase->m_Damage, 0, 0, -1, WEAPON_GUN); // pack the Projectile and send it to the client Directly CNetObj_Projectile p; @@ -369,7 +369,7 @@ void CCharacter::FireWeapon() ProjStartPos, vec2(cosf(a), sinf(a))*Speed, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_ShotgunLifetime), - 1, 0, 0, -1, WEAPON_SHOTGUN); + g_pData->m_Weapons.m_Shotgun.m_pBase->m_Damage, 0, 0, -1, WEAPON_SHOTGUN); // pack the Projectile and send it to the client Directly CNetObj_Projectile p; @@ -391,7 +391,7 @@ void CCharacter::FireWeapon() ProjStartPos, Direction, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime), - 1, true, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); + g_pData->m_Weapons.m_Grenade.m_pBase->m_Damage, true, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); // pack the Projectile and send it to the client Directly CNetObj_Projectile p; @@ -452,7 +452,7 @@ void CCharacter::HandleWeapons() // ammo regen int AmmoRegenTime = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Ammoregentime; - if(AmmoRegenTime) + if(AmmoRegenTime && m_aWeapons[m_ActiveWeapon].m_Ammo >= 0) { // If equipped and not active, regen ammo? if (m_ReloadTimer <= 0) @@ -463,7 +463,8 @@ void CCharacter::HandleWeapons() if ((Server()->Tick() - m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart) >= AmmoRegenTime * Server()->TickSpeed() / 1000) { // Add some ammo - m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, 10); + m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, + g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Maxammo); m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1; } } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index bcc36e03c..96c710d1b 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -69,7 +69,6 @@ private: { int m_AmmoRegenStart; int m_Ammo; - int m_Ammocost; bool m_Got; } m_aWeapons[NUM_WEAPONS]; diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 67e2b4a8d..a23e52ef2 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -1,5 +1,6 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include #include #include "character.h" @@ -30,7 +31,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) m_From = From; m_Pos = At; m_Energy = -1; - pHit->TakeDamage(vec2(0.f, 0.f), GameServer()->Tuning()->m_LaserDamage, m_Owner, WEAPON_LASER); + pHit->TakeDamage(vec2(0.f, 0.f), g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Damage, m_Owner, WEAPON_LASER); return true; } diff --git a/src/game/server/entities/pickup.cpp b/src/game/server/entities/pickup.cpp index 254aa5ca2..d3eb2c570 100644 --- a/src/game/server/entities/pickup.cpp +++ b/src/game/server/entities/pickup.cpp @@ -67,7 +67,7 @@ void CPickup::Tick() break; case PICKUP_GRENADE: - if(pChr->GiveWeapon(WEAPON_GRENADE, 10)) + if(pChr->GiveWeapon(WEAPON_GRENADE, g_pData->m_Weapons.m_aId[WEAPON_GRENADE].m_Maxammo)) { RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE); @@ -76,7 +76,7 @@ void CPickup::Tick() } break; case PICKUP_SHOTGUN: - if(pChr->GiveWeapon(WEAPON_SHOTGUN, 10)) + if(pChr->GiveWeapon(WEAPON_SHOTGUN, g_pData->m_Weapons.m_aId[WEAPON_SHOTGUN].m_Maxammo)) { RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN); @@ -85,7 +85,7 @@ void CPickup::Tick() } break; case PICKUP_LASER: - if(pChr->GiveWeapon(WEAPON_LASER, 10)) + if(pChr->GiveWeapon(WEAPON_LASER, g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Maxammo)) { RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index c65497728..f27a6cb4f 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -136,20 +137,24 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag { // deal damage CCharacter *apEnts[MAX_CLIENTS]; - float Radius = 135.0f; + float Radius = g_pData->m_Explosion.m_Radius; float InnerRadius = 48.0f; + float MaxForce = g_pData->m_Explosion.m_MaxForce; + int MaxDamage = g_pData->m_Explosion.m_MaxDamage; 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); + vec2 Force(0, MaxForce); 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); + Force = normalize(Diff) * MaxForce; + float Factor = 1 - clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); + Force *= Factor; + if(NoDamage) + apEnts[i]->TakeDamage(Force, 0, Owner, Weapon); + else + apEnts[i]->TakeDamage(Force, (int)(Factor * MaxDamage), Owner, Weapon); } } } diff --git a/src/game/tuning.h b/src/game/tuning.h index 5bdb576e0..ecd7ef08d 100644 --- a/src/game/tuning.h +++ b/src/game/tuning.h @@ -41,7 +41,6 @@ MACRO_TUNING_PARAM(LaserReach, laser_reach, 800.0f) MACRO_TUNING_PARAM(LaserBounceDelay, laser_bounce_delay, 150) MACRO_TUNING_PARAM(LaserBounceNum, laser_bounce_num, 1) MACRO_TUNING_PARAM(LaserBounceCost, laser_bounce_cost, 0) -MACRO_TUNING_PARAM(LaserDamage, laser_damage, 5) MACRO_TUNING_PARAM(PlayerCollision, player_collision, 1) MACRO_TUNING_PARAM(PlayerHooking, player_hooking, 1)