support noteskin-changing attacks

cache trick icons
change AI probability format
This commit is contained in:
Chris Danford
2003-04-22 04:54:04 +00:00
parent 0e11d79ec8
commit 4b7d640324
22 changed files with 267 additions and 219 deletions
+8 -8
View File
@@ -24,9 +24,11 @@
#define ITEM_COMBO( i ) THEME->GetMetricI("Inventory",ssprintf("Item%dCombo",i+1))
#define ITEM_EFFECT( i ) THEME->GetMetric ("Inventory",ssprintf("Item%dEffect",i+1))
#define ITEM_LEVEL( i ) THEME->GetMetricI("Inventory",ssprintf("Item%dLevel",i+1))
CachedThemeMetricF ITEM_USE_RATE_SECONDS("Inventory","ItemUseRateSeconds");
const PlayerNumber OPPOSITE_PLAYER[NUM_PLAYERS] = { PLAYER_2, PLAYER_1 };
#define ITEM_USE_PROBABILITY (1.f/ITEM_USE_RATE_SECONDS)
struct Item
{
@@ -52,6 +54,7 @@ void ReloadItems()
Inventory::Inventory()
{
ITEM_USE_RATE_SECONDS.Refresh();
}
void Inventory::Load( PlayerNumber pn )
@@ -114,18 +117,15 @@ void Inventory::Update( float fDelta )
if( GAMESTATE->m_PlayerController[m_PlayerNumber] != PC_HUMAN &&
GAMESTATE->m_fSongBeat < GAMESTATE->m_pCurSong->m_fLastBeat )
{
// every one second, consider using an item
// every 1 seconds, try to use an item
int iLastSecond = (int)(RageTimer::GetTimeSinceStart() - fDelta);
int iThisSecond = (int)RageTimer::GetTimeSinceStart();
if( iLastSecond != iThisSecond )
{
int iSlotToConsider = rand()%NUM_INVENTORY_SLOTS;
bool bTimeToUse = (rand()%6)==0;
if( !GAMESTATE->m_Inventory[m_PlayerNumber][iSlotToConsider].IsBlank() &&
bTimeToUse )
{
UseItem( iSlotToConsider );
}
for( int s=0; s<NUM_INVENTORY_SLOTS; s++ )
if( !GAMESTATE->m_Inventory[m_PlayerNumber][s].IsBlank() )
if( randomf(0,1) < ITEM_USE_PROBABILITY )
UseItem( s );
}
}
}