move m_Ninja in Character Core

This commit is contained in:
c0d3d3v 2022-03-24 01:05:41 +01:00
parent 320e9e030f
commit 3957a7404e
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
7 changed files with 52 additions and 56 deletions

View file

@ -54,6 +54,7 @@ class CHud : public CComponent
void PreparePlayerStateQuads(); void PreparePlayerStateQuads();
void RenderPlayerState(const int ClientID); void RenderPlayerState(const int ClientID);
void RenderNinjaBar(float x, float y, float Progress);
void RenderGameTimer(); void RenderGameTimer();
void RenderPauseNotification(); void RenderPauseNotification();
@ -101,9 +102,12 @@ private:
int m_FlagOffset; int m_FlagOffset;
int m_AirjumpOffset; int m_AirjumpOffset;
int m_AirjumpEmptyOffset; int m_AirjumpEmptyOffset;
int m_WeaponHammerOffset;
int m_WeaponGunOffset;
int m_WeaponShotgunOffset; int m_WeaponShotgunOffset;
int m_WeaponGrenadeOffset; int m_WeaponGrenadeOffset;
int m_WeaponLaserOffset; int m_WeaponLaserOffset;
int m_WeaponNinjaOffset;
int m_EndlessJumpOffset; int m_EndlessJumpOffset;
int m_EndlessHookOffset; int m_EndlessHookOffset;
int m_JetpackOffset; int m_JetpackOffset;
@ -119,10 +123,10 @@ private:
int m_NoLaserHitOffset; int m_NoLaserHitOffset;
int m_DummyHammerOffset; int m_DummyHammerOffset;
int m_DummyCopyOffset; int m_DummyCopyOffset;
// int m_FreezeBarFullLeftOffset; int m_NinjaBarFullLeftOffset;
// int m_FreezeBarFullOffset; int m_NinjaBarFullOffset;
// int m_FreezeBarEmptyOffset; int m_NinjaBarEmptyOffset;
// int m_FreezeBarEmptyRightOffset; int m_NinjaBarEmptyRightOffset;
}; };
#endif #endif

View file

