From 8ae17b44229b4a52920a7e3dc782760831fb798e Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Tue, 19 Aug 2014 23:58:35 -0600 Subject: [PATCH] Changed LifeMeterTime to not crash when not in course mode. Changed _fallback's life settings back to forcing together. Added ForceImmediateFailForBattery theme metric. Gave up on FailFadeRemovePlayer lua function and removed it. --- Docs/Luadoc/Lua.xml | 1 - Docs/Luadoc/LuaDocumentation.xml | 3 --- Themes/_fallback/metrics.ini | 7 ++++--- src/LifeMeterTime.cpp | 34 ++++++++++++++++++++++++++++---- src/ScreenGameplay.cpp | 34 +++++++++----------------------- 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index e9d4837441..30bc228a44 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -1326,7 +1326,6 @@ - diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 1678836a71..72f674241a 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -3791,9 +3791,6 @@ save yourself some time, copy this for undocumented things: Returns true if a single has its NoteField centered. - - Removes the notes for the specified player. - Returns a dummy PlayerInfo for the specified index. diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 893ffa12a1..395da38d74 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -2540,19 +2540,19 @@ Persp,5="mod,distant;name,Distant" # Song options # LifeType="3" -LifeType=(GAMESTATE:IsCourseMode() and 3 or 2).."" +LifeType=(GAMESTATE:IsCourseMode() and 3 or 2)..";together" LifeTypeDefault="" LifeType,1="mod,bar;name,Bar" LifeType,2="mod,battery;name,Battery" LifeType,3="mod,lifetime;name,LifeTime" # -BarDrain="3" +BarDrain="3;together" BarDrainDefault="" BarDrain,1="mod,normal-drain;name,Normal" BarDrain,2="mod,norecover;name,NoRecover" BarDrain,3="mod,suddendeath;name,SuddenDeath" # -BatLives="10" +BatLives="10;together" BatLivesDefault="" BatLives,1="mod,1 life;name,1" BatLives,2="mod,2 lives;name,2" @@ -3301,6 +3301,7 @@ UnpauseWithStart=true InitialBackgroundBrightness=1.0 SecondsBetweenComments=10.0 ScoreKeeperClass=ScoreKeeperClass() +ForceImmediateFailForBattery=true TickEarlySeconds=0 LightsMode="LightsMode_Gameplay" SurvivalModOverride=true diff --git a/src/LifeMeterTime.cpp b/src/LifeMeterTime.cpp index 4ecf65837b..b201d92661 100644 --- a/src/LifeMeterTime.cpp +++ b/src/LifeMeterTime.cpp @@ -1,6 +1,7 @@ #include "global.h" #include "LifeMeterTime.h" #include "ThemeManager.h" +#include "Song.h" #include "Steps.h" #include "ActorUtil.h" #include "Course.h" @@ -94,11 +95,36 @@ void LifeMeterTime::OnLoadSong() if( GetLifeSeconds() <= 0 && GAMESTATE->GetCourseSongIndex() > 0 ) return; - Course* pCourse = GAMESTATE->m_pCurCourse; - ASSERT( pCourse != NULL ); - float fOldLife = m_fLifeTotalLostSeconds; - float fGainSeconds = pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds; + float fGainSeconds = 0; + if(GAMESTATE->IsCourseMode()) + { + Course* pCourse = GAMESTATE->m_pCurCourse; + ASSERT( pCourse != NULL ); + fGainSeconds= pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].fGainSeconds; + } + else + { + // Placeholderish, at least this way it won't crash when someone tries it + // out in non-course mode. -Kyz + Song* song= GAMESTATE->m_pCurSong; + ASSERT(song != NULL); + float song_len= song->m_fMusicLengthSeconds; + Steps* steps= GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]; + ASSERT(steps != NULL); + RadarValues radars= steps->GetRadarValues(m_pPlayerState->m_PlayerNumber); + float scorable_things= radars[RadarCategory_TapsAndHolds] + + radars[RadarCategory_Lifts]; + if(g_fTimeMeterSecondsChange[SE_Held] > 0.0f) + { + scorable_things+= radars[RadarCategory_Holds] + + radars[RadarCategory_Rolls]; + } + // Calculate the amount of time to give for the player to need 80% W1. + float gainable_score_time= scorable_things * g_fTimeMeterSecondsChange[SE_W1]; + fGainSeconds= song_len - (gainable_score_time * INITIAL_VALUE); + } + if( MIN_LIFE_TIME > fGainSeconds ) fGainSeconds = MIN_LIFE_TIME; m_fLifeTotalGainedSeconds += fGainSeconds; diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 82108082c4..aff5d2b36a 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -71,6 +71,7 @@ static ThemeMetric INITIAL_BACKGROUND_BRIGHTNESS ("ScreenGameplay","InitialBackgroundBrightness"); static ThemeMetric SECONDS_BETWEEN_COMMENTS ("ScreenGameplay","SecondsBetweenComments"); static ThemeMetric SCORE_KEEPER_CLASS ("ScreenGameplay","ScoreKeeperClass"); +static ThemeMetric FORCE_IMMEDIATE_FAIL_FOR_BATTERY("ScreenGameplay", "ForceImmediateFailForBattery"); AutoScreenMessage( SM_PlayGo ); @@ -1095,13 +1096,15 @@ void ScreenGameplay::LoadNextSong() // No need to do this here. We do it in SongFinished(). //GAMESTATE->RemoveAllActiveAttacks(); - /* If we're in battery mode, force FailImmediate. We assume in Player::Step - * that failed players can't step. */ - FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) + // Force immediate fail behavior changed to theme metric by Kyz. + if(FORCE_IMMEDIATE_FAIL_FOR_BATTERY) { - if(pi->GetPlayerState()->m_PlayerOptions.GetStage().m_LifeType == LifeType_Battery) + FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) { - PO_GROUP_ASSIGN(pi->GetPlayerState()->m_PlayerOptions, ModsLevel_Song, m_FailType, FailType_Immediate); + if(pi->GetPlayerState()->m_PlayerOptions.GetStage().m_LifeType == LifeType_Battery) + { + PO_GROUP_ASSIGN(pi->GetPlayerState()->m_PlayerOptions, ModsLevel_Song, m_FailType, FailType_Immediate); + } } } @@ -1652,7 +1655,6 @@ void ScreenGameplay::Update( float fDeltaTime ) FailType ft = GAMESTATE->GetPlayerFailType( pi->GetPlayerState() ); LifeType lt = pi->GetPlayerState()->m_PlayerOptions.GetStage().m_LifeType; - if( ft == FailType_Off || ft == FailType_EndOfSong ) continue; @@ -1820,10 +1822,7 @@ void ScreenGameplay::Update( float fDeltaTime ) if( !GAMESTATE->IsCpuPlayer(pi->m_pn) ) continue; - SOUND->PlayOnceFromDir( THEME->GetPathS(m_sName,"oni die") ); - pi->ShowOniGameOver(); - pi->m_NoteData.Init(); // remove all notes and scoring - pi->m_pPlayer->FadeToFail(); // tell the NoteField to fade to white + FailFadeRemovePlayer(&*pi); } } } @@ -1926,14 +1925,6 @@ void ScreenGameplay::FailFadeRemovePlayer(PlayerInfo* pi) pi->m_pPlayer->FadeToFail(); // tell the NoteField to fade to white } -void ScreenGameplay::FailFadeRemovePlayer(PlayerNumber pn) -{ - if(pn < m_vPlayerInfo.size()) - { - FailFadeRemovePlayer(&m_vPlayerInfo[pn]); - } -} - float ScreenGameplay::GetHasteRate() { return m_fCurrHasteRate; @@ -3004,12 +2995,6 @@ public: lua_pushnumber(L, true_bps); return 1; } - static int FailFadeRemovePlayer(T* p, lua_State* L) - { - PlayerNumber pn= Enum::Check(L, 1); - p->FailFadeRemovePlayer(pn); - return 0; - } LunaScreenGameplay() { @@ -3027,7 +3012,6 @@ public: ADD_METHOD( HasteTimeBetweenUpdates ); ADD_METHOD( HasteLifeSwitchPoint ); ADD_METHOD( GetTrueBPS ); - ADD_METHOD( FailFadeRemovePlayer ); } };