This commit is contained in:
PhallenTree 2025-01-06 12:31:43 +00:00 committed by GitHub
parent ca590818b8
commit 3bd248f7ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 18 deletions

View file

@ -1410,6 +1410,14 @@ void Task_PlayerController_RestoreBgmAfterCry(u8 taskId)
#define tExpTask_gainedExp_2 data[4] // Stored as two half-words containing a word. #define tExpTask_gainedExp_2 data[4] // Stored as two half-words containing a word.
#define tExpTask_frames data[10] #define tExpTask_frames data[10]
static void DynamaxModifyHPLevelUp(struct Pokemon *mon, u32 battler, u32 oldMaxHP)
{
ApplyDynamaxHPMultiplier(mon);
gBattleScripting.levelUpHP = GetMonData(mon, MON_DATA_MAX_HP) - oldMaxHP; // overwrite levelUpHP since it overflows
gBattleMons[battler].hp += gBattleScripting.levelUpHP;
SetMonData(mon, MON_DATA_HP, &gBattleMons[battler].hp);
}
static s32 GetTaskExpValue(u8 taskId) static s32 GetTaskExpValue(u8 taskId)
{ {
return (u16)(gTasks[taskId].tExpTask_gainedExp_1) | (gTasks[taskId].tExpTask_gainedExp_2 << 16); return (u16)(gTasks[taskId].tExpTask_gainedExp_1) | (gTasks[taskId].tExpTask_gainedExp_2 << 16);
@ -1437,13 +1445,7 @@ static void Task_GiveExpToMon(u8 taskId)
// Reapply Dynamax HP multiplier after stats are recalculated. // Reapply Dynamax HP multiplier after stats are recalculated.
if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX && monId == gBattlerPartyIndexes[battler]) if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX && monId == gBattlerPartyIndexes[battler])
{ DynamaxModifyHPLevelUp(mon, battler, oldMaxHP);
ApplyDynamaxHPMultiplier(mon);
// overwrite levelUpHP since it overflows
gBattleScripting.levelUpHP = GetMonData(mon, MON_DATA_MAX_HP) - oldMaxHP;
gBattleMons[battler].hp += gBattleScripting.levelUpHP;
SetMonData(mon, MON_DATA_HP, &gBattleMons[battler].hp);
}
gainedExp -= nextLvlExp - currExp; gainedExp -= nextLvlExp - currExp;
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);
@ -1524,13 +1526,7 @@ static void Task_GiveExpWithExpBar(u8 taskId)
// Reapply Dynamax HP multiplier after stats are recalculated. // Reapply Dynamax HP multiplier after stats are recalculated.
if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX && monId == gBattlerPartyIndexes[battler]) if (GetActiveGimmick(battler) == GIMMICK_DYNAMAX && monId == gBattlerPartyIndexes[battler])
{ DynamaxModifyHPLevelUp(mon, battler, oldMaxHP);
ApplyDynamaxHPMultiplier(mon);
// overwrite levelUpHP since it overflows
gBattleScripting.levelUpHP = GetMonData(mon, MON_DATA_MAX_HP) - oldMaxHP;
gBattleMons[battler].hp += gBattleScripting.levelUpHP;
SetMonData(mon, MON_DATA_HP, &gBattleMons[battler].hp);
}
gainedExp -= expOnNextLvl - currExp; gainedExp -= expOnNextLvl - currExp;
BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp); BtlController_EmitTwoReturnValues(battler, BUFFER_B, RET_VALUE_LEVELED_UP, gainedExp);

View file

@ -123,7 +123,7 @@ bool32 CanDynamax(u32 battler)
// Returns whether a battler is transformed into a Gigantamax form. // Returns whether a battler is transformed into a Gigantamax form.
bool32 IsGigantamaxed(u32 battler) bool32 IsGigantamaxed(u32 battler)
{ {
struct Pokemon *mon = &GetSideParty(GetBattlerSide(battler))[gBattlerPartyIndexes[battler]]; struct Pokemon *mon = GetPartyBattlerData(battler);
if ((gSpeciesInfo[gBattleMons[battler].species].isGigantamax) && GetMonData(mon, MON_DATA_GIGANTAMAX_FACTOR)) if ((gSpeciesInfo[gBattleMons[battler].species].isGigantamax) && GetMonData(mon, MON_DATA_GIGANTAMAX_FACTOR))
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -151,7 +151,7 @@ u16 GetNonDynamaxHP(u32 battler)
return gBattleMons[battler].hp; return gBattleMons[battler].hp;
else else
{ {
struct Pokemon *mon = &GetSideParty(GetBattlerSide(battler))[gBattlerPartyIndexes[battler]]; struct Pokemon *mon = GetPartyBattlerData(battler);
uq4_12_t mult = GetDynamaxLevelHPMultiplier(GetMonData(mon, MON_DATA_DYNAMAX_LEVEL), TRUE); uq4_12_t mult = GetDynamaxLevelHPMultiplier(GetMonData(mon, MON_DATA_DYNAMAX_LEVEL), TRUE);
u32 hp = UQ_4_12_TO_INT((gBattleMons[battler].hp * mult) + UQ_4_12_ROUND); u32 hp = UQ_4_12_TO_INT((gBattleMons[battler].hp * mult) + UQ_4_12_ROUND);
return hp; return hp;
@ -165,7 +165,7 @@ u16 GetNonDynamaxMaxHP(u32 battler)
return gBattleMons[battler].maxHP; return gBattleMons[battler].maxHP;
else else
{ {
struct Pokemon *mon = &GetSideParty(GetBattlerSide(battler))[gBattlerPartyIndexes[battler]]; struct Pokemon *mon = GetPartyBattlerData(battler);
uq4_12_t mult = GetDynamaxLevelHPMultiplier(GetMonData(mon, MON_DATA_DYNAMAX_LEVEL), TRUE); uq4_12_t mult = GetDynamaxLevelHPMultiplier(GetMonData(mon, MON_DATA_DYNAMAX_LEVEL), TRUE);
u32 maxHP = UQ_4_12_TO_INT((gBattleMons[battler].maxHP * mult) + UQ_4_12_ROUND); u32 maxHP = UQ_4_12_TO_INT((gBattleMons[battler].maxHP * mult) + UQ_4_12_ROUND);
return maxHP; return maxHP;
@ -510,7 +510,7 @@ void BS_UpdateDynamax(void)
{ {
NATIVE_ARGS(); NATIVE_ARGS();
u32 battler = gBattleScripting.battler; u32 battler = gBattleScripting.battler;
struct Pokemon *mon = &GetSideParty(GetBattlerSide(battler))[gBattlerPartyIndexes[battler]]; struct Pokemon *mon = GetPartyBattlerData(battler);
if (!IsGigantamaxed(battler)) // RecalcBattlerStats will get called on form change. if (!IsGigantamaxed(battler)) // RecalcBattlerStats will get called on form change.
RecalcBattlerStats(battler, mon, GetActiveGimmick(battler) == GIMMICK_DYNAMAX); RecalcBattlerStats(battler, mon, GetActiveGimmick(battler) == GIMMICK_DYNAMAX);