@ -87,7 +87,7 @@ void CCharacter::HandleJetpack()
void CCharacter::RemoveNinja() void CCharacter::RemoveNinja()
{ {
m_Ninja.m_CurrentMoveTime = 0; m_Core.m_Ninja.m_CurrentMoveTime = 0;
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false; m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false;
m_Core.m_ActiveWeapon = m_LastWeapon; m_Core.m_ActiveWeapon = m_LastWeapon;
@ -99,7 +99,7 @@ void CCharacter::HandleNinja()
if(m_Core.m_ActiveWeapon != WEAPON_NINJA) if(m_Core.m_ActiveWeapon != WEAPON_NINJA)
return; return;
if((GameWorld()->GameTick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * GameWorld()->GameTickSpeed() / 1000)) if((GameWorld()->GameTick() - m_Core.m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * GameWorld()->GameTickSpeed() / 1000))
{ {
// time's up, return // time's up, return
RemoveNinja(); RemoveNinja();
@ -109,18 +109,18 @@ void CCharacter::HandleNinja()
// force ninja Weapon // force ninja Weapon
SetWeapon(WEAPON_NINJA); SetWeapon(WEAPON_NINJA);
m_Ninja.m_CurrentMoveTime--; m_Core.m_Ninja.m_CurrentMoveTime--;
if(m_Ninja.m_CurrentMoveTime == 0) if(m_Core.m_Ninja.m_CurrentMoveTime == 0)
{ {
// reset velocity // reset velocity
m_Core.m_Vel = m_Ninja.m_ActivationDir * m_Ninja.m_OldVelAmount; m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * m_Core.m_Ninja.m_OldVelAmount;
} }
if(m_Ninja.m_CurrentMoveTime > 0) if(m_Core.m_Ninja.m_CurrentMoveTime > 0)
{ {
// Set velocity // Set velocity
m_Core.m_Vel = 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;
Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f); Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f);
@ -445,9 +445,9 @@ void CCharacter::FireWeapon()
// reset Hit objects // reset Hit objects
m_NumObjectsHit = 0; m_NumObjectsHit = 0;
m_Ninja.m_ActivationDir = Direction; m_Core.m_Ninja.m_ActivationDir = Direction;
m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * GameWorld()->GameTickSpeed() / 1000; m_Core.m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * GameWorld()->GameTickSpeed() / 1000;
m_Ninja.m_OldVelAmount = length(m_Core.m_Vel); m_Core.m_Ninja.m_OldVelAmount = length(m_Core.m_Vel);
} }
break; break;
} }
@ -482,7 +482,7 @@ void CCharacter::HandleWeapons()
void CCharacter::GiveNinja() void CCharacter::GiveNinja()
{ {
m_Ninja.m_ActivationTick = GameWorld()->GameTick(); m_Core.m_Ninja.m_ActivationTick = GameWorld()->GameTick();
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true; m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true;
if(!m_FreezeTime) if(!m_FreezeTime)
m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1; m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
@ -923,7 +923,7 @@ void CCharacter::DDRaceTick()
if(m_FreezeTime > 0) if(m_FreezeTime > 0)
m_FreezeTime--; m_FreezeTime--;
else else
m_Ninja.m_ActivationTick = GameWorld()->GameTick(); m_Core.m_Ninja.m_ActivationTick = GameWorld()->GameTick();
if(!m_CanMoveInFreeze) if(!m_CanMoveInFreeze)
{ {
m_Input.m_Direction = 0; m_Input.m_Direction = 0;
@ -1060,7 +1060,7 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
m_Core.Reset(); m_Core.Reset();
m_Core.Init(&GameWorld()->m_Core, GameWorld()->Collision(), GameWorld()->Teams()); m_Core.Init(&GameWorld()->m_Core, GameWorld()->Collision(), GameWorld()->Teams());
m_Core.m_Id = ID; m_Core.m_Id = ID;
mem_zero(&m_Ninja, sizeof(m_Ninja)); mem_zero(&m_Core.m_Ninja, sizeof(m_Core.m_Ninja));
mem_zero(&m_SavedInput, sizeof(m_SavedInput)); mem_zero(&m_SavedInput, sizeof(m_SavedInput));
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput; m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
m_ProximityRadius = ms_PhysSize; m_ProximityRadius = ms_PhysSize;

View file

@ -116,9 +116,9 @@ public:
void SetWeaponGot(int Type, bool Value) { m_Core.m_aWeapons[Type].m_Got = Value; } void SetWeaponGot(int Type, bool Value) { m_Core.m_aWeapons[Type].m_Got = Value; }
int GetWeaponAmmo(int Type) { return m_Core.m_aWeapons[Type].m_Ammo; } int GetWeaponAmmo(int Type) { return m_Core.m_aWeapons[Type].m_Ammo; }
void SetWeaponAmmo(int Type, int Value) { m_Core.m_aWeapons[Type].m_Ammo = Value; } void SetWeaponAmmo(int Type, int Value) { m_Core.m_aWeapons[Type].m_Ammo = Value; }
void SetNinjaActivationDir(vec2 ActivationDir) { m_Ninja.m_ActivationDir = ActivationDir; } void SetNinjaActivationDir(vec2 ActivationDir) { m_Core.m_Ninja.m_ActivationDir = ActivationDir; }
void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; } void SetNinjaActivationTick(int ActivationTick) { m_Core.m_Ninja.m_ActivationTick = ActivationTick; }
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; } void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Core.m_Ninja.m_CurrentMoveTime = CurrentMoveTime; }
int GetCID() { return m_ID; } int GetCID() { return m_ID; }
void SetInput(CNetObj_PlayerInput *pNewInput) void SetInput(CNetObj_PlayerInput *pNewInput)
{ {
@ -170,15 +170,6 @@ private:
int m_NumInputs; int m_NumInputs;
// ninja
struct NinjaStat
{
vec2 m_ActivationDir;
int m_ActivationTick;
int m_CurrentMoveTime;
int m_OldVelAmount;
} m_Ninja;
// the player core for the physics // the player core for the physics
CCharacterCore m_Core; CCharacterCore m_Core;

View file

@ -580,6 +580,7 @@ void CCharacterCore::ReadDDNet(const CNetObj_DDNetCharacter *pObjDDNet)
m_aWeapons[WEAPON_SHOTGUN].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_SHOTGUN) != 0; m_aWeapons[WEAPON_SHOTGUN].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_SHOTGUN) != 0;
m_aWeapons[WEAPON_GRENADE].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_GRENADE) != 0; m_aWeapons[WEAPON_GRENADE].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_GRENADE) != 0;
m_aWeapons[WEAPON_LASER].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_LASER) != 0; m_aWeapons[WEAPON_LASER].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_LASER) != 0;
m_aWeapons[WEAPON_NINJA].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_NINJA) != 0;
// Available jumps // Available jumps
m_Jumps = pObjDDNet->m_Jumps; m_Jumps = pObjDDNet->m_Jumps;

