From b4befeb3df69f9b3441761b492dbd83aff7a22fc Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 18 Aug 2003 02:37:43 +0000 Subject: [PATCH] support Transforms as attacks --- stepmania/src/GameState.cpp | 12 +++++ stepmania/src/GameState.h | 1 + stepmania/src/NoteDataUtil.cpp | 86 ++++++++++++++++++++++------------ stepmania/src/NoteDataUtil.h | 14 +++--- stepmania/src/Player.cpp | 46 ++++++++++++++++++ stepmania/src/StepMania.dsp | 12 +++-- 6 files changed, 129 insertions(+), 42 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 77e44ba9b4..9dd1312f19 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -521,6 +521,18 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a ) { LOG->Trace( "Launch attack '%s' against P%d", a.sModifier.c_str(), target+1 ); + // + // Peek at the effect being applied. If it's a transform, add it to + // a list of transforms that should be applied by the Player on its + // next update. + // + PlayerOptions po; + po.FromString( a.sModifier ); + if( po.m_Transform != PlayerOptions::TRANSFORM_NONE ) + { + m_TransformsToApply[target].push_back( po.m_Transform ); + } + // search for an open slot for( int s=0; s m_TransformsToApply[NUM_PLAYERS]; // used in PLAY_MODE_BATTLE Attack m_Inventory[NUM_PLAYERS][NUM_INVENTORY_SLOTS]; diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 78bab0cb3e..c629510651 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -482,7 +482,7 @@ void NoteDataUtil::SwapSides( NoteData &in ) in.Convert4sToHoldNotes(); } -void NoteDataUtil::Little(NoteData &in) +void NoteDataUtil::Little(NoteData &in, float fStartBeat, float fEndBeat) { int i; @@ -498,13 +498,21 @@ void NoteDataUtil::Little(NoteData &in) in.RemoveHoldNote( i ); } -void NoteDataUtil::Wide( NoteData &in ) +void NoteDataUtil::Wide( NoteData &in, float fStartBeat, float fEndBeat ) { + // Make all all quarter notes into jumps. + in.ConvertHoldNotesTo4s(); - // make all all quarter notes jumps - int max_row = in.GetLastRow(); - for( int i=0; i<=max_row; i+=ROWS_PER_BEAT*2 ) // every even beat + int first_row = 0; + if( fStartBeat != -1 ) + first_row = BeatToNoteRow(fStartBeat); + + int last_row = in.GetLastRow(); + if( fEndBeat != -1 ) + last_row = BeatToNoteRow(fEndBeat); + + for( int i=first_row; i<=last_row; i+=ROWS_PER_BEAT*2 ) // every even beat { if( in.GetNumTapNonEmptyTracks(i) != 1 ) continue; // skip. Don't place during holds @@ -545,32 +553,40 @@ void NoteDataUtil::Wide( NoteData &in ) in.Convert4sToHoldNotes(); } -void NoteDataUtil::Big( NoteData &in ) +void NoteDataUtil::Big( NoteData &in, float fStartBeat, float fEndBeat ) { - InsertIntelligentTaps(in,1.0f,0.5f,false); // add 8ths between 4ths + InsertIntelligentTaps(in,1.0f,0.5f,false,fStartBeat,fEndBeat); // add 8ths between 4ths } -void NoteDataUtil::Quick( NoteData &in ) +void NoteDataUtil::Quick( NoteData &in, float fStartBeat, float fEndBeat ) { - InsertIntelligentTaps(in,0.5f,0.25f,false); // add 16ths between 8ths + InsertIntelligentTaps(in,0.5f,0.25f,false,fStartBeat,fEndBeat); // add 16ths between 8ths } -void NoteDataUtil::Skippy( NoteData &in ) +void NoteDataUtil::Skippy( NoteData &in, float fStartBeat, float fEndBeat ) { - InsertIntelligentTaps(in,1.0f,0.75f,true); // add 16ths between 4ths + InsertIntelligentTaps(in,1.0f,0.75f,true,fStartBeat,fEndBeat); // add 16ths between 4ths } -void NoteDataUtil::InsertIntelligentTaps( NoteData &in, float fBeatInterval, float fInsertBeatOffset, bool bNewTapSameAsBeginning ) +void NoteDataUtil::InsertIntelligentTaps( NoteData &in, float fBeatInterval, float fInsertBeatOffset, bool bSkippy, float fStartBeat, float fEndBeat ) { ASSERT( fInsertBeatOffset <= fBeatInterval ); in.ConvertHoldNotesTo4s(); - // insert a beat in the middle of every fBeatInterval - int max_row = in.GetLastRow(); + // Insert a beat in the middle of every fBeatInterval. + + int first_row = 0; + if( fStartBeat != -1 ) + first_row = BeatToNoteRow(fStartBeat); + + int last_row = in.GetLastRow(); + if( fEndBeat != -1 ) + last_row = BeatToNoteRow(fEndBeat); + int rows_per_interval = BeatToNoteRow( fBeatInterval ); int insert_row_offset = BeatToNoteRow( fInsertBeatOffset ); - for( int i=0; i<=max_row; i+=rows_per_interval ) + for( int i=first_row; i<=last_row; i+=rows_per_interval ) { int iRowEarlier = i; int iRowLater = i + rows_per_interval; @@ -596,12 +612,12 @@ void NoteDataUtil::InsertIntelligentTaps( NoteData &in, float fBeatInterval, flo int iTrackOfNoteEarlier = in.GetFirstNonEmptyTrack(iRowEarlier); int iTrackOfNoteLater = in.GetFirstNonEmptyTrack(iRowLater); int iTrackOfNoteToAdd = 0; - if( bNewTapSameAsBeginning && + if( bSkippy && iTrackOfNoteEarlier != iTrackOfNoteLater ) // Don't make skips on the same note { iTrackOfNoteToAdd = iTrackOfNoteEarlier; } - else // bNewTapSameAsBeginning + else { // choose a randomish track if( abs(iTrackOfNoteEarlier-iTrackOfNoteLater) == 2 ) @@ -624,6 +640,28 @@ void NoteDataUtil::InsertIntelligentTaps( NoteData &in, float fBeatInterval, flo in.Convert4sToHoldNotes(); } +void NoteDataUtil::Mines( NoteData &in, float fStartBeat, float fEndBeat ) +{ + int iTapCount = 0; + + int first_row = 0; + if( fStartBeat != -1 ) + first_row = BeatToNoteRow(fStartBeat); + + int last_row = in.GetLastRow(); + if( fEndBeat != -1 ) + last_row = BeatToNoteRow(fEndBeat); + + for( int r=first_row; r<=last_row; r++ ) + for( int t=0; tm_TransformsToApply[m_PlayerNumber].size(); i++ ) + { + // Start beat needs to be far enough ahead to be off screen so that + // addition arrows don't suddenly pop on. + float fStartBeat = GAMESTATE->m_fSongBeat + BEATS_PER_MEASURE*2; + fStartBeat = ((int)fStartBeat)+1; + float fStartSeconds = GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat( fStartBeat ); + float fEndSeconds = fStartSeconds+10; + float fEndBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fEndSeconds ); + fEndBeat = ((int)fEndBeat)+1; + + switch( GAMESTATE->m_TransformsToApply[m_PlayerNumber][i] ) + { + case PlayerOptions::TRANSFORM_LITTLE: + NoteDataUtil::Little( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Little( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_WIDE: + NoteDataUtil::Wide( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Wide( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_BIG: + NoteDataUtil::Big( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Big( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_QUICK: + NoteDataUtil::Quick( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Quick( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_SKIPPY: + NoteDataUtil::Skippy( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Skippy( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_MINES: + NoteDataUtil::Mines( *this, fStartBeat, fEndBeat ); + NoteDataUtil::Mines( m_NoteField, fStartBeat, fEndBeat ); + break; + case PlayerOptions::TRANSFORM_NONE: + default: + ASSERT(0); + } + } + GAMESTATE->m_TransformsToApply[m_PlayerNumber].clear(); + + ActorFrame::Update( fDeltaTime ); } diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 248bce0bcc..e4c580d577 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -65,7 +65,7 @@ IntDir=.\../Debug6 TargetDir=\stepmania\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -102,7 +102,7 @@ IntDir=.\Debug TargetDir=\stepmania\stepmania TargetName=default SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -142,7 +142,7 @@ IntDir=.\../Release6 TargetDir=\stepmania\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -179,7 +179,11 @@ XBCP=xbecopy.exe # ADD BASE XBCP /NOLOGO # ADD XBCP /NOLOGO # Begin Special Build Tool -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +IntDir=.\StepMania___Xbox_Release +TargetDir=\stepmania\stepmania +TargetName=default +SOURCE="$(InputPath)" +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool