Clean up EarlyFire entity gametick logic

This commit is contained in:
Tater 2024-06-03 01:02:03 -05:00
parent ec4f377194
commit f27086df60
6 changed files with 35 additions and 33 deletions

View file

@ -514,11 +514,7 @@ void CCharacter::FireWeapon(bool EarlyFire)
else
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GunLifetime);
int StartTick = Server()->Tick();
if(EarlyFire)
StartTick--;
new CProjectile(
CProjectile *Projectile = new CProjectile(
GameWorld(),
WEAPON_GUN, //Type
m_pPlayer->GetCid(), //Owner
@ -528,11 +524,10 @@ void CCharacter::FireWeapon(bool EarlyFire)
false, //Freeze
false, //Explosive
-1, //SoundImpact
MouseTarget, //InitDir
0,
0,
StartTick // StartTick
MouseTarget //InitDir
);
if(EarlyFire)
Projectile->SetStartTick(Server()->Tick() - 1);
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
}
@ -547,7 +542,10 @@ void CCharacter::FireWeapon(bool EarlyFire)
else
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN, EarlyFire);
CLaser *Laser = new CLaser(&GameServer()->m_World, m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_SHOTGUN);
if(EarlyFire)
Laser->SetEvalTick(Server()->Tick() - 1);
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
}
break;
@ -560,11 +558,7 @@ void CCharacter::FireWeapon(bool EarlyFire)
else
Lifetime = (int)(Server()->TickSpeed() * TuningList()[m_TuneZone].m_GrenadeLifetime);
int StartTick = Server()->Tick();
if(EarlyFire)
StartTick--;
new CProjectile(
CProjectile *Projectile = new CProjectile(
GameWorld(),
WEAPON_GRENADE, //Type
m_pPlayer->GetCid(), //Owner
@ -574,11 +568,10 @@ void CCharacter::FireWeapon(bool EarlyFire)
false, //Freeze
true, //Explosive
SOUND_GRENADE_EXPLODE, //SoundImpact
MouseTarget, // MouseTarget
0,
0,
StartTick //StartTick
MouseTarget // MouseTarget
);
if(EarlyFire)
Projectile->SetStartTick(Server()->Tick() - 1);
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE, TeamMask());
}
@ -592,7 +585,10 @@ void CCharacter::FireWeapon(bool EarlyFire)
else
LaserReach = TuningList()[m_TuneZone].m_LaserReach;
new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER, EarlyFire);
CLaser *Laser = new CLaser(GameWorld(), m_Pos, Direction, LaserReach, m_pPlayer->GetCid(), WEAPON_LASER);
if(EarlyFire)
Laser->SetEvalTick(Server()->Tick() - 1);
GameServer()->CreateSound(m_Pos, SOUND_LASER_FIRE, TeamMask()); // NOLINT(clang-analyzer-unix.Malloc)
}
break;

View file

@ -11,7 +11,7 @@
#include <game/server/gamecontext.h>
#include <game/server/gamemodes/DDRace.h>
CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type, bool EarlyTick) :
CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type) :
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{
m_Pos = Pos;
@ -32,7 +32,12 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner
m_BelongsToPracticeTeam = pOwnerChar && pOwnerChar->Teams()->IsPractice(pOwnerChar->Team());
GameWorld()->InsertEntity(this);
DoBounce(EarlyTick);
DoBounce();
}
void CLaser::SetEvalTick(int Tick)
{
m_EvalTick = Tick;
}
bool CLaser::HitCharacter(vec2 From, vec2 To)

View file

@ -14,8 +14,7 @@ public:
vec2 Direction,
float StartEnergy,
int Owner,
int Type,
bool EarlyTick = false);
int Type);
virtual void Reset() override;
virtual void Tick() override;
@ -49,6 +48,9 @@ private:
bool m_TeleportCancelled;
bool m_IsBlueTeleport;
bool m_BelongsToPracticeTeam;
public:
void SetEvalTick(int Tick);
};
#endif

View file

@ -23,8 +23,7 @@ CProjectile::CProjectile(
int SoundImpact,
vec2 InitDir,
int Layer,
int Number,
int StartTick) :
int Number) :
CEntity(pGameWorld, CGameWorld::ENTTYPE_PROJECTILE)
{
m_Type = Type;
@ -35,10 +34,6 @@ CProjectile::CProjectile(
//m_Damage = Damage;
m_SoundImpact = SoundImpact;
m_StartTick = Server()->Tick();
if(StartTick >= 0)
m_StartTick = StartTick;
m_Explosive = Explosive;
m_Layer = Layer;
@ -54,6 +49,11 @@ CProjectile::CProjectile(
GameWorld()->InsertEntity(this);
}
void CProjectile::SetStartTick(int Tick)
{
m_StartTick = Tick;
}
void CProjectile::Reset()
{
m_MarkedForDestroy = true;

View file

@ -20,8 +20,7 @@ public:
int SoundImpact,
vec2 InitDir,
int Layer = 0,
int Number = 0,
int StartTick = -1);
int Number = 0);
vec2 GetPos(float Time);
void FillInfo(CNetObj_Projectile *pProj);
@ -51,6 +50,7 @@ private:
vec2 m_InitDir;
public:
void SetStartTick(int Tick);
void SetBouncing(int Value);
bool FillExtraInfoLegacy(CNetObj_DDRaceProjectile *pProj);
void FillExtraInfo(CNetObj_DDNetProjectile *pProj);

View file

@ -59,7 +59,6 @@ public:
void OnPlayerFreshInput(CNetObj_PlayerInput *pNewInput);
void OnPlayerInput(CNetObj_PlayerInput *pNewInput);
void OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput);
void OnDisconnect();
void KillCharacter(int Weapon = WEAPON_GAME, bool SendKillMsg = true);