mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-26 21:33:53 +01:00
Merge branch 'battle4_fixes' into decompile_battle5
This commit is contained in:
commit
cd879d6f8a
@ -254,11 +254,21 @@
|
||||
#define MOVE_TARGET_FOES_AND_ALLY 0x20
|
||||
#define MOVE_TARGET_OPPONENTS_FIELD 0x40
|
||||
|
||||
// defines for the u8 array gTypeEffectiveness
|
||||
#define TYPE_EFFECT_ATK_TYPE(i)((gTypeEffectiveness[i + 0]))
|
||||
#define TYPE_EFFECT_DEF_TYPE(i)((gTypeEffectiveness[i + 1]))
|
||||
#define TYPE_EFFECT_MULTIPLIER(i)((gTypeEffectiveness[i + 2]))
|
||||
|
||||
// defines for the gTypeEffectiveness multipliers
|
||||
#define TYPE_MUL_NO_EFFECT 0
|
||||
#define TYPE_MUL_NOT_EFFECTIVE 5
|
||||
#define TYPE_MUL_NORMAL 10
|
||||
#define TYPE_MUL_SUPER_EFFECTIVE 20
|
||||
|
||||
// special type table Ids
|
||||
#define TYPE_FORESIGHT 0xFE
|
||||
#define TYPE_ENDTABLE 0xFF
|
||||
|
||||
#define BS_GET_TARGET 0
|
||||
#define BS_GET_ATTACKER 1
|
||||
#define BS_GET_EFFECT_BANK 2
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "calculate_base_damage.h"
|
||||
#include "rng.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "battle_interface.h"
|
||||
#include "species.h"
|
||||
#include "songs.h"
|
||||
#include "text.h"
|
||||
@ -118,7 +119,7 @@ struct TrainerMoney
|
||||
|
||||
extern const struct BattleMove gBattleMoves[];
|
||||
extern const struct BaseStats gBaseStats[];
|
||||
extern const u8 gTypeEffectiveness[];
|
||||
extern const u8 gTypeEffectiveness[336];
|
||||
extern const u16 gMissStringIds[];
|
||||
extern const u16 gTrappingMoves[];
|
||||
extern const struct TrainerMoney gTrainerMoneyTable[];
|
||||
@ -139,7 +140,6 @@ extern void sub_81A5BF8(void); // battle frontier 2
|
||||
extern void sub_81A5D44(void); // battle frontier 2
|
||||
extern void sub_81B8E80(u8 bank, u8, u8); // party menu
|
||||
extern bool8 sub_81B1250(void); // ?
|
||||
extern u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); // battle interface
|
||||
extern bool8 InBattlePike(void);
|
||||
extern bool8 InBattlePyramid(void);
|
||||
extern u16 GetBattlePyramidPickupItemId(void);
|
||||
@ -340,7 +340,7 @@ static void atk48_playstatchangeanimation(void);
|
||||
static void atk49_moveend(void);
|
||||
static void atk4A_typecalc2(void);
|
||||
static void atk4B_return_atk_to_ball(void);
|
||||
static void atk4C_copy_poke_data(void);
|
||||
static void atk4C_get_switched_mon_data(void);
|
||||
static void atk4D_switch_data_update(void);
|
||||
static void atk4E_switchin_anim(void);
|
||||
static void atk4F_jump_if_cannot_switch(void);
|
||||
@ -368,7 +368,7 @@ static void atk64_statusanimation(void);
|
||||
static void atk65_status2animation(void);
|
||||
static void atk66_chosenstatusanimation(void);
|
||||
static void atk67_yesnobox(void);
|
||||
static void atk68_80246A0(void);
|
||||
static void atk68_cancel_everyones_actions(void);
|
||||
static void atk69_dmg_adjustment3(void);
|
||||
static void atk6A_removeitem(void);
|
||||
static void atk6B_atknameinbuff1(void);
|
||||
@ -457,7 +457,7 @@ static void atkBD_copyfoestats(void);
|
||||
static void atkBE_rapidspinfree(void);
|
||||
static void atkBF_set_defense_curl(void);
|
||||
static void atkC0_recoverbasedonsunlight(void);
|
||||
static void atkC1_hidden_power(void);
|
||||
static void atkC1_hidden_power_calc(void);
|
||||
static void atkC2_selectnexttarget(void);
|
||||
static void atkC3_setfutureattack(void);
|
||||
static void atkC4_beat_up(void);
|
||||
@ -592,7 +592,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atk49_moveend,
|
||||
atk4A_typecalc2,
|
||||
atk4B_return_atk_to_ball,
|
||||
atk4C_copy_poke_data,
|
||||
atk4C_get_switched_mon_data,
|
||||
atk4D_switch_data_update,
|
||||
atk4E_switchin_anim,
|
||||
atk4F_jump_if_cannot_switch,
|
||||
@ -620,7 +620,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atk65_status2animation,
|
||||
atk66_chosenstatusanimation,
|
||||
atk67_yesnobox,
|
||||
atk68_80246A0,
|
||||
atk68_cancel_everyones_actions,
|
||||
atk69_dmg_adjustment3,
|
||||
atk6A_removeitem,
|
||||
atk6B_atknameinbuff1,
|
||||
@ -709,7 +709,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
|
||||
atkBE_rapidspinfree,
|
||||
atkBF_set_defense_curl,
|
||||
atkC0_recoverbasedonsunlight,
|
||||
atkC1_hidden_power,
|
||||
atkC1_hidden_power_calc,
|
||||
atkC2_selectnexttarget,
|
||||
atkC3_setfutureattack,
|
||||
atkC4_beat_up,
|
||||
@ -828,7 +828,7 @@ static const u32 sStatusFlagsForMoveEffects[] =
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
STATUS2_ESCAPE_PREVENTION,
|
||||
0x08000000,
|
||||
STATUS2_NIGHTMARE,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
@ -1244,7 +1244,7 @@ bool8 JumpIfMoveAffectedByProtect(u16 move)
|
||||
return affected;
|
||||
}
|
||||
|
||||
bool8 AccuracyCalcHelper(u16 move)
|
||||
static bool8 AccuracyCalcHelper(u16 move)
|
||||
{
|
||||
if (gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker)
|
||||
{
|
||||
@ -1543,9 +1543,6 @@ static void ModulateDmgByType(u8 multiplier)
|
||||
}
|
||||
}
|
||||
|
||||
#define TYPE_FORESIGHT 0xFE
|
||||
#define TYPE_ENDTABLE 0xFF
|
||||
|
||||
static void atk06_typecalc(void)
|
||||
{
|
||||
s32 i = 0;
|
||||
@ -1577,24 +1574,24 @@ static void atk06_typecalc(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
else if (gTypeEffectiveness[i] == moveType)
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1)
|
||||
ModulateDmgByType(gTypeEffectiveness[i + 2]);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1)
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 &&
|
||||
gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2)
|
||||
ModulateDmgByType(gTypeEffectiveness[i + 2]);
|
||||
ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i));
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@ -1636,45 +1633,46 @@ static void CheckWonderGuardAndLevitate(void)
|
||||
return;
|
||||
}
|
||||
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check no effect
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 0)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
gProtectStructs[gBankAttacker].targetNotAffected = 1;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 &&
|
||||
gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 &&
|
||||
gTypeEffectiveness[i + 2] == TYPE_MUL_NO_EFFECT)
|
||||
TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
gProtectStructs[gBankAttacker].targetNotAffected = 1;
|
||||
}
|
||||
|
||||
// check super effective
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 20)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20)
|
||||
flags |= 1;
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
flags |= 1;
|
||||
|
||||
// check not very effective
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1 && gTypeEffectiveness[i + 2] == 5)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5)
|
||||
flags |= 2;
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == TYPE_MUL_NOT_EFFECTIVE)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
flags |= 2;
|
||||
}
|
||||
i += 3;
|
||||
@ -1749,9 +1747,9 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i]!= TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[bankDef].status2 & STATUS2_FORESIGHT)
|
||||
break;
|
||||
@ -1759,15 +1757,15 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef)
|
||||
continue;
|
||||
}
|
||||
|
||||
else if (gTypeEffectiveness[i] == moveType)
|
||||
else if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[bankDef].type1)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type1)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[bankDef].type2 &&
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type2 &&
|
||||
gBattleMons[bankDef].type1 != gBattleMons[bankDef].type2)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@ -1801,21 +1799,21 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i] != TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == type1)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type1)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == type2 && type1 != type2)
|
||||
ModulateDmgByType2(gTypeEffectiveness[i + 2], move, &flags);
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == type2 && type1 != type2)
|
||||
ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags);
|
||||
}
|
||||
i += 3;
|
||||
}
|
||||
@ -5235,9 +5233,9 @@ static void atk4A_typecalc2(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
while (gTypeEffectiveness[i]!= TYPE_ENDTABLE)
|
||||
while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE)
|
||||
{
|
||||
if (gTypeEffectiveness[i] == TYPE_FORESIGHT)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT)
|
||||
{
|
||||
@ -5250,43 +5248,43 @@ static void atk4A_typecalc2(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (gTypeEffectiveness[i] == moveType)
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == moveType)
|
||||
{
|
||||
// check type1
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type1)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1)
|
||||
{
|
||||
if (gTypeEffectiveness[i + 2] == 0)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
break;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 2] == 5)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 2] == 20)
|
||||
if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_SUPEREFFECTIVE;
|
||||
}
|
||||
}
|
||||
// check type2
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2)
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2)
|
||||
{
|
||||
if (gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 0)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT)
|
||||
{
|
||||
gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED;
|
||||
break;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 5)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_NOTVERYEFFECTIVE;
|
||||
}
|
||||
if (gTypeEffectiveness[i + 1] == gBattleMons[gBankTarget].type2
|
||||
if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2
|
||||
&& gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2
|
||||
&& gTypeEffectiveness[i + 2] == 20)
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
|
||||
{
|
||||
flags |= MOVESTATUS_SUPEREFFECTIVE;
|
||||
}
|
||||
@ -5325,7 +5323,7 @@ static void atk4B_return_atk_to_ball(void)
|
||||
gBattlescriptCurrInstr++;
|
||||
}
|
||||
|
||||
static void atk4C_copy_poke_data(void)
|
||||
static void atk4C_get_switched_mon_data(void)
|
||||
{
|
||||
if (gBattleExecBuffer)
|
||||
return;
|
||||
@ -5334,7 +5332,7 @@ static void atk4C_copy_poke_data(void)
|
||||
|
||||
gBattlePartyID[gActiveBank] = *(gBattleStruct->field_5C + gActiveBank);
|
||||
|
||||
EmitGetMonData(0, 0, gBitTable[gBattlePartyID[gActiveBank]]);
|
||||
EmitGetMonData(0, REQUEST_ALL_BATTLE, gBitTable[gBattlePartyID[gActiveBank]]);
|
||||
MarkBufferBankForExecution(gActiveBank);
|
||||
|
||||
gBattlescriptCurrInstr += 2;
|
||||
@ -5371,7 +5369,7 @@ static void atk4D_switch_data_update(void)
|
||||
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
for (i = 0; i < BATTLE_STATS_NO; i++)
|
||||
{
|
||||
gBattleMons[gActiveBank].statStages[i] = oldData.statStages[i];
|
||||
}
|
||||
@ -5387,11 +5385,8 @@ static void atk4D_switch_data_update(void)
|
||||
}
|
||||
|
||||
gBattleScripting.bank = gActiveBank;
|
||||
gBattleTextBuff1[0] = PLACEHOLDER_BEGIN;
|
||||
gBattleTextBuff1[1] = 7;
|
||||
gBattleTextBuff1[2] = gActiveBank;
|
||||
gBattleTextBuff1[3] = gBattlePartyID[gActiveBank];
|
||||
gBattleTextBuff1[4] = EOS;
|
||||
|
||||
PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gActiveBank, gBattlePartyID[gActiveBank]);
|
||||
|
||||
gBattlescriptCurrInstr += 2;
|
||||
}
|
||||
@ -6576,7 +6571,7 @@ static void atk67_yesnobox(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void atk68_80246A0(void)
|
||||
static void atk68_cancel_everyones_actions(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@ -8558,13 +8553,11 @@ static void atk9D_mimicattackcopy(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atk9E_metronome(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
const u16 *move;
|
||||
s32 i, j;
|
||||
s32 i;
|
||||
|
||||
gCurrentMove = (Random() & 0x1FF) + 1;
|
||||
if (gCurrentMove > LAST_MOVE_INDEX)
|
||||
@ -8572,102 +8565,26 @@ static void atk9E_metronome(void)
|
||||
|
||||
for (i = 0; i < 4; i++); // ?
|
||||
|
||||
for (move = sMovesForbiddenToCopy; ; move++)
|
||||
i = -1;
|
||||
while (1)
|
||||
{
|
||||
if (*move == gCurrentMove)
|
||||
i++;
|
||||
if (sMovesForbiddenToCopy[i] == gCurrentMove)
|
||||
break;
|
||||
if (*move == METRONOME_FORBIDDEN_END)
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
break;
|
||||
}
|
||||
|
||||
if (*move == METRONOME_FORBIDDEN_END)
|
||||
break;
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
{
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
|
||||
gBankTarget = GetMoveTarget(gCurrentMove, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
|
||||
gBankTarget = GetMoveTarget(gCurrentMove, 0);
|
||||
}
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atk9E_metronome(void)
|
||||
{
|
||||
asm(
|
||||
"\n\
|
||||
.syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r8\n\
|
||||
push {r7}\n\
|
||||
ldr r7, =gCurrentMove\n\
|
||||
movs r6, 0xB1\n\
|
||||
lsls r6, 1\n\
|
||||
ldr r5, =sMovesForbiddenToCopy\n\
|
||||
ldr r0, =gBattlescriptCurrInstr\n\
|
||||
mov r8, r0\n\
|
||||
_080524EE:\n\
|
||||
bl Random\n\
|
||||
ldr r2, =0x000001ff\n\
|
||||
adds r1, r2, 0\n\
|
||||
ands r0, r1\n\
|
||||
adds r0, 0x1\n\
|
||||
strh r0, [r7]\n\
|
||||
cmp r0, r6\n\
|
||||
bhi _080524EE\n\
|
||||
movs r0, 0x3\n\
|
||||
_08052502:\n\
|
||||
subs r0, 0x1\n\
|
||||
cmp r0, 0\n\
|
||||
bge _08052502\n\
|
||||
ldr r4, =gCurrentMove\n\
|
||||
ldrh r2, [r4]\n\
|
||||
ldr r3, =0x0000ffff\n\
|
||||
subs r0, r5, 0x2\n\
|
||||
_08052510:\n\
|
||||
adds r0, 0x2\n\
|
||||
ldrh r1, [r0]\n\
|
||||
cmp r1, r2\n\
|
||||
beq _0805251C\n\
|
||||
cmp r1, r3\n\
|
||||
bne _08052510\n\
|
||||
_0805251C:\n\
|
||||
ldr r0, =0x0000ffff\n\
|
||||
cmp r1, r0\n\
|
||||
bne _080524EE\n\
|
||||
ldr r2, =gHitMarker\n\
|
||||
ldr r0, [r2]\n\
|
||||
ldr r1, =0xfffffbff\n\
|
||||
ands r0, r1\n\
|
||||
str r0, [r2]\n\
|
||||
ldr r3, =gBattleScriptsForMoveEffects\n\
|
||||
ldr r2, =gBattleMoves\n\
|
||||
ldrh r1, [r4]\n\
|
||||
lsls r0, r1, 1\n\
|
||||
adds r0, r1\n\
|
||||
lsls r0, 2\n\
|
||||
adds r0, r2\n\
|
||||
ldrb r0, [r0]\n\
|
||||
lsls r0, 2\n\
|
||||
adds r0, r3\n\
|
||||
ldr r0, [r0]\n\
|
||||
mov r1, r8\n\
|
||||
str r0, [r1]\n\
|
||||
ldrh r0, [r4]\n\
|
||||
movs r1, 0\n\
|
||||
bl GetMoveTarget\n\
|
||||
ldr r1, =gBankTarget\n\
|
||||
strb r0, [r1]\n\
|
||||
pop {r3}\n\
|
||||
mov r8, r3\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
.syntax divided");
|
||||
}
|
||||
|
||||
#endif // NONMATCHING
|
||||
|
||||
static void atk9F_dmgtolevel(void)
|
||||
{
|
||||
gBattleMoveDamage = gBattleMons[gBankAttacker].level;
|
||||
@ -8814,7 +8731,6 @@ static void atkA5_painsplitdmgcalc(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
{
|
||||
if (gUnknown_02024250[gBankAttacker] == 0
|
||||
@ -8829,298 +8745,58 @@ static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 type = 0, rands = 0;
|
||||
do
|
||||
s32 i, j, rands;
|
||||
|
||||
for (rands = 0; rands < 1000; rands++)
|
||||
{
|
||||
while (((type = (Random() & 0x7F)) > 0x70));
|
||||
while (((i = (Random() & 0x7F)) > sizeof(gTypeEffectiveness) / 3));
|
||||
|
||||
type *= 3;
|
||||
i *= 3;
|
||||
|
||||
if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker]
|
||||
&& gTypeEffectiveness[type + 2] <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1]
|
||||
&& gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1])
|
||||
if (TYPE_EFFECT_ATK_TYPE(i) == gUnknown_02024258[gBankAttacker]
|
||||
&& TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE
|
||||
&& gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i)
|
||||
&& gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i))
|
||||
{
|
||||
gBattleMons[gBankAttacker].type1 = type;
|
||||
gBattleMons[gBankAttacker].type2 = type;
|
||||
gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i);
|
||||
gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(i);
|
||||
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, type)
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(i))
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rands++;
|
||||
} while (rands <= 999);
|
||||
|
||||
type = 0, rands = 0;
|
||||
do
|
||||
for (j = 0, rands = 0; rands < sizeof(gTypeEffectiveness); j += 3, rands += 3)
|
||||
{
|
||||
s8 var = (s8)(gTypeEffectiveness[type]);
|
||||
if (var > -1 || var < -2)
|
||||
switch (TYPE_EFFECT_ATK_TYPE(j))
|
||||
{
|
||||
if (gTypeEffectiveness[type] == gUnknown_02024258[gBankAttacker]
|
||||
&& gTypeEffectiveness[type + 2] <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != gTypeEffectiveness[type + 1]
|
||||
&& gBattleMons[gBankAttacker].type2 != gTypeEffectiveness[type + 1])
|
||||
case TYPE_ENDTABLE:
|
||||
case TYPE_FORESIGHT:
|
||||
break;
|
||||
default:
|
||||
if (TYPE_EFFECT_ATK_TYPE(j) == gUnknown_02024258[gBankAttacker]
|
||||
&& TYPE_EFFECT_MULTIPLIER(j) <= 5
|
||||
&& gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i)
|
||||
&& gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i))
|
||||
{
|
||||
gBattleMons[gBankAttacker].type1 = gTypeEffectiveness[rands + 1];
|
||||
gBattleMons[gBankAttacker].type2 = gTypeEffectiveness[rands + 1];
|
||||
gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands);
|
||||
gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(rands);
|
||||
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, gTypeEffectiveness[rands + 1])
|
||||
PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(rands))
|
||||
|
||||
gBattlescriptCurrInstr += 5;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
type += 3, rands += 3;
|
||||
} while (rands < 336);
|
||||
}
|
||||
|
||||
gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atkA6_settypetorandomresistance(void) // conversion 2
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
mov r6, r9\n\
|
||||
mov r5, r8\n\
|
||||
push {r5-r7}\n\
|
||||
ldr r1, =gUnknown_02024250\n\
|
||||
ldr r4, =gBankAttacker\n\
|
||||
ldrb r0, [r4]\n\
|
||||
lsls r0, 1\n\
|
||||
adds r2, r0, r1\n\
|
||||
ldrh r1, [r2]\n\
|
||||
cmp r1, 0\n\
|
||||
beq _08052B7E\n\
|
||||
ldr r0, =0x0000ffff\n\
|
||||
cmp r1, r0\n\
|
||||
beq _08052B7E\n\
|
||||
ldrh r0, [r2]\n\
|
||||
bl IsTwoTurnsMove\n\
|
||||
lsls r0, 24\n\
|
||||
cmp r0, 0\n\
|
||||
beq _08052C1C\n\
|
||||
ldr r1, =gBattleMons\n\
|
||||
ldr r2, =gUnknown_02024270\n\
|
||||
ldrb r0, [r4]\n\
|
||||
adds r0, r2\n\
|
||||
ldrb r2, [r0]\n\
|
||||
movs r0, 0x58\n\
|
||||
muls r0, r2\n\
|
||||
adds r1, 0x50\n\
|
||||
adds r0, r1\n\
|
||||
ldr r0, [r0]\n\
|
||||
movs r1, 0x80\n\
|
||||
lsls r1, 5\n\
|
||||
ands r0, r1\n\
|
||||
cmp r0, 0\n\
|
||||
beq _08052C1C\n\
|
||||
_08052B7E:\n\
|
||||
ldr r3, =gBattlescriptCurrInstr\n\
|
||||
ldr r2, [r3]\n\
|
||||
ldrb r1, [r2, 0x1]\n\
|
||||
ldrb r0, [r2, 0x2]\n\
|
||||
lsls r0, 8\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x3]\n\
|
||||
lsls r0, 16\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x4]\n\
|
||||
lsls r0, 24\n\
|
||||
orrs r1, r0\n\
|
||||
str r1, [r3]\n\
|
||||
b _08052D08\n\
|
||||
.pool\n\
|
||||
_08052BB4:\n\
|
||||
mov r0, r12\n\
|
||||
strb r5, [r0]\n\
|
||||
mov r1, r10\n\
|
||||
ldrb r0, [r1]\n\
|
||||
muls r0, r2\n\
|
||||
adds r0, r7\n\
|
||||
adds r0, 0x22\n\
|
||||
strb r5, [r0]\n\
|
||||
ldr r1, =gBattleTextBuff1\n\
|
||||
movs r0, 0xFD\n\
|
||||
strb r0, [r1]\n\
|
||||
movs r0, 0x3\n\
|
||||
strb r0, [r1, 0x1]\n\
|
||||
strb r5, [r1, 0x2]\n\
|
||||
movs r0, 0xFF\n\
|
||||
strb r0, [r1, 0x3]\n\
|
||||
ldr r1, =gBattlescriptCurrInstr\n\
|
||||
b _08052C0A\n\
|
||||
.pool\n\
|
||||
_08052BE0:\n\
|
||||
mov r0, r8\n\
|
||||
adds r0, 0x1\n\
|
||||
adds r0, r3\n\
|
||||
ldrb r2, [r0]\n\
|
||||
strb r2, [r4]\n\
|
||||
mov r4, r10\n\
|
||||
ldrb r0, [r4]\n\
|
||||
muls r0, r6\n\
|
||||
ldr r7, =gBattleMons\n\
|
||||
adds r0, r7\n\
|
||||
adds r0, 0x22\n\
|
||||
strb r2, [r0]\n\
|
||||
ldr r1, =gBattleTextBuff1\n\
|
||||
movs r0, 0xFD\n\
|
||||
strb r0, [r1]\n\
|
||||
movs r0, 0x3\n\
|
||||
strb r0, [r1, 0x1]\n\
|
||||
strb r2, [r1, 0x2]\n\
|
||||
movs r0, 0xFF\n\
|
||||
strb r0, [r1, 0x3]\n\
|
||||
mov r1, r12\n\
|
||||
_08052C0A:\n\
|
||||
ldr r0, [r1]\n\
|
||||
adds r0, 0x5\n\
|
||||
str r0, [r1]\n\
|
||||
b _08052D08\n\
|
||||
.pool\n\
|
||||
_08052C1C:\n\
|
||||
movs r4, 0\n\
|
||||
mov r8, r4\n\
|
||||
movs r7, 0x7F\n\
|
||||
mov r9, r7\n\
|
||||
_08052C24:\n\
|
||||
bl Random\n\
|
||||
mov r4, r9\n\
|
||||
ands r4, r0\n\
|
||||
cmp r4, 0x70\n\
|
||||
bhi _08052C24\n\
|
||||
lsls r0, r4, 1\n\
|
||||
adds r4, r0, r4\n\
|
||||
ldr r6, =gTypeEffectiveness\n\
|
||||
adds r3, r4, r6\n\
|
||||
ldr r1, =gUnknown_02024258\n\
|
||||
ldr r2, =gBankAttacker\n\
|
||||
ldrb r5, [r2]\n\
|
||||
lsls r0, r5, 1\n\
|
||||
adds r0, r1\n\
|
||||
ldrb r1, [r3]\n\
|
||||
mov r10, r2\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r1, r0\n\
|
||||
bne _08052C80\n\
|
||||
adds r0, r4, 0x2\n\
|
||||
adds r0, r6\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, 0x5\n\
|
||||
bhi _08052C80\n\
|
||||
ldr r7, =gBattleMons\n\
|
||||
movs r2, 0x58\n\
|
||||
adds r0, r5, 0\n\
|
||||
muls r0, r2\n\
|
||||
adds r3, r0, r7\n\
|
||||
movs r0, 0x21\n\
|
||||
adds r0, r3\n\
|
||||
mov r12, r0\n\
|
||||
adds r0, r4, 0x1\n\
|
||||
adds r0, r6\n\
|
||||
ldrb r5, [r0]\n\
|
||||
mov r1, r12\n\
|
||||
ldrb r0, [r1]\n\
|
||||
adds r1, r5, 0\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052C80\n\
|
||||
adds r0, r3, 0\n\
|
||||
adds r0, 0x22\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, r1\n\
|
||||
bne _08052BB4\n\
|
||||
_08052C80:\n\
|
||||
movs r7, 0x1\n\
|
||||
add r8, r7\n\
|
||||
ldr r0, =0x000003e7\n\
|
||||
cmp r8, r0\n\
|
||||
ble _08052C24\n\
|
||||
movs r0, 0\n\
|
||||
mov r8, r0\n\
|
||||
ldr r1, =gBattlescriptCurrInstr\n\
|
||||
mov r12, r1\n\
|
||||
ldr r3, =gTypeEffectiveness\n\
|
||||
adds r0, r4, 0x1\n\
|
||||
adds r0, r3\n\
|
||||
mov r9, r0\n\
|
||||
adds r5, r3, 0\n\
|
||||
_08052C9C:\n\
|
||||
ldrb r1, [r5]\n\
|
||||
cmp r1, 0xFF\n\
|
||||
bgt _08052CA6\n\
|
||||
cmp r1, 0xFE\n\
|
||||
bge _08052CE0\n\
|
||||
_08052CA6:\n\
|
||||
mov r4, r10\n\
|
||||
ldrb r2, [r4]\n\
|
||||
lsls r0, r2, 1\n\
|
||||
ldr r7, =gUnknown_02024258\n\
|
||||
adds r0, r7\n\
|
||||
ldrh r0, [r0]\n\
|
||||
cmp r1, r0\n\
|
||||
bne _08052CE0\n\
|
||||
ldrb r0, [r5, 0x2]\n\
|
||||
cmp r0, 0x5\n\
|
||||
bhi _08052CE0\n\
|
||||
movs r6, 0x58\n\
|
||||
adds r0, r2, 0\n\
|
||||
muls r0, r6\n\
|
||||
ldr r1, =gBattleMons\n\
|
||||
adds r2, r0, r1\n\
|
||||
adds r4, r2, 0\n\
|
||||
adds r4, 0x21\n\
|
||||
ldrb r0, [r4]\n\
|
||||
mov r7, r9\n\
|
||||
ldrb r1, [r7]\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052CE0\n\
|
||||
adds r0, r2, 0\n\
|
||||
adds r0, 0x22\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, r1\n\
|
||||
beq _08052CE0\n\
|
||||
b _08052BE0\n\
|
||||
_08052CE0:\n\
|
||||
adds r5, 0x3\n\
|
||||
movs r0, 0x3\n\
|
||||
add r8, r0\n\
|
||||
ldr r0, =0x0000014f\n\
|
||||
cmp r8, r0\n\
|
||||
bls _08052C9C\n\
|
||||
mov r1, r12\n\
|
||||
ldr r2, [r1]\n\
|
||||
ldrb r1, [r2, 0x1]\n\
|
||||
ldrb r0, [r2, 0x2]\n\
|
||||
lsls r0, 8\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x3]\n\
|
||||
lsls r0, 16\n\
|
||||
orrs r1, r0\n\
|
||||
ldrb r0, [r2, 0x4]\n\
|
||||
lsls r0, 24\n\
|
||||
orrs r1, r0\n\
|
||||
mov r4, r12\n\
|
||||
str r1, [r4]\n\
|
||||
_08052D08:\n\
|
||||
pop {r3-r5}\n\
|
||||
mov r8, r3\n\
|
||||
mov r9, r4\n\
|
||||
mov r10, r5\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r0}\n\
|
||||
bx r0\n\
|
||||
.pool\n\
|
||||
.syntax divided");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
static void atkA7_setalwayshitflag(void)
|
||||
{
|
||||
gStatuses3[gBankTarget] &= ~(STATUS3_ALWAYS_HITS);
|
||||
@ -9859,24 +9535,24 @@ static void atkC0_recoverbasedonsunlight(void)
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
static void atkC1_hidden_power(void)
|
||||
static void atkC1_hidden_power_calc(void)
|
||||
{
|
||||
s32 powerBits;
|
||||
s32 typeBits;
|
||||
u32 powerBits = 0;
|
||||
u32 typeBits = 0;
|
||||
|
||||
powerBits = ((gBattleMons[gBankAttacker].hpIV & 2) >> 1)
|
||||
| ((gBattleMons[gBankAttacker].attackIV & 2) << 0)
|
||||
| ((gBattleMons[gBankAttacker].defenseIV & 2) << 1)
|
||||
| ((gBattleMons[gBankAttacker].speedIV & 2) << 2)
|
||||
| ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3)
|
||||
| ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].hpIV & 2) >> 1);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].attackIV & 2) << 0);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].defenseIV & 2) << 1);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].speedIV & 2) << 2);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3);
|
||||
powerBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4);
|
||||
|
||||
typeBits = ((gBattleMons[gBankAttacker].hpIV & 1) << 0)
|
||||
| ((gBattleMons[gBankAttacker].attackIV & 1) << 1)
|
||||
| ((gBattleMons[gBankAttacker].defenseIV & 1) << 2)
|
||||
| ((gBattleMons[gBankAttacker].speedIV & 1) << 3)
|
||||
| ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4)
|
||||
| ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].hpIV & 1) << 0);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].attackIV & 1) << 1);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].defenseIV & 1) << 2);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].speedIV & 1) << 3);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4);
|
||||
typeBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5);
|
||||
|
||||
gDynamicBasePower = (40 * powerBits) / 63 + 30;
|
||||
|
||||
@ -9890,7 +9566,7 @@ static void atkC1_hidden_power(void)
|
||||
|
||||
#else
|
||||
__attribute__((naked))
|
||||
static void atkC1_hidden_power(void)
|
||||
static void atkC1_hidden_power_calc(void)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
|
Loading…
x
Reference in New Issue
Block a user