Merge pull request #8851 from ChillerDragon/pr_chr_get_tuning

Simplify character tuning code
This commit is contained in:
Dennis Felsing 2024-08-31 08:24:42 +00:00 committed by GitHub
commit a83248b9ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 45 deletions

View file

@ -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;
}
}

View file

@ -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