progress #1 on porting battle_util
This commit is contained in:
@@ -34,7 +34,6 @@ enum
|
||||
|
||||
extern const u8 *gAIScriptPtr;
|
||||
extern u8 *BattleAIs[];
|
||||
extern u16 gLastUsedMove[];
|
||||
|
||||
static void BattleAICmd_if_random_less_than(void);
|
||||
static void BattleAICmd_if_random_greater_than(void);
|
||||
@@ -466,7 +465,7 @@ void sub_80C7164(void)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] == 0)
|
||||
{
|
||||
BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] = gLastUsedMove[gBattlerTarget];
|
||||
BATTLE_HISTORY->usedMoves[gBattlerTarget >> 1][i] = gLastMoves[gBattlerTarget];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1035,9 +1034,9 @@ static void BattleAICmd_is_most_powerful_move(void)
|
||||
static void BattleAICmd_get_move(void)
|
||||
{
|
||||
if (gAIScriptPtr[1] == USER)
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBattlerAttacker];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerAttacker];
|
||||
else
|
||||
AI_THINKING_STRUCT->funcResult = gLastUsedMove[gBattlerTarget];
|
||||
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerTarget];
|
||||
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
@@ -1373,7 +1372,7 @@ static void BattleAICmd_get_weather(void)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_RAIN;
|
||||
if (gBattleWeather & WEATHER_SANDSTORM_ANY)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_SANDSTORM;
|
||||
if (gBattleWeather & WEATHER_SUNNY_ANY)
|
||||
if (gBattleWeather & WEATHER_SUN_ANY)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_SUNNY;
|
||||
if (gBattleWeather & WEATHER_HAIL)
|
||||
AI_THINKING_STRUCT->funcResult = WEATHER_TYPE_HAIL;
|
||||
@@ -1931,7 +1930,7 @@ static void BattleAICmd_if_level_compare(void)
|
||||
|
||||
static void BattleAICmd_if_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer != 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
@@ -1939,7 +1938,7 @@ static void BattleAICmd_if_taunted(void)
|
||||
|
||||
static void BattleAICmd_if_not_taunted(void)
|
||||
{
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
|
||||
if (gDisableStructs[gBattlerTarget].tauntTimer == 0)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
else
|
||||
gAIScriptPtr += 5;
|
||||
|
||||
+1147
File diff suppressed because it is too large
Load Diff
+1
-4
@@ -19,10 +19,7 @@ void AllocateBattleResources(void)
|
||||
*ptr++ = AllocZeroed(8);
|
||||
while (--i >= 0);
|
||||
}
|
||||
// TODO: Figure out whether 0x200 is really the size of *gBattleStruct.
|
||||
// The following works in pokeem:
|
||||
// gBattleStruct = AllocZeroed(sizeof(*gBattleStruct));
|
||||
gBattleStruct = AllocZeroed(0x200);
|
||||
gBattleStruct = AllocZeroed(sizeof(*gBattleStruct));
|
||||
gBattleResources = AllocZeroed(sizeof(*gBattleResources));
|
||||
gBattleResources->secretBase = AllocZeroed(sizeof(*gBattleResources->secretBase));
|
||||
gBattleResources->flags = AllocZeroed(sizeof(*gBattleResources->flags));
|
||||
|
||||
+9
-9
@@ -2552,7 +2552,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de
|
||||
damage /= 2;
|
||||
|
||||
// sunny
|
||||
if (gBattleWeather & WEATHER_SUNNY_ANY)
|
||||
if (gBattleWeather & WEATHER_SUN_ANY)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -4117,14 +4117,14 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
|
||||
{
|
||||
gAbsentBattlerFlags &= ~gBitTable[sp34];
|
||||
CopyPlayerPartyMonToBattleData(sp34, pokemon_order_func(gBattlerPartyIndexes[sp34]));
|
||||
if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.unk4 < 255)
|
||||
gBattleResults.unk4++;
|
||||
if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.numRevivesUsed < 255)
|
||||
gBattleResults.numRevivesUsed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gAbsentBattlerFlags &= ~gBitTable[gActiveBattler ^ 2];
|
||||
if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.unk4 < 255)
|
||||
gBattleResults.unk4++;
|
||||
if (GetBattlerSide(gActiveBattler) == 0 && gBattleResults.numRevivesUsed < 255)
|
||||
gBattleResults.numRevivesUsed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4164,8 +4164,8 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
|
||||
gBattleMons[sp34].hp = data;
|
||||
if (!(r10 & 0x10) && GetBattlerSide(gActiveBattler) == 0)
|
||||
{
|
||||
if (gBattleResults.unk3 < 255)
|
||||
gBattleResults.unk3++;
|
||||
if (gBattleResults.numHealingItemsUsed < 255)
|
||||
gBattleResults.numHealingItemsUsed++;
|
||||
// I have to re-use this variable to match.
|
||||
r5 = gActiveBattler;
|
||||
gActiveBattler = sp34;
|
||||
@@ -4204,7 +4204,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
|
||||
SetMonData(pkmn, MON_DATA_PP1 + r5, &data);
|
||||
if (gMain.inBattle
|
||||
&& sp34 != 4 && !(gBattleMons[sp34].status2 & 0x200000)
|
||||
&& !(gDisableStructs[sp34].unk18_b & gBitTable[r5]))
|
||||
&& !(gDisableStructs[sp34].mimickedMoves & gBitTable[r5]))
|
||||
gBattleMons[sp34].pp[r5] = data;
|
||||
retVal = FALSE;
|
||||
}
|
||||
@@ -4229,7 +4229,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *pkmn, u16 item, u8 partyIndex, u8 mo
|
||||
SetMonData(pkmn, MON_DATA_PP1 + moveIndex, &data);
|
||||
if (gMain.inBattle
|
||||
&& sp34 != 4 && !(gBattleMons[sp34].status2 & 0x200000)
|
||||
&& !(gDisableStructs[sp34].unk18_b & gBitTable[moveIndex]))
|
||||
&& !(gDisableStructs[sp34].mimickedMoves & gBitTable[moveIndex]))
|
||||
gBattleMons[sp34].pp[moveIndex] = data;
|
||||
retVal = FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user