From ed07cf213a42ed7d786768a1c99977431a66da8a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 30 Nov 2006 08:22:30 +0000 Subject: [PATCH] "haste" mod --- stepmania/src/ScreenGameplay.cpp | 29 +++++++++++++++++++++++++++++ stepmania/src/SongOptions.cpp | 17 +++++++++++++++++ stepmania/src/SongOptions.h | 1 + 3 files changed, 47 insertions(+) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index f837d26e0b..0b19d0c643 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1588,6 +1588,35 @@ void ScreenGameplay::Update( float fDeltaTime ) } } + if( GAMESTATE->m_SongOptions.GetCurrent().m_fHaste != 0.0f ) + { + float fLife = 0; + FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + { + if( !GAMESTATE->IsHumanPlayer(pi->m_pn) ) + continue; + fLife = max( fLife, pi->m_pLifeMeter->GetLife() ); + } + + /* Scale the music nonlinearly. Only slow the song down below 0.25, so we + * don't drag the music out too long. Stick at 1x up to 0.5, so we start + * at 1x if the life meter defaults to 0.5. Increase gradually up to 0.9. + * Accelerate sharply above 0.9. */ + float fSpeed = 1.0f; + if( fLife < 0.25f ) + fSpeed = SCALE( fLife, 0.0f, 0.25f, 0.5f, 1.0f ); + else if( fLife > 0.5f && fLife < 0.9f ) + fSpeed = SCALE( fLife, 0.5f, 0.9f, 1.0f, 1.25f ); + else if( fLife >= 0.9f ) + fSpeed = SCALE( fLife, 0.9f, 1.0f, 1.25f, 2.5f ); + + fSpeed *= GAMESTATE->m_SongOptions.GetCurrent().m_fHaste; + fSpeed *= GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; + + RageSoundParams p = m_pSoundMusic->GetParams(); + p.m_fSpeed = fSpeed; + m_pSoundMusic->SetParams( p ); + } switch( m_DancingState ) { diff --git a/stepmania/src/SongOptions.cpp b/stepmania/src/SongOptions.cpp index b581125fc2..bef223415d 100644 --- a/stepmania/src/SongOptions.cpp +++ b/stepmania/src/SongOptions.cpp @@ -13,6 +13,8 @@ void SongOptions::Init() m_bAssistTick = false; m_fMusicRate = 1.0f; m_SpeedfMusicRate = 1.0f; + m_fHaste = 0.0f; + m_SpeedfHaste = 1.0f; m_AutosyncType = AUTOSYNC_OFF; m_bSaveScore = true; } @@ -28,6 +30,7 @@ void SongOptions::Approach( const SongOptions& other, float fDeltaSeconds ) DO_COPY( m_DrainType ); DO_COPY( m_iBatteryLives ); APPROACH( fMusicRate ); + APPROACH( fHaste ); DO_COPY( m_bAssistTick ); DO_COPY( m_AutosyncType ); DO_COPY( m_bSaveScore ); @@ -35,6 +38,16 @@ void SongOptions::Approach( const SongOptions& other, float fDeltaSeconds ) #undef DO_COPY } +static void AddPart( vector &AddTo, float level, RString name ) +{ + if( level == 0 ) + return; + + const RString LevelStr = (level == 1)? RString(""): ssprintf( "%i%% ", (int) roundf(level*100) ); + + AddTo.push_back( LevelStr + name ); +} + void SongOptions::GetMods( vector &AddTo ) const { switch( m_LifeType ) @@ -74,6 +87,8 @@ void SongOptions::GetMods( vector &AddTo ) const AddTo.push_back( s + "xMusic" ); } + AddPart( AddTo, m_fHaste, "Haste" ); + switch( m_AutosyncType ) { case AUTOSYNC_OFF: break; @@ -176,6 +191,7 @@ void SongOptions::FromString( const RString &sOptions ) else if( sBit == "bar" ) m_LifeType = LIFE_BAR; else if( sBit == "battery" ) m_LifeType = LIFE_BATTERY; else if( sBit == "lifetime" ) m_LifeType = LIFE_TIME; + else if( sBit == "haste" ) m_fHaste = on? 1.0f:0.0f; } } @@ -187,6 +203,7 @@ bool SongOptions::operator==( const SongOptions &other ) const COMPARE( m_iBatteryLives ); COMPARE( m_FailType ); COMPARE( m_fMusicRate ); + COMPARE( m_fHaste ); COMPARE( m_bAssistTick ); COMPARE( m_AutosyncType ); COMPARE( m_bSaveScore ); diff --git a/stepmania/src/SongOptions.h b/stepmania/src/SongOptions.h index 2b7f589054..6062a99701 100644 --- a/stepmania/src/SongOptions.h +++ b/stepmania/src/SongOptions.h @@ -29,6 +29,7 @@ public: FAIL_OFF }; // never fail FailType m_FailType; float m_fMusicRate, m_SpeedfMusicRate; + float m_fHaste, m_SpeedfHaste; bool m_bAssistTick; enum AutosyncType { AUTOSYNC_OFF,