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) if(m_Core.m_Jetpack)
{ {
float Strength; float Strength = GetTuning(m_TuneZone)->m_JetpackStrength;
if(!m_TuneZone)
Strength = Tuning()->m_JetpackStrength;
else
Strength = TuningList()[m_TuneZone].m_JetpackStrength;
TakeDamage(Direction * -1.0f * (Strength / 100.0f / 6.11f), 0, m_pPlayer->GetCid(), m_Core.m_ActiveWeapon); 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 // Set velocity
m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity; m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
vec2 OldPos = m_Pos; vec2 OldPos = m_Pos;
vec2 GroundElasticity; vec2 GroundElasticity = vec2(
GetTuning(m_TuneZone)->m_GroundElasticityX,
if(!m_TuneZone) GetTuning(m_TuneZone)->m_GroundElasticityY);
GroundElasticity = vec2(Tuning()->m_GroundElasticityX, Tuning()->m_GroundElasticityY);
else
GroundElasticity = vec2(TuningList()[m_TuneZone].m_GroundElasticityX, TuningList()[m_TuneZone].m_GroundElasticityY);
Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), GroundElasticity); Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), GroundElasticity);
@ -498,11 +491,7 @@ void CCharacter::FireWeapon()
else else
Dir = vec2(0.f, -1.f); Dir = vec2(0.f, -1.f);
float Strength; float Strength = GetTuning(m_TuneZone)->m_HammerStrength;
if(!m_TuneZone)
Strength = Tuning()->m_HammerStrength;
else
Strength = TuningList()[m_TuneZone].m_HammerStrength;
vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f; vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f;
Temp = ClampVel(pTarget->m_MoveRestrictions, Temp); 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 we Hit anything, we have to wait for the reload
if(Hits) if(Hits)
{ {
float FireDelay; float FireDelay = GetTuning(m_TuneZone)->m_HammerHitFireDelay;
if(!m_TuneZone)
FireDelay = Tuning()->m_HammerHitFireDelay;
else
FireDelay = TuningList()[m_TuneZone].m_HammerHitFireDelay;
m_ReloadTimer = FireDelay * Server()->TickSpeed() / 1000; 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) if(!m_Core.m_Jetpack || !m_pPlayer->m_NinjaJetpack || m_Core.m_HasTelegunGun)
{ {
int Lifetime; int Lifetime = (int)(Server()->TickSpeed() * GetTuning(m_TuneZone)->m_GunLifetime);
if(!m_TuneZone)
Lifetime = (int)(Server()->TickSpeed() * Tuning()->m_GunLifetime);
else
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GunLifetime);
new CProjectile( new CProjectile(
GameWorld(), GameWorld(),
@ -562,11 +543,7 @@ void CCharacter::FireWeapon()
case WEAPON_SHOTGUN: case WEAPON_SHOTGUN:
{ {
float LaserReach; float LaserReach = GetTuning(m_TuneZone)->m_LaserReach;
if(!m_TuneZone)
LaserReach = Tuning()->m_LaserReach;
else
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN); 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) GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
@ -575,11 +552,7 @@ void CCharacter::FireWeapon()
case WEAPON_GRENADE: case WEAPON_GRENADE:
{ {
int Lifetime; int Lifetime = (int)(Server()->TickSpeed() * GetTuning(m_TuneZone)->m_GrenadeLifetime);
if(!m_TuneZone)
Lifetime = (int)(Server()->TickSpeed() * Tuning()->m_GrenadeLifetime);
else
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GrenadeLifetime);
new CProjectile( new CProjectile(
GameWorld(), GameWorld(),
@ -600,11 +573,7 @@ void CCharacter::FireWeapon()
case WEAPON_LASER: case WEAPON_LASER:
{ {
float LaserReach; float LaserReach = GetTuning(m_TuneZone)->m_LaserReach;
if(!m_TuneZone)
LaserReach = Tuning()->m_LaserReach;
else
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER); 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) GameServer()->CreateSound(m_Pos, SOUND_LASER_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
@ -630,10 +599,7 @@ void CCharacter::FireWeapon()
if(!m_ReloadTimer) if(!m_ReloadTimer)
{ {
float FireDelay; float FireDelay;
if(!m_TuneZone) GetTuning(m_TuneZone)->Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
Tuning()->Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
else
TuningList()[m_TuneZone].Get(38 + m_Core.m_ActiveWeapon, &FireDelay);
m_ReloadTimer = FireDelay * Server()->TickSpeed() / 1000; m_ReloadTimer = FireDelay * Server()->TickSpeed() / 1000;
} }
} }

View file

@ -263,6 +263,7 @@ public:
bool IsSuper() const { return m_Core.m_Super; } bool IsSuper() const { return m_Core.m_Super; }
CSaveTee &GetLastRescueTeeRef(int Mode = RESCUEMODE_AUTO) { return m_RescueTee[Mode]; } CSaveTee &GetLastRescueTeeRef(int Mode = RESCUEMODE_AUTO) { return m_RescueTee[Mode]; }
CTuningParams *GetTuning(int Zone) { return Zone ? &TuningList()[Zone] : Tuning(); }
}; };
enum enum