mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Simplify character tuning code
entities/character.cpp now has the same api as prediction/entities/character.cpp
This commit is contained in:
parent
60688bf80e
commit
c02a2ed1d6
|
@ -234,11 +234,7 @@ void CCharacter::HandleJetpack()
|
|||
{
|
||||
if(m_Core.m_Jetpack)
|
||||
{
|
||||
float Strength;
|
||||
if(!m_TuneZone)
|
||||
Strength = Tuning()->m_JetpackStrength;
|
||||
else
|
||||
Strength = TuningList()[m_TuneZone].m_JetpackStrength;
|
||||
float Strength = GetTuning(m_TuneZone)->m_JetpackStrength;
|
||||
TakeDamage(Direction * -1.0f * (Strength / 100.0f / 6.11f), 0, m_pPlayer->GetCid(), m_Core.m_ActiveWeapon);
|
||||
}
|
||||
}
|
||||
|
@ -282,12 +278,9 @@ void CCharacter::HandleNinja()
|
|||
// Set velocity
|
||||
m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
|
||||
vec2 OldPos = m_Pos;
|
||||
vec2 GroundElasticity;
|
||||
|
||||
if(!m_TuneZone)
|
||||
GroundElasticity = vec2(Tuning()->m_GroundElasticityX, Tuning()->m_GroundElasticityY);
|
||||
else
|
||||
GroundElasticity = vec2(TuningList()[m_TuneZone].m_GroundElasticityX, TuningList()[m_TuneZone].m_GroundElasticityY);
|
||||
vec2 GroundElasticity = vec2(
|
||||
GetTuning(m_TuneZone)->m_GroundElasticityX,
|
||||
GetTuning(m_TuneZone)->m_GroundElasticityY);
|
||||
|
||||
Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), GroundElasticity);
|
||||
|
||||
|
@ -498,11 +491,7 @@ void CCharacter::FireWeapon()
|
|||
else
|
||||
Dir = vec2(0.f, -1.f);
|
||||
|
||||
float Strength;
|
||||
if(!m_TuneZone)
|
||||
Strength = Tuning()->m_HammerStrength;
|
||||
else
|
||||
Strength = TuningList()[m_TuneZone].m_HammerStrength;
|
||||
float Strength = GetTuning(m_TuneZone)->m_HammerStrength;
|
||||
|
||||
vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f;
|
||||
Temp = ClampVel(pTarget->m_MoveRestrictions, Temp);
|
||||
|
@ -522,11 +511,7 @@ void CCharacter::FireWeapon()
|
|||
// if we Hit anything, we have to wait for the reload
|
||||
if(Hits)
|
||||
{
|
||||
float FireDelay;
|
||||
if(!m_TuneZone)
|
||||
FireDelay = Tuning()->m_HammerHitFireDelay;
|
||||
else
|
||||
FireDelay = TuningList()[m_TuneZone].m_HammerHitFireDelay;
|
||||
float FireDelay = GetTuning(m_TuneZone)->m_HammerHitFireDelay;
|
||||
m_ReloadTimer = FireDelay * Server()->TickSpeed() / 1000;
|
||||
}
|
||||
}
|
||||
|
@ -536,11 +521,7 @@ void CCharacter::FireWeapon()
|
|||
{
|
||||
if(!m_Core.m_Jetpack || !m_pPlayer->m_NinjaJetpack || m_Core.m_HasTelegunGun)
|
||||
{
|
||||
int Lifetime;
|
||||
if(!m_TuneZone)
|
||||
Lifetime = (int)(Server()->TickSpeed() * Tuning()->m_GunLifetime);
|
||||
else
|
||||
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GunLifetime);
|
||||
int Lifetime = (int)(Server()->TickSpeed() * GetTuning(m_TuneZone)->m_GunLifetime);
|
||||
|
||||
new CProjectile(
|
||||
GameWorld(),
|
||||
|
@ -562,11 +543,7 @@ void CCharacter::FireWeapon()
|
|||
|
||||
case WEAPON_SHOTGUN:
|
||||
{
|
||||
float LaserReach;
|
||||
if(!m_TuneZone)
|
||||
LaserReach = Tuning()->m_LaserReach;
|
||||
else
|
||||
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
|
||||
float LaserReach = GetTuning(m_TuneZone)->m_LaserReach;
|
||||
|
||||
new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN);
|
||||
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
|
||||
|
@ -575,11 +552,7 @@ void CCharacter::FireWeapon()
|
|||
|
||||
case WEAPON_GRENADE:
|
||||
{
|
||||
int Lifetime;
|
||||
if(!m_TuneZone)
|
||||
Lifetime = (int)(Server()->TickSpeed() * Tuning()->m_GrenadeLifetime);
|
||||
else
|
||||
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GrenadeLifetime);
|
||||
int Lifetime = (int)(Server()->TickSpeed() * GetTuning(m_TuneZone)->m_GrenadeLifetime);
|
||||
|
||||
new CProjectile(
|
||||
GameWorld(),
|
||||
|
@ -600,11 +573,7 @@ void CCharacter::FireWeapon()
|
|||
|
||||
case WEAPON_LASER:
|
||||
{
|
||||
float LaserReach;
|
||||
if(!m_TuneZone)
|
||||
LaserReach = Tuning()->m_LaserReach;
|
||||
else
|
||||
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
|
||||
float LaserReach = GetTuning(m_TuneZone)->m_LaserReach;
|
||||
|
||||
new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER);
|
||||
GameServer()->CreateSound(m_Pos, SOUND_LASER_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
|
||||
|
@ -630,10 +599,7 @@ void CCharacter::FireWeapon()
|
|||
if(!m_ReloadTimer)
|
||||
{
|
||||
float FireDelay;
|
||||
if(!m_TuneZone)
|
||||
Tuning()->Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
|
||||
else
|
||||
TuningList()[m_TuneZone].Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
|
||||
GetTuning(m_TuneZone)->Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
|
||||
m_ReloadTimer = FireDelay * Server()->TickSpeed() / 1000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,6 +263,7 @@ public:
|
|||
bool IsSuper() const { return m_Core.m_Super; }
|
||||
|
||||
CSaveTee &GetLastRescueTeeRef(int Mode = RESCUEMODE_AUTO) { return m_RescueTee[Mode]; }
|
||||
CTuningParams *GetTuning(int Zone) { return Zone ? &TuningList()[Zone] : Tuning(); }
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in a new issue