mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 03:04:15 +01:00
battle file more done and clean up tv
This commit is contained in:
parent
8ff9cb0ede
commit
a9212eeb66
File diff suppressed because it is too large
Load Diff
@ -3388,7 +3388,7 @@ _0813980C:
|
||||
_0813981C:
|
||||
ldrh r5, [r2]
|
||||
adds r0, r5, 0
|
||||
bl sub_80EF370
|
||||
bl CountDigits
|
||||
adds r3, r0, 0
|
||||
lsls r3, 24
|
||||
lsrs r3, 24
|
||||
@ -3408,7 +3408,7 @@ _0813983C:
|
||||
adds r4, 0x4
|
||||
ldrh r5, [r2]
|
||||
adds r0, r5, 0
|
||||
bl sub_80EF370
|
||||
bl CountDigits
|
||||
adds r3, r0, 0
|
||||
lsls r3, 24
|
||||
lsrs r3, 24
|
||||
|
@ -368,6 +368,94 @@ struct BattleResults
|
||||
u8 catchAttempts[11]; // 0x36
|
||||
};
|
||||
|
||||
struct BattleLinkStringSide
|
||||
{
|
||||
u32 spikesMonId:3;
|
||||
u32 reflectMonId:3;
|
||||
u32 lightScreenMonId:3;
|
||||
u32 safeguardMonId:3;
|
||||
u32 mistMonId:3;
|
||||
u32 futureSightMonId:3;
|
||||
u32 doomDesireMonId:3;
|
||||
u32 perishSongMonId:3;
|
||||
u32 wishMonId:3;
|
||||
u32 grudgeMonId:3;
|
||||
u32 field_8_6:2;
|
||||
u32 spikesMoveSlot:2;
|
||||
u32 reflectMoveSlot:2;
|
||||
u32 lightScreenMoveSlot:2;
|
||||
u32 safeguardMoveSlot:2;
|
||||
u32 mistMoveSlot:2;
|
||||
u32 futureSightMoveSlot:2;
|
||||
u32 doomDesireMoveSlot:2;
|
||||
u32 perishSongMoveSlot:2;
|
||||
u32 wishMoveSlot:2;
|
||||
u32 grudgeMoveSlot:2;
|
||||
u32 destinyBondMonId:3;
|
||||
u32 destinyBondMoveSlot:2;
|
||||
u32 field_3_0:4;
|
||||
u32 field_3_1:3;
|
||||
u32 explosion:1;
|
||||
u32 explosionMoveSlot:2;
|
||||
u32 explosionMonId:3;
|
||||
u32 perishSong:1;
|
||||
u32 field_4_2:1;
|
||||
u32 field_5_0:3;
|
||||
u32 field_5_1:2;
|
||||
};
|
||||
|
||||
struct BattleLinkStringPosition
|
||||
{
|
||||
u32 curseMonId:3;
|
||||
u32 leechSeedMonId:3;
|
||||
u32 nightmareMonId:3;
|
||||
u32 wrapMonId:3;
|
||||
u32 attractMonId:3;
|
||||
u32 confusionMonId:3;
|
||||
u32 curseMoveSlot:2;
|
||||
u32 leechSeedMoveSlot:2;
|
||||
u32 nightmareMoveSlot:2;
|
||||
u32 wrapMoveSlot:2;
|
||||
u32 attractMoveSlot:2;
|
||||
u32 confusionMoveSlot:2;
|
||||
u32 waterSportMoveSlot:2;
|
||||
u32 waterSportMonId:3;
|
||||
u32 mudSportMonId:3;
|
||||
u32 mudSportMoveSlot:2;
|
||||
u32 ingrainMonId:3;
|
||||
u32 ingrainMoveSlot:2;
|
||||
u32 field_5_5:3;
|
||||
u32 field_6_0:2;
|
||||
};
|
||||
|
||||
struct BattleLinkStringMon
|
||||
{
|
||||
u32 psnMonId:3;
|
||||
u32 badPsnMonId:3;
|
||||
u32 brnMonId:3;
|
||||
u32 prlzMonId:3;
|
||||
u32 slpMonId:3;
|
||||
u32 frzMonId:3;
|
||||
u32 psnMoveSlot:2;
|
||||
u32 badPsnMoveSlot:2;
|
||||
u32 brnMoveSlot:2;
|
||||
u32 prlzMoveSlot:2;
|
||||
u32 slpMoveSlot:2;
|
||||
u32 frzMoveSlot:2;
|
||||
};
|
||||
|
||||
struct UnknownBattleLinkStruct
|
||||
{
|
||||
struct BattleLinkStringMon mon[2][6]; // [side][partyId]
|
||||
struct BattleLinkStringPosition pos[2][2]; // [side][flank]
|
||||
struct BattleLinkStringSide side[2]; // [side]
|
||||
};
|
||||
|
||||
struct UnknownBattleLinkArrayStruct
|
||||
{
|
||||
s16 unk0[2][6*4];
|
||||
};
|
||||
|
||||
struct BattleStruct
|
||||
{
|
||||
u8 turnEffectsTracker;
|
||||
@ -472,9 +560,9 @@ struct BattleStruct
|
||||
u8 wishPerishSongBattlerId;
|
||||
bool8 overworldWeatherDone;
|
||||
u8 atkCancellerTracker;
|
||||
s16 field_1A4[2][PARTY_SIZE * 4];
|
||||
u8 field_204[104];
|
||||
u8 field_26C[40];
|
||||
struct UnknownBattleLinkArrayStruct field_1A4;
|
||||
struct UnknownBattleLinkStruct field_204;
|
||||
u8 notSureWhatFieldLol[0x28];
|
||||
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
|
||||
u8 field_298[8];
|
||||
u8 field_2A0;
|
||||
@ -493,6 +581,7 @@ struct BattleStruct
|
||||
#define IS_MOVE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
|
||||
#define IS_MOVE_SPECIAL(moveType)(moveType > TYPE_MYSTERY)
|
||||
|
||||
|
||||
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
|
||||
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
|
||||
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
|
||||
|
@ -4,16 +4,16 @@
|
||||
#define WINDOW_CLEAR 0x1
|
||||
#define WINDOW_x80 0x80
|
||||
|
||||
void AI_CalcDmg(u8 bankAtk, u8 bankDef);
|
||||
u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef);
|
||||
void AI_CalcDmg(u8 battlerIdAtk, u8 battlerIdDef);
|
||||
u8 TypeCalc(u16 move, u8 battlerIdAtk, u8 battlerIdDef);
|
||||
u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility);
|
||||
u8 GetBattlerTurnOrderNum(u8 bank);
|
||||
u8 GetBattlerTurnOrderNum(u8 battlerId);
|
||||
void SetMoveEffect(bool8 primary, u8 certain);
|
||||
void BattleDestroyYesNoCursorAt(u8 cursorPosition);
|
||||
void BattleCreateYesNoCursorAt(u8 cursorPosition);
|
||||
void BufferMoveToLearnIntoBattleTextBuff2(void);
|
||||
void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags);
|
||||
bool8 UproarWakeUpCheck(u8 bank);
|
||||
bool8 UproarWakeUpCheck(u8 battlerId);
|
||||
|
||||
extern void (* const gBattleScriptingCommandsTable[])(void);
|
||||
extern const u8 gUnknown_0831C494[][4];
|
||||
|
43
include/tv.h
43
include/tv.h
@ -3,19 +3,40 @@
|
||||
|
||||
extern u8 *const gTVStringVarPtrs[3];
|
||||
|
||||
void ClearTVShowData(void);
|
||||
void PutPokemonTodayCaughtOnAir(void);
|
||||
void sub_80EE184(void);
|
||||
void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u16 betterMove);
|
||||
void sub_80EE8C8(u16 winStreak, u8 facility);
|
||||
void DoTVShow(void);
|
||||
void DoTVShowInSearchOfTrainers(void);
|
||||
void sub_80EDCE8(void);
|
||||
void sub_80EE2CC(void);
|
||||
void sub_80EE72C(void);
|
||||
void sub_80EED10(void);
|
||||
void sub_80EED34(void);
|
||||
void sub_80EED60(u16 delta);
|
||||
void sub_80F01B8(void);
|
||||
void sub_80F01E8(void *src, u32 size, u8 masterIdx);
|
||||
void sub_80EE4DC(struct Pokemon *pokemon, u8 ribbonMonDataIdx);
|
||||
u32 GetPlayerIDAsU32(void);
|
||||
bool8 GetPriceReduction(u8 newsKind);
|
||||
u8 GetRibbonCount(struct Pokemon *pokemon);
|
||||
void TV_PutSecretBaseVisitOnTheAir(void);
|
||||
void sub_80EE184(void);
|
||||
void sub_80EEA70(void);
|
||||
void sub_80F14F8(TVShow *shows);
|
||||
size_t sub_80EF370(int value);
|
||||
bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unused, u8 sheen, u8 language);
|
||||
void SetPokemonAnglerSpecies(u16 species);
|
||||
void UpdateTVShowsPerDay(u16 days);
|
||||
void PutBattleUpdateOnTheAir(u8 a0, u16 a1, u16 a2, u16 a3);
|
||||
size_t CountDigits(int value);
|
||||
u8 GetRibbonCount(struct Pokemon *pokemon);
|
||||
void sub_80EDE70(u16 nCoinsSpent);
|
||||
void sub_80EDE84(u16 nCoinsSpent);
|
||||
void sub_80EDD78(u16 nCoinsPaidOut);
|
||||
void sub_80EEA70(void);
|
||||
void sub_80EDB44(void);
|
||||
void sub_80EDC60(const u16 *words);
|
||||
void sub_80EDA80(void);
|
||||
void sub_80F0C7C(void *src, u32 size, u8 masterIdx);
|
||||
void sub_80F0BB8(void);
|
||||
void sub_80ED950(bool8 flag);
|
||||
void sub_80EEC80(void);
|
||||
void sub_80EECA4(void);
|
||||
void sub_80EECC8(void);
|
||||
void sub_80EECEC(void);
|
||||
void sub_80F1208(TVShow *shows);
|
||||
void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed);
|
||||
|
||||
#endif //GUARD_TV_H
|
||||
|
@ -121,10 +121,10 @@ void sub_8032768(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(gBattleStruct->field_1A4); i++)
|
||||
*(gBattleStruct->field_1A4 + i) = 0;
|
||||
*((u8*)(&gBattleStruct->field_1A4) + i) = 0;
|
||||
|
||||
for (i = 0; i < sizeof(gBattleStruct->field_204); i++)
|
||||
*(gBattleStruct->field_204 + i) = 0;
|
||||
*((u8*)(&gBattleStruct->field_204) + i) = 0;
|
||||
}
|
||||
|
||||
static void InitSinglePlayerBtlControllers(void)
|
||||
|
@ -9,89 +9,6 @@
|
||||
#include "battle_message.h"
|
||||
#include "tv.h"
|
||||
|
||||
struct BattleLinkStringSide
|
||||
{
|
||||
u32 spikesMonId:3;
|
||||
u32 reflectMoveId:3;
|
||||
u32 lightScreenMonId:3;
|
||||
u32 safeguardMonId:3;
|
||||
u32 mistMonId:3;
|
||||
u32 futureSightMonId:3;
|
||||
u32 doomDesireMonId:3;
|
||||
u32 perishSongMonId:3;
|
||||
u32 wishMonId:3;
|
||||
u32 grudgeMonId:3;
|
||||
u32 field_8_6:2;
|
||||
u32 spikesMoveSlot:2;
|
||||
u32 reflectMoveSlot:2;
|
||||
u32 lightScreenMoveSlot:2;
|
||||
u32 safeguardMoveSlot:2;
|
||||
u32 mistMoveSlot:2;
|
||||
u32 futureSightMoveSlot:2;
|
||||
u32 doomDesireMoveSlot:2;
|
||||
u32 perishSongMoveSlot:2;
|
||||
u32 wishMoveSlot:2;
|
||||
u32 grudgeMoveSlot:2;
|
||||
u32 destinyBondMonId:3;
|
||||
u32 destinyBondMoveSlot:2;
|
||||
u32 field_3_0:4;
|
||||
u32 field_3_1:3;
|
||||
u32 field_4_0_0:1;
|
||||
u32 field_4_0:2;
|
||||
u32 field_4_0_b:3;
|
||||
u32 field_4_1:1;
|
||||
u32 field_4_2:1;
|
||||
u32 field_5_0:3;
|
||||
u32 field_5_1:2;
|
||||
};
|
||||
|
||||
struct BattleLinkStringPosition
|
||||
{
|
||||
u32 curseMonId:3;
|
||||
u32 leechSeedMonId:3;
|
||||
u32 nightmareMonId:3;
|
||||
u32 wrapMonId:3;
|
||||
u32 attractMonId:3;
|
||||
u32 confusionMonId:3;
|
||||
u32 curseMoveSlot:2;
|
||||
u32 leechSeedMoveSlot:2;
|
||||
u32 nightmareMoveSlot:2;
|
||||
u32 wrapMoveSlot:2;
|
||||
u32 attractMoveSlot:2;
|
||||
u32 confusionMoveSlot:2;
|
||||
u32 waterSportMoveSlot:2;
|
||||
u32 waterSportMonId:3;
|
||||
u32 mudSportMonId:3;
|
||||
u32 mudSportMoveSlot:2;
|
||||
u32 ingrainMonId:3;
|
||||
u32 ingrainMoveSlot:2;
|
||||
u32 field_5_5:3;
|
||||
u32 field_6_0:2;
|
||||
};
|
||||
|
||||
struct BattleLinkStringMon
|
||||
{
|
||||
u32 psnMonId:3;
|
||||
u32 badPsnMonId:3;
|
||||
u32 brnMonId:3;
|
||||
u32 prlzMonId:3;
|
||||
u32 slpMonId:3;
|
||||
u32 frzMonId:3;
|
||||
u32 psnMoveSlot:2;
|
||||
u32 badPsnMoveSlot:2;
|
||||
u32 brnMoveSlot:2;
|
||||
u32 prlzMoveSlot:2;
|
||||
u32 slpMoveSlot:2;
|
||||
u32 frzMoveSlot:2;
|
||||
};
|
||||
|
||||
struct UnknownBattleLinkStruct
|
||||
{
|
||||
struct BattleLinkStringMon mon[2][6]; // [side][partyId]
|
||||
struct BattleLinkStringPosition pos[2][2]; // [side][flank]
|
||||
struct BattleLinkStringSide side[2]; // [side]
|
||||
};
|
||||
|
||||
extern struct StringInfoBattle *gStringInfo;
|
||||
|
||||
extern const struct BattleMove gBattleMoves[];
|
||||
@ -102,9 +19,12 @@ void sub_817E684(u8 arg0, u16 arg1, u8 arg2, u8 arg3);
|
||||
void sub_817EECC(void);
|
||||
void sub_817EA80(u8 arg0);
|
||||
void sub_817F394(u16 weatherFlags, u16 moveId, u8 moveSlot);
|
||||
bool8 sub_817F21C(u16 moveId, s32 *dmg, u16 *powerOverride);
|
||||
|
||||
// const rom data
|
||||
extern const u16 *const gUnknown_0860A834[];
|
||||
extern const u16 gUnknown_0860A8A4[];
|
||||
extern const u16 gUnknown_0860A4AC[];
|
||||
|
||||
// code
|
||||
void sub_817C95C(u16 stringId)
|
||||
@ -120,7 +40,7 @@ void sub_817C95C(u16 stringId)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && stringId != STRINGID_ITDOESNTAFFECT && stringId != STRINGID_NOTVERYEFFECTIVE)
|
||||
return;
|
||||
|
||||
structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204);
|
||||
structPtr = &gBattleStruct->field_204;
|
||||
|
||||
atkSide = GetBattlerSide(gBattlerAttacker);
|
||||
defSide = GetBattlerSide(gBattlerTarget);
|
||||
@ -179,7 +99,7 @@ void sub_817C95C(u16 stringId)
|
||||
case STRINGID_FAINTINTHREE:
|
||||
structPtr->side[atkSide].perishSongMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1;
|
||||
structPtr->side[atkSide].perishSongMoveSlot = moveSlot;
|
||||
structPtr->side[atkSide].field_4_1 = 1;
|
||||
structPtr->side[atkSide].perishSong = 1;
|
||||
break;
|
||||
case STRINGID_PKMNPERISHCOUNTFELL:
|
||||
if (*perishCount == 0)
|
||||
@ -455,7 +375,7 @@ void sub_817C95C(u16 stringId)
|
||||
break;
|
||||
case STRINGID_PKMNRAISEDDEF:
|
||||
case STRINGID_PKMNRAISEDDEFALITTLE:
|
||||
structPtr->side[atkSide].reflectMoveId = gBattlerPartyIndexes[gBattlerAttacker] + 1;
|
||||
structPtr->side[atkSide].reflectMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1;
|
||||
structPtr->side[atkSide].reflectMoveSlot = moveSlot;
|
||||
break;
|
||||
case STRINGID_PKMNRAISEDSPDEF:
|
||||
@ -466,7 +386,7 @@ void sub_817C95C(u16 stringId)
|
||||
case STRINGID_PKMNSXWOREOFF:
|
||||
if (*finishedMoveId == MOVE_REFLECT)
|
||||
{
|
||||
structPtr->side[atkSide].reflectMoveId = 0;
|
||||
structPtr->side[atkSide].reflectMonId = 0;
|
||||
structPtr->side[atkSide].reflectMoveSlot = 0;
|
||||
}
|
||||
if (*finishedMoveId == MOVE_LIGHT_SCREEN)
|
||||
@ -501,7 +421,7 @@ void sub_817C95C(u16 stringId)
|
||||
sub_817E684(16, 0, structPtr->side[defSide].mistMonId - 1, structPtr->side[defSide].mistMoveSlot);
|
||||
break;
|
||||
case STRINGID_THEWALLSHATTERED:
|
||||
structPtr->side[defSide].reflectMoveId = 0;
|
||||
structPtr->side[defSide].reflectMonId = 0;
|
||||
structPtr->side[defSide].reflectMoveSlot = 0;
|
||||
structPtr->side[defSide].lightScreenMonId = 0;
|
||||
structPtr->side[defSide].lightScreenMoveSlot = 0;
|
||||
@ -548,7 +468,7 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
|
||||
return;
|
||||
|
||||
structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204);
|
||||
structPtr = &gBattleStruct->field_204;
|
||||
|
||||
atkSide = GetBattlerSide(gBattlerAttacker);
|
||||
defSide = GetBattlerSide(gBattlerTarget);
|
||||
@ -575,10 +495,10 @@ void sub_817E0FC(u16 move, u16 weatherFlags, struct DisableStruct *disableStruct
|
||||
}
|
||||
if (move == MOVE_SELF_DESTRUCT || move == MOVE_EXPLOSION)
|
||||
{
|
||||
structPtr->side[atkSide ^ BIT_SIDE].field_4_0_b = gBattlerPartyIndexes[gBattlerAttacker] + 1;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].field_4_0 = moveSlot;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].explosionMonId = gBattlerPartyIndexes[gBattlerAttacker] + 1;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot = moveSlot;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].field_3_0 = 13;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].field_4_0_0 = 1;
|
||||
structPtr->side[atkSide ^ BIT_SIDE].explosion = 1;
|
||||
}
|
||||
|
||||
sub_817E684(13, gBattleMoves[move].type, gBattleMoves[move].power, 0);
|
||||
@ -595,7 +515,7 @@ void sub_817E32C(u8 animationId)
|
||||
if (!(gBattleTypeFlags & BATTLE_TYPE_LINK))
|
||||
return;
|
||||
|
||||
structPtr = (struct UnknownBattleLinkStruct*)(&gBattleStruct->field_204);
|
||||
structPtr = &gBattleStruct->field_204;
|
||||
atkSide = GetBattlerSide(gBattlerAttacker);
|
||||
switch (animationId)
|
||||
{
|
||||
@ -625,7 +545,7 @@ void sub_817E3F4(void)
|
||||
u16 playerBestSpecies = 0, opponentBestSpecies = 0;
|
||||
s16 playerBestSum = 0, opponentBestSum = SHRT_MAX;
|
||||
u8 playerBestMonId = 0, opponentBestMonId = 0;
|
||||
s16 *array = NULL;
|
||||
struct UnknownBattleLinkArrayStruct *array = NULL;
|
||||
u8 countPlayer = 0, countOpponent = 0;
|
||||
s16 sum = 0;
|
||||
u16 species = 0;
|
||||
@ -635,7 +555,7 @@ void sub_817E3F4(void)
|
||||
if (gBattleStruct->field_B3)
|
||||
return;
|
||||
|
||||
array = (void*) &gBattleStruct->field_1A4[0];
|
||||
array = &gBattleStruct->field_1A4;
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) != SPECIES_NONE)
|
||||
@ -653,7 +573,7 @@ void sub_817E3F4(void)
|
||||
if (species != SPECIES_NONE && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG, NULL))
|
||||
{
|
||||
for (sum = 0, j = 0; j < 4; j++)
|
||||
sum += array[i * 4 + j];
|
||||
sum += array->unk0[0][i * 4 + j];
|
||||
|
||||
if (playerBestSum < sum)
|
||||
{
|
||||
@ -666,8 +586,9 @@ void sub_817E3F4(void)
|
||||
species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES, NULL);
|
||||
if (species != SPECIES_NONE && !GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG, NULL))
|
||||
{
|
||||
s32 id = 1;
|
||||
for (sum = 0, j = 0; j < 4; j++)
|
||||
sum += array[i * 4 + j];
|
||||
sum += array->unk0[id][i * 4 + j];
|
||||
|
||||
if (opponentBestSum == sum)
|
||||
{
|
||||
@ -689,9 +610,9 @@ void sub_817E3F4(void)
|
||||
|
||||
for (sum = 0, i = 0, j = 0; j < 4; j++)
|
||||
{
|
||||
if (sum < array[playerBestMonId * 4 + j])
|
||||
if (sum < array->unk0[0][playerBestMonId * 4 + j])
|
||||
{
|
||||
sum = array[playerBestMonId * 4 + j];
|
||||
sum = array->unk0[0][playerBestMonId * 4 + j];
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
@ -1041,3 +962,345 @@ _0817E670:\n\
|
||||
.pool");
|
||||
}
|
||||
#endif
|
||||
|
||||
void sub_817E684(u8 caseId, u16 arg1, u8 arg2, u8 arg3)
|
||||
{
|
||||
struct UnknownBattleLinkArrayStruct *array = &gBattleStruct->field_1A4;
|
||||
struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204;
|
||||
u32 atkSide = GetBattlerSide(gBattlerAttacker);
|
||||
u32 defSide = GetBattlerSide(gBattlerTarget);
|
||||
const u16 *ptr;
|
||||
s32 i;
|
||||
|
||||
switch (caseId)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 18:
|
||||
case 22 ... 27:
|
||||
array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg1] += gUnknown_0860A834[caseId][arg2];
|
||||
break;
|
||||
case 3 ... 7:
|
||||
i = 0;
|
||||
ptr = gUnknown_0860A834[caseId];
|
||||
do
|
||||
{
|
||||
if (arg1 == ptr[i])
|
||||
{
|
||||
array->unk0[atkSide][gBattlerPartyIndexes[gBattlerAttacker] * 4 + arg2] += ptr[i+1];
|
||||
break;
|
||||
}
|
||||
i += 2;
|
||||
} while (ptr[i] != 0xFFFF);
|
||||
break;
|
||||
case 19:
|
||||
structPtr->side[arg2 ^ 1].field_3_0 = 0;
|
||||
array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1];
|
||||
break;
|
||||
case 20:
|
||||
structPtr->side[arg2].field_3_0 = 0;
|
||||
case 2:
|
||||
array->unk0[arg2][0 * 4 + arg3] += gUnknown_0860A834[caseId][arg1];
|
||||
break;
|
||||
case 17:
|
||||
array->unk0[atkSide][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1];
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
case 15:
|
||||
case 16:
|
||||
case 21:
|
||||
array->unk0[atkSide ^ BIT_SIDE][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][arg1];
|
||||
break;
|
||||
case 10:
|
||||
array->unk0[arg1][arg2 * 4 + arg3] += gUnknown_0860A834[caseId][0];
|
||||
break;
|
||||
case 11:
|
||||
if (structPtr->pos[defSide][0].waterSportMonId != -(structPtr->pos[defSide][1].waterSportMonId) && arg1 == 10)
|
||||
{
|
||||
if (structPtr->pos[defSide][0].waterSportMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->pos[defSide][0].waterSportMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->pos[defSide][0].waterSportMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
if (structPtr->pos[defSide][1].waterSportMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->pos[defSide][1].waterSportMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->pos[defSide][1].waterSportMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (structPtr->pos[defSide][0].mudSportMonId != -(structPtr->pos[defSide][1].mudSportMonId) && arg1 == 13)
|
||||
{
|
||||
if (structPtr->pos[defSide][0].mudSportMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->pos[defSide][0].mudSportMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->pos[defSide][0].mudSportMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
if (structPtr->pos[defSide][1].mudSportMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->pos[defSide][1].mudSportMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->pos[defSide][1].mudSportMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (arg1 <= 8 && arg2 != 0 && structPtr->side[defSide].reflectMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->side[defSide].reflectMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->side[defSide].reflectMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (arg1 > 8 && arg2 != 0 && structPtr->side[defSide].lightScreenMonId != 0)
|
||||
{
|
||||
u32 id = (structPtr->side[defSide].lightScreenMonId - 1) * 4;
|
||||
array->unk0[defSide][id + structPtr->side[defSide].lightScreenMoveSlot] += gUnknown_0860A834[caseId][0];
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_817EA80(u8 arg0)
|
||||
{
|
||||
struct UnknownBattleLinkStruct *structPtr = &gBattleStruct->field_204;
|
||||
u32 atkSide = GetBattlerSide(gBattlerAttacker);
|
||||
u32 defSide = GetBattlerSide(gBattlerTarget);
|
||||
u32 atkArrId = structPtr->side[atkSide].field_3_1;
|
||||
s32 i;
|
||||
|
||||
if (structPtr->side[atkSide].field_3_0 != 0)
|
||||
{
|
||||
switch (structPtr->side[atkSide].field_3_0)
|
||||
{
|
||||
case 1:
|
||||
if (structPtr->pos[atkSide][atkArrId].curseMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->pos[atkSide][atkArrId].curseMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].curseMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (structPtr->pos[atkSide][atkArrId].leechSeedMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->pos[atkSide][atkArrId].leechSeedMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].leechSeedMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (structPtr->mon[atkSide][atkArrId].psnMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->mon[atkSide][atkArrId].psnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].psnMoveSlot);
|
||||
}
|
||||
if (structPtr->mon[atkSide][atkArrId].badPsnMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->mon[atkSide][atkArrId].badPsnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].badPsnMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (structPtr->mon[atkSide][atkArrId].brnMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->mon[atkSide][atkArrId].brnMonId - 1) * 4 + structPtr->mon[atkSide][atkArrId].brnMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (structPtr->pos[atkSide][atkArrId].nightmareMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->pos[atkSide][atkArrId].nightmareMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].nightmareMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (structPtr->pos[atkSide][atkArrId].wrapMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->pos[atkSide][atkArrId].wrapMonId - 1) * 4 + structPtr->pos[atkSide][atkArrId].wrapMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (structPtr->side[atkSide].spikesMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->side[atkSide].spikesMonId - 1) * 4 + structPtr->side[atkSide].spikesMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if (structPtr->side[atkSide].futureSightMonId != 0)
|
||||
{
|
||||
sub_817E684(20, 0, atkSide,
|
||||
(structPtr->side[atkSide].futureSightMonId - 1) * 4 + structPtr->side[atkSide].futureSightMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (structPtr->side[atkSide].doomDesireMonId != 0)
|
||||
{
|
||||
sub_817E684(20, 0, atkSide,
|
||||
(structPtr->side[atkSide].doomDesireMonId - 1) * 4 + structPtr->side[atkSide].doomDesireMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (structPtr->side[atkSide].perishSong
|
||||
&& structPtr->side[atkSide].perishSongMonId - 1 != gBattlerPartyIndexes[gBattlerAttacker])
|
||||
{
|
||||
sub_817E684(19, 0, atkSide,
|
||||
(structPtr->side[atkSide].perishSongMonId - 1) * 4 + structPtr->side[atkSide].perishSongMoveSlot);
|
||||
}
|
||||
if (structPtr->side[atkSide ^ BIT_SIDE].perishSong)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->side[atkSide ^ BIT_SIDE].perishSongMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].perishSongMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
if (structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->side[atkSide ^ BIT_SIDE].destinyBondMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].destinyBondMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (structPtr->pos[atkSide][i].confusionMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->pos[atkSide][i].confusionMonId - 1) * 4 + structPtr->pos[atkSide][i].confusionMoveSlot);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
if (structPtr->side[atkSide].explosion)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide,
|
||||
(structPtr->side[atkSide].explosionMonId - 1) * 4 + structPtr->side[atkSide].explosionMoveSlot);
|
||||
}
|
||||
if (structPtr->side[atkSide ^ BIT_SIDE].explosion)
|
||||
{
|
||||
sub_817E684(19, 0, atkSide ^ BIT_SIDE,
|
||||
(structPtr->side[atkSide ^ BIT_SIDE].explosionMonId - 1) * 4 + structPtr->side[atkSide ^ BIT_SIDE].explosionMoveSlot);
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (arg0 == 1)
|
||||
{
|
||||
sub_817E684(20, 0, atkSide,
|
||||
(gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6);
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (structPtr->side[defSide].field_3_0 == 7)
|
||||
{
|
||||
if (structPtr->side[defSide].spikesMonId != 0)
|
||||
{
|
||||
sub_817E684(19, 0, defSide ^ BIT_SIDE,
|
||||
(structPtr->side[defSide].spikesMonId - 1) * 4 + structPtr->side[defSide].spikesMoveSlot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_817E684(20, 0, atkSide,
|
||||
(gBattlerPartyIndexes[gBattlerAttacker]) * 4 + structPtr->side[atkSide].field_8_6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_817EECC(void)
|
||||
{
|
||||
s32 i;
|
||||
s32 dmgByMove[4];
|
||||
u16 powerOverride;
|
||||
u16 currMoveSaved;
|
||||
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
|
||||
return;
|
||||
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
|
||||
return;
|
||||
if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5)
|
||||
return;
|
||||
if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6)
|
||||
return;
|
||||
if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL)
|
||||
return;
|
||||
if (gBattleTypeFlags & (BATTLE_TYPE_PALACE | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID))
|
||||
return;
|
||||
if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]]].power == 0)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
currMoveSaved = gBattleMons[gBattlerAttacker].moves[gMoveSelectionCursor[gBattlerAttacker]];
|
||||
while (1)
|
||||
{
|
||||
if (currMoveSaved == gUnknown_0860A4AC[i])
|
||||
break;
|
||||
i++;
|
||||
if (gUnknown_0860A4AC[i] == 0xFFFF)
|
||||
break;
|
||||
}
|
||||
|
||||
if (gUnknown_0860A4AC[i] != 0xFFFF)
|
||||
return;
|
||||
|
||||
dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage;
|
||||
currMoveSaved = gCurrentMove;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
gCurrentMove = gBattleMons[gBattlerAttacker].moves[i];
|
||||
powerOverride = 0;
|
||||
if (sub_817F21C(gCurrentMove, &dmgByMove[i], &powerOverride))
|
||||
{
|
||||
u8 moveResultFlags;
|
||||
u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)];
|
||||
gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove,
|
||||
sideStatus, powerOverride,
|
||||
0, gBattlerAttacker, gBattlerTarget);
|
||||
|
||||
if (gStatuses3[gBattlerAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC)
|
||||
gBattleMoveDamage *= 2;
|
||||
if (gProtectStructs[gBattlerAttacker].helpingHand)
|
||||
gBattleMoveDamage = gBattleMoveDamage * 15 / 10;
|
||||
|
||||
moveResultFlags = TypeCalc(gCurrentMove, gBattlerAttacker, gBattlerTarget);
|
||||
dmgByMove[i] = gBattleMoveDamage;
|
||||
if (dmgByMove[i] == 0 && !(moveResultFlags & MOVE_RESULT_NO_EFFECT))
|
||||
dmgByMove[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[gMoveSelectionCursor[gBattlerAttacker]])
|
||||
{
|
||||
u16 opponentSpecies, playerSpecies;
|
||||
s32 bestMoveId;
|
||||
|
||||
if (gMoveSelectionCursor[gBattlerAttacker] != 0)
|
||||
bestMoveId = 0;
|
||||
else
|
||||
bestMoveId = 1;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (i != gMoveSelectionCursor[gBattlerAttacker] && dmgByMove[i] > dmgByMove[bestMoveId])
|
||||
bestMoveId = i;
|
||||
}
|
||||
|
||||
opponentSpecies = GetMonData(&gEnemyParty [gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_SPECIES, NULL);
|
||||
playerSpecies = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_SPECIES, NULL);
|
||||
sub_80EE35C(opponentSpecies, playerSpecies, gMoveSelectionCursor[gBattlerAttacker], gBattleMons[gBattlerAttacker].moves, gBattleMons[gBattlerAttacker].moves[bestMoveId]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gBattleMoveDamage = dmgByMove[gMoveSelectionCursor[gBattlerAttacker]];
|
||||
gCurrentMove = currMoveSaved;
|
||||
}
|
||||
|
@ -2196,7 +2196,7 @@ void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move)
|
||||
(var) /= (gStatStageRatios)[(mon)->statStages[(statIndex)]][1]; \
|
||||
}
|
||||
|
||||
s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 bankAtk, u8 bankDef)
|
||||
s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *defender, u32 move, u16 sideStatus, u16 powerOverride, u8 typeOverride, u8 battlerIdAtk, u8 battlerIdDef)
|
||||
{
|
||||
u32 i;
|
||||
s32 damage = 0;
|
||||
@ -2226,8 +2226,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
|
||||
if (attacker->item == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
attackerHoldEffect = gEnigmaBerries[bankAtk].holdEffect;
|
||||
attackerHoldEffectParam = gEnigmaBerries[bankAtk].holdEffectParam;
|
||||
attackerHoldEffect = gEnigmaBerries[battlerIdAtk].holdEffect;
|
||||
attackerHoldEffectParam = gEnigmaBerries[battlerIdAtk].holdEffectParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2237,8 +2237,8 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
|
||||
if (defender->item == ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
defenderHoldEffect = gEnigmaBerries[bankDef].holdEffect;
|
||||
defenderHoldEffectParam = gEnigmaBerries[bankDef].holdEffectParam;
|
||||
defenderHoldEffect = gEnigmaBerries[battlerIdDef].holdEffect;
|
||||
defenderHoldEffectParam = gEnigmaBerries[battlerIdDef].holdEffectParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2249,13 +2249,13 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
if (attacker->ability == ABILITY_HUGE_POWER || attacker->ability == ABILITY_PURE_POWER)
|
||||
attack *= 2;
|
||||
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, bankAtk))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE01_GET, battlerIdAtk))
|
||||
attack = (110 * attack) / 100;
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, bankDef))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE05_GET, battlerIdDef))
|
||||
defense = (110 * defense) / 100;
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankAtk))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, battlerIdAtk))
|
||||
spAttack = (110 * spAttack) / 100;
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, bankDef))
|
||||
if (ShouldGetStatBadgeBoost(FLAG_BADGE07_GET, battlerIdDef))
|
||||
spDefense = (110 * spDefense) / 100;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(sHoldEffectToType); i++)
|
||||
@ -2440,7 +2440,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
}
|
||||
|
||||
// flash fire triggered
|
||||
if ((gBattleResources->flags->flags[bankAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE)
|
||||
if ((gBattleResources->flags->flags[battlerIdAtk] & UNKNOWN_FLAG_FLASH_FIRE) && type == TYPE_FIRE)
|
||||
damage = (15 * damage) / 10;
|
||||
}
|
||||
|
||||
|
@ -1612,7 +1612,7 @@ bool8 ScrCmd_buffernumberstring(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 stringVarIndex = ScriptReadByte(ctx);
|
||||
u16 v1 = VarGet(ScriptReadHalfword(ctx));
|
||||
u8 v2 = sub_80EF370(v1);
|
||||
u8 v2 = CountDigits(v1);
|
||||
|
||||
ConvertIntToDecimalStringN(sScriptStringVars[stringVarIndex], v1, 0, v2);
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user