View file

@ -231,6 +231,15 @@ public:
bool m_Got; bool m_Got;
} m_aWeapons[NUM_WEAPONS]; } m_aWeapons[NUM_WEAPONS];
// ninja
struct
{
vec2 m_ActivationDir;
int m_ActivationTick;
int m_CurrentMoveTime;
int m_OldVelAmount;
} m_Ninja;
bool m_NewHook; bool m_NewHook;
int m_Jumped; int m_Jumped;

View file

@ -185,14 +185,14 @@ void CCharacter::HandleNinja()
if(m_Core.m_ActiveWeapon != WEAPON_NINJA) if(m_Core.m_ActiveWeapon != WEAPON_NINJA)
return; return;
if((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) if((Server()->Tick() - m_Core.m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
{ {
// time's up, return // time's up, return
RemoveNinja(); RemoveNinja();
return; return;
} }
int NinjaTime = m_Ninja.m_ActivationTick + (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000) - Server()->Tick(); int NinjaTime = m_Core.m_Ninja.m_ActivationTick + (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000) - Server()->Tick();
if(NinjaTime % Server()->TickSpeed() == 0 && NinjaTime / Server()->TickSpeed() <= 5) if(NinjaTime % Server()->TickSpeed() == 0 && NinjaTime / Server()->TickSpeed() <= 5)
{ {
@ -204,18 +204,18 @@ void CCharacter::HandleNinja()
// force ninja Weapon // force ninja Weapon
SetWeapon(WEAPON_NINJA); SetWeapon(WEAPON_NINJA);
m_Ninja.m_CurrentMoveTime--; m_Core.m_Ninja.m_CurrentMoveTime--;
if(m_Ninja.m_CurrentMoveTime == 0) if(m_Core.m_Ninja.m_CurrentMoveTime == 0)
{ {
// reset velocity // reset velocity
m_Core.m_Vel = m_Ninja.m_ActivationDir * m_Ninja.m_OldVelAmount; m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * m_Core.m_Ninja.m_OldVelAmount;
} }
if(m_Ninja.m_CurrentMoveTime > 0) if(m_Core.m_Ninja.m_CurrentMoveTime > 0)
{ {
// Set velocity // Set velocity
m_Core.m_Vel = 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;
GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), 0.f); GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), 0.f);
@ -569,9 +569,9 @@ void CCharacter::FireWeapon()
// reset Hit objects // reset Hit objects
m_NumObjectsHit = 0; m_NumObjectsHit = 0;
m_Ninja.m_ActivationDir = Direction; m_Core.m_Ninja.m_ActivationDir = Direction;
m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000; m_Core.m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000;
m_Ninja.m_OldVelAmount = length(m_Core.m_Vel); m_Core.m_Ninja.m_OldVelAmount = length(m_Core.m_Vel);
GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
} }
@ -616,7 +616,7 @@ void CCharacter::HandleWeapons()
void CCharacter::GiveNinja() void CCharacter::GiveNinja()
{ {
m_Ninja.m_ActivationTick = Server()->Tick(); m_Core.m_Ninja.m_ActivationTick = Server()->Tick();
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true; m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true;
m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1; m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
if(m_Core.m_ActiveWeapon != WEAPON_NINJA) if(m_Core.m_ActiveWeapon != WEAPON_NINJA)
@ -629,7 +629,7 @@ void CCharacter::GiveNinja()
void CCharacter::RemoveNinja() void CCharacter::RemoveNinja()
{ {
m_Ninja.m_CurrentMoveTime = 0; m_Core.m_Ninja.m_CurrentMoveTime = 0;
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false; m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false;
m_Core.m_ActiveWeapon = m_LastWeapon; m_Core.m_ActiveWeapon = m_LastWeapon;
@ -856,7 +856,7 @@ void CCharacter::TickPaused()
{ {
++m_AttackTick; ++m_AttackTick;
++m_DamageTakenTick; ++m_DamageTakenTick;
++m_Ninja.m_ActivationTick; ++m_Core.m_Ninja.m_ActivationTick;
++m_ReckoningTick; ++m_ReckoningTick;
if(m_LastAction != -1) if(m_LastAction != -1)
++m_LastAction; ++m_LastAction;
@ -1147,7 +1147,7 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
if(m_FreezeTime > 0 || m_FreezeTime == -1 || m_DeepFreeze) if(m_FreezeTime > 0 || m_FreezeTime == -1 || m_DeepFreeze)
pCharacter->m_AmmoCount = m_FreezeTick + g_Config.m_SvFreezeDelay * Server()->TickSpeed(); pCharacter->m_AmmoCount = m_FreezeTick + g_Config.m_SvFreezeDelay * Server()->TickSpeed();
else if(Weapon == WEAPON_NINJA) else if(Weapon == WEAPON_NINJA)
pCharacter->m_AmmoCount = m_Ninja.m_ActivationTick + g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000; pCharacter->m_AmmoCount = m_Core.m_Ninja.m_ActivationTick + g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000;
pCharacter->m_Health = Health; pCharacter->m_Health = Health;
pCharacter->m_Armor = Armor; pCharacter->m_Armor = Armor;
@ -2075,7 +2075,7 @@ void CCharacter::DDRaceTick()
if(m_FreezeTime > 0) if(m_FreezeTime > 0)
m_FreezeTime--; m_FreezeTime--;
else else
m_Ninja.m_ActivationTick = Server()->Tick(); m_Core.m_Ninja.m_ActivationTick = Server()->Tick();
m_Input.m_Direction = 0; m_Input.m_Direction = 0;
m_Input.m_Jump = 0; m_Input.m_Jump = 0;
m_Input.m_Hook = 0; m_Input.m_Hook = 0;

View file

@ -128,15 +128,6 @@ private:
int m_Health; int m_Health;
int m_Armor; int m_Armor;
// ninja
struct
{
vec2 m_ActivationDir;
int m_ActivationTick;
int m_CurrentMoveTime;
int m_OldVelAmount;
} m_Ninja;
// the player core for the physics // the player core for the physics
CCharacterCore m_Core; CCharacterCore m_Core;
CGameTeams *m_pTeams = nullptr; CGameTeams *m_pTeams = nullptr;
@ -253,9 +244,9 @@ public:
int GetWeaponAmmo(int Type) { return m_Core.m_aWeapons[Type].m_Ammo; } int GetWeaponAmmo(int Type) { return m_Core.m_aWeapons[Type].m_Ammo; }
void SetWeaponAmmo(int Type, int Value) { m_Core.m_aWeapons[Type].m_Ammo = Value; } void SetWeaponAmmo(int Type, int Value) { m_Core.m_aWeapons[Type].m_Ammo = Value; }
bool IsAlive() { return m_Alive; } bool IsAlive() { return m_Alive; }
void SetNinjaActivationDir(vec2 ActivationDir) { m_Ninja.m_ActivationDir = ActivationDir; } void SetNinjaActivationDir(vec2 ActivationDir) { m_Core.m_Ninja.m_ActivationDir = ActivationDir; }
void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; } void SetNinjaActivationTick(int ActivationTick) { m_Core.m_Ninja.m_ActivationTick = ActivationTick; }
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; } void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Core.m_Ninja.m_CurrentMoveTime = CurrentMoveTime; }
int GetLastAction() const { return m_LastAction; } int GetLastAction() const { return m_LastAction; }