Skip to content

Commit

Permalink
kill haste mod
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jun 7, 2017
1 parent 65d0312 commit 5a44b46
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 219 deletions.
3 changes: 0 additions & 3 deletions src/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,6 @@ void GameState::ResetStageStatistics()
}

m_fOpponentHealthPercent = 1;
m_fHasteRate = 0;
m_fLastHasteUpdateMusicSeconds = 0;
m_fAccumulatedHasteSeconds = 0;
m_fTugLifePercentP1 = 0.5f;
FOREACH_PlayerNumber( p )
{
Expand Down
5 changes: 0 additions & 5 deletions src/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ class GameState
bool AllAreInDangerOrWorse() const;
bool OneIsHot() const;

// Haste
float m_fHasteRate; // [-1,+1]; 0 = normal speed
float m_fLastHasteUpdateMusicSeconds;
float m_fAccumulatedHasteSeconds;

// used by themes that support heart rate entry.
RageTimer m_DanceStartTime;
float m_DanceDuration;
Expand Down
13 changes: 0 additions & 13 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,19 +1510,6 @@ void Player::ChangeLife( TapNoteScore tns )
m_pLifeMeter->ChangeLife( tns );

ChangeLifeRecord();

switch( tns )
{
case TNS_None:
case TNS_Miss:
case TNS_CheckpointMiss:
case TNS_HitMine:
++m_pPlayerState->m_iTapsMissedSinceLastHasteUpdate;
break;
default:
++m_pPlayerState->m_iTapsHitSinceLastHasteUpdate;
break;
}
}

void Player::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
Expand Down
3 changes: 0 additions & 3 deletions src/PlayerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ void PlayerState::Reset()
m_PlayerController = PC_HUMAN;

m_iCpuSkill = 5;

m_iTapsHitSinceLastHasteUpdate = 0;
m_iTapsMissedSinceLastHasteUpdate = 0;
}

// pointless if attacks are gone?
Expand Down
4 changes: 0 additions & 4 deletions src/PlayerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ class PlayerState

int m_iCpuSkill; // only used when m_PlayerController is PC_CPU

// Haste
int m_iTapsHitSinceLastHasteUpdate;
int m_iTapsMissedSinceLastHasteUpdate;

// Stores the bpm that was picked for reading the chart if the player is using an mmod.
float m_fReadBPM;

Expand Down
2 changes: 1 addition & 1 deletion src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ XNode* Profile::SavePlaylistsCreateNode() const {
XNode* playlists = new XNode("Playlists");
auto& pls = SONGMAN->allplaylists;
FOREACHM(string, Playlist, pls, i)
if(i->first != "")
if(i->first != "" && i->first != "Favorites")
playlists->AppendChild(i->second.CreateNode());
return playlists;
}
Expand Down
168 changes: 1 addition & 167 deletions src/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,6 @@ void ScreenGameplay::Init()
UNPAUSE_WITH_START.Load( m_sName, "UnpauseWithStart");
SURVIVAL_MOD_OVERRIDE.Load(m_sName, "SurvivalModOverride");

// Default values. The theme can set its own through the Lua interface.
m_HasteTurningPoints.clear();
m_HasteTurningPoints.push_back(-1);
m_HasteTurningPoints.push_back(0);
m_HasteTurningPoints.push_back(0.3f);
m_HasteTurningPoints.push_back(1);
m_HasteAddAmounts.clear();
m_HasteAddAmounts.push_back(-0.5f);
m_HasteAddAmounts.push_back(0);
m_HasteAddAmounts.push_back(0.2f);
m_HasteAddAmounts.push_back(0.5f);
m_fHasteTimeBetweenUpdates= 4;
m_fHasteLifeSwitchPoint= 0.5f;
m_fCurrHasteRate= 1; // Should this be in BeginSong? Not sure whether it should carry over between songs.

