summaryrefslogtreecommitdiff
path: root/src/battle_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle_util.c')
-rw-r--r--src/battle_util.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/battle_util.c b/src/battle_util.c
index eb3907157..7025f0e3f 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -1,19 +1,31 @@
#include "global.h"
#include "battle.h"
-#include "battle_util.h"
#include "battle_anim.h"
+#include "battle_arena.h"
+#include "battle_pyramid.h"
+#include "battle_util.h"
#include "pokemon.h"
+#include "international_string_util.h"
#include "item.h"
#include "util.h"
#include "battle_scripts.h"
#include "random.h"
+#include "text.h"
+#include "safari_zone.h"
+#include "sound.h"
+#include "sprite.h"
#include "string_util.h"
+#include "task.h"
+#include "trig.h"
+#include "window.h"
+#include "battle_message.h"
#include "battle_ai_script_commands.h"
#include "battle_controllers.h"
#include "event_data.h"
#include "link.h"
#include "field_weather.h"
#include "constants/abilities.h"
+#include "constants/battle_anim.h"
#include "constants/battle_move_effects.h"
#include "constants/battle_script_commands.h"
#include "constants/battle_string_ids.h"
@@ -21,17 +33,16 @@
#include "constants/hold_effects.h"
#include "constants/items.h"
#include "constants/moves.h"
+#include "constants/songs.h"
#include "constants/species.h"
#include "constants/weather.h"
-#include "battle_arena.h"
-#include "battle_pyramid.h"
-#include "international_string_util.h"
-#include "safari_zone.h"
-#include "sound.h"
-#include "task.h"
-#include "trig.h"
-#include "window.h"
-#include "constants/songs.h"
+
+/*
+NOTE: The data and functions in this file up until (but not including) sSoundMovesTable
+are actually part of battle_main.c. They needed to be moved to this file in order to
+match the ROM; this is also why sSoundMovesTable's declaration is in the middle of
+functions instead of at the top of the file with the other declarations.
+*/
extern const u8 *const gBattleScriptsForMoveEffects[];
extern const u8 *const gBattlescriptsForBallThrow[];
@@ -283,9 +294,7 @@ void HandleAction_UseItem(void)
gBattlerAttacker = gBattlerTarget = gBattlerByTurnOrder[gCurrentTurnActionNumber];
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
-
ClearFuryCutterDestinyBondGrudge(gBattlerAttacker);
-
gLastUsedItem = gBattleBufferB[gBattlerAttacker][1] | (gBattleBufferB[gBattlerAttacker][2] << 8);
if (gLastUsedItem <= LAST_BALL) // is ball
@@ -311,18 +320,18 @@ void HandleAction_UseItem(void)
break;
case AI_ITEM_CURE_CONDITION:
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
- if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & 1)
+ if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 1)
{
- if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & 0x3E)
+ if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 0x3E)
gBattleCommunication[MULTISTRING_CHOOSER] = 5;
}
else
{
- do
+ while (!(*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 1))
{
- *(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) >>= 1;
+ *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1;
gBattleCommunication[MULTISTRING_CHOOSER]++;
- } while (!(*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & 1));
+ }
}
break;
case AI_ITEM_X_STAT:
@@ -338,7 +347,7 @@ void HandleAction_UseItem(void)
while (!((*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1))) & 1))
{
- *(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) >>= 1;
+ *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1;
gBattleTextBuff1[2]++;
}
@@ -354,7 +363,7 @@ void HandleAction_UseItem(void)
break;
}
- gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + (gBattlerAttacker >> 1))];
+ gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBattlerAttacker / 2)];
}
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
}
@@ -527,6 +536,8 @@ void HandleAction_ThrowPokeblock(void)
gBattleStruct->safariPkblThrowCounter++;
if (gBattleStruct->safariEscapeFactor > 1)
{
+ // BUG: The safariEscapeFactor is unintetionally able to become 0 (but it can not become negative!). This causes the pokeblock throw glitch.
+ // To fix that change the < in the if statement below to <=.
if (gBattleStruct->safariEscapeFactor < sPkblToEscapeFactor[gBattleStruct->safariPkblThrowCounter][gBattleCommunication[MULTISTRING_CHOOSER]])
gBattleStruct->safariEscapeFactor = 1;
else