From 66750a3220212b4fdfcd4ee65e1c46626bf4b5e4 Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Mon, 23 Aug 2010 00:04:26 +0200 Subject: [PATCH] Weapon pickup Sound Spam Disabled /Pause Fixed but disabled pause with ninja Signed-off-by: GreYFoXGTi --- src/game/server/entities/character.cpp | 12 ++++++-- src/game/server/entities/pickup.cpp | 7 ++++- src/game/server/gamecontext.cpp | 6 ++-- src/game/server/player.cpp | 40 ++++++++++++++++++++++++-- src/game/server/player.h | 16 +++++++++++ 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 49c048802..caa2371b1 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -510,13 +510,13 @@ bool CCharacter::GiveWeapon(int Weapon, int Ammo) void CCharacter::GiveNinja() { + if(!m_aWeapons[WEAPON_NINJA].m_Got) + GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA); m_Ninja.m_ActivationTick = Server()->Tick(); m_aWeapons[WEAPON_NINJA].m_Got = true; m_aWeapons[WEAPON_NINJA].m_Ammo = -1; m_LastWeapon = m_ActiveWeapon; m_ActiveWeapon = WEAPON_NINJA; - - GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA); } void CCharacter::SetEmote(int Emote, int Tick) @@ -1012,7 +1012,13 @@ bool CCharacter::UnFreeze() m_Ninja.m_ActivationDir=vec2(0,0); m_Ninja.m_ActivationTick=0; m_Ninja.m_CurrentMoveTime=0; - + for(int i=0;im_aWeapons[i].m_Ammo = 0; sound = true; } + if(pChr->m_FreezeTime) + { + pChr->m_aWeapons[WEAPON_GUN].m_Ammo = 0; + pChr->m_aWeapons[WEAPON_HAMMER].m_Ammo =0; + } } if (sound) { @@ -87,7 +92,7 @@ void CPickup::Tick() case POWERUP_WEAPON: - if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS) + if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->m_aWeapons[m_Subtype].m_Got || pChr->m_aWeapons[m_Subtype].m_Ammo != -1)) { if(pChr->GiveWeapon(m_Subtype, -1)) { diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 81237c6ae..63a9cc0e3 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -651,8 +651,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) if(g_Config.m_SvPauseable) { CCharacter* chr = p->GetCharacter(); - - if(!p->GetTeam()) + + if(!p->GetTeam() && (!chr->m_aWeapons[WEAPON_NINJA].m_Got || chr->m_FreezeTime)) { p->SaveCharacter(); p->SetTeam(-1); @@ -663,6 +663,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) p->SetTeam(0); //p->LoadCharacter();//TODO:Check if this system Works } + else + SendChatTarget(ClientId, "You are not allowed to pause with ninja"); //if(chr->m_RaceState==RACE_STARTED) // chr->m_RaceState = RACE_PAUSE; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 4fff1268f..bb95d2e5f 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -236,16 +236,50 @@ void CPlayer::LoadCharacter() { Character->GiveWeapon(i, -1); } } + Character->m_FreezeTime = m_PauseInfo.m_FreezeTime; + Character->m_Doored = m_PauseInfo.m_Doored; + Character->m_OldPos = m_PauseInfo.m_OldPos; + Character->m_OlderPos = m_PauseInfo.m_OlderPos; + Character->m_LastAction = m_PauseInfo.m_LastAction; + Character->m_Jumped = m_PauseInfo.m_Jumped; + Character->m_Health = m_PauseInfo.m_Health; + Character->m_Armor = m_PauseInfo.m_Armor; + Character->m_PlayerState = m_PauseInfo.m_PlayerState; + Character->m_LastMove = m_PauseInfo.m_LastMove; + Character->m_LastSpeedup = m_PauseInfo.m_LastSpeedup; + Character->m_PrevPos = m_PauseInfo.m_PrevPos; + Character->m_ActiveWeapon = m_PauseInfo.m_ActiveWeapon; + Character->m_LastWeapon = m_PauseInfo.m_LastWeapon; + Character->m_HammerType = m_PauseInfo.m_HammerType; + Character->m_Super = m_PauseInfo.m_Super; m_PauseInfo.m_Respawn = false; } -void CPlayer::SaveCharacter() { +void CPlayer::SaveCharacter() +{ m_PauseInfo.m_Core = Character->m_Core; m_PauseInfo.m_StartTime = Character->m_StartTime; m_PauseInfo.m_RaceState = Character->m_RaceState; - for(int i = 0; i < NUM_WEAPONS; ++i) { + for(int i = 0; i < WEAPON_NINJA; ++i) + { m_PauseInfo.m_aHasWeapon[i] = Character->m_aWeapons[i].m_Got; } + m_PauseInfo.m_FreezeTime=Character->m_FreezeTime; + m_PauseInfo.m_Doored = Character->m_Doored; + m_PauseInfo.m_OldPos = Character->m_OldPos; + m_PauseInfo.m_OlderPos = Character->m_OlderPos; + m_PauseInfo.m_LastAction = Character->m_LastAction; + m_PauseInfo.m_Jumped = Character->m_Jumped; + m_PauseInfo.m_Health = Character->m_Health; + m_PauseInfo.m_Armor = Character->m_Armor; + m_PauseInfo.m_PlayerState = Character->m_PlayerState; + m_PauseInfo.m_LastMove = Character->m_LastMove; + m_PauseInfo.m_LastSpeedup = Character->m_LastSpeedup; + m_PauseInfo.m_PrevPos = Character->m_PrevPos; + m_PauseInfo.m_ActiveWeapon = Character->m_ActiveWeapon; + m_PauseInfo.m_LastWeapon = Character->m_LastWeapon; + m_PauseInfo.m_HammerType = Character->m_HammerType; + m_PauseInfo.m_Super = Character->m_Super; //m_PauseInfo.m_RefreshTime = Character->m_RefreshTime; } @@ -300,4 +334,4 @@ void CPlayer::AfkTimer(int new_target_x, int new_target_y) serv->Kick(m_ClientID,"Away from keyboard"); } } -} \ No newline at end of file +} diff --git a/src/game/server/player.h b/src/game/server/player.h index 5ed029807..6390e84dd 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -38,8 +38,24 @@ public: int m_StartTime; int m_RaceState; //int m_RefreshTime; + int m_FreezeTime; + bool m_Doored; + vec2 m_OldPos; + vec2 m_OlderPos; + int m_LastAction; + int m_Jumped; + int m_Health; + int m_Armor; + int m_PlayerState; + int m_LastMove; + int m_LastSpeedup; + vec2 m_PrevPos; + int m_ActiveWeapon; + int m_LastWeapon; bool m_Respawn; bool m_aHasWeapon[NUM_WEAPONS]; + int m_HammerType; + bool m_Super; } m_PauseInfo; void LoadCharacter(); void SaveCharacter();