Add StageStats::bFailedEarlier, to simplify gameplay logic. This should

fix course weirdness.
This commit is contained in:
Glenn Maynard
2003-09-15 22:48:37 +00:00
parent f598a50e6f
commit 751ca831c2
10 changed files with 66 additions and 86 deletions
-1
View File
@@ -31,7 +31,6 @@ public:
virtual bool IsInDanger( PlayerNumber pn ) { return false; }; virtual bool IsInDanger( PlayerNumber pn ) { return false; };
virtual bool IsHot( PlayerNumber pn ) { return false; }; virtual bool IsHot( PlayerNumber pn ) { return false; };
virtual bool IsFailing( PlayerNumber pn ) { return false; }; virtual bool IsFailing( PlayerNumber pn ) { return false; };
virtual bool FailedEarlier( PlayerNumber pn ) { return false; };
virtual void OnTaunt(); virtual void OnTaunt();
protected: protected:
-1
View File
@@ -28,7 +28,6 @@ public:
virtual bool IsInDanger( PlayerNumber pn ) { return false; }; virtual bool IsInDanger( PlayerNumber pn ) { return false; };
virtual bool IsHot( PlayerNumber pn ) { return false; }; virtual bool IsHot( PlayerNumber pn ) { return false; };
virtual bool IsFailing( PlayerNumber pn ) { return false; }; virtual bool IsFailing( PlayerNumber pn ) { return false; };
virtual bool FailedEarlier( PlayerNumber pn ) { return false; };
protected: protected:
-2
View File
@@ -34,7 +34,6 @@ public:
virtual bool IsInDanger() = 0; virtual bool IsInDanger() = 0;
virtual bool IsHot() = 0; virtual bool IsHot() = 0;
virtual bool IsFailing() = 0; virtual bool IsFailing() = 0;
virtual bool FailedEarlier() = 0;
virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) = 0; virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) = 0;
@@ -59,7 +58,6 @@ public:
virtual bool IsInDanger( PlayerNumber pn ) = 0; virtual bool IsInDanger( PlayerNumber pn ) = 0;
virtual bool IsHot( PlayerNumber pn ) = 0; virtual bool IsHot( PlayerNumber pn ) = 0;
virtual bool IsFailing( PlayerNumber pn ) = 0; virtual bool IsFailing( PlayerNumber pn ) = 0;
virtual bool FailedEarlier( PlayerNumber pn ) = 0;
virtual void OnTaunt() {}; virtual void OnTaunt() {};
}; };
+1 -5
View File
@@ -376,7 +376,7 @@ void LifeMeterBar::ChangeLife( TapNoteScore score )
CLAMP( m_fLifePercentage, 0, 1 ); CLAMP( m_fLifePercentage, 0, 1 );
if( m_fLifePercentage <= FAIL_THRESHOLD ) if( m_fLifePercentage <= FAIL_THRESHOLD )
m_bFailedEarlier = true; GAMESTATE->m_CurStageStats.bFailedEarlier[m_PlayerNumber] = true;
m_fLifeVelocity += fDeltaLife; m_fLifeVelocity += fDeltaLife;
} }
@@ -414,10 +414,6 @@ bool LifeMeterBar::IsFailing()
return m_fLifePercentage <= 0; return m_fLifePercentage <= 0;
} }
bool LifeMeterBar::FailedEarlier()
{
return m_bFailedEarlier;
}
void LifeMeterBar::Update( float fDeltaTime ) void LifeMeterBar::Update( float fDeltaTime )
{ {
-1
View File
@@ -35,7 +35,6 @@ public:
virtual bool IsInDanger(); virtual bool IsInDanger();
virtual bool IsHot(); virtual bool IsHot();
virtual bool IsFailing(); virtual bool IsFailing();
virtual bool FailedEarlier();
void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty); void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty);
void FillForHowToPlay(int NumPerfects, int NumMisses); void FillForHowToPlay(int NumPerfects, int NumMisses);
+4 -10
View File
@@ -34,7 +34,6 @@ LifeMeterBattery::LifeMeterBattery()
{ {
m_iLivesLeft = GAMESTATE->m_SongOptions.m_iBatteryLives; m_iLivesLeft = GAMESTATE->m_SongOptions.m_iBatteryLives;
m_iTrailingLivesLeft = m_iLivesLeft; m_iTrailingLivesLeft = m_iLivesLeft;
m_bFailedEarlier = false;
m_fBatteryBlinkTime = 0; m_fBatteryBlinkTime = 0;
@@ -90,7 +89,7 @@ void LifeMeterBattery::Load( PlayerNumber pn )
void LifeMeterBattery::OnSongEnded() void LifeMeterBattery::OnSongEnded()
{ {
if( m_bFailedEarlier ) if( GAMESTATE->m_CurStageStats.bFailedEarlier[m_PlayerNumber] )
return; return;
if( m_iLivesLeft < GAMESTATE->m_SongOptions.m_iBatteryLives ) if( m_iLivesLeft < GAMESTATE->m_SongOptions.m_iBatteryLives )
@@ -107,7 +106,7 @@ void LifeMeterBattery::OnSongEnded()
void LifeMeterBattery::ChangeLife( TapNoteScore score ) void LifeMeterBattery::ChangeLife( TapNoteScore score )
{ {
if( m_bFailedEarlier ) if( GAMESTATE->m_CurStageStats.bFailedEarlier[m_PlayerNumber] )
return; return;
switch( score ) switch( score )
@@ -134,7 +133,7 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score )
ASSERT(0); ASSERT(0);
} }
if( m_iLivesLeft == 0 ) if( m_iLivesLeft == 0 )
m_bFailedEarlier = true; GAMESTATE->m_CurStageStats.bFailedEarlier[m_PlayerNumber] = true;
} }
void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
@@ -188,12 +187,7 @@ bool LifeMeterBattery::IsHot()
bool LifeMeterBattery::IsFailing() bool LifeMeterBattery::IsFailing()
{ {
return m_bFailedEarlier; return GAMESTATE->m_CurStageStats.bFailedEarlier[m_PlayerNumber];
}
bool LifeMeterBattery::FailedEarlier()
{
return m_bFailedEarlier;
} }
void LifeMeterBattery::Refresh() void LifeMeterBattery::Refresh()
-2
View File
@@ -34,7 +34,6 @@ public:
virtual bool IsInDanger(); virtual bool IsInDanger();
virtual bool IsHot(); virtual bool IsHot();
virtual bool IsFailing(); virtual bool IsFailing();
virtual bool FailedEarlier();
virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) { }; virtual void UpdateNonstopLifebar(int cleared, int total, int ProgressiveLifebarDifficulty) { };
@@ -43,7 +42,6 @@ public:
private: private:
int m_iLivesLeft; // dead when 0 int m_iLivesLeft; // dead when 0
int m_iTrailingLivesLeft; // lags m_iLivesLeft int m_iTrailingLivesLeft; // lags m_iLivesLeft
bool m_bFailedEarlier;
float m_fBatteryBlinkTime; // if > 0 battery is blinking float m_fBatteryBlinkTime; // if > 0 battery is blinking
+53 -62
View File
@@ -905,10 +905,8 @@ bool ScreenGameplay::AllAreFailing()
bool ScreenGameplay::AllFailedEarlier() bool ScreenGameplay::AllFailedEarlier()
{ {
for( int p=0; p<NUM_PLAYERS; p++ ) for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(p) ) if( GAMESTATE->IsPlayerEnabled(p) && !GAMESTATE->m_CurStageStats.bFailedEarlier[p] )
if( (m_pLifeMeter[p] && !m_pLifeMeter[p]->FailedEarlier()) || return false;
(m_pCombinedLifeMeter && !m_pCombinedLifeMeter->FailedEarlier((PlayerNumber)p)) )
return false;
return true; return true;
} }
@@ -1104,9 +1102,6 @@ void ScreenGameplay::Update( float fDeltaTime )
} }
} }
} }
/* What is this line for? pn is always 2 here which goes into iPossibleDancePoints[0]
GAMESTATE->m_CurStageStats.bFailed[pn] = true;
*/
// //
// Check to see if it's time to play a ScreenGameplay comment // Check to see if it's time to play a ScreenGameplay comment
@@ -1156,74 +1151,62 @@ void ScreenGameplay::Update( float fDeltaTime )
m_soundAssistTick.Play(); m_soundAssistTick.Play();
} }
/* Set m_CurStageStats.bFailed for failed players, send SM_BeginFailed
* if all players failed, and kill dead Oni players. This is all FAIL_ARCADE
* only. In FAIL_END_OF_SONG, this happens in SM_NotesEnded. */
void ScreenGameplay::UpdateCheckFail() void ScreenGameplay::UpdateCheckFail()
{ {
if( GAMESTATE->m_SongOptions.m_FailType != SongOptions::FAIL_ARCADE )
return;
/* Handle the background danger graphic. */
if( AllAreFailing() ) SCREENMAN->PostMessageToTopScreen( SM_BeginFailed, 0 );
if( AllAreInDanger() ) m_Background.TurnDangerOn();
else m_Background.TurnDangerOff();
int pn; int pn;
switch( GAMESTATE->m_SongOptions.m_FailType ) switch( GAMESTATE->m_SongOptions.m_LifeType )
{ {
case SongOptions::FAIL_ARCADE: case SongOptions::LIFE_BAR:
switch( GAMESTATE->m_SongOptions.m_LifeType ) // check for individual fail
{
case SongOptions::LIFE_BAR:
if( AllAreFailing() ) SCREENMAN->PostMessageToTopScreen( SM_BeginFailed, 0 );
if( AllAreInDanger() ) m_Background.TurnDangerOn();
else m_Background.TurnDangerOff();
// check for individual fail
for ( pn=0; pn<NUM_PLAYERS; pn++ )
{
if( (m_pLifeMeter[pn] && m_pLifeMeter[pn]->IsFailing() && !GAMESTATE->m_CurStageStats.bFailed[pn]) ||
(m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing((PlayerNumber)pn) && !GAMESTATE->m_CurStageStats.bFailed[pn]) )
{
LOG->Trace("Player %d failed", (int)pn);
GAMESTATE->m_CurStageStats.bFailed[pn] = true; // fail
}
}
break;
case SongOptions::LIFE_BATTERY:
if( AllFailedEarlier() )SCREENMAN->PostMessageToTopScreen( SM_BeginFailed, 0 );
if( AllAreInDanger() ) m_Background.TurnDangerOn();
else m_Background.TurnDangerOff();
// check for individual fail
for( pn=0; pn<NUM_PLAYERS; pn++ )
{
if( !GAMESTATE->IsPlayerEnabled(pn) )
continue;
if( (m_pLifeMeter[pn] && !m_pLifeMeter[pn]->IsFailing()) ||
(m_pCombinedLifeMeter && !m_pCombinedLifeMeter->IsFailing((PlayerNumber)pn)) )
continue; /* isn't failing */
if( GAMESTATE->m_CurStageStats.bFailed[pn] )
continue; /* failed and is already dead */
if( !AllFailedEarlier() ) // if not the last one to fail
{
// kill them!
m_soundOniDie.PlayRandom();
ShowOniGameOver((PlayerNumber)pn);
m_Player[pn].Init(); // remove all notes and scoring
m_Player[pn].FadeToFail(); // tell the NoteField to fade to white
}
GAMESTATE->m_CurStageStats.bFailed[pn] = true;
}
break;
}
break;
case SongOptions::FAIL_END_OF_SONG:
// we still need to check for fail for scoring purposes
for ( pn=0; pn<NUM_PLAYERS; pn++ ) for ( pn=0; pn<NUM_PLAYERS; pn++ )
{ {
if( (m_pLifeMeter[pn] && m_pLifeMeter[pn]->IsFailing() && !GAMESTATE->m_CurStageStats.bFailed[pn]) || if( !GAMESTATE->IsPlayerEnabled(pn) )
(m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing((PlayerNumber)pn) && !GAMESTATE->m_CurStageStats.bFailed[pn]) ) continue;
if( GAMESTATE->m_CurStageStats.bFailed[pn] )
continue; /* already failed */
if( (m_pLifeMeter[pn] && m_pLifeMeter[pn]->IsFailing()) ||
(m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing((PlayerNumber)pn)) )
{ {
LOG->Trace("Player %d failed", (int)pn); LOG->Trace("Player %d failed", (int)pn);
GAMESTATE->m_CurStageStats.bFailed[pn] = true; // fail GAMESTATE->m_CurStageStats.bFailed[pn] = true; // fail
} }
} }
break; break;
case SongOptions::FAIL_OFF: case SongOptions::LIFE_BATTERY:
// check for individual fail
for( pn=0; pn<NUM_PLAYERS; pn++ )
{
if( !GAMESTATE->IsPlayerEnabled(pn) )
continue;
if( (m_pLifeMeter[pn] && !m_pLifeMeter[pn]->IsFailing()) ||
(m_pCombinedLifeMeter && !m_pCombinedLifeMeter->IsFailing((PlayerNumber)pn)) )
continue; /* isn't failing */
if( GAMESTATE->m_CurStageStats.bFailed[pn] )
continue; /* failed and is already dead */
if( !AllFailedEarlier() ) // if not the last one to fail
{
// kill them!
m_soundOniDie.PlayRandom();
ShowOniGameOver((PlayerNumber)pn);
m_Player[pn].Init(); // remove all notes and scoring
m_Player[pn].FadeToFail(); // tell the NoteField to fade to white
}
GAMESTATE->m_CurStageStats.bFailed[pn] = true;
}
break; break;
default:
ASSERT(0);
} }
} }
@@ -1586,6 +1569,14 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
GAMESTATE->RemoveAllActiveAttacks(); GAMESTATE->RemoveAllActiveAttacks();
/* All players failed. */
if( GAMESTATE->m_SongOptions.m_FailType == SongOptions::FAIL_END_OF_SONG && AllFailedEarlier() )
{
for( p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsPlayerEnabled(p) )
GAMESTATE->m_CurStageStats.bFailed[p]=true;
}
for( p=0; p<NUM_PLAYERS; p++ ) for( p=0; p<NUM_PLAYERS; p++ )
{ {
if( !GAMESTATE->IsPlayerEnabled(p) ) if( !GAMESTATE->IsPlayerEnabled(p) )
+1
View File
@@ -36,6 +36,7 @@ void StageStats::AddStats( const StageStats& other )
iMeter[p] += other.iMeter[p] * iLengthMultiplier; iMeter[p] += other.iMeter[p] * iLengthMultiplier;
fAliveSeconds[p] += other.fAliveSeconds[p]; fAliveSeconds[p] += other.fAliveSeconds[p];
bFailed[p] |= other.bFailed[p]; bFailed[p] |= other.bFailed[p];
bFailedEarlier[p] |= other.bFailedEarlier[p];
iPossibleDancePoints[p] += other.iPossibleDancePoints[p]; iPossibleDancePoints[p] += other.iPossibleDancePoints[p];
iActualDancePoints[p] += other.iActualDancePoints[p]; iActualDancePoints[p] += other.iActualDancePoints[p];
+6 -1
View File
@@ -29,7 +29,12 @@ struct StageStats
enum { STAGE_INVALID, STAGE_NORMAL, STAGE_EXTRA, STAGE_EXTRA2 } StageType; enum { STAGE_INVALID, STAGE_NORMAL, STAGE_EXTRA, STAGE_EXTRA2 } StageType;
int iMeter[NUM_PLAYERS]; int iMeter[NUM_PLAYERS];
float fAliveSeconds[NUM_PLAYERS]; // how far into the music did they last before failing? Updated by Gameplay. float fAliveSeconds[NUM_PLAYERS]; // how far into the music did they last before failing? Updated by Gameplay.
bool bFailed[NUM_PLAYERS]; // true if they have failed at any point during the song /* This indicates whether the player failed the song; it's always false for FAIL_OFF
* and is only set to true in FAIL_END_OF_SONG at the end of the song. */
bool bFailed[NUM_PLAYERS];
/* This indicates whether the player bottomed out his bar/ran out of lives at some
* point during the song. It's set in all fail modes. */
bool bFailedEarlier[NUM_PLAYERS];
int iPossibleDancePoints[NUM_PLAYERS]; int iPossibleDancePoints[NUM_PLAYERS];
int iActualDancePoints[NUM_PLAYERS]; int iActualDancePoints[NUM_PLAYERS];
int iTapNoteScores[NUM_PLAYERS][NUM_TAP_NOTE_SCORES]; int iTapNoteScores[NUM_PLAYERS][NUM_TAP_NOTE_SCORES];