if( UseSongBackgroundAndForeground() )
{
m_pSongBackground = new Background;
Expand Down Expand Up @@ -1456,9 +1441,6 @@ void ScreenGameplay::Update( float fDeltaTime )

{
float fSpeed = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
if( GAMESTATE->m_SongOptions.GetCurrent().m_fHaste != 0.0f )
fSpeed *= GetHasteRate();

RageSoundParams p = m_pSoundMusic->GetParams();
if( fabsf(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f)
{
Expand Down Expand Up @@ -1562,28 +1544,6 @@ void ScreenGameplay::Update( float fDeltaTime )
if( curBeat >= s.GetFirstBeat() && curBeat < s.GetLastBeat() )
{
STATSMAN->m_CurStageStats.m_fStepsSeconds += fUnscaledDeltaTime;

if( GAMESTATE->m_SongOptions.GetCurrent().m_fHaste != 0.0f )
{

/* Don't know why haste rates are being updated when the mod is not in
use. Quickly checked whether or not doing this affects non-haste gameplay
and it doesn't appear to, nor should it. If it somehow does in certain
situations that should be addressed. - Mina*/
UpdateHasteRate();

float fHasteRate = GetHasteRate();
// For negative haste, accumulate seconds while the song is slowed down.
if(GAMESTATE->m_SongOptions.GetCurrent().m_fHaste < 0)
{
GAMESTATE->m_fAccumulatedHasteSeconds -= (fUnscaledDeltaTime * fHasteRate) - fUnscaledDeltaTime;
}
// For positive haste, accumulate seconds while the song is sped up.
else
{
GAMESTATE->m_fAccumulatedHasteSeconds += (fUnscaledDeltaTime * fHasteRate) - fUnscaledDeltaTime;
}
}
}

// Check for end of song
Expand Down Expand Up @@ -1770,121 +1730,6 @@ void ScreenGameplay::FailFadeRemovePlayer(PlayerInfo* pi)
pi->m_pPlayer->FadeToFail(); // tell the NoteField to fade to white
}

float ScreenGameplay::GetHasteRate()
{
return m_fCurrHasteRate;
}

void ScreenGameplay::UpdateHasteRate()
{
if( GAMESTATE->m_Position.m_fMusicSeconds < GAMESTATE->m_fLastHasteUpdateMusicSeconds || // new song
GAMESTATE->m_Position.m_fMusicSeconds > GAMESTATE->m_fLastHasteUpdateMusicSeconds + m_fHasteTimeBetweenUpdates )
{
bool bAnyPlayerHitAllNotes = false;
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
{
if( !GAMESTATE->IsHumanPlayer(pi->m_pn) )
continue;

PlayerState *pPS = pi->GetPlayerState();
if( pPS->m_iTapsHitSinceLastHasteUpdate > 0 &&
pPS->m_iTapsMissedSinceLastHasteUpdate == 0 )
bAnyPlayerHitAllNotes = true;

pPS->m_iTapsHitSinceLastHasteUpdate = 0;
pPS->m_iTapsMissedSinceLastHasteUpdate = 0;
}

if( bAnyPlayerHitAllNotes )
GAMESTATE->m_fHasteRate += 0.1f;
CLAMP( GAMESTATE->m_fHasteRate, -1.0f, +1.0f );

GAMESTATE->m_fLastHasteUpdateMusicSeconds = GAMESTATE->m_Position.m_fMusicSeconds;
}

/* If the life meter is less than half full, push the haste rate down to let
* the player use his accumulated haste time. */
float fMaxLife = 0;
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
{
if( !GAMESTATE->IsHumanPlayer(pi->m_pn) )
continue;
// In Battle/Rave mode, the players don't have life meters.
if(pi->m_pLifeMeter)
{
fMaxLife= max(fMaxLife, pi->m_pLifeMeter->GetLife());
}
else
{
fMaxLife= 1;
}
}
if( fMaxLife <= m_fHasteLifeSwitchPoint )
GAMESTATE->m_fHasteRate = SCALE( fMaxLife, 0.0f, m_fHasteLifeSwitchPoint, -1.0f, 0.0f );
CLAMP( GAMESTATE->m_fHasteRate, -1.0f, +1.0f );

float fSpeed = 1.0f;
// If there are no turning points or no add amounts, the bad themer probably thinks that's a way to disable haste.
// Since we're outside a lua function, crashing (asserting) won't point back to the source of the problem.
if(m_HasteTurningPoints.size() < 2 || m_HasteAddAmounts.size() < 2 ||
m_HasteTurningPoints.size() != m_HasteAddAmounts.size())
{
m_fCurrHasteRate= fSpeed;
return;
}
float options_haste= GAMESTATE->m_SongOptions.GetCurrent().m_fHaste;
float scale_from_low= -1;
float scale_from_high= 1;
float scale_to_low= 0;
float scale_to_high=0;
for(size_t turning_point= 0; turning_point < m_HasteTurningPoints.size();
++turning_point)
{
float curr_turning_point= m_HasteTurningPoints[turning_point];
scale_from_high= curr_turning_point;
scale_to_high= m_HasteAddAmounts[turning_point];
if(GAMESTATE->m_fHasteRate < curr_turning_point)
{
break;
}
scale_from_low= curr_turning_point;
scale_to_low= m_HasteAddAmounts[turning_point];
}
// If negative haste is being used, the game instead slows down when the player does well.
float speed_add= SCALE(GAMESTATE->m_fHasteRate, scale_from_low, scale_from_high, scale_to_low, scale_to_high) * options_haste;
if(scale_from_low == scale_from_high)
{
speed_add= scale_to_high * options_haste;
}
CLAMP(speed_add, -1.0f, 1.0f);

// Only adjust speed_add by AccumulatedHasteSeconds when the player is losing seconds. Otherwise, gaining the first second is interfered with.
bool losing_seconds= false;
if(options_haste > 0)
{
losing_seconds= speed_add < 0;
}
else
{
losing_seconds= speed_add > 0;
}
if( losing_seconds && GAMESTATE->m_fAccumulatedHasteSeconds <= 1 )
{
/* Only allow slowing down the song while the players have accumulated
* haste. This prevents dragging on the song by keeping the life meter
* nearly empty. */
/* In positive haste mode, the player accumulates seconds while the song
* is sped up, and loses them while the song is slowed down. "<= 1"
* means that the player is only eligible to slow the song down when
* they are down to their last accumulated second. -Kyz */
// 1 second left is full speed_add, 0 seconds left is no speed_add.
float clamp_secs= max(0, GAMESTATE->m_fAccumulatedHasteSeconds);
speed_add = speed_add * clamp_secs;
}
fSpeed += speed_add;
m_fCurrHasteRate= fSpeed;
}

void ScreenGameplay::SendCrossedMessages()
{
{
Expand Down Expand Up @@ -2789,7 +2634,6 @@ class LunaScreenGameplay: public Luna<ScreenGameplay>
}
static int PauseGame( T* p, lua_State *L ) { p->Pause( BArg(1)); return 0; }
static int IsPaused( T* p, lua_State *L ) { lua_pushboolean( L, p->IsPaused() ); return 1; }
static int GetHasteRate( T* p, lua_State *L ) { lua_pushnumber( L, p->GetHasteRate() ); return 1; }
static bool TurningPointsValid(lua_State* L, int index)
{
size_t size= lua_objlen(L, index);
Expand All @@ -2815,10 +2659,6 @@ class LunaScreenGameplay: public Luna<ScreenGameplay>
{
return TurningPointsValid(L, index);
}
FLOAT_TABLE_INTERFACE(HasteTurningPoints, HasteTurningPoints, TurningPointsValid);
FLOAT_TABLE_INTERFACE(HasteAddAmounts, HasteAddAmounts, AddAmountsValid);
FLOAT_NO_SPEED_INTERFACE(HasteTimeBetweenUpdates, HasteTimeBetweenUpdates, (v > 0));
FLOAT_NO_SPEED_INTERFACE(HasteLifeSwitchPoint, HasteLifeSwitchPoint, (v >= 0 && v <= 1));
static int begin_backing_out(T* p, lua_State* L)
{
p->BeginBackingOutFromGameplay();
Expand All @@ -2827,10 +2667,9 @@ class LunaScreenGameplay: public Luna<ScreenGameplay>
static int GetTrueBPS(T* p, lua_State* L)
{
PlayerNumber pn= Enum::Check<PlayerNumber>(L, 1);
float haste= p->GetHasteRate();
float rate= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
float bps= GAMESTATE->m_pPlayerState[pn]->m_Position.m_fCurBPS;
float true_bps= haste * rate * bps;
float true_bps= rate * bps;
lua_pushnumber(L, true_bps);
return 1;
}
Expand All @@ -2844,11 +2683,6 @@ class LunaScreenGameplay: public Luna<ScreenGameplay>
// sm-ssc additions:
ADD_METHOD( PauseGame );
ADD_METHOD( IsPaused );
ADD_METHOD( GetHasteRate );
ADD_METHOD( HasteTurningPoints );
ADD_METHOD( HasteAddAmounts );
ADD_METHOD( HasteTimeBetweenUpdates );
ADD_METHOD( HasteLifeSwitchPoint );
ADD_METHOD(begin_backing_out);
ADD_METHOD( GetTrueBPS );
}
Expand Down
11 changes: 0 additions & 11 deletions src/ScreenGameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,10 @@ class ScreenGameplay : public ScreenWithMenuElements
PlayerInfo *GetDummyPlayerInfo( int iDummyIndex );
void Pause(bool bPause) { PauseGame(bPause); }
bool IsPaused() const { return m_bPaused; }
float GetHasteRate();

void FailFadeRemovePlayer(PlayerInfo* pi);
void FailFadeRemovePlayer(PlayerNumber pn);
void BeginBackingOutFromGameplay();

vector<float> m_HasteTurningPoints; // Values at which the meaning of GAMESTATE->m_fHasteRate changes.
vector<float> m_HasteAddAmounts; // Amounts that are added to speed depending on what turning point has been passed.
float m_fHasteTimeBetweenUpdates; // Seconds between haste updates.
float m_fHasteLifeSwitchPoint; // Life amount below which GAMESTATE->m_fHasteRate is based on the life amount.

protected:
virtual void UpdateStageStats( MultiPlayer /* mp */ ) {}; // overridden for multiplayer

Expand Down Expand Up @@ -217,10 +210,6 @@ class ScreenGameplay : public ScreenWithMenuElements

virtual void InitSongQueues();

void UpdateHasteRate();
float m_fCurrHasteRate;
// These exist so that the haste rate isn't recalculated every time GetHasteRate is called, which is at least once per frame. -Kyz

/** @brief The different game states of ScreenGameplay. */
enum DancingState {
STATE_INTRO = 0, /**< The starting state, pressing Back isn't allowed here. */
Expand Down
9 changes: 0 additions & 9 deletions src/SongOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ void SongOptions::Init()
m_bAssistMetronome = false;
m_fMusicRate = 1.0f;
m_SpeedfMusicRate = 1.0f;
m_fHaste = 0.0f;
m_SpeedfHaste = 1.0f;
m_AutosyncType = AutosyncType_Off;
m_SoundEffectType = SoundEffectType_Off;
m_bStaticBackground = false;
Expand All @@ -47,7 +45,6 @@ void SongOptions::Approach( const SongOptions& other, float fDeltaSeconds )
x = other.x;

APPROACH( fMusicRate );
APPROACH( fHaste );
DO_COPY( m_bAssistClap );
DO_COPY( m_bAssistMetronome );
DO_COPY( m_AutosyncType );
Expand Down Expand Up @@ -80,8 +77,6 @@ void SongOptions::GetMods( vector<RString> &AddTo ) const
AddTo.push_back( s + "xMusic" );
}

AddPart( AddTo, m_fHaste, "Haste" );

switch( m_AutosyncType )
{
case AutosyncType_Off: break;
Expand Down Expand Up @@ -188,7 +183,6 @@ bool SongOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut )
else if( sBit == "randombg" ) m_bRandomBGOnly = on;
else if( sBit == "savescore" ) m_bSaveScore = on;
else if( sBit == "savereplay" ) m_bSaveReplay = on;
else if( sBit == "haste" ) m_fHaste = on? 1.0f:0.0f;
else
return false;

Expand All @@ -199,7 +193,6 @@ bool SongOptions::operator==( const SongOptions &other ) const
{
#define COMPARE(x) { if( x != other.x ) return false; }
COMPARE( m_fMusicRate );
COMPARE( m_fHaste );
COMPARE( m_bAssistClap );
COMPARE( m_bAssistMetronome );
COMPARE( m_AutosyncType );
Expand Down Expand Up @@ -231,7 +224,6 @@ class LunaSongOptions: public Luna<SongOptions>
BOOL_INTERFACE(SaveScore, SaveScore);
BOOL_INTERFACE(SaveReplay, SaveReplay);
FLOAT_INTERFACE(MusicRate, MusicRate, (v > 0.0f && v <= 3.0f)); // Greater than 3 seems to crash frequently, haven't investigated why. -Kyz
FLOAT_INTERFACE(Haste, Haste, (v >= -1.0f && v <= 1.0f));

LunaSongOptions()
{
Expand All @@ -244,7 +236,6 @@ class LunaSongOptions: public Luna<SongOptions>
ADD_METHOD(SaveScore);
ADD_METHOD(SaveReplay);
ADD_METHOD(MusicRate);
ADD_METHOD(Haste);
}
};

Expand Down
Loading

0 comments on commit 5a44b46

Please sign in to comment.