Fixed evolution tracker updates (#4503)
* update evolution tracker correctly * Update src/battle_script_commands.c --------- Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
parent
5ec08ee98c
commit
d98a4cb9a5
1 changed files with 28 additions and 8 deletions
|
@ -365,7 +365,7 @@ static void RemoveAllTerrains(void);
|
|||
static bool8 CanAbilityPreventStatLoss(u16 abilityDef, bool8 isIntimidate);
|
||||
static bool8 CanBurnHitThaw(u16 move);
|
||||
static u32 GetNextTarget(u32 moveTarget, bool32 excludeCurrent);
|
||||
static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount);
|
||||
static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 usedMove);
|
||||
|
||||
static void Cmd_attackcanceler(void);
|
||||
static void Cmd_accuracycheck(void);
|
||||
|
@ -6316,7 +6316,7 @@ static void Cmd_moveend(void)
|
|||
case MOVEEND_SET_EVOLUTION_TRACKER:
|
||||
// If the Pokémon needs to keep track of move usage for its evolutions, do it
|
||||
if (originallyUsedMove != MOVE_NONE)
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_MOVE_TWENTY_TIMES, 1);
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_MOVE_TWENTY_TIMES, 1, originallyUsedMove);
|
||||
gBattleScripting.moveendState++;
|
||||
break;
|
||||
case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits.
|
||||
|
@ -16785,7 +16785,7 @@ void BS_RunStatChangeItems(void)
|
|||
ItemBattleEffects(ITEMEFFECT_STATS_CHANGED, GetBattlerForBattleScript(cmd->battler), FALSE);
|
||||
}
|
||||
|
||||
static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount)
|
||||
static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount, u16 usedMove)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
|
@ -16810,9 +16810,19 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount)
|
|||
// We only have 9 bits to use
|
||||
u16 val = min(511, GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER) + upAmount);
|
||||
// Reset progress if you faint for the recoil method.
|
||||
if (gBattleMons[gBattlerAttacker].hp == 0 && (evolutionMethod == EVO_LEVEL_RECOIL_DAMAGE_MALE || evolutionMethod == EVO_LEVEL_RECOIL_DAMAGE_FEMALE))
|
||||
val = 0;
|
||||
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val);
|
||||
switch (evolutionMethod)
|
||||
{
|
||||
case EVO_LEVEL_MOVE_TWENTY_TIMES:
|
||||
if (evolutions[i].param == usedMove)
|
||||
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val);
|
||||
break;
|
||||
case EVO_LEVEL_RECOIL_DAMAGE_MALE:
|
||||
case EVO_LEVEL_RECOIL_DAMAGE_FEMALE:
|
||||
if (gBattleMons[gBattlerAttacker].hp == 0)
|
||||
val = 0;
|
||||
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -16822,8 +16832,18 @@ static void TryUpdateEvolutionTracker(u32 evolutionMethod, u32 upAmount)
|
|||
void BS_TryUpdateRecoilTracker(void)
|
||||
{
|
||||
NATIVE_ARGS();
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_MALE, gBattleMoveDamage);
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_FEMALE, gBattleMoveDamage);
|
||||
u8 gender = GetMonGender(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]);
|
||||
|
||||
switch(gender)
|
||||
{
|
||||
case MON_MALE:
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_MALE, gBattleMoveDamage, MOVE_NONE);
|
||||
break;
|
||||
case MON_FEMALE:
|
||||
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_FEMALE, gBattleMoveDamage, MOVE_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue