void CTriggerTimerStart::EndTouch(CBaseEntity *pOther) { ConVarRef cheatsRef("sv_cheats"); if (pOther->IsPlayer()) { //do not start timer if player is in practice mode or has cheats on if (!cheatsRef.GetBool() && pOther->GetMoveType() != MOVETYPE_NOCLIP) { g_Timer.Start(gpGlobals->tickcount); if (IsLimitingSpeed()) { Vector velocity = pOther->GetAbsVelocity(); if (IsLimitingSpeedOnlyXY()) { Vector2D vel2D = velocity.AsVector2D(); if (velocity.AsVector2D().IsLengthGreaterThan(m_fMaxLeaveSpeed)) { // Isn't it nice how Vector2D.h doesn't have Normalize() on it? // It only has a NormalizeInPlace... Not simple enough for me vel2D = ((vel2D / vel2D.Length()) * m_fMaxLeaveSpeed); pOther->SetAbsVelocity(Vector(vel2D.x, vel2D.y, velocity.z)); } } else { if (velocity.IsLengthGreaterThan(m_fMaxLeaveSpeed)) { pOther->SetAbsVelocity(velocity.Normalized() * m_fMaxLeaveSpeed); } } } } else DevWarning("You must turn off cheats or practice mode to start the timer!\n"); } BaseClass::EndTouch(pOther); }
void CTriggerTimerStart::EndTouch(CBaseEntity *pOther) { if (pOther->IsPlayer()) { CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther); //surf or other gamemodes has timer start on exiting zone, bhop timer starts when the player jumps if (!pPlayer->m_bHasPracticeMode && !g_Timer->IsRunning()) // do not start timer if player is in practice mode or it's already running. { if (IsLimitingSpeed()) { Vector velocity = pOther->GetAbsVelocity(); // Isn't it nice how Vector2D.h doesn't have Normalize() on it? // It only has a NormalizeInPlace... Not simple enough for me Vector2D vel2D = velocity.AsVector2D(); if (pPlayer->DidPlayerBhop()) { if (velocity.AsVector2D().IsLengthGreaterThan(m_fBhopLeaveSpeed)) { vel2D = ((vel2D / vel2D.Length()) * (m_fBhopLeaveSpeed)); pOther->SetAbsVelocity(Vector(vel2D.x, vel2D.y, velocity.z)); } } } g_Timer->Start(gpGlobals->tickcount); if (g_Timer->IsRunning()) { //Used for trimming later on if (g_ReplaySystem->GetReplayManager()->Recording()) { g_ReplaySystem->SetTimerStartTick(gpGlobals->tickcount); } pPlayer->m_RunData.m_bTimerRunning = g_Timer->IsRunning(); //Used for spectating later on pPlayer->m_RunData.m_iStartTick = gpGlobals->tickcount; } } pPlayer->m_RunData.m_bIsInZone = false; pPlayer->m_RunData.m_bMapFinished = false; } else { CMomentumReplayGhostEntity *pGhost = dynamic_cast<CMomentumReplayGhostEntity*>(pOther); if (pGhost) { pGhost->m_RunData.m_bIsInZone = false; pGhost->m_RunData.m_bMapFinished = false; pGhost->m_RunData.m_bTimerRunning = true; pGhost->m_RunData.m_iStartTick = gpGlobals->tickcount; pGhost->StartTimer(gpGlobals->tickcount); //Needed for hud_comparisons IGameEvent *timerStateEvent = gameeventmanager->CreateEvent("timer_state"); if (timerStateEvent) { timerStateEvent->SetInt("ent", pGhost->entindex()); timerStateEvent->SetBool("is_running", true); gameeventmanager->FireEvent(timerStateEvent); } } } // stop thinking on end touch SetNextThink(-1); BaseClass::EndTouch(pOther); }