diff options
Diffstat (limited to 'src/game/server/entities/character.cpp')
| -rw-r--r-- | src/game/server/entities/character.cpp | 107 |
1 files changed, 82 insertions, 25 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 821aade5..06c1c913 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -56,8 +56,30 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) { m_EmoteStop = -1; m_LastAction = -1; - m_ActiveWeapon = WEAPON_GUN; - m_LastWeapon = WEAPON_HAMMER; + + /*zCatch */ + if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 1) + { + m_ActiveWeapon = WEAPON_RIFLE; + m_LastWeapon = WEAPON_RIFLE; + } + else if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 3) + { + m_ActiveWeapon = WEAPON_HAMMER; + m_LastWeapon = WEAPON_HAMMER; + } + else if(GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 4) + { + m_ActiveWeapon = WEAPON_GRENADE; + m_LastWeapon = WEAPON_GRENADE; + } + else + { + m_ActiveWeapon = WEAPON_GUN; + m_LastWeapon = WEAPON_HAMMER; + } + /* end zCatch */ + m_QueuedWeapon = -1; m_pPlayer = pPlayer; @@ -115,20 +137,21 @@ void CCharacter::HandleNinja() if(m_ActiveWeapon != WEAPON_NINJA) return; - vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); - - if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) + /* zCatch */ + if(GameServer()->m_pController->IsZCatch() == false || (GameServer()->m_pController->IsZCatch() && g_Config.m_SvMode == 0)) { - // time's up, return - m_aWeapons[WEAPON_NINJA].m_Got = false; - m_ActiveWeapon = m_LastWeapon; - if(m_ActiveWeapon == WEAPON_NINJA) - m_ActiveWeapon = WEAPON_GUN; + if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) + { + // time's up, return + m_aWeapons[WEAPON_NINJA].m_Got = false; + m_ActiveWeapon = m_LastWeapon; - SetWeapon(m_ActiveWeapon); - return; + SetWeapon(m_ActiveWeapon); + return; + } } - + /* zCatch end*/ + // force ninja Weapon SetWeapon(WEAPON_NINJA); @@ -183,7 +206,7 @@ void CCharacter::HandleNinja() if(m_NumObjectsHit < 10) m_apHitObjects[m_NumObjectsHit++] = aEnts[i]; - aEnts[i]->TakeDamage(vec2(0, 10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA); + aEnts[i]->TakeDamage(vec2(0, -10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA); } } @@ -436,8 +459,6 @@ void CCharacter::HandleWeapons() //ninja HandleNinja(); - vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); - // check reload timer if(m_ReloadTimer) { @@ -490,7 +511,8 @@ void CCharacter::GiveNinja() m_Ninja.m_ActivationTick = Server()->Tick(); m_aWeapons[WEAPON_NINJA].m_Got = true; m_aWeapons[WEAPON_NINJA].m_Ammo = -1; - m_LastWeapon = m_ActiveWeapon; + if (m_ActiveWeapon != WEAPON_NINJA) + m_LastWeapon = m_ActiveWeapon; m_ActiveWeapon = WEAPON_NINJA; GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA); @@ -531,6 +553,18 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); } +void CCharacter::ResetInput() +{ + m_Input.m_Direction = 0; + m_Input.m_Hook = 0; + // simulate releasing the fire button + if((m_Input.m_Fire&1) != 0) + m_Input.m_Fire++; + m_Input.m_Fire &= INPUT_STATE_MASK; + m_Input.m_Jump = 0; + m_LatestPrevInput = m_LatestInput = m_Input; +} + void CCharacter::Tick() { if(m_pPlayer->m_ForceBalanced) @@ -700,11 +734,18 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage) return false; - - // m_pPlayer only inflicts half damage on self + + /* zCatch */ + bool Is_zCatch = GameServer()->m_pController->IsZCatch(); + if(From == m_pPlayer->GetCID()) - Dmg = max(1, Dmg/2); - + if(Is_zCatch && g_Config.m_SvMode != 1) + Dmg = 0; //No selfdamage, except in vanilla-mode + // m_pPlayer only inflicts half damage on self + else + Dmg = max(1, Dmg/2); + /* end zCatch */ + m_DamageTaken++; // create healthmod indicator @@ -718,8 +759,15 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) m_DamageTaken = 0; GameServer()->CreateDamageInd(m_Pos, 0, Dmg); } - - if(Dmg) + /* zCatch*/ + //One-Shot-One-Kill + if(Is_zCatch && (g_Config.m_SvMode != 0 && g_Config.m_SvMode != 2)) // all except vanilla-mode and all weapons + { + m_Health = 0; + m_Armor = 0; + } + /* end zCatch*/ + else if(Dmg) { if(m_Armor) { @@ -748,7 +796,15 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) - GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, CmaskOne(From)); + { + int Mask = CmaskOne(From); + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) + Mask |= CmaskOne(i); + } + GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask); + } // check for death if(m_Health <= 0) @@ -821,7 +877,8 @@ void CCharacter::Snap(int SnappingClient) pCharacter->m_Direction = m_Input.m_Direction; - if(m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 || m_pPlayer->GetCID() == GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID) + if(m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 || + (!g_Config.m_SvStrictSpectateMode && m_pPlayer->GetCID() == GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID)) { pCharacter->m_Health = m_Health; pCharacter->m_Armor = m_Armor; |