Skip to content

Commit

Permalink
quick bugfix: practice mode prespeed (again..) and timer status
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxxi committed Apr 14, 2016
1 parent c9c1d78 commit 83ed4f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 0 additions & 2 deletions mp/src/game/client/momentum/ui/hud_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class C_Timer : public CHudElement, public Panel
char stLocalized[BUFSIZELOCL], cpLocalized[BUFSIZELOCL], linearLocalized[BUFSIZELOCL],
startZoneLocalized[BUFSIZELOCL], mapFinishedLocalized[BUFSIZELOCL], practiceModeLocalized[BUFSIZELOCL],
noTimerLocalized[BUFSIZELOCL];

bool m_bPlayStartSound, m_bPlayStopSound;
};

DECLARE_HUDELEMENT(C_Timer);
Expand Down
12 changes: 8 additions & 4 deletions mp/src/game/server/momentum/mom_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,22 @@ void CMomentumPlayer::LimitSpeedInStartZone()
bool bhopGameMode = (gm.GetInt() == MOMGM_BHOP || gm.GetInt() == MOMGM_SCROLL);
if (m_bInsideStartZone)
{
if (GetGroundEntity() == NULL)
if (GetGroundEntity() == NULL && !g_Timer.IsPracticeMode(this)) //don't count ticks in air if we're in practice mode
m_nTicksInAir++;
else
m_nTicksInAir = 0;
//depending on gamemode, limit speed either outright or only when player is in practice mode
if (bhopGameMode ? ((!g_Timer.IsRunning() && m_nTicksInAir > MAX_AIRTIME_TICKS) || g_Timer.IsPracticeMode(this)) : g_Timer.IsPracticeMode(this))

//set bhop flag to true so we can't prespeed with practice mode
if (g_Timer.IsPracticeMode(this)) m_bDidPlayerBhop = true;

//depending on gamemode, limit speed outright when player exceeds punish vel
if (bhopGameMode && ((!g_Timer.IsRunning() && m_nTicksInAir > MAX_AIRTIME_TICKS)))
{
Vector velocity = GetLocalVelocity();
float PunishVelSquared = startTrigger->GetPunishSpeed()*startTrigger->GetPunishSpeed();
if (velocity.Length2DSqr() > PunishVelSquared) //more efficent to check agaisnt the square of velocity
{
velocity = ((velocity / velocity.Length()) * (gpGlobals->interval_per_tick == 0.01 ? startTrigger->GetPunishSpeed() : startTrigger->GetPunishSpeed() / 2));
velocity = (velocity / velocity.Length()) * startTrigger->GetPunishSpeed();
SetAbsVelocity(Vector(velocity.x, velocity.y, velocity.z));
}
}
Expand Down
28 changes: 14 additions & 14 deletions mp/src/game/server/momentum/mom_triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ END_DATADESC()

void CTriggerTimerStart::EndTouch(CBaseEntity *pOther)
{
IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone");
if (pOther->IsPlayer())
{
CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther);
Expand All @@ -122,13 +121,14 @@ void CTriggerTimerStart::EndTouch(CBaseEntity *pOther)
}

}
if (mapZoneEvent)
{
mapZoneEvent->SetBool("inside_startzone", false);
gameeventmanager->FireEvent(mapZoneEvent);
}
pPlayer->m_bInsideStartZone = false;
}
IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone");
if (mapZoneEvent)
{
mapZoneEvent->SetBool("inside_startzone", false);
gameeventmanager->FireEvent(mapZoneEvent);
}
// stop thinking on end touch
SetNextThink(-1);
BaseClass::EndTouch(pOther);
Expand All @@ -137,27 +137,27 @@ void CTriggerTimerStart::EndTouch(CBaseEntity *pOther)
void CTriggerTimerStart::StartTouch(CBaseEntity *pOther)
{
g_Timer.SetStartTrigger(this);

if (pOther->IsPlayer())
{
CMomentumPlayer *pPlayer = ToCMOMPlayer(pOther);
pPlayer->m_bInsideStartZone = true;
pPlayer->m_flLastJumpVel = 0; //also reset last jump velocity when we enter the start zone

IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone");
if (mapZoneEvent)
{
mapZoneEvent->SetBool("inside_startzone", true);
mapZoneEvent->SetBool("map_finished", false);
gameeventmanager->FireEvent(mapZoneEvent);
}

if (g_Timer.IsRunning())
{
g_Timer.Stop(false);
g_Timer.DispatchResetMessage();
//lower the player's speed if they try to jump back into the start zone
}
}
IGameEvent *mapZoneEvent = gameeventmanager->CreateEvent("player_inside_mapzone");
if (mapZoneEvent)
{
mapZoneEvent->SetBool("inside_startzone", true);
mapZoneEvent->SetBool("map_finished", false);
gameeventmanager->FireEvent(mapZoneEvent);
}
// start thinking
SetNextThink(gpGlobals->curtime);
BaseClass::StartTouch(pOther);
Expand Down

0 comments on commit 83ed4f9

Please sign in to comment.