Files
itgmania212121/stepmania/src/ScoreKeeperRave.cpp
T

216 lines
7.2 KiB
C++
Raw Normal View History

2003-06-30 18:08:27 +00:00
#include "global.h"
#include "ScoreKeeperRave.h"
#include "ThemeManager.h"
#include "RageUtil.h"
#include "GameState.h"
#include "Character.h"
2003-07-28 07:56:25 +00:00
#include "ScreenManager.h"
2004-01-11 23:33:56 +00:00
#include "PrefsManager.h"
#include "ThemeMetric.h"
#include "PlayerState.h"
#include "NoteTypes.h"
2003-06-30 18:08:27 +00:00
ThemeMetric<float> ATTACK_DURATION_SECONDS ("ScoreKeeperRave","AttackDurationSeconds");
2003-06-30 18:08:27 +00:00
2006-11-21 03:27:27 +00:00
static void SuperMeterPercentChangeInit( size_t /*ScoreEvent*/ i, RString &sNameOut, float &defaultValueOut )
{
sNameOut = "SuperMeterPercentChange" + ScoreEventToString( (ScoreEvent)i );
switch( i )
{
default: ASSERT(0);
case SE_W1: defaultValueOut = +0.05f; break;
case SE_W2: defaultValueOut = +0.04f; break;
case SE_W3: defaultValueOut = +0.02f; break;
case SE_W4: defaultValueOut = +0.00f; break;
case SE_W5: defaultValueOut = -0.00f; break;
case SE_Miss: defaultValueOut = -0.20f; break;
case SE_HitMine: defaultValueOut = -0.40f; break;
case SE_Held: defaultValueOut = +0.04f; break;
case SE_LetGo: defaultValueOut = -0.20f; break;
}
}
static Preference1D<float> g_fSuperMeterPercentChange( SuperMeterPercentChangeInit, NUM_ScoreEvent );
2006-10-01 02:32:23 +00:00
ScoreKeeperRave::ScoreKeeperRave( PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats ) :
ScoreKeeper(pPlayerState, pPlayerStageStats)
2003-06-30 18:08:27 +00:00
{
}
void ScoreKeeperRave::HandleTapScore( const TapNote &tn )
2004-01-02 08:43:14 +00:00
{
TapNoteScore score = tn.result.tns;
2004-01-12 02:09:21 +00:00
float fPercentToMove = 0;
2006-10-01 02:33:52 +00:00
if( score == TNS_HitMine )
2006-11-21 03:27:27 +00:00
fPercentToMove = g_fSuperMeterPercentChange[SE_HitMine];
2004-01-11 23:33:56 +00:00
AddSuperMeterDelta( fPercentToMove );
2004-01-02 08:43:14 +00:00
}
2003-06-30 18:08:27 +00:00
#define CROSSED( val ) (fOld < val && fNew >= val)
#define CROSSED_ATTACK_LEVEL( level ) CROSSED(1.f/NUM_ATTACK_LEVELS*(level+1))
2006-11-14 22:01:21 +00:00
void ScoreKeeperRave::HandleTapRowScore( const NoteData &nd, int iRow )
2003-06-30 18:08:27 +00:00
{
TapNoteScore scoreOfLastTap;
int iNumTapsInRow;
2003-06-30 18:08:27 +00:00
float fPercentToMove;
GetScoreOfLastTapInRow( nd, iRow, scoreOfLastTap, iNumTapsInRow );
if( iNumTapsInRow <= 0 )
return;
2003-06-30 18:08:27 +00:00
switch( scoreOfLastTap )
{
DEFAULT_FAIL( scoreOfLastTap );
2006-11-21 03:27:27 +00:00
case TNS_W1: fPercentToMove = g_fSuperMeterPercentChange[SE_W1]; break;
case TNS_W2: fPercentToMove = g_fSuperMeterPercentChange[SE_W2]; break;
case TNS_W3: fPercentToMove = g_fSuperMeterPercentChange[SE_W3]; break;
case TNS_W4: fPercentToMove = g_fSuperMeterPercentChange[SE_W4]; break;
case TNS_W5: fPercentToMove = g_fSuperMeterPercentChange[SE_W5]; break;
case TNS_Miss: fPercentToMove = g_fSuperMeterPercentChange[SE_Miss]; break;
2003-06-30 18:08:27 +00:00
}
2004-01-11 23:33:56 +00:00
AddSuperMeterDelta( fPercentToMove );
}
void ScoreKeeperRave::HandleHoldScore( const TapNote &tn )
2004-01-11 23:33:56 +00:00
{
TapNoteScore tapScore = tn.result.tns;
2004-01-12 02:09:21 +00:00
float fPercentToMove = 0;
2004-01-11 23:33:56 +00:00
switch( tapScore )
{
2006-11-21 03:27:27 +00:00
case TNS_HitMine: fPercentToMove = g_fSuperMeterPercentChange[SE_HitMine]; break;
2004-01-11 23:33:56 +00:00
}
AddSuperMeterDelta( fPercentToMove );
}
extern ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE;
void ScoreKeeperRave::HandleTapScoreNone()
{
if( PENALIZE_TAP_SCORE_NONE )
{
float fPercentToMove = g_fSuperMeterPercentChange[SE_Miss];
AddSuperMeterDelta( fPercentToMove );
}
}
2004-01-11 23:33:56 +00:00
void ScoreKeeperRave::AddSuperMeterDelta( float fUnscaledPercentChange )
{
if( PREFSMAN->m_bMercifulDrain && fUnscaledPercentChange<0 )
{
float fSuperPercentage = m_pPlayerState->m_fSuperMeter / NUM_ATTACK_LEVELS;
2004-01-11 23:33:56 +00:00
fUnscaledPercentChange *= SCALE( fSuperPercentage, 0.f, 1.f, 0.5f, 1.f);
}
// more mercy: Grow super meter slower or faster depending on life.
if( PREFSMAN->m_bMercifulSuperMeter )
{
2004-01-12 02:09:21 +00:00
float fLifePercentage = 0;
switch( m_pPlayerState->m_PlayerNumber )
2004-01-11 23:33:56 +00:00
{
case PLAYER_1: fLifePercentage = GAMESTATE->m_fTugLifePercentP1; break;
case PLAYER_2: fLifePercentage = 1 - GAMESTATE->m_fTugLifePercentP1; break;
default: ASSERT(0);
}
CLAMP( fLifePercentage, 0.f, 1.f );
2004-01-11 23:33:56 +00:00
if( fUnscaledPercentChange > 0 )
2004-01-12 03:47:55 +00:00
fUnscaledPercentChange *= SCALE( fLifePercentage, 0.f, 1.f, 1.7f, 0.3f);
2004-01-11 23:33:56 +00:00
else // fUnscaledPercentChange <= 0
2004-01-12 03:47:55 +00:00
fUnscaledPercentChange /= SCALE( fLifePercentage, 0.f, 1.f, 1.7f, 0.3f);
2004-01-11 23:33:56 +00:00
}
2003-06-30 18:08:27 +00:00
2004-01-11 23:33:56 +00:00
2004-01-12 03:47:55 +00:00
// mercy: drop super meter faster if at a higher level
if( fUnscaledPercentChange < 0 )
fUnscaledPercentChange *= SCALE( m_pPlayerState->m_fSuperMeter, 0.f, 1.f, 0.01f, 1.f );
2004-01-12 03:47:55 +00:00
AttackLevel oldAL = (AttackLevel)(int)m_pPlayerState->m_fSuperMeter;
2004-01-11 23:33:56 +00:00
float fPercentToMove = fUnscaledPercentChange;
m_pPlayerState->m_fSuperMeter += fPercentToMove * m_pPlayerState->m_fSuperMeterGrowthScale;
CLAMP( m_pPlayerState->m_fSuperMeter, 0.f, NUM_ATTACK_LEVELS );
2003-06-30 18:08:27 +00:00
AttackLevel newAL = (AttackLevel)(int)m_pPlayerState->m_fSuperMeter;
2003-06-30 18:08:27 +00:00
if( newAL > oldAL )
{
2004-01-11 23:33:56 +00:00
LaunchAttack( oldAL );
2003-06-30 18:08:27 +00:00
if( newAL == NUM_ATTACK_LEVELS ) // hit upper bounds of meter
m_pPlayerState->m_fSuperMeter -= 1.f;
2003-06-30 18:08:27 +00:00
}
2004-05-16 05:21:43 +00:00
// mercy: if losing remove attacks on life drain
2004-01-11 23:33:56 +00:00
if( fUnscaledPercentChange < 0 )
2004-05-16 05:21:43 +00:00
{
bool bWinning;
switch( m_pPlayerState->m_PlayerNumber )
2004-05-16 05:21:43 +00:00
{
case PLAYER_1: bWinning = GAMESTATE->m_fTugLifePercentP1 > 0.5f; break;
case PLAYER_2: bWinning = GAMESTATE->m_fTugLifePercentP1 < 0.5f; break;
default: ASSERT(0);
}
if( !bWinning )
2006-01-13 05:57:18 +00:00
m_pPlayerState->EndActiveAttacks();
2004-05-16 05:21:43 +00:00
}
2003-06-30 18:08:27 +00:00
}
2004-01-11 23:33:56 +00:00
2003-06-30 18:08:27 +00:00
void ScoreKeeperRave::LaunchAttack( AttackLevel al )
{
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
2006-01-22 01:00:06 +00:00
RString* asAttacks = GAMESTATE->m_pCurCharacters[pn]->m_sAttacks[al]; // [NUM_ATTACKS_PER_LEVEL]
RString sAttackToGive;
2003-08-31 02:26:07 +00:00
if (GAMESTATE->m_pCurCharacters[pn] != NULL)
sAttackToGive = asAttacks[ RandomInt(NUM_ATTACKS_PER_LEVEL) ];
2003-08-31 02:26:07 +00:00
else
{
/* If you add any note skins here, you need to make sure they're cached, too. */
2006-01-22 01:00:06 +00:00
RString DefaultAttacks[8] = { "1.5x", "2.0x", "0.5x", "reverse", "sudden", "boost", "brake", "wave" };
sAttackToGive = DefaultAttacks[ RandomInt(8) ];
2003-08-31 02:26:07 +00:00
}
PlayerNumber pnToAttack = OPPOSITE_PLAYER[pn];
PlayerState *pPlayerStateToAttack = GAMESTATE->m_pPlayerState[pnToAttack];
2003-06-30 18:08:27 +00:00
2003-10-25 22:00:58 +00:00
Attack a;
2003-06-30 18:08:27 +00:00
a.level = al;
a.fSecsRemaining = ATTACK_DURATION_SECONDS;
2005-05-20 08:57:59 +00:00
a.sModifiers = sAttackToGive;
2003-06-30 18:08:27 +00:00
2003-07-28 07:56:25 +00:00
// remove current attack (if any)
pPlayerStateToAttack->RemoveActiveAttacks();
2003-07-28 07:56:25 +00:00
// apply new attack
pPlayerStateToAttack->LaunchAttack( a );
2003-06-30 18:08:27 +00:00
2003-11-26 08:25:45 +00:00
// SCREENMAN->SystemMessage( ssprintf( "attacking %d with %s", pnToAttack, sAttackToGive.c_str() ) );
2003-06-30 18:08:27 +00:00
}
2004-05-31 21:35:31 +00:00
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/