2003-10-25 22:00:58 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "Attack.h"
|
|
|
|
|
#include "GameState.h"
|
2003-12-05 20:31:06 +00:00
|
|
|
#include "RageUtil.h"
|
2003-10-25 22:00:58 +00:00
|
|
|
#include "song.h"
|
2004-07-23 04:45:48 +00:00
|
|
|
#include "Foreach.h"
|
2004-12-20 06:25:59 +00:00
|
|
|
#include "PlayerOptions.h"
|
2003-10-25 22:00:58 +00:00
|
|
|
|
2004-12-20 06:25:59 +00:00
|
|
|
void Attack::GetAttackBeats( const Song *song, const PlayerState* pPlayerState, float &fStartBeat, float &fEndBeat ) const
|
2003-10-25 22:00:58 +00:00
|
|
|
{
|
2004-07-23 04:45:48 +00:00
|
|
|
ASSERT( song );
|
|
|
|
|
|
2003-10-25 22:00:58 +00:00
|
|
|
if( fStartSecond >= 0 )
|
|
|
|
|
{
|
2003-12-05 20:31:06 +00:00
|
|
|
CHECKPOINT;
|
2003-10-25 22:00:58 +00:00
|
|
|
fStartBeat = song->GetBeatFromElapsedTime( fStartSecond );
|
|
|
|
|
fEndBeat = song->GetBeatFromElapsedTime( fStartSecond+fSecsRemaining );
|
2004-12-20 06:25:59 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-12-05 20:31:06 +00:00
|
|
|
CHECKPOINT;
|
2003-10-26 03:02:30 +00:00
|
|
|
/* If fStartSecond < 0, then the attack starts right off the screen; this requires
|
|
|
|
|
* that a song actually be playing. Pre-queued course attacks must always have
|
|
|
|
|
* fStartSecond >= 0. */
|
|
|
|
|
ASSERT( GAMESTATE->m_pCurSong );
|
|
|
|
|
|
2004-12-20 06:25:59 +00:00
|
|
|
ASSERT( pPlayerState );
|
|
|
|
|
|
2003-10-25 22:00:58 +00:00
|
|
|
/* We're setting this effect on the fly. If it's an arrow-changing effect
|
2004-07-23 04:45:48 +00:00
|
|
|
* (transform or note skin), apply it in the future, after what's currently on
|
2003-10-25 22:00:58 +00:00
|
|
|
* screen, so new arrows will scroll on screen with this effect. */
|
2004-12-20 06:25:59 +00:00
|
|
|
GAMESTATE->GetUndisplayedBeats( pPlayerState, fSecsRemaining, fStartBeat, fEndBeat );
|
2003-10-25 22:00:58 +00:00
|
|
|
}
|
2003-11-19 11:52:20 +00:00
|
|
|
|
2005-04-22 05:15:10 +00:00
|
|
|
// loading the course should have caught this.
|
2004-06-16 00:38:31 +00:00
|
|
|
ASSERT_M( fEndBeat >= fStartBeat, ssprintf("%f >= %f", fEndBeat, fStartBeat) );
|
2003-10-25 22:00:58 +00:00
|
|
|
}
|
2004-05-31 20:04:56 +00:00
|
|
|
|
|
|
|
|
bool Attack::operator== ( const Attack &rhs ) const
|
|
|
|
|
{
|
|
|
|
|
#define EQUAL(a) (a==rhs.a)
|
|
|
|
|
return
|
|
|
|
|
EQUAL(level) &&
|
|
|
|
|
EQUAL(fStartSecond) &&
|
|
|
|
|
EQUAL(fSecsRemaining) &&
|
2005-05-20 08:57:59 +00:00
|
|
|
EQUAL(sModifiers) &&
|
2004-05-31 20:04:56 +00:00
|
|
|
EQUAL(bOn) &&
|
|
|
|
|
EQUAL(bGlobal);
|
|
|
|
|
}
|
2004-05-31 22:42:12 +00:00
|
|
|
|
2004-07-23 04:45:48 +00:00
|
|
|
bool Attack::ContainsTransformOrTurn() const
|
|
|
|
|
{
|
|
|
|
|
PlayerOptions po;
|
2005-05-20 08:57:59 +00:00
|
|
|
po.FromString( sModifiers );
|
2004-07-23 04:45:48 +00:00
|
|
|
return po.ContainsTransformOrTurn();
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-03 23:30:56 +00:00
|
|
|
Attack Attack::FromGlobalCourseModifier( const CString &sModifiers )
|
|
|
|
|
{
|
|
|
|
|
Attack a;
|
|
|
|
|
a.fStartSecond = 0;
|
|
|
|
|
a.fSecsRemaining = 10000; /* whole song */
|
|
|
|
|
a.level = ATTACK_LEVEL_1;
|
2005-05-20 08:57:59 +00:00
|
|
|
a.sModifiers = sModifiers;
|
2005-01-03 23:30:56 +00:00
|
|
|
a.bGlobal = true;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-30 19:32:31 +00:00
|
|
|
CString Attack::GetTextDescription() const
|
|
|
|
|
{
|
|
|
|
|
CString s = sModifiers + " " + ssprintf("(%.2f seconds)", fSecsRemaining);
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-23 04:45:48 +00:00
|
|
|
bool AttackArray::ContainsTransformOrTurn() const
|
|
|
|
|
{
|
|
|
|
|
FOREACH_CONST( Attack, *this, a )
|
|
|
|
|
{
|
|
|
|
|
if( a->ContainsTransformOrTurn() )
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-31 22:42:12 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2003-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.
|
|
|
|
|
*/
|