Merge pull request #7328 from Zwelf/pr-save-ninja

Save/load ninja
This commit is contained in:
Dennis Felsing 2023-10-09 09:40:02 +00:00 committed by GitHub
commit f81af726e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 4 deletions

View file

@ -644,8 +644,12 @@ void CCharacter::GiveNinja()
void CCharacter::RemoveNinja() void CCharacter::RemoveNinja()
{ {
m_Core.m_Ninja.m_ActivationDir = vec2(0, 0);
m_Core.m_Ninja.m_ActivationTick = 0;
m_Core.m_Ninja.m_CurrentMoveTime = 0; m_Core.m_Ninja.m_CurrentMoveTime = 0;
m_Core.m_Ninja.m_OldVelAmount = 0;
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false; m_Core.m_aWeapons[WEAPON_NINJA].m_Got = false;
m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_Core.m_ActiveWeapon = m_LastWeapon; m_Core.m_ActiveWeapon = m_LastWeapon;
SetWeapon(m_Core.m_ActiveWeapon); SetWeapon(m_Core.m_ActiveWeapon);

View file

@ -32,6 +32,14 @@ void CSaveTee::Save(CCharacter *pChr)
m_aWeapons[i].m_Got = pChr->m_Core.m_aWeapons[i].m_Got; m_aWeapons[i].m_Got = pChr->m_Core.m_aWeapons[i].m_Got;
} }
m_Ninja.m_ActivationDir = pChr->m_Core.m_Ninja.m_ActivationDir;
if(pChr->m_Core.m_Ninja.m_ActivationTick)
m_Ninja.m_ActivationTick = pChr->Server()->Tick() - pChr->m_Core.m_Ninja.m_ActivationTick;
else
m_Ninja.m_ActivationTick = 0;
m_Ninja.m_CurrentMoveTime = pChr->m_Core.m_Ninja.m_CurrentMoveTime;
m_Ninja.m_OldVelAmount = pChr->m_Core.m_Ninja.m_OldVelAmount;
m_LastWeapon = pChr->m_LastWeapon; m_LastWeapon = pChr->m_LastWeapon;
m_QueuedWeapon = pChr->m_QueuedWeapon; m_QueuedWeapon = pChr->m_QueuedWeapon;
@ -136,6 +144,14 @@ void CSaveTee::Load(CCharacter *pChr, int Team, bool IsSwap)
pChr->m_Core.m_aWeapons[i].m_Got = m_aWeapons[i].m_Got; pChr->m_Core.m_aWeapons[i].m_Got = m_aWeapons[i].m_Got;
} }
pChr->m_Core.m_Ninja.m_ActivationDir = m_Ninja.m_ActivationDir;
if(m_Ninja.m_ActivationTick)
pChr->m_Core.m_Ninja.m_ActivationTick = pChr->Server()->Tick() - m_Ninja.m_ActivationTick;
else
pChr->m_Core.m_Ninja.m_ActivationTick = 0;
pChr->m_Core.m_Ninja.m_CurrentMoveTime = m_Ninja.m_CurrentMoveTime;
pChr->m_Core.m_Ninja.m_OldVelAmount = m_Ninja.m_OldVelAmount;
pChr->m_LastWeapon = m_LastWeapon; pChr->m_LastWeapon = m_LastWeapon;
pChr->m_QueuedWeapon = m_QueuedWeapon; pChr->m_QueuedWeapon = m_QueuedWeapon;
@ -272,7 +288,8 @@ char *CSaveTee::GetString(const CSaveTeam *pTeam)
"%d\t%d\t%d\t%d\t" // input stuff "%d\t%d\t%d\t%d\t" // input stuff
"%d\t" // m_ReloadTimer "%d\t" // m_ReloadTimer
"%d\t" // m_TeeStarted "%d\t" // m_TeeStarted
"%d", //m_LiveFreeze "%d\t" //m_LiveFreeze
"%f\t%f\t%d\t%d\t%d", // m_Ninja
m_aName, m_Alive, m_Paused, m_NeededFaketuning, m_TeeFinished, m_IsSolo, m_aName, m_Alive, m_Paused, m_NeededFaketuning, m_TeeFinished, m_IsSolo,
// weapons // weapons
m_aWeapons[0].m_AmmoRegenStart, m_aWeapons[0].m_Ammo, m_aWeapons[0].m_Ammocost, m_aWeapons[0].m_Got, m_aWeapons[0].m_AmmoRegenStart, m_aWeapons[0].m_Ammo, m_aWeapons[0].m_Ammocost, m_aWeapons[0].m_Got,
@ -305,7 +322,8 @@ char *CSaveTee::GetString(const CSaveTeam *pTeam)
m_InputDirection, m_InputJump, m_InputFire, m_InputHook, m_InputDirection, m_InputJump, m_InputFire, m_InputHook,
m_ReloadTimer, m_ReloadTimer,
m_TeeStarted, m_TeeStarted,
m_LiveFrozen); m_LiveFrozen,
m_Ninja.m_ActivationDir.x, m_Ninja.m_ActivationDir.y, m_Ninja.m_ActivationTick, m_Ninja.m_CurrentMoveTime, m_Ninja.m_OldVelAmount);
return m_aString; return m_aString;
} }
@ -345,7 +363,8 @@ int CSaveTee::FromString(const char *pString)
"%d\t%d\t%d\t%d\t" // input stuff "%d\t%d\t%d\t%d\t" // input stuff
"%d\t" // m_ReloadTimer "%d\t" // m_ReloadTimer
"%d\t" // m_TeeStarted "%d\t" // m_TeeStarted
"%d", // m_LiveFreeze "%d\t" // m_LiveFreeze
"%f\t%f\t%d\t%d\t%d", // m_Ninja
m_aName, &m_Alive, &m_Paused, &m_NeededFaketuning, &m_TeeFinished, &m_IsSolo, m_aName, &m_Alive, &m_Paused, &m_NeededFaketuning, &m_TeeFinished, &m_IsSolo,
// weapons // weapons
&m_aWeapons[0].m_AmmoRegenStart, &m_aWeapons[0].m_Ammo, &m_aWeapons[0].m_Ammocost, &m_aWeapons[0].m_Got, &m_aWeapons[0].m_AmmoRegenStart, &m_aWeapons[0].m_Ammo, &m_aWeapons[0].m_Ammocost, &m_aWeapons[0].m_Got,
@ -378,7 +397,8 @@ int CSaveTee::FromString(const char *pString)
&m_InputDirection, &m_InputJump, &m_InputFire, &m_InputHook, &m_InputDirection, &m_InputJump, &m_InputFire, &m_InputHook,
&m_ReloadTimer, &m_ReloadTimer,
&m_TeeStarted, &m_TeeStarted,
&m_LiveFrozen); &m_LiveFrozen,
&m_Ninja.m_ActivationDir.x, &m_Ninja.m_ActivationDir.y, &m_Ninja.m_ActivationTick, &m_Ninja.m_CurrentMoveTime, &m_Ninja.m_OldVelAmount);
switch(Num) // Don't forget to update this when you save / load more / less. switch(Num) // Don't forget to update this when you save / load more / less.
{ {
case 96: case 96:
@ -408,6 +428,20 @@ int CSaveTee::FromString(const char *pString)
m_LiveFrozen = false; m_LiveFrozen = false;
[[fallthrough]]; [[fallthrough]];
case 110: case 110:
if(m_aWeapons[WEAPON_NINJA].m_Got)
{
// remove ninja
m_aWeapons[WEAPON_NINJA].m_Got = false;
m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_ActiveWeapon = m_LastWeapon;
}
m_Ninja.m_ActivationDir.x = 0.0;
m_Ninja.m_ActivationDir.y = 0.0;
m_Ninja.m_ActivationTick = 0;
m_Ninja.m_CurrentMoveTime = 0;
m_Ninja.m_OldVelAmount = 0;
[[fallthrough]];
case 115:
return 0; return 0;
default: default:
dbg_msg("load", "failed to load tee-string"); dbg_msg("load", "failed to load tee-string");

View file

@ -60,6 +60,15 @@ private:
int m_Got; int 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;
int m_LastWeapon; int m_LastWeapon;
int m_QueuedWeapon; int m_QueuedWeapon;