Ejemplo n.º 1
0
void LifeMeterBar::Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats )
{
	LifeMeter::Load( pPlayerState, pPlayerStageStats );

	PlayerNumber pn = pPlayerState->m_PlayerNumber;

	DrainType dtype = pPlayerState->m_PlayerOptions.GetStage().m_DrainType;
	switch( dtype )
	{
		case DrainType_Normal:
			m_fLifePercentage = INITIAL_VALUE;
			break;
			/* These types only go down, so they always start at full. */
		case DrainType_NoRecover:
		case DrainType_SuddenDeath:
			m_fLifePercentage = 1.0f;	break;
		default:
			FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
	}

	// Change life difficulty to really easy if merciful beginner on
	m_bMercifulBeginnerInEffect = 
		GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR  &&  
		GAMESTATE->IsPlayerEnabled( pPlayerState )  &&
		GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == Difficulty_Beginner  &&
		PREFSMAN->m_bMercifulBeginner;

	AfterLifeChanged();
}
Ejemplo n.º 2
0
void LifeMeterBar::ChangeLife( float fDeltaLife )
{
    if( PREFSMAN->m_bMercifulDrain  &&  fDeltaLife < 0 )
        fDeltaLife *= SCALE( m_fLifePercentage, 0.f, 1.f, 0.5f, 1.f);

    // handle progressiveness and ComboToRegainLife here
    if( fDeltaLife >= 0 )
    {
        m_iMissCombo = 0;
        m_iComboToRegainLife = max( m_iComboToRegainLife-1, 0 );
        if ( m_iComboToRegainLife > 0 )
            fDeltaLife = 0.0f;
    }
    else
    {
        fDeltaLife *= 1 + (float)m_iProgressiveLifebar/8 * m_iMissCombo;
        // do this after; only successive boo/miss will
        // increase the amount of life lost.
        m_iMissCombo++;
        /* Increase by m_iRegenComboAfterMiss; never push it beyond m_iMaxRegenComboAfterMiss
         * but don't reduce it if it's already past. */
        const int NewComboToRegainLife = min(
                                             (int)PREFSMAN->m_iMaxRegenComboAfterMiss,
                                             m_iComboToRegainLife + PREFSMAN->m_iRegenComboAfterMiss );
        m_iComboToRegainLife = max( m_iComboToRegainLife, NewComboToRegainLife );
    }

    /* If we've already failed, there's no point in letting them fill up the bar again.  */
    if( STATSMAN->m_CurStageStats.m_player[m_PlayerNumber].bFailed )
        fDeltaLife = 0;

    switch( GAMESTATE->m_SongOptions.m_DrainType )
    {
    case SongOptions::DRAIN_NORMAL:
    case SongOptions::DRAIN_NO_RECOVER:
        if( fDeltaLife > 0 )
            fDeltaLife *= m_fLifeDifficulty;
        else
            fDeltaLife /= m_fLifeDifficulty;
        break;
    }

    // check if this step would cause a fail
    if( m_fLifePercentage + fDeltaLife <= FAIL_THRESHOLD  &&  m_fLifePercentage > FAIL_THRESHOLD )
    {
        /* Increase by m_iRegenComboAfterFail; never push it beyond m_iMaxRegenComboAfterFail
         * but don't reduce it if it's already past. */
        const int NewComboToRegainLife = min(
                                             (int)PREFSMAN->m_iMaxRegenComboAfterFail,
                                             m_iComboToRegainLife + PREFSMAN->m_iRegenComboAfterFail );
        m_iComboToRegainLife = max( m_iComboToRegainLife, NewComboToRegainLife );
    }

    m_fLifePercentage += fDeltaLife;
    CLAMP( m_fLifePercentage, 0, 1 );
    AfterLifeChanged();

    if( m_fLifePercentage <= FAIL_THRESHOLD )
        STATSMAN->m_CurStageStats.m_player[m_PlayerNumber].bFailedEarlier = true;
}
Ejemplo n.º 3
0
void LifeMeterBar::FillForHowToPlay(int NumPerfects, int NumMisses)
{
	m_iProgressiveLifebar = 0;  // disable progressive lifebar

	float AmountForPerfect	= NumPerfects * m_fLifeDifficulty * 0.008f;
	float AmountForMiss		= NumMisses / m_fLifeDifficulty * 0.08f;

	m_fLifePercentage = AmountForMiss - AmountForPerfect;
	CLAMP( m_fLifePercentage, 0.0f, 1.0f );
	AfterLifeChanged();
}
void LifeMeterBar::ChangeLife( float fDeltaLife )
{
	bool bUseMercifulDrain = m_bMercifulBeginnerInEffect || PREFSMAN->m_bMercifulDrain;
	if( bUseMercifulDrain  &&  fDeltaLife < 0 )
		fDeltaLife *= SCALE( m_fLifePercentage, 0.f, 1.f, 0.5f, 1.f);

	// handle progressiveness and ComboToRegainLife here
	if( fDeltaLife >= 0 )
	{
		m_iMissCombo = 0;
		m_iComboToRegainLife = max( m_iComboToRegainLife-1, 0 );
		if ( m_iComboToRegainLife > 0 )
			fDeltaLife = 0.0f;
	}
	else
	{
		fDeltaLife *= 1 + (float)m_iProgressiveLifebar/8 * m_iMissCombo;
		// do this after; only successive W5/miss will increase the amount of life lost.
		m_iMissCombo++;
		m_iComboToRegainLife = PREFSMAN->m_iRegenComboAfterMiss;
	}

	// If we've already failed, there's no point in letting them fill up the bar again.
	if( m_pPlayerStageStats->m_bFailed )
		return;

	switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType )
	{
		case SongOptions::DRAIN_NORMAL:
		case SongOptions::DRAIN_NO_RECOVER:
			if( fDeltaLife > 0 )
				fDeltaLife *= m_fLifeDifficulty;
			else
				fDeltaLife /= m_fLifeDifficulty;
			break;
		case SongOptions::DRAIN_SUDDEN_DEATH:
			// This should always -1.0f;
			if( fDeltaLife < 0 )
				fDeltaLife = -1.0f;
			else
				fDeltaLife = 0;
			break;
		default:
		break;
	}

	m_fLifePercentage += fDeltaLife;
	CLAMP( m_fLifePercentage, 0, LIFE_MULTIPLIER );
	AfterLifeChanged();
}
void LifeMeterBar::Load( const PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats )
{
	LifeMeter::Load( pPlayerState, pPlayerStageStats );

	PlayerNumber pn = pPlayerState->m_PlayerNumber;

	// Change life difficulty to really easy if merciful beginner on
	m_bMercifulBeginnerInEffect = 
		GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR  &&  
		GAMESTATE->IsPlayerEnabled( pPlayerState )  &&
		GAMESTATE->m_pCurSteps[pn]->GetDifficulty() == Difficulty_Beginner  &&
		PREFSMAN->m_bMercifulBeginner;

	AfterLifeChanged();
}
Ejemplo n.º 6
0
LifeMeterBar::LifeMeterBar()
{
	m_pStream = new LifeMeterStream;

	switch( GAMESTATE->m_SongOptions.m_DrainType )
	{
	case SongOptions::DRAIN_NORMAL:			m_fLifePercentage = 0.5f;	break;
	case SongOptions::DRAIN_NO_RECOVER:		m_fLifePercentage = 1.0f;	break;
	case SongOptions::DRAIN_SUDDEN_DEATH:	m_fLifePercentage = 1.0f;	break;
	default:	ASSERT(0);
	}

	m_fTrailingLifePercentage = 0;
	m_fLifeVelocity = 0;
	m_fHotAlpha = 0;
	m_bFailedEarlier = false;

	// set up lifebar
	m_fBaseLifeDifficulty = PREFSMAN->m_fLifeDifficultyScale;
	m_fLifeDifficulty = m_fBaseLifeDifficulty;

	m_quadBlackBackground.SetDiffuse( RageColor(0,0,0,1) );
	m_quadBlackBackground.SetZoomX( (float)METER_WIDTH );
	m_quadBlackBackground.SetZoomY( (float)METER_HEIGHT );

	this->AddChild( &m_quadBlackBackground );
	this->AddChild( m_pStream );

	// set up progressive lifebar
	m_iProgressiveLifebar = PREFSMAN->m_iProgressiveLifebar;
	m_iMissCombo = 0;

	// set up combotoregainlife
	m_iComboToRegainLife = 0;

	AfterLifeChanged();
}
Ejemplo n.º 7
0
void LifeMeterBar::ForceFail()
{
    m_fLifePercentage = 0;
    AfterLifeChanged();
}
Ejemplo n.º 8
0
LifeMeterBar::LifeMeterBar()
{
    switch( GAMESTATE->m_SongOptions.m_DrainType )
    {
    case SongOptions::DRAIN_NORMAL:
        m_fLifePercentage = INITIAL_VALUE;
        break;

    /* These types only go down, so they always start at full. */
    case SongOptions::DRAIN_NO_RECOVER:
    case SongOptions::DRAIN_SUDDEN_DEATH:
        m_fLifePercentage = 1.0f;
        break;
    default:
        ASSERT(0);
    }

    const CString sType = "LifeMeterBar";

    m_fPassingAlpha = 0;
    m_fHotAlpha = 0;
    m_bFailedEarlier = false;

    m_fBaseLifeDifficulty = PREFSMAN->m_fLifeDifficultyScale;
    m_fLifeDifficulty = m_fBaseLifeDifficulty;

    // set up progressive lifebar
    m_iProgressiveLifebar = PREFSMAN->m_iProgressiveLifebar;
    m_iMissCombo = 0;

    // set up combotoregainlife
    m_iComboToRegainLife = 0;

    m_sprBackground.Load( THEME->GetPathG(sType,"background") );
    m_sprBackground->SetName( "Background" );
    m_sprBackground->ZoomToWidth( METER_WIDTH );
    m_sprBackground->ZoomToHeight( METER_HEIGHT );
    this->AddChild( m_sprBackground );

    m_quadDangerGlow.ZoomToWidth( METER_WIDTH );
    m_quadDangerGlow.ZoomToHeight( METER_HEIGHT );
    m_quadDangerGlow.SetEffectDiffuseShift();
    m_quadDangerGlow.SetEffectColor1( RageColor(1,0,0,0.8f) );
    m_quadDangerGlow.SetEffectColor2( RageColor(1,0,0,0) );
    m_quadDangerGlow.SetEffectClock( Actor::CLOCK_BGM_BEAT );
    this->AddChild( &m_quadDangerGlow );

    m_pStream = new StreamDisplay;
    bool bExtra = GAMESTATE->IsExtraStage()||GAMESTATE->IsExtraStage2();
    CString sExtra = bExtra ? "extra " : "";
    m_pStream->Load(
        METER_WIDTH,
        METER_HEIGHT,
        NUM_STRIPS,
        NUM_CHAMBERS,
        THEME->GetPathG(sType,sExtra+"normal"),
        THEME->GetPathG(sType,sExtra+"hot"),
        THEME->GetPathG(sType,sExtra+"passing"),
        THEME->GetMetricA(sType,"StreamNormalOnCommand"),
        THEME->GetMetricA(sType,"StreamHotOnCommand"),
        THEME->GetMetricA(sType,"StreamPassingOnCommand")
    );
    this->AddChild( m_pStream );

    m_sprFrame.Load( THEME->GetPathG(sType,sExtra+"frame") );
    m_sprFrame->SetName( "Frame" );
    this->AddChild( m_sprFrame );

    AfterLifeChanged();
}