port ModifyStatByNature fakematch fix (from #1179)
This commit is contained in:
+13
-9
@@ -5746,25 +5746,29 @@ u8 GetTrainerEncounterMusicId(u16 trainerOpponentId)
|
|||||||
|
|
||||||
u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
|
u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
|
||||||
{
|
{
|
||||||
// Dont modify HP, Accuracy, or Evasion by nature
|
u16 retVal;
|
||||||
|
// Don't modify HP, Accuracy, or Evasion by nature
|
||||||
if (statIndex <= STAT_HP || statIndex > NUM_NATURE_STATS)
|
if (statIndex <= STAT_HP || statIndex > NUM_NATURE_STATS)
|
||||||
{
|
{
|
||||||
// Should just be "return n", but it wouldn't match without this.
|
return n;
|
||||||
u16 retVal = n;
|
|
||||||
retVal++;
|
|
||||||
retVal--;
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (gNatureStatTable[nature][statIndex - 1])
|
switch (gNatureStatTable[nature][statIndex - 1])
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return (u16)(n * 110) / 100; // NOTE: will overflow for n > 595 because the intermediate value is cast to u16 before the division. Fix by removing (u16) cast
|
retVal = n * 110;
|
||||||
|
retVal /= 100;
|
||||||
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
return (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
|
retVal = n * 90;
|
||||||
|
retVal /= 100;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
retVal = n;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_LEAGUE_BATTLE \
|
#define IS_LEAGUE_BATTLE \
|
||||||
|
|||||||
Reference in New Issue
Block a user