mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Merge pull request #1882 from GriffinRichards/ambient
Add time ranges to UpdateAmbientCry
This commit is contained in:
commit
f91abdf765
@ -1260,23 +1260,34 @@ static void PlayAmbientCry(void)
|
||||
PlayCry_NormalNoDucking(sAmbientCrySpecies, pan, volume, CRY_PRIORITY_AMBIENT);
|
||||
}
|
||||
|
||||
// States for UpdateAmbientCry
|
||||
enum {
|
||||
AMB_CRY_INIT,
|
||||
AMB_CRY_FIRST,
|
||||
AMB_CRY_RESET,
|
||||
AMB_CRY_WAIT,
|
||||
AMB_CRY_IDLE,
|
||||
};
|
||||
|
||||
void UpdateAmbientCry(s16 *state, u16 *delayCounter)
|
||||
{
|
||||
u8 i, monsCount, divBy;
|
||||
|
||||
switch (*state)
|
||||
{
|
||||
case 0:
|
||||
case AMB_CRY_INIT:
|
||||
// This state will be revisited whenever ResetFieldTasksArgs is called (which happens on map transition)
|
||||
if (sAmbientCrySpecies == SPECIES_NONE)
|
||||
*state = 4;
|
||||
*state = AMB_CRY_IDLE;
|
||||
else
|
||||
*state = 1;
|
||||
*state = AMB_CRY_FIRST;
|
||||
break;
|
||||
case 1:
|
||||
case AMB_CRY_FIRST:
|
||||
// It takes between 1200-3599 frames (~20-60 seconds) to play the first ambient cry after entering a map
|
||||
*delayCounter = (Random() % 2400) + 1200;
|
||||
*state = 3;
|
||||
*state = AMB_CRY_WAIT;
|
||||
break;
|
||||
case 2:
|
||||
case AMB_CRY_RESET:
|
||||
divBy = 1;
|
||||
monsCount = CalculatePlayerPartyCount();
|
||||
for (i = 0; i < monsCount; i++)
|
||||
@ -1288,18 +1299,20 @@ void UpdateAmbientCry(s16 *state, u16 *delayCounter)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Ambient cries after the first one take between 1200-2399 frames (~20-40 seconds)
|
||||
// If the player has a pokemon with the ability Swarm in their party, the time is halved to 600-1199 frames (~10-20 seconds)
|
||||
*delayCounter = ((Random() % 1200) + 1200) / divBy;
|
||||
*state = 3;
|
||||
*state = AMB_CRY_WAIT;
|
||||
break;
|
||||
case 3:
|
||||
(*delayCounter)--;
|
||||
if (*delayCounter == 0)
|
||||
case AMB_CRY_WAIT:
|
||||
if (--(*delayCounter) == 0)
|
||||
{
|
||||
PlayAmbientCry();
|
||||
*state = 2;
|
||||
*state = AMB_CRY_RESET;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case AMB_CRY_IDLE:
|
||||
// No land/water pokemon on this map
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user