minor fixes
and remove unnecessary NONMATCHING
This commit is contained in:
-17
@@ -278,23 +278,6 @@ gStatusConditionString_LoveJpn:: @ 82500C4
|
||||
gUnknown_82500CC:: @ 82500CC
|
||||
.incbin "baserom.gba", 0x2500CC, 0x38
|
||||
|
||||
.section .rodata.825098C
|
||||
|
||||
gUnknown_825098C:: @ 825098C
|
||||
.incbin "baserom.gba", 0x25098C, 0x8
|
||||
|
||||
gUnknown_8250994:: @ 8250994
|
||||
.incbin "baserom.gba", 0x250994, 0x60
|
||||
|
||||
gUnknown_82509F4:: @ 82509F4
|
||||
.incbin "baserom.gba", 0x2509F4, 0x18
|
||||
|
||||
gSpriteSheet_EnemyShadow:: @ 8250A0C
|
||||
.incbin "baserom.gba", 0x250A0C, 0x10
|
||||
|
||||
gSpriteTemplate_EnemyShadow:: @ 8250A1C
|
||||
.incbin "baserom.gba", 0x250A1C, 0x18
|
||||
|
||||
.section .rodata.8260270
|
||||
|
||||
gUnknown_8260270:: @ 8260270
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
.section .rodata
|
||||
.balign 4
|
||||
|
||||
gUnknown_825098C:: @ 825098C
|
||||
.incbin "baserom.gba", 0x25098C, 0x8
|
||||
|
||||
gUnknown_8250994:: @ 8250994
|
||||
.incbin "baserom.gba", 0x250994, 0x60
|
||||
|
||||
gUnknown_82509F4:: @ 82509F4
|
||||
.incbin "baserom.gba", 0x2509F4, 0x18
|
||||
|
||||
gSpriteSheet_EnemyShadow:: @ 8250A0C
|
||||
.incbin "baserom.gba", 0x250A0C, 0x10
|
||||
|
||||
gSpriteTemplate_EnemyShadow:: @ 8250A1C
|
||||
.incbin "baserom.gba", 0x250A1C, 0x18
|
||||
@@ -81,7 +81,7 @@ enum
|
||||
|
||||
#define RET_VALUE_LEVELLED_UP 11
|
||||
|
||||
#define INSTANT_HP_BAR_DROP 32767
|
||||
#define INSTANT_HP_BAR_DROP 0x7FFF
|
||||
|
||||
// Special return values in gBattleBufferB from Battle Controller functions.
|
||||
#define RET_VALUE_LEVELED_UP 11
|
||||
|
||||
@@ -293,5 +293,4 @@
|
||||
#define BATTLE_TERRAIN_BUILDING 8
|
||||
#define BATTLE_TERRAIN_PLAIN 9
|
||||
|
||||
|
||||
#endif // GUARD_CONSTANTS_BATTLE_H
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@ SECTIONS {
|
||||
src/battle_util.o(.rodata);
|
||||
src/battle_script_commands.o(.rodata);
|
||||
src/battle_controller_player.o(.rodata);
|
||||
data/data.o(.rodata.825098C);
|
||||
data/smokescreen.o(.rodata);
|
||||
src/battle_controller_opponent.o(.rodata);
|
||||
src/battle_controller_link_opponent.o(.rodata);
|
||||
src/pokemon.o(.rodata);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define AI_ACTION_UNK7 0x0040
|
||||
#define AI_ACTION_UNK8 0x0080
|
||||
|
||||
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
|
||||
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
|
||||
#define AI_THINKING_STRUCT (gBattleResources->ai)
|
||||
#define BATTLE_HISTORY (gBattleResources->battleHistory)
|
||||
|
||||
// AI states
|
||||
enum
|
||||
@@ -1808,14 +1808,8 @@ static void BattleAICmd_get_used_held_item(void)
|
||||
battlerId = gBattlerAttacker;
|
||||
else
|
||||
battlerId = gBattlerTarget;
|
||||
|
||||
// This is likely a leftover from Ruby's code and its ugly ewram access.
|
||||
#ifdef NONMATCHING
|
||||
AI_THINKING_STRUCT->funcResult = gBattleStruct->usedHeldItems[battlerId];
|
||||
#else
|
||||
AI_THINKING_STRUCT->funcResult = *(u8*)((u8*)(gBattleStruct) + offsetof(struct BattleStruct, usedHeldItems) + (battlerId * 2));
|
||||
#endif // NONMATCHING
|
||||
|
||||
AI_THINKING_STRUCT->funcResult = ((u8 *)gBattleStruct->usedHeldItems)[battlerId * 2];
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
|
||||
+66
-124
@@ -19,7 +19,7 @@ static bool8 ShouldUseItem(void);
|
||||
static bool8 ShouldSwitchIfPerishSong(void)
|
||||
{
|
||||
if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG
|
||||
&& gDisableStructs[gActiveBattler].perishSongTimer == 0)
|
||||
&& gDisableStructs[gActiveBattler].perishSongTimer == 0)
|
||||
{
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = PARTY_SIZE;
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
@@ -55,17 +55,13 @@ static bool8 ShouldSwitchIfWonderGuard(void)
|
||||
// Find a Pokemon in the party that has a super effective move.
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[gActiveBattler])
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0
|
||||
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|
||||
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG
|
||||
|| i == gBattlerPartyIndexes[gActiveBattler])
|
||||
continue;
|
||||
GetMonData(&gEnemyParty[i], MON_DATA_SPECIES); // Unused return value.
|
||||
GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM); // Unused return value.
|
||||
|
||||
GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM); // Unused return value.
|
||||
for (opposingBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT), j = 0; j < MAX_MON_MOVES; ++j)
|
||||
{
|
||||
move = GetMonData(&gEnemyParty[i], MON_DATA_MOVE1 + j);
|
||||
@@ -91,13 +87,11 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
u8 absorbingTypeAbility;
|
||||
s32 i;
|
||||
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3)
|
||||
if ((HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3)
|
||||
|| (gLastLandedMoves[gActiveBattler] == MOVE_NONE))
|
||||
return FALSE;
|
||||
if (gLastLandedMoves[gActiveBattler] == MOVE_NONE)
|
||||
return FALSE;
|
||||
if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
|
||||
return FALSE;
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
|
||||
if (gLastLandedMoves[gActiveBattler] == 0xFFFF
|
||||
|| gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
|
||||
return FALSE;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
@@ -127,19 +121,13 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
u16 species;
|
||||
u8 monAbility;
|
||||
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn1])
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES);
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM) != ABILITY_NONE)
|
||||
@@ -159,11 +147,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
|
||||
|
||||
static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
{
|
||||
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP))
|
||||
return FALSE;
|
||||
if (gBattleMons[gActiveBattler].ability != ABILITY_NATURAL_CURE)
|
||||
return FALSE;
|
||||
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2)
|
||||
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
|
||||
|| (gBattleMons[gActiveBattler].ability != ABILITY_NATURAL_CURE)
|
||||
|| (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2))
|
||||
return FALSE;
|
||||
if ((gLastLandedMoves[gActiveBattler] == MOVE_NONE || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
|
||||
{
|
||||
@@ -177,9 +163,8 @@ static bool8 ShouldSwitchIfNaturalCure(void)
|
||||
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
|
||||
return TRUE;
|
||||
}
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 1))
|
||||
return TRUE;
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1))
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 1)
|
||||
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1))
|
||||
return TRUE;
|
||||
if (Random() & 1)
|
||||
{
|
||||
@@ -209,9 +194,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
|
||||
moveFlags = AI_TypeCalc(move, gBattleMons[opposingBattler].species, gBattleMons[opposingBattler].ability);
|
||||
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE)
|
||||
{
|
||||
if (noRng)
|
||||
return TRUE;
|
||||
if (Random() % 10 != 0)
|
||||
if (noRng || (Random() % 10))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -261,11 +244,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
|
||||
if (gLastLandedMoves[gActiveBattler] == 0)
|
||||
return FALSE;
|
||||
if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
|
||||
return FALSE;
|
||||
if (gLastHitBy[gActiveBattler] == 0xFF)
|
||||
return FALSE;
|
||||
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
|
||||
if ((gLastLandedMoves[gActiveBattler] == 0xFFFF)
|
||||
|| (gLastHitBy[gActiveBattler] == 0xFF)
|
||||
|| (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0))
|
||||
return FALSE;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
@@ -280,25 +261,18 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
|
||||
battlerIn1 = gActiveBattler;
|
||||
battlerIn2 = gActiveBattler;
|
||||
}
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
u16 species;
|
||||
u8 monAbility;
|
||||
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn1])
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES);
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_ABILITY_NUM) != ABILITY_NONE)
|
||||
@@ -333,21 +307,14 @@ static bool8 ShouldSwitch(void)
|
||||
s32 i;
|
||||
s32 availableToSwitch;
|
||||
|
||||
if (gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
|
||||
return FALSE;
|
||||
if (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
|
||||
return FALSE;
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0))
|
||||
return FALSE;
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
|
||||
if ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION))
|
||||
|| (gStatuses3[gActiveBattler] & STATUS3_ROOTED)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0)
|
||||
|| AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0))
|
||||
return FALSE; // misses the flying or levitate check
|
||||
if (AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MAGNET_PULL, 0, 0))
|
||||
{
|
||||
if (gBattleMons[gActiveBattler].type1 == TYPE_STEEL)
|
||||
if ((gBattleMons[gActiveBattler].type1 == TYPE_STEEL) || (gBattleMons[gActiveBattler].type2 == TYPE_STEEL))
|
||||
return FALSE;
|
||||
if (gBattleMons[gActiveBattler].type2 == TYPE_STEEL)
|
||||
return FALSE;
|
||||
}
|
||||
availableToSwitch = 0;
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
@@ -364,38 +331,28 @@ static bool8 ShouldSwitch(void)
|
||||
}
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn1])
|
||||
continue;
|
||||
if (i == gBattlerPartyIndexes[battlerIn2])
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
if ((GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| (i == gBattlerPartyIndexes[battlerIn1])
|
||||
|| (i == gBattlerPartyIndexes[battlerIn2])
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
++availableToSwitch;
|
||||
}
|
||||
if (!availableToSwitch)
|
||||
return FALSE;
|
||||
if (ShouldSwitchIfPerishSong())
|
||||
if (ShouldSwitchIfPerishSong()
|
||||
|| ShouldSwitchIfWonderGuard()
|
||||
|| FindMonThatAbsorbsOpponentsMove()
|
||||
|| ShouldSwitchIfNaturalCure())
|
||||
return TRUE;
|
||||
if (ShouldSwitchIfWonderGuard())
|
||||
return TRUE;
|
||||
if (FindMonThatAbsorbsOpponentsMove())
|
||||
return TRUE;
|
||||
if (ShouldSwitchIfNaturalCure())
|
||||
return TRUE;
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(FALSE))
|
||||
return FALSE;
|
||||
if (AreStatsRaised())
|
||||
if (HasSuperEffectiveMoveAgainstOpponents(FALSE)
|
||||
|| AreStatsRaised())
|
||||
return FALSE;
|
||||
if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 2)
|
||||
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 3))
|
||||
|| FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 3))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -423,20 +380,14 @@ void AI_TrySwitchOrUseItem(void)
|
||||
battlerIn1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
|
||||
battlerIn2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
|
||||
}
|
||||
|
||||
for (monToSwitchId = 0; monToSwitchId < PARTY_SIZE; ++monToSwitchId)
|
||||
{
|
||||
if (GetMonData(&gEnemyParty[monToSwitchId], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (monToSwitchId == gBattlerPartyIndexes[battlerIn1])
|
||||
continue;
|
||||
if (monToSwitchId == gBattlerPartyIndexes[battlerIn2])
|
||||
continue;
|
||||
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
continue;
|
||||
if (monToSwitchId == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
continue;
|
||||
break;
|
||||
if ((!GetMonData(&gEnemyParty[monToSwitchId], MON_DATA_HP) == 0)
|
||||
&& (monToSwitchId != gBattlerPartyIndexes[battlerIn1])
|
||||
&& (monToSwitchId != gBattlerPartyIndexes[battlerIn2])
|
||||
&& (monToSwitchId != *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
&& (monToSwitchId != *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
*(gBattleStruct->AI_monToSwitchIntoId + (GetBattlerPosition(gActiveBattler) >> 1)) = monToSwitchId;
|
||||
@@ -568,17 +519,12 @@ u8 GetMostSuitableMonToSwitchInto(void)
|
||||
// If we couldn't find the best mon in terms of typing, find the one that deals most damage.
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if ((u16)(GetMonData(&gEnemyParty[i], MON_DATA_SPECIES)) == SPECIES_NONE)
|
||||
continue;
|
||||
if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (gBattlerPartyIndexes[battlerIn1] == i)
|
||||
continue;
|
||||
if (gBattlerPartyIndexes[battlerIn2] == i)
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
continue;
|
||||
if (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2))
|
||||
if (((u16)(GetMonData(&gEnemyParty[i], MON_DATA_SPECIES)) == SPECIES_NONE)
|
||||
|| (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0)
|
||||
|| (gBattlerPartyIndexes[battlerIn1] == i)
|
||||
|| (gBattlerPartyIndexes[battlerIn2] == i)
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn1))
|
||||
|| (i == *(gBattleStruct->monToSwitchIntoId + battlerIn2)))
|
||||
continue;
|
||||
for (j = 0; j < MAX_MON_MOVES; ++j)
|
||||
{
|
||||
@@ -636,9 +582,7 @@ static bool8 ShouldUseItem(void)
|
||||
if (i && validMons > (gBattleResources->battleHistory->itemsNo - i) + 1)
|
||||
continue;
|
||||
item = gBattleResources->battleHistory->trainerItems[i];
|
||||
if (item == ITEM_NONE)
|
||||
continue;
|
||||
if (gItemEffectTable[item - ITEM_POTION] == NULL)
|
||||
if (item == ITEM_NONE || gItemEffectTable[item - ITEM_POTION] == NULL)
|
||||
continue;
|
||||
if (item == ITEM_ENIGMA_BERRY)
|
||||
itemEffects = gSaveBlock1Ptr->enigmaBerry.itemEffect;
|
||||
@@ -656,9 +600,7 @@ static bool8 ShouldUseItem(void)
|
||||
break;
|
||||
case AI_ITEM_HEAL_HP:
|
||||
paramOffset = GetItemEffectParamOffset(item, 4, 4);
|
||||
if (paramOffset == 0)
|
||||
break;
|
||||
if (gBattleMons[gActiveBattler].hp == 0)
|
||||
if (paramOffset == 0 || gBattleMons[gActiveBattler].hp == 0)
|
||||
break;
|
||||
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 4 || gBattleMons[gActiveBattler].maxHP - gBattleMons[gActiveBattler].hp > itemEffects[paramOffset])
|
||||
shouldUse = TRUE;
|
||||
|
||||
@@ -1149,8 +1149,8 @@ static void LinkOpponentHandleDrawTrainerPic(void)
|
||||
trainerPicId = sub_80447AC();
|
||||
}
|
||||
else if ((gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_RUBY
|
||||
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_SAPPHIRE
|
||||
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_EMERALD)
|
||||
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_SAPPHIRE
|
||||
|| (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].version & 0xFF) == VERSION_EMERALD)
|
||||
{
|
||||
if (gLinkPlayers[GetMultiplayerId() ^ BIT_SIDE].gender != MALE)
|
||||
trainerPicId = gFacilityClassToPicIndex[FACILITY_CLASS_PKMN_TRAINER_5];
|
||||
@@ -1272,7 +1272,7 @@ static void LinkOpponentDoMoveAnimation(void)
|
||||
{
|
||||
case 0:
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
|
||||
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
|
||||
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
|
||||
{
|
||||
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
|
||||
@@ -668,7 +668,6 @@ static void HandleMoveSwitching(void)
|
||||
MoveSelectionDisplayMoveNames();
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
perMovePPBonuses[i] = (gBattleMons[gActiveBattler].ppBonuses & (3 << (i * 2))) >> (i * 2);
|
||||
|
||||
totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]];
|
||||
perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]] = perMovePPBonuses[gMultiUsePlayerCursor];
|
||||
perMovePPBonuses[gMultiUsePlayerCursor] = totalPPBonuses;
|
||||
@@ -746,7 +745,6 @@ static void HandleMoveSwitching(void)
|
||||
MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor);
|
||||
gMultiUsePlayerCursor ^= 1;
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler])
|
||||
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0);
|
||||
else
|
||||
@@ -763,7 +761,6 @@ static void HandleMoveSwitching(void)
|
||||
MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor);
|
||||
gMultiUsePlayerCursor ^= 1;
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler])
|
||||
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0);
|
||||
else
|
||||
@@ -780,7 +777,6 @@ static void HandleMoveSwitching(void)
|
||||
MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor);
|
||||
gMultiUsePlayerCursor ^= 2;
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler])
|
||||
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0);
|
||||
else
|
||||
@@ -797,7 +793,6 @@ static void HandleMoveSwitching(void)
|
||||
MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor);
|
||||
gMultiUsePlayerCursor ^= 2;
|
||||
PlaySE(SE_SELECT);
|
||||
|
||||
if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler])
|
||||
MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0);
|
||||
else
|
||||
@@ -981,7 +976,7 @@ static void sub_802FD18(void)
|
||||
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
|
||||
sub_80F1720(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
|
||||
if (gSprites[gUnknown_3004FFC[gActiveBattler]].callback == SpriteCallbackDummy
|
||||
&& !(gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive))
|
||||
&& !(gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive))
|
||||
{
|
||||
DestroySprite(&gSprites[gUnknown_3004FFC[gActiveBattler]]);
|
||||
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler],
|
||||
@@ -1057,7 +1052,6 @@ static void Task_GiveExpToMon(u8 taskId)
|
||||
gActiveBattler = battlerId;
|
||||
BtlController_EmitTwoReturnValues(1, RET_VALUE_LEVELED_UP, gainedExp);
|
||||
gActiveBattler = savedActiveBattler;
|
||||
|
||||
if (IsDoubleBattle() == TRUE
|
||||
&& ((u16)(monId) == gBattlerPartyIndexes[battlerId] || (u16)(monId) == gBattlerPartyIndexes[battlerId ^ BIT_FLANK]))
|
||||
gTasks[taskId].func = Task_LaunchLvlUpAnim;
|
||||
@@ -2261,7 +2255,7 @@ static void PlayerHandleFaintAnimation(void)
|
||||
{
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
|
||||
++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2345,7 +2339,7 @@ static void PlayerDoMoveAnimation(void)
|
||||
{
|
||||
case 0:
|
||||
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
|
||||
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
|
||||
&& !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
|
||||
{
|
||||
gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
|
||||
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
|
||||
@@ -2587,7 +2581,7 @@ static void PlayerHandleDMA3Transfer(void)
|
||||
| (gBattleBufferA[gActiveBattler][4] << 24);
|
||||
u16 sizeArg = gBattleBufferA[gActiveBattler][5] | (gBattleBufferA[gActiveBattler][6] << 8);
|
||||
const u8 *src = &gBattleBufferA[gActiveBattler][7];
|
||||
u8 *dst = (u8*)(dstArg);
|
||||
u8 *dst = (u8 *)(dstArg);
|
||||
u32 size = sizeArg;
|
||||
|
||||
while (TRUE)
|
||||
|
||||
@@ -414,7 +414,7 @@ static void SafariHandlePrintString(void)
|
||||
|
||||
gBattle_BG0_X = 0;
|
||||
gBattle_BG0_Y = 0;
|
||||
stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]);
|
||||
stringId = (u16 *)(&gBattleBufferA[gActiveBattler][2]);
|
||||
BufferStringBattle(*stringId);
|
||||
if (sub_80D89B0(*stringId))
|
||||
BattlePutTextOnWindow(gDisplayedStringBattle, 0x40);
|
||||
|
||||
@@ -193,7 +193,6 @@ static void InitLinkBtlControllers(void)
|
||||
multiplayerId = GetMultiplayerId();
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_IS_MASTER)
|
||||
gBattleMainFunc = BeginBattleIntro;
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; ++i)
|
||||
{
|
||||
switch (gLinkPlayers[i].id)
|
||||
@@ -383,7 +382,7 @@ enum
|
||||
LINK_BUFF_SIZE_HI,
|
||||
LINK_BUFF_ABSENT_BATTLER_FLAGS,
|
||||
LINK_BUFF_EFFECT_BATTLER,
|
||||
LINK_BUFF_DATA,
|
||||
LINK_BUFF_DATA
|
||||
};
|
||||
|
||||
void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data)
|
||||
@@ -602,7 +601,7 @@ static void BtlController_EmitSetRawMonData(u8 bufferId, u8 monId, u8 bytes, voi
|
||||
sBattleBuffersTransferData[1] = monId;
|
||||
sBattleBuffersTransferData[2] = bytes;
|
||||
for (i = 0; i < bytes; ++i)
|
||||
sBattleBuffersTransferData[3 + i] = *(u8*)(data++);
|
||||
sBattleBuffersTransferData[3 + i] = *(u8 *)(data++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, bytes + 3);
|
||||
}
|
||||
|
||||
@@ -702,7 +701,7 @@ static void BtlController_EmitPause(u8 bufferId, u8 toWait, void *data)
|
||||
sBattleBuffersTransferData[0] = CONTROLLER_PAUSE;
|
||||
sBattleBuffersTransferData[1] = toWait;
|
||||
for (i = 0; i < toWait * 3; ++i)
|
||||
sBattleBuffersTransferData[2 + i] = *(u8*)(data++);
|
||||
sBattleBuffersTransferData[2 + i] = *(u8 *)(data++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, toWait * 3 + 2);
|
||||
}
|
||||
|
||||
@@ -775,7 +774,6 @@ void BtlController_EmitPrintSelectionString(u8 bufferId, u16 stringID)
|
||||
sBattleBuffersTransferData[1] = CONTROLLER_PRINTSTRINGPLAYERONLY;
|
||||
sBattleBuffersTransferData[2] = stringID;
|
||||
sBattleBuffersTransferData[3] = (stringID & 0xFF00) >> 8;
|
||||
|
||||
stringInfo = (struct BattleMsgData*)(&sBattleBuffersTransferData[4]);
|
||||
stringInfo->currentMove = gCurrentMove;
|
||||
stringInfo->originallyUsedMove = gChosenMove;
|
||||
@@ -820,7 +818,7 @@ void BtlController_EmitChooseMove(u8 bufferId, bool8 isDoubleBattle, bool8 NoPpN
|
||||
sBattleBuffersTransferData[2] = NoPpNumber;
|
||||
sBattleBuffersTransferData[3] = 0;
|
||||
for (i = 0; i < sizeof(*movePpData); ++i)
|
||||
sBattleBuffersTransferData[4 + i] = *((u8*)(movePpData) + i);
|
||||
sBattleBuffersTransferData[4 + i] = *((u8 *)(movePpData) + i);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sizeof(*movePpData) + 4);
|
||||
}
|
||||
|
||||
@@ -917,7 +915,7 @@ void BtlController_EmitDataTransfer(u8 bufferId, u16 size, void *data)
|
||||
sBattleBuffersTransferData[2] = size;
|
||||
sBattleBuffersTransferData[3] = (size & 0xFF00) >> 8;
|
||||
for (i = 0; i < size; ++i)
|
||||
sBattleBuffersTransferData[4 + i] = *(u8*)(data++);
|
||||
sBattleBuffersTransferData[4 + i] = *(u8 *)(data++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 4);
|
||||
}
|
||||
|
||||
@@ -934,7 +932,7 @@ static void BtlController_EmitDMA3Transfer(u8 bufferId, void *dst, u16 size, voi
|
||||
sBattleBuffersTransferData[5] = size;
|
||||
sBattleBuffersTransferData[6] = (size & 0xFF00) >> 8;
|
||||
for (i = 0; i < size; ++i)
|
||||
sBattleBuffersTransferData[7 + i] = *(u8*)(data++);
|
||||
sBattleBuffersTransferData[7 + i] = *(u8 *)(data++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 7);
|
||||
}
|
||||
|
||||
@@ -947,7 +945,7 @@ static void BtlController_EmitPlayBGM(u8 bufferId, u16 songId, void *unusedDumbD
|
||||
sBattleBuffersTransferData[1] = songId;
|
||||
sBattleBuffersTransferData[2] = (songId & 0xFF00) >> 8;
|
||||
for (i = 0; i < songId; ++i)
|
||||
sBattleBuffersTransferData[3 + i] = *(u8*)(unusedDumbDataParameter++);
|
||||
sBattleBuffersTransferData[3 + i] = *(u8 *)(unusedDumbDataParameter++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, songId + 3);
|
||||
}
|
||||
|
||||
@@ -960,7 +958,7 @@ static void BtlController_EmitCmd32(u8 bufferId, u16 size, void *data)
|
||||
sBattleBuffersTransferData[1] = size;
|
||||
sBattleBuffersTransferData[2] = (size & 0xFF00) >> 8;
|
||||
for (i = 0; i < size; ++i)
|
||||
sBattleBuffersTransferData[3 + i] = *(u8*)(data++);
|
||||
sBattleBuffersTransferData[3 + i] = *(u8 *)(data++);
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, size + 3);
|
||||
}
|
||||
|
||||
@@ -1110,7 +1108,7 @@ void BtlController_EmitDrawPartyStatusSummary(u8 bufferId, struct HpAndStatus* h
|
||||
sBattleBuffersTransferData[2] = (arg2 & 0x80) >> 7;
|
||||
sBattleBuffersTransferData[3] = CONTROLLER_DRAWPARTYSTATUSSUMMARY;
|
||||
for (i = 0; i < (s32)(sizeof(struct HpAndStatus) * PARTY_SIZE); ++i)
|
||||
sBattleBuffersTransferData[4 + i] = *(i + (u8*)(hpAndStatus));
|
||||
sBattleBuffersTransferData[4 + i] = *(i + (u8 *)(hpAndStatus));
|
||||
PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, sizeof(struct HpAndStatus) * PARTY_SIZE + 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -220,13 +220,13 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattler, u8 atkBattler, u8 de
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
|
||||
&& !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
|
||||
&& !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else if (gBattleSpritesDataPtr->battlerData[activeBattler].behindSubstitute
|
||||
&& tableId == B_ANIM_SUBSTITUTE_FADE
|
||||
&& gSprites[gBattlerSpriteIds[activeBattler]].invisible)
|
||||
&& tableId == B_ANIM_SUBSTITUTE_FADE
|
||||
&& gSprites[gBattlerSpriteIds[activeBattler]].invisible)
|
||||
{
|
||||
LoadBattleMonGfxAndAnimate(activeBattler, TRUE, gBattlerSpriteIds[activeBattler]);
|
||||
ClearBehindSubstituteBit(activeBattler);
|
||||
|
||||
@@ -51,12 +51,6 @@
|
||||
|
||||
#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBattlerTarget].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED))
|
||||
|
||||
struct StatFractions
|
||||
{
|
||||
u8 dividend;
|
||||
u8 divisor;
|
||||
};
|
||||
|
||||
extern const u8 *const gBattleScriptsForMoveEffects[];
|
||||
|
||||
static bool8 IsTwoTurnsMove(u16 move);
|
||||
@@ -575,6 +569,12 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atkF7_finishturn,
|
||||
};
|
||||
|
||||
struct StatFractions
|
||||
{
|
||||
u8 dividend;
|
||||
u8 divisor;
|
||||
};
|
||||
|
||||
static const struct StatFractions sAccuracyStageRatios[] =
|
||||
{
|
||||
{ 33, 100 }, // -6
|
||||
@@ -1078,7 +1078,7 @@ static void atk01_accuracycheck(void)
|
||||
s8 buff;
|
||||
u16 calc;
|
||||
|
||||
if (move == 0)
|
||||
if (move == MOVE_NONE)
|
||||
move = gCurrentMove;
|
||||
GET_MOVE_TYPE(move, type);
|
||||
if (JumpIfMoveAffectedByProtect(move) || AccuracyCalcHelper(move))
|
||||
@@ -2021,6 +2021,7 @@ static void atk10_printstring(void)
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
u16 var = T2_READ_16(gBattlescriptCurrInstr + 1);
|
||||
|
||||
PrepareStringBattle(var, gBattlerAttacker);
|
||||
gBattlescriptCurrInstr += 3;
|
||||
gBattleCommunication[MSG_DISPLAY] = 1;
|
||||
@@ -2047,6 +2048,7 @@ static void atk12_waitmessage(void)
|
||||
else
|
||||
{
|
||||
u16 toWait = T2_READ_16(gBattlescriptCurrInstr + 1);
|
||||
|
||||
if (++gPauseCounterBattle >= toWait)
|
||||
{
|
||||
gPauseCounterBattle = 0;
|
||||
@@ -2360,12 +2362,10 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
||||
*synchronizeEffect = gBattleCommunication[MOVE_EFFECT_BYTE];
|
||||
gHitMarker |= HITMARKER_SYNCHRONISE_EFFECT;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (statusChanged == FALSE)
|
||||
{
|
||||
++gBattlescriptCurrInstr;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -2378,6 +2378,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
||||
else
|
||||
{
|
||||
u8 side;
|
||||
|
||||
switch (gBattleCommunication[MOVE_EFFECT_BYTE])
|
||||
{
|
||||
case MOVE_EFFECT_CONFUSION:
|
||||
@@ -2471,9 +2472,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
|
||||
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
|
||||
for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; ++gBattleCommunication[MULTISTRING_CHOOSER])
|
||||
{
|
||||
if (gBattleCommunication[MULTISTRING_CHOOSER] > 4)
|
||||
break;
|
||||
if (gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
|
||||
if (gBattleCommunication[MULTISTRING_CHOOSER] > 4 || gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3103,17 +3102,18 @@ static void atk23_getexp(void)
|
||||
|
||||
for (viaSentIn = 0, i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0)
|
||||
continue;
|
||||
if (gBitTable[i] & sentIn)
|
||||
++viaSentIn;
|
||||
item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
|
||||
if (item == ITEM_ENIGMA_BERRY)
|
||||
holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(item);
|
||||
if (holdEffect == HOLD_EFFECT_EXP_SHARE)
|
||||
++viaExpShare;
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
|
||||
{
|
||||
if (gBitTable[i] & sentIn)
|
||||
++viaSentIn;
|
||||
item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
|
||||
if (item == ITEM_ENIGMA_BERRY)
|
||||
holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
|
||||
else
|
||||
holdEffect = ItemId_GetHoldEffect(item);
|
||||
if (holdEffect == HOLD_EFFECT_EXP_SHARE)
|
||||
++viaExpShare;
|
||||
}
|
||||
}
|
||||
calculatedExp = gBaseStats[gBattleMons[gBattlerFainted].species].expYield * gBattleMons[gBattlerFainted].level / 7;
|
||||
if (viaExpShare) // at least one mon is getting exp via exp share
|
||||
@@ -3497,7 +3497,7 @@ static void atk2A_jumpifhalfword(void)
|
||||
static void atk2B_jumpifword(void)
|
||||
{
|
||||
u8 caseID = gBattlescriptCurrInstr[1];
|
||||
const u32* memWord = T2_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
const u32 *memWord = T2_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
u32 value = T1_READ_32(gBattlescriptCurrInstr + 6);
|
||||
const u8 *jumpPtr = T2_READ_PTR(gBattlescriptCurrInstr + 10);
|
||||
|
||||
@@ -3978,7 +3978,7 @@ static void atk49_moveend(void)
|
||||
u16 originallyUsedMove;
|
||||
|
||||
if (gChosenMove == 0xFFFF)
|
||||
originallyUsedMove = 0;
|
||||
originallyUsedMove = MOVE_NONE;
|
||||
else
|
||||
originallyUsedMove = gChosenMove;
|
||||
arg1 = gBattlescriptCurrInstr[1];
|
||||
@@ -5539,7 +5539,7 @@ static void atk61_drawpartystatussummary(void)
|
||||
for (i = 0; i < PARTY_SIZE; ++i)
|
||||
{
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE
|
||||
|| GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
|| GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
|
||||
{
|
||||
hpStatuses[i].hp = 0xFFFF;
|
||||
hpStatuses[i].status = 0;
|
||||
@@ -5579,8 +5579,8 @@ static void atk64_statusanimation(void)
|
||||
{
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
if (!(gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE)
|
||||
&& gDisableStructs[gActiveBattler].substituteHP == 0
|
||||
&& !(gHitMarker & HITMARKER_NO_ANIMATIONS))
|
||||
&& gDisableStructs[gActiveBattler].substituteHP == 0
|
||||
&& !(gHitMarker & HITMARKER_NO_ANIMATIONS))
|
||||
{
|
||||
BtlController_EmitStatusAnimation(0, FALSE, gBattleMons[gActiveBattler].status1);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
@@ -5598,8 +5598,8 @@ static void atk65_status2animation(void)
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
wantedToAnimate = T1_READ_32(gBattlescriptCurrInstr + 2);
|
||||
if (!(gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE)
|
||||
&& gDisableStructs[gActiveBattler].substituteHP == 0
|
||||
&& !(gHitMarker & HITMARKER_NO_ANIMATIONS))
|
||||
&& gDisableStructs[gActiveBattler].substituteHP == 0
|
||||
&& !(gHitMarker & HITMARKER_NO_ANIMATIONS))
|
||||
{
|
||||
BtlController_EmitStatusAnimation(0, TRUE, gBattleMons[gActiveBattler].status2 & wantedToAnimate);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
@@ -6142,7 +6142,7 @@ static void atk76_various(void)
|
||||
break;
|
||||
}
|
||||
if (i == MAX_MON_MOVES)
|
||||
*choicedMove = 0;
|
||||
*choicedMove = MOVE_NONE;
|
||||
}
|
||||
break;
|
||||
case VARIOUS_CASE_7:
|
||||
@@ -6280,10 +6280,8 @@ static void atk78_faintifabilitynotdamp(void)
|
||||
if (!gBattleControllerExecFlags)
|
||||
{
|
||||
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; ++gBattlerTarget)
|
||||
{
|
||||
if (gBattleMons[gBattlerTarget].ability == ABILITY_DAMP)
|
||||
break;
|
||||
}
|
||||
if (gBattlerTarget == gBattlersCount)
|
||||
{
|
||||
gActiveBattler = gBattlerAttacker;
|
||||
@@ -6293,12 +6291,8 @@ static void atk78_faintifabilitynotdamp(void)
|
||||
++gBattlescriptCurrInstr;
|
||||
|
||||
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; ++gBattlerTarget)
|
||||
{
|
||||
if (gBattlerTarget == gBattlerAttacker)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
if (gBattlerTarget != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6328,12 +6322,8 @@ static void atk7A_jumpifnexttargetvalid(void)
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
for (++gBattlerTarget; ; ++gBattlerTarget)
|
||||
{
|
||||
if (gBattlerTarget == gBattlerAttacker)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
if (gBattlerTarget != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
break;
|
||||
}
|
||||
if (gBattlerTarget >= gBattlersCount)
|
||||
gBattlescriptCurrInstr += 5;
|
||||
else
|
||||
@@ -6380,12 +6370,8 @@ static void atk7C_trymirrormove(void)
|
||||
{
|
||||
move = *(i * 2 + gBattlerAttacker * 8 + gBattleStruct->lastTakenMoveFrom + 0)
|
||||
| (*(i * 2 + gBattlerAttacker * 8 + gBattleStruct->lastTakenMoveFrom + 1) << 8);
|
||||
|
||||
if (move != MOVE_NONE && move != 0xFFFF)
|
||||
{
|
||||
movesArray[validMovesCount] = move;
|
||||
++validMovesCount;
|
||||
}
|
||||
movesArray[validMovesCount++] = move;
|
||||
}
|
||||
}
|
||||
move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0)
|
||||
@@ -7889,12 +7875,8 @@ static void atkA8_copymovepermanently(void) // sketch
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == MOVE_SKETCH)
|
||||
continue;
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] == gLastPrintedMoves[gBattlerTarget])
|
||||
if (gBattleMons[gBattlerAttacker].moves[i] != MOVE_SKETCH && gBattleMons[gBattlerAttacker].moves[i] == gLastPrintedMoves[gBattlerTarget])
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
@@ -7927,11 +7909,11 @@ static void atkA8_copymovepermanently(void) // sketch
|
||||
static bool8 IsTwoTurnsMove(u16 move)
|
||||
{
|
||||
if (gBattleMoves[move].effect == EFFECT_SKULL_BASH
|
||||
|| gBattleMoves[move].effect == EFFECT_RAZOR_WIND
|
||||
|| gBattleMoves[move].effect == EFFECT_SKY_ATTACK
|
||||
|| gBattleMoves[move].effect == EFFECT_SOLARBEAM
|
||||
|| gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE
|
||||
|| gBattleMoves[move].effect == EFFECT_BIDE)
|
||||
|| gBattleMoves[move].effect == EFFECT_RAZOR_WIND
|
||||
|| gBattleMoves[move].effect == EFFECT_SKY_ATTACK
|
||||
|| gBattleMoves[move].effect == EFFECT_SOLARBEAM
|
||||
|| gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE
|
||||
|| gBattleMoves[move].effect == EFFECT_BIDE)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -7939,8 +7921,8 @@ static bool8 IsTwoTurnsMove(u16 move)
|
||||
|
||||
static bool8 IsInvalidForSleepTalkOrAssist(u16 move)
|
||||
{
|
||||
if (move == 0 || move == MOVE_SLEEP_TALK || move == MOVE_ASSIST
|
||||
|| move == MOVE_MIRROR_MOVE || move == MOVE_METRONOME)
|
||||
if (move == MOVE_NONE || move == MOVE_SLEEP_TALK || move == MOVE_ASSIST
|
||||
|| move == MOVE_MIRROR_MOVE || move == MOVE_METRONOME)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
@@ -7953,11 +7935,11 @@ static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a c
|
||||
&& (gBattleWeather & WEATHER_SUN_ANY))
|
||||
return 2;
|
||||
if (gBattleMoves[move].effect == EFFECT_SKULL_BASH
|
||||
|| gBattleMoves[move].effect == EFFECT_RAZOR_WIND
|
||||
|| gBattleMoves[move].effect == EFFECT_SKY_ATTACK
|
||||
|| gBattleMoves[move].effect == EFFECT_SOLARBEAM
|
||||
|| gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE
|
||||
|| gBattleMoves[move].effect == EFFECT_BIDE)
|
||||
|| gBattleMoves[move].effect == EFFECT_RAZOR_WIND
|
||||
|| gBattleMoves[move].effect == EFFECT_SKY_ATTACK
|
||||
|| gBattleMoves[move].effect == EFFECT_SOLARBEAM
|
||||
|| gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE
|
||||
|| gBattleMoves[move].effect == EFFECT_BIDE)
|
||||
if ((gHitMarker & HITMARKER_CHARGING))
|
||||
return 1;
|
||||
return 2;
|
||||
@@ -8056,7 +8038,7 @@ static void atkAD_tryspiteppreduce(void)
|
||||
gBattleMons[gBattlerTarget].pp[i] -= ppToDeduct;
|
||||
gActiveBattler = gBattlerTarget;
|
||||
if (!(gDisableStructs[gActiveBattler].mimickedMoves & gBitTable[i])
|
||||
&& !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED))
|
||||
&& !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED))
|
||||
{
|
||||
BtlController_EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBattler].pp[i]);
|
||||
MarkBattlerForControllerExec(gActiveBattler);
|
||||
@@ -8391,12 +8373,8 @@ static void atkB9_magnitudedamagecalculation(void)
|
||||
}
|
||||
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude)
|
||||
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; ++gBattlerTarget)
|
||||
{
|
||||
if (gBattlerTarget == gBattlerAttacker)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // a valid target was found
|
||||
if (gBattlerTarget != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // a valid target was found
|
||||
break;
|
||||
}
|
||||
++gBattlescriptCurrInstr;
|
||||
}
|
||||
|
||||
@@ -8578,12 +8556,8 @@ static void atkC1_hiddenpowercalc(void)
|
||||
static void atkC2_selectfirstvalidtarget(void)
|
||||
{
|
||||
for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; ++gBattlerTarget)
|
||||
{
|
||||
if (gBattlerTarget == gBattlerAttacker)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
if (gBattlerTarget != gBattlerAttacker && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
break;
|
||||
}
|
||||
++gBattlescriptCurrInstr;
|
||||
}
|
||||
|
||||
@@ -9058,7 +9032,7 @@ static void atkDB_tryimprison(void)
|
||||
for (i = 0; i < MAX_MON_MOVES; ++i)
|
||||
{
|
||||
if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[battlerId].moves[i]
|
||||
&& gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE)
|
||||
&& gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE)
|
||||
break;
|
||||
}
|
||||
if (i != MAX_MON_MOVES)
|
||||
@@ -9187,12 +9161,8 @@ static void atkE1_trygetintimidatetarget(void)
|
||||
side = GetBattlerSide(gBattleScripting.battler);
|
||||
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.battler].ability)
|
||||
for (;gBattlerTarget < gBattlersCount; ++gBattlerTarget)
|
||||
{
|
||||
if (GetBattlerSide(gBattlerTarget) == side)
|
||||
continue;
|
||||
if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
if (GetBattlerSide(gBattlerTarget) != side && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]))
|
||||
break;
|
||||
}
|
||||
if (gBattlerTarget >= gBattlersCount)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
else
|
||||
@@ -9768,21 +9738,21 @@ static void atkF3_trygivecaughtmonnick(void)
|
||||
BattleCreateYesNoCursorAt();
|
||||
break;
|
||||
case 1:
|
||||
if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0)
|
||||
if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BattleDestroyYesNoCursorAt();
|
||||
gBattleCommunication[CURSOR_POSITION] = 0;
|
||||
BattleCreateYesNoCursorAt();
|
||||
}
|
||||
if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0)
|
||||
if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
BattleDestroyYesNoCursorAt();
|
||||
gBattleCommunication[CURSOR_POSITION] = 1;
|
||||
BattleCreateYesNoCursorAt();
|
||||
}
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
if (JOY_NEW(A_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
if (gBattleCommunication[CURSOR_POSITION] == 0)
|
||||
@@ -9795,7 +9765,7 @@ static void atkF3_trygivecaughtmonnick(void)
|
||||
gBattleCommunication[MULTIUSE_STATE] = 4;
|
||||
}
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
else if (JOY_NEW(B_BUTTON))
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
gBattleCommunication[MULTIUSE_STATE] = 4;
|
||||
|
||||
+3
-2
@@ -240,6 +240,7 @@ void sub_8017434(u8 battler)
|
||||
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
|
||||
{
|
||||
u8 flank = ((battler & BIT_FLANK) >> 1);
|
||||
|
||||
gSentPokesToOpponent[flank] = 0;
|
||||
for (i = 0; i < gBattlersCount; i += 2)
|
||||
if (!(gAbsentBattlerFlags & gBitTable[i]))
|
||||
@@ -283,7 +284,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
|
||||
u8 holdEffect;
|
||||
u8 limitations = 0;
|
||||
u16 move = gBattleMons[gActiveBattler].moves[gBattleBufferB[gActiveBattler][2]];
|
||||
u16* choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
|
||||
u16 *choicedMove = &gBattleStruct->choicedMove[gActiveBattler];
|
||||
|
||||
if (gDisableStructs[gActiveBattler].disabledMove == move && move != MOVE_NONE)
|
||||
{
|
||||
@@ -444,7 +445,7 @@ u8 DoFieldEndTurnEffects(void)
|
||||
SwapTurnOrder(i, j);
|
||||
}
|
||||
{
|
||||
u8* var = &gBattleStruct->turnCountersTracker;
|
||||
u8 *var = &gBattleStruct->turnCountersTracker;
|
||||
|
||||
++*var;
|
||||
gBattleStruct->turnSideTracker = 0;
|
||||
|
||||
+1
-1
@@ -6059,4 +6059,4 @@
|
||||
"secondaryId": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user