diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index 8feb87952d..42aa62444b 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -13,6 +13,7 @@ StepMania current development * [ScreenGameplay] LifeMeterChangedP1 message is no longer broadcast for for P2's lifemeter. Use LifeMeterChangedP2. "Life" and "StepsSecond" are passed in the params table for the message. +* [LifeMeterBattery] CourseSongRewardLives metric added. 2013/10/09 ---------- diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index b99685446d..cca33326ee 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -672,6 +672,8 @@ MinesSubtractLives=1 HeldAddLives=0 # how many lives an unsuccessful hold will cost you. LetGoSubtractLives=1 +# this function returns how many lives to add when a song ends in course mode. +CourseSongRewardLives=function(life_meter, pn) if GAMESTATE:GetCurrentSteps(pn):GetMeter() >= 8 then return 2 end return 1 end # How many lives trigger the "Danger" state. DangerThreshold=1 diff --git a/src/LifeMeterBattery.cpp b/src/LifeMeterBattery.cpp index d880343fab..4279c85f9b 100644 --- a/src/LifeMeterBattery.cpp +++ b/src/LifeMeterBattery.cpp @@ -30,6 +30,7 @@ void LifeMeterBattery::Load( const PlayerState *pPlayerState, PlayerStageStats * MINES_SUBTRACT_LIVES.Load(sType, "MinesSubtractLives"); HELD_ADD_LIVES.Load(sType, "HeldAddLives"); LET_GO_SUBTRACT_LIVES.Load(sType, "LetGoSubtractLives"); + COURSE_SONG_REWARD_LIVES.Load(sType, "CourseSongRewardLives"); LIVES_FORMAT.Load(sType, "NumLivesFormat"); @@ -89,7 +90,17 @@ void LifeMeterBattery::OnSongEnded() if( pCourse && pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].iGainLives > -1 ) m_iLivesLeft += pCourse->m_vEntries[GAMESTATE->GetCourseSongIndex()].iGainLives; else - m_iLivesLeft += ( GAMESTATE->m_pCurSteps[pn]->GetMeter()>=8 ? 2 : 1 ); + { + Lua *L= LUA->Get(); + COURSE_SONG_REWARD_LIVES.PushSelf(L); + PushSelf(L); + LuaHelpers::Push(L, pn); + RString error= "Error running CourseSongRewardLives callback: "; + LuaHelpers::RunScriptOnStack(L, error, 1, 1, true); + m_iLivesLeft += luaL_optnumber(L, -1, 0); + lua_settop(L, 0); + LUA->Release(L); + } m_iLivesLeft = min( m_iLivesLeft, GAMESTATE->m_SongOptions.GetSong().m_iBatteryLives ); if( m_iTrailingLivesLeft < m_iLivesLeft ) diff --git a/src/LifeMeterBattery.h b/src/LifeMeterBattery.h index 34279924a1..6d20b59a1f 100644 --- a/src/LifeMeterBattery.h +++ b/src/LifeMeterBattery.h @@ -52,6 +52,7 @@ private: ThemeMetric MINES_SUBTRACT_LIVES; ThemeMetric HELD_ADD_LIVES; ThemeMetric LET_GO_SUBTRACT_LIVES; + ThemeMetric COURSE_SONG_REWARD_LIVES; ThemeMetric LIVES_FORMAT; AutoActor m_sprFrame;