allow many attacks at once, not limited by inventory size

This commit is contained in:
Glenn Maynard
2003-10-24 05:43:04 +00:00
parent 798aa63370
commit a8a8591221
2 changed files with 10 additions and 6 deletions
+8 -5
View File
@@ -147,7 +147,7 @@ void GameState::Update( float fDelta )
m_bActiveAttackEndedThisUpdate[p] = false; m_bActiveAttackEndedThisUpdate[p] = false;
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ ) for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
{ {
if( m_ActiveAttacks[p][s].fSecsRemaining > 0 ) if( m_ActiveAttacks[p][s].fSecsRemaining > 0 )
{ {
@@ -624,18 +624,21 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
} }
// search for an open slot // search for an open slot
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ ) for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
if( m_ActiveAttacks[target][s].fSecsRemaining <= 0 ) if( m_ActiveAttacks[target][s].fSecsRemaining <= 0 )
{ {
m_ActiveAttacks[target][s] = a; m_ActiveAttacks[target][s] = a;
GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( target ); GAMESTATE->RebuildPlayerOptionsFromActiveAttacks( target );
return; return;
} }
LOG->Warn("Couldn't launch attack '%s' against p%i: no empty attack slots",
a.sModifier.c_str(), target );
} }
void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn ) void GameState::RemoveActiveAttacksForPlayer( PlayerNumber pn )
{ {
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ ) for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
{ {
m_ActiveAttacks[pn][s].fSecsRemaining = 0; m_ActiveAttacks[pn][s].fSecsRemaining = 0;
m_ActiveAttacks[pn][s].sModifier = ""; m_ActiveAttacks[pn][s].sModifier = "";
@@ -657,7 +660,7 @@ void GameState::RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn )
{ {
// rebuild player options // rebuild player options
PlayerOptions po = m_StoredPlayerOptions[pn]; PlayerOptions po = m_StoredPlayerOptions[pn];
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ ) for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
po.FromString( m_ActiveAttacks[pn][s].sModifier ); po.FromString( m_ActiveAttacks[pn][s].sModifier );
m_PlayerOptions[pn] = po; m_PlayerOptions[pn] = po;
} }
@@ -666,7 +669,7 @@ int GameState::GetSumOfActiveAttackLevels( PlayerNumber pn )
{ {
int iSum = 0; int iSum = 0;
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ ) for( int s=0; s<MAX_SIMULTANEOUS_ATTACKS; s++ )
if( m_ActiveAttacks[pn][s].fSecsRemaining > 0 ) if( m_ActiveAttacks[pn][s].fSecsRemaining > 0 )
iSum += m_ActiveAttacks[pn][s].level; iSum += m_ActiveAttacks[pn][s].level;
+2 -1
View File
@@ -175,7 +175,8 @@ public:
bool IsBlank() { return sModifier.empty(); } bool IsBlank() { return sModifier.empty(); }
void MakeBlank() { sModifier=""; } void MakeBlank() { sModifier=""; }
}; };
Attack m_ActiveAttacks[NUM_PLAYERS][NUM_INVENTORY_SLOTS]; enum { MAX_SIMULTANEOUS_ATTACKS=16 };
Attack m_ActiveAttacks[NUM_PLAYERS][MAX_SIMULTANEOUS_ATTACKS];
vector<PlayerOptions::Transform> m_TransformsToApply[NUM_PLAYERS]; vector<PlayerOptions::Transform> m_TransformsToApply[NUM_PLAYERS];
// used in PLAY_MODE_BATTLE // used in PLAY_MODE_BATTLE