mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
using weapon damage for explosion damage
removed unused nodamage parameter in CreateExplosion took projectile damage for explosion maxdamage replaced some 0s by false as it should be
This commit is contained in:
parent
c9bdc32fc0
commit
ee2d53b411
|
@ -160,7 +160,6 @@ class Weapons(Struct):
|
|||
class Explosion(Struct):
|
||||
def __init__(self):
|
||||
Struct.__init__(self, "CDataExplosion")
|
||||
self.max_damage = Int(6)
|
||||
self.radius = Float(135)
|
||||
self.max_force = Float(12)
|
||||
|
||||
|
@ -563,7 +562,7 @@ container.weapons.id.Add(weapon)
|
|||
|
||||
weapon = WeaponSpec(container, "grenade")
|
||||
weapon.firedelay.Set(500) # TODO: fix this
|
||||
weapon.damage.Set(0)
|
||||
weapon.damage.Set(6)
|
||||
weapon.visual_size.Set(96)
|
||||
weapon.offsetx.Set(24)
|
||||
weapon.offsety.Set(-2)
|
||||
|
|
|
@ -334,7 +334,7 @@ void CCharacter::FireWeapon()
|
|||
ProjStartPos,
|
||||
Direction,
|
||||
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
|
||||
g_pData->m_Weapons.m_Gun.m_pBase->m_Damage, 0, 0, -1, WEAPON_GUN);
|
||||
g_pData->m_Weapons.m_Gun.m_pBase->m_Damage, false, 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),
|
||||
g_pData->m_Weapons.m_Shotgun.m_pBase->m_Damage, 0, 0, -1, WEAPON_SHOTGUN);
|
||||
g_pData->m_Weapons.m_Shotgun.m_pBase->m_Damage, false, 0, -1, WEAPON_SHOTGUN);
|
||||
|
||||
// pack the Projectile and send it to the client Directly
|
||||
CNetObj_Projectile p;
|
||||
|
|
|
@ -74,7 +74,7 @@ void CProjectile::Tick()
|
|||
GameServer()->CreateSound(CurPos, m_SoundImpact);
|
||||
|
||||
if(m_Explosive)
|
||||
GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, false);
|
||||
GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, m_Damage);
|
||||
|
||||
else if(TargetChr)
|
||||
TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);
|
||||
|
|
|
@ -123,7 +123,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, int MaxDamage)
|
||||
{
|
||||
// create the event
|
||||
CNetEvent_Explosion *pEvent = (CNetEvent_Explosion *)m_Events.Create(NETEVENTTYPE_EXPLOSION, sizeof(CNetEvent_Explosion));
|
||||
|
@ -133,29 +133,21 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag
|
|||
pEvent->m_Y = (int)Pos.y;
|
||||
}
|
||||
|
||||
if (!NoDamage)
|
||||
// deal damage
|
||||
CCharacter *apEnts[MAX_CLIENTS];
|
||||
float Radius = g_pData->m_Explosion.m_Radius;
|
||||
float InnerRadius = 48.0f;
|
||||
float MaxForce = g_pData->m_Explosion.m_MaxForce;
|
||||
int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||
for(int i = 0; i < Num; i++)
|
||||
{
|
||||
// deal damage
|
||||
CCharacter *apEnts[MAX_CLIENTS];
|
||||
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 Force(0, MaxForce);
|
||||
float l = length(Diff);
|
||||
if(l)
|
||||
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);
|
||||
}
|
||||
vec2 Diff = apEnts[i]->m_Pos - Pos;
|
||||
vec2 Force(0, MaxForce);
|
||||
float l = length(Diff);
|
||||
if(l)
|
||||
Force = normalize(Diff) * MaxForce;
|
||||
float Factor = 1 - clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f);
|
||||
apEnts[i]->TakeDamage(Force * Factor, (int)(Factor * MaxDamage), Owner, Weapon);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
|
||||
// helper functions
|
||||
void CreateDamageInd(vec2 Pos, float AngleMod, int Amount);
|
||||
void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage);
|
||||
void CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamage);
|
||||
void CreateHammerHit(vec2 Pos);
|
||||
void CreatePlayerSpawn(vec2 Pos);
|
||||
void CreateDeath(vec2 Pos, int Who);
|
||||
|
|
Loading…
Reference in a new issue