clear battle code and battlescripts

This commit is contained in:
DizzyEggg 2017-11-26 11:55:17 +01:00
parent 938d346b6d
commit cc572f7c00
6 changed files with 124 additions and 133 deletions

View File

@ -163,7 +163,7 @@
.4byte \param4
.endm
.macro jumpifstatus3 bank, status3, param2, param3
.macro jumpifstatus3condition bank, status3, param2, param3
.byte 0x21
.byte \bank
.4byte \status3
@ -1253,3 +1253,19 @@
.macro jumpifbyteequal byte1, byte2, jumpptr
jumpifarrayequal \byte1, \byte2, 0x1, \jumpptr
.endm
.macro jumpifmove move, jumpptr
jumpifhalfword EQUAL, gCurrentMove, \move, \jumpptr
.endm
.macro jumpifnotmove move, jumpptr
jumpifhalfword NOT_EQUAL, gCurrentMove, \move, \jumpptr
.endm
.macro jumpifstatus3 bank, status, jumpptr
jumpifstatus3condition \bank, \status, 0x0, \jumpptr
.endm
.macro jumpifnostatus3 bank, status, jumpptr
jumpifstatus3condition \bank, \status, 0x1, \jumpptr
.endm

View File

@ -246,8 +246,8 @@ BattleScript_EffectUnused83::
BattleScript_EffectUnused8d::
BattleScript_EffectUnusedA3::
BattleScript_EffectHit::
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_SURF, BattleScript_HitFromAtkCanceler
jumpifstatus3 TARGET, STATUS3_UNDERWATER, 0x1, BattleScript_HitFromAtkCanceler
jumpifnotmove MOVE_SURF, BattleScript_HitFromAtkCanceler
jumpifnostatus3 TARGET, STATUS3_UNDERWATER, BattleScript_HitFromAtkCanceler
orword gHitMarker, HITMARKER_IGNORE_UNDERWATER
setbyte sDMG_MULTIPLIER, 0x2
BattleScript_HitFromAtkCanceler::
@ -507,7 +507,7 @@ BattleScript_EffectStatUp::
BattleScript_EffectStatUpAfterAtkCanceler::
attackstring
ppreduce
statbuffchange 0x41, BattleScript_StatUpEnd
statbuffchange AFFECTS_USER | 0x1, BattleScript_StatUpEnd
jumpifbyte NOT_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_StatUpAttackAnim
pause 0x20
goto BattleScript_StatUpPrintString
@ -611,7 +611,7 @@ BattleScript_EffectRoar::
attackstring
ppreduce
jumpifability TARGET, ABILITY_SUCTION_CUPS, BattleScript_82DB5B9
jumpifstatus3 TARGET, STATUS3_ROOTED, 0x0, BattleScript_82DB109
jumpifstatus3 TARGET, STATUS3_ROOTED, BattleScript_82DB109
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE
jumpifword COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_ARENA, BattleScript_ButItFailed
@ -808,7 +808,7 @@ BattleScript_82D9040::
setbyte sANIM_TURN, 0x1
clearstatusfromeffect ATTACKER
orword gHitMarker, HITMARKER_NO_PPDEDUCT
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_SKY_ATTACK, BattleScript_HitFromAccCheck
jumpifnotmove MOVE_SKY_ATTACK, BattleScript_HitFromAccCheck
setmoveeffect EFFECT_FLINCH
goto BattleScript_HitFromAccCheck
@ -848,8 +848,8 @@ BattleScript_EffectDragonRage::
goto BattleScript_HitFromAtkAnimation
BattleScript_EffectTrap::
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_WHIRLPOOL, BattleScript_82D9105
jumpifstatus3 TARGET, STATUS3_UNDERWATER, 0x1, BattleScript_82D9105
jumpifnotmove MOVE_WHIRLPOOL, BattleScript_82D9105
jumpifnostatus3 TARGET, STATUS3_UNDERWATER, BattleScript_82D9105
orword gHitMarker, HITMARKER_IGNORE_UNDERWATER
setbyte sDMG_MULTIPLIER, 0x2
BattleScript_82D9105::
@ -917,7 +917,7 @@ BattleScript_EffectFocusEnergy::
BattleScript_EffectRecoil::
setmoveeffect EFFECT_RECOIL_25 | AFFECTS_USER | CERTAIN
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_STRUGGLE, BattleScript_EffectHit
jumpifnotmove MOVE_STRUGGLE, BattleScript_EffectHit
incrementgamestat 0x1B
goto BattleScript_EffectHit
@ -1389,7 +1389,7 @@ BattleScript_EffectHealBell::
waitanimation
printfromtable gPartyStatusHealStringIds
waitmessage 0x40
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_HEAL_BELL, BattleScript_82D96FE
jumpifnotmove MOVE_HEAL_BELL, BattleScript_82D96FE
jumpifbyte NO_COMMON_BITS, cMULTISTRING_CHOOSER, 0x1, BattleScript_82D96ED
printstring STRINGID_PKMNSXBLOCKSY
waitmessage 0x40
@ -1517,17 +1517,17 @@ BattleScript_CurseTrySpeed::
attackanimation
waitanimation
setstatchanger SPEED, 1, TRUE
statbuffchange 0x41, BattleScript_CurseTryAttack
statbuffchange AFFECTS_USER | 0x1, BattleScript_CurseTryAttack
printfromtable gStatDownStringIds
waitmessage 0x40
BattleScript_CurseTryAttack::
setstatchanger ATK, 1, FALSE
statbuffchange 0x41, BattleScript_CurseTryDefence
statbuffchange AFFECTS_USER | 0x1, BattleScript_CurseTryDefence
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_CurseTryDefence::
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_CurseEnd
statbuffchange AFFECTS_USER | 0x1, BattleScript_CurseEnd
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_CurseEnd::
@ -1838,7 +1838,7 @@ BattleScript_EffectSkullBash::
setbyte sTWOTURN_STRINGID, 0x2
call BattleScriptFirstChargingTurn
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_82D9C16
statbuffchange AFFECTS_USER | 0x1, BattleScript_82D9C16
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82D9C16
setgraphicalstatchangevalues
playanimation ATTACKER, ANIM_STATS_CHANGE, sANIM_ARG1
@ -1848,7 +1848,7 @@ BattleScript_82D9C16::
goto BattleScript_MoveEnd
BattleScript_EffectTwister::
jumpifstatus3 TARGET, STATUS3_ON_AIR, 0x1, BattleScript_82D9C35
jumpifnostatus3 TARGET, STATUS3_ON_AIR, BattleScript_82D9C35
orword gHitMarker, HITMARKER_IGNORE_ON_AIR
setbyte sDMG_MULTIPLIER, 0x2
BattleScript_82D9C35::
@ -1862,7 +1862,7 @@ BattleScript_EffectEarthquake::
selectfirstvalidtarget
BattleScript_82D9C44::
movevaluescleanup
jumpifstatus3 TARGET, STATUS3_UNDERGROUND, 0x1, BattleScript_82D9C64
jumpifnostatus3 TARGET, STATUS3_UNDERGROUND, BattleScript_82D9C64
orword gHitMarker, HITMARKER_IGNORE_UNDERGROUND
setbyte sDMG_MULTIPLIER, 0x2
goto BattleScript_82D9C73
@ -1918,13 +1918,13 @@ BattleScript_EffectFutureSight::
goto BattleScript_MoveEnd
BattleScript_EffectGust::
jumpifstatus3 TARGET, STATUS3_ON_AIR, 0x1, BattleScript_EffectHit
jumpifnostatus3 TARGET, STATUS3_ON_AIR, BattleScript_EffectHit
orword gHitMarker, HITMARKER_IGNORE_ON_AIR
setbyte sDMG_MULTIPLIER, 0x2
goto BattleScript_EffectHit
BattleScript_EffectStomp::
jumpifstatus3 TARGET, STATUS3_MINIMIZED, 0x1, BattleScript_82D9C35
jumpifnostatus3 TARGET, STATUS3_MINIMIZED, BattleScript_82D9C35
setbyte sDMG_MULTIPLIER, 0x2
goto BattleScript_82D9C35
@ -2002,9 +2002,9 @@ BattleScript_BeatUpEnd::
BattleScript_EffectSemiInvulnerable::
jumpifstatus2 ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_SecondTurnSemiInvulnerable
jumpifword COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_SecondTurnSemiInvulnerable
jumpifhalfword EQUAL, gCurrentMove, MOVE_FLY, BattleScript_FirstTurnFly
jumpifhalfword EQUAL, gCurrentMove, MOVE_DIVE, BattleScript_FirstTurnDive
jumpifhalfword EQUAL, gCurrentMove, MOVE_BOUNCE, BattleScript_FirstTurnBounce
jumpifmove MOVE_FLY, BattleScript_FirstTurnFly
jumpifmove MOVE_DIVE, BattleScript_FirstTurnDive
jumpifmove MOVE_BOUNCE, BattleScript_FirstTurnBounce
setbyte sTWOTURN_STRINGID, 0x5
goto BattleScript_FirstTurnSemiInvulnerable
@ -2029,7 +2029,7 @@ BattleScript_SecondTurnSemiInvulnerable::
setbyte sANIM_TURN, 0x1
clearstatusfromeffect ATTACKER
orword gHitMarker, HITMARKER_NO_PPDEDUCT
jumpifhalfword NOT_EQUAL, gCurrentMove, MOVE_BOUNCE, BattleScript_82D9EA3
jumpifnotmove MOVE_BOUNCE, BattleScript_82D9EA3
setmoveeffect EFFECT_PARALYSIS
BattleScript_82D9EA3::
accuracycheck BattleScript_SemiInvulnerableMiss, ACC_CURR_MOVE
@ -2046,7 +2046,7 @@ BattleScript_EffectDefenseCurl::
ppreduce
setdefensecurlbit
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_82D9ED3
statbuffchange AFFECTS_USER | 0x1, BattleScript_82D9ED3
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_StatUpPrintString
attackanimation
waitanimation
@ -2724,13 +2724,13 @@ BattleScript_82DA5F8::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0x24, 0x0
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DA623
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA623
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA623
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DA623::
setstatchanger SPDEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DA642
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA642
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA642
printfromtable gStatUpStringIds
waitmessage 0x40
@ -2753,13 +2753,13 @@ BattleScript_82DA66A::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0x6, 0x0
setstatchanger ATK, 1, FALSE
statbuffchange 0x41, BattleScript_82DA695
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA695
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA695
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DA695::
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DA6B4
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA6B4
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA6B4
printfromtable gStatUpStringIds
waitmessage 0x40
@ -2778,13 +2778,13 @@ BattleScript_82DA6CE::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0x30, 0x0
setstatchanger SPATK, 1, FALSE
statbuffchange 0x41, BattleScript_82DA6F9
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA6F9
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA6F9
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DA6F9::
setstatchanger SPDEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DA718
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA718
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA718
printfromtable gStatUpStringIds
waitmessage 0x40
@ -2810,13 +2810,13 @@ BattleScript_82DA746::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0xA, 0x0
setstatchanger ATK, 1, FALSE
statbuffchange 0x41, BattleScript_82DA771
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA771
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA771
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DA771::
setstatchanger SPEED, 1, FALSE
statbuffchange 0x41, BattleScript_82DA790
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DA790
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DA790
printfromtable gStatUpStringIds
waitmessage 0x40
@ -3493,27 +3493,27 @@ BattleScript_82DAF54::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0x3E, 0x0
setstatchanger ATK, 1, FALSE
statbuffchange 0x41, BattleScript_82DAF72
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DAF72
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DAF72::
setstatchanger DEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DAF86
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DAF86
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DAF86::
setstatchanger SPEED, 1, FALSE
statbuffchange 0x41, BattleScript_82DAF9A
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DAF9A
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DAF9A::
setstatchanger SPATK, 1, FALSE
statbuffchange 0x41, BattleScript_82DAFAE
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DAFAE
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DAFAE::
setstatchanger SPDEF, 1, FALSE
statbuffchange 0x41, BattleScript_82DAFC2
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DAFC2
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_82DAFC2::
@ -3664,14 +3664,14 @@ BattleScript_AtkDefDown::
playstatchangeanimation ATTACKER, 0x6, 0xD
playstatchangeanimation ATTACKER, 0x2, 0x9
setstatchanger ATK, 1, TRUE
statbuffchange 0xC1, BattleScript_82DB144
statbuffchange AFFECTS_USER | CERTAIN | 0x1, BattleScript_82DB144
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB144
printfromtable gStatDownStringIds
waitmessage 0x40
BattleScript_82DB144::
playstatchangeanimation ATTACKER, 0x4, 0x9
setstatchanger DEF, 1, TRUE
statbuffchange 0xC1, BattleScript_82DB167
statbuffchange AFFECTS_USER | CERTAIN | 0x1, BattleScript_82DB167
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB167
printfromtable gStatDownStringIds
waitmessage 0x40
@ -3737,7 +3737,7 @@ BattleScript_SAtkDown2::
setbyte sFIELD_1B, 0x0
playstatchangeanimation ATTACKER, 0x10, 0xB
setstatchanger SPATK, 2, TRUE
statbuffchange 0xC1, BattleScript_82DB1FE
statbuffchange AFFECTS_USER | CERTAIN | 0x1, BattleScript_82DB1FE
jumpifbyte EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB1FE
printfromtable gStatDownStringIds
waitmessage 0x40
@ -3974,7 +3974,7 @@ BattleScript_MoveEffectConfusion::
return
BattleScript_MoveEffectRecoil33::
jumpifhalfword EQUAL, gCurrentMove, MOVE_STRUGGLE, BattleScript_DoRecoil33
jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil33
jumpifability ATTACKER, ABILITY_ROCK_HEAD, BattleScript_Recoil33End
BattleScript_DoRecoil33::
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000
@ -4450,7 +4450,7 @@ BattleScript_BerryConfuseHealEnd2::
BattleScript_BerryStatRaiseEnd2::
playanimation ATTACKER, ANIM_ITEM_EFFECT, NULL
statbuffchange 0x41, BattleScript_82DB85B
statbuffchange AFFECTS_USER | 0x1, BattleScript_82DB85B
BattleScript_82DB85B::
setbyte cMULTISTRING_CHOOSER, 0x4
call BattleScript_StatUp

View File

@ -837,9 +837,10 @@ extern struct BattleStruct* gBattleStruct;
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
#define SET_STAT_BUFF_ID(n)((n & 0xF))
#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0))
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7))
struct BattleScripting
{
s32 painSplitHp;

View File

@ -74,6 +74,14 @@
#define B_BUFF_PLACEHOLDER_BEGIN 0xFD
#define B_BUFF_EOS 0xFF
#define PREPARE_FLAVOUR_BUFFER(textVar, flavourId) \
{ \
textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \
textVar[1] = B_BUFF_NEGATIVE_FLAVOUR; \
textVar[2] = flavourId; \
textVar[3] = B_BUFF_EOS; \
}
#define PREPARE_STAT_BUFFER(textVar, statId) \
{ \
textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \

View File

@ -214,7 +214,7 @@ static void atk1D_jumpifstatus2(void);
static void atk1E_jumpifability(void);
static void atk1F_jumpifsideaffecting(void);
static void atk20_jumpifstat(void);
static void atk21_jumpifstatus3(void);
static void atk21_jumpifstatus3condition(void);
static void atk22_jumpiftype(void);
static void atk23_getexp(void);
static void atk24(void);
@ -466,7 +466,7 @@ void (* const gBattleScriptingCommandsTable[])(void) =
atk1E_jumpifability,
atk1F_jumpifsideaffecting,
atk20_jumpifstat,
atk21_jumpifstatus3,
atk21_jumpifstatus3condition,
atk22_jumpiftype,
atk23_getexp,
atk24,
@ -3314,10 +3314,10 @@ static void atk20_jumpifstat(void)
gBattlescriptCurrInstr += 9;
}
static void atk21_jumpifstatus3(void)
static void atk21_jumpifstatus3condition(void)
{
u32 flags;
const u8* jumpPtr;
const u8 *jumpPtr;
gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]);
flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2);
@ -7557,9 +7557,9 @@ static void atk88_negativedamage(void)
gBattlescriptCurrInstr++;
}
static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr)
static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr)
{
bool8 certain = 0;
bool8 certain = FALSE;
bool8 notProtectAffected = FALSE;
u32 index;
@ -7667,15 +7667,15 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr)
if (statValue == -2)
{
gBattleTextBuff2[1] = B_BUFF_STRING;
gBattleTextBuff2[2] = 0xD3; // harshly
gBattleTextBuff2[3] = 0xD3 >> 8;
gBattleTextBuff2[2] = STRINGID_STATHARSHLY;
gBattleTextBuff2[3] = STRINGID_STATHARSHLY >> 8;
index = 4;
}
gBattleTextBuff2[index] = B_BUFF_STRING;
index++;
gBattleTextBuff2[index] = 0xD4; // fell
gBattleTextBuff2[index] = STRINGID_STATFELL;
index++;
gBattleTextBuff2[index] = 0xD4 >> 8;
gBattleTextBuff2[index] = STRINGID_STATFELL >> 8;
index++;
gBattleTextBuff2[index] = B_BUFF_EOS;
@ -7694,15 +7694,15 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8* BS_ptr)
if (statValue == 2)
{
gBattleTextBuff2[1] = B_BUFF_STRING;
gBattleTextBuff2[2] = 0xD1; // sharply
gBattleTextBuff2[3] = 0xD1 >> 8;
gBattleTextBuff2[2] = STRINGID_STATSHARPLY;
gBattleTextBuff2[3] = STRINGID_STATSHARPLY >> 8;
index = 4;
}
gBattleTextBuff2[index] = B_BUFF_STRING;
index++;
gBattleTextBuff2[index] = 0xD2; // rose
gBattleTextBuff2[index] = STRINGID_STATROSE;
index++;
gBattleTextBuff2[index] = 0xD2 >> 8;
gBattleTextBuff2[index] = STRINGID_STATROSE >> 8;
index++;
gBattleTextBuff2[index] = B_BUFF_EOS;

View File

@ -14,6 +14,7 @@
#include "text.h"
#include "string_util.h"
#include "battle_message.h"
#include "battle_string_ids.h"
#include "battle_ai_script_commands.h"
#include "battle_controllers.h"
#include "event_data.h"
@ -2615,7 +2616,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
gBattleStruct->moneyMultiplier = 2;
break;
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < 8; i++)
for (i = 0; i < BATTLE_STATS_NO; i++)
{
if (gBattleMons[bank].statStages[i] < 6)
{
@ -2652,19 +2653,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_RESTORE_PP:
if (!moveTurn)
{
struct Pokemon* poke;
struct Pokemon *mon;
u8 ppBonuses;
u16 move;
if (GetBankSide(bank) == SIDE_PLAYER)
poke = &gPlayerParty[gBattlePartyID[bank]];
mon = &gPlayerParty[gBattlePartyID[bank]];
else
poke = &gEnemyParty[gBattlePartyID[bank]];
mon = &gEnemyParty[gBattlePartyID[bank]];
for (i = 0; i < 4; i++)
{
move = GetMonData(poke, MON_DATA_MOVE1 + i);
changedPP = GetMonData(poke, MON_DATA_PP1 + i);
ppBonuses = GetMonData(poke, MON_DATA_PP_BONUSES);
move = GetMonData(mon, MON_DATA_MOVE1 + i);
changedPP = GetMonData(mon, MON_DATA_PP1 + i);
ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES);
if (move && changedPP == 0)
break;
}
@ -2675,11 +2676,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
changedPP = maxPP;
else
changedPP = changedPP + bankQuality;
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 2;
gBattleTextBuff1[2] = move;
gBattleTextBuff1[3] = move >> 8;
gBattleTextBuff1[4] = 0xFF;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);
BattleScriptExecute(BattleScript_BerryPPHealEnd2);
EmitSetMonData(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP);
MarkBufferBankForExecution(gActiveBank);
@ -2688,7 +2687,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
}
break;
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < 8; i++)
for (i = 0; i < BATTLE_STATS_NO; i++)
{
if (gBattleMons[bank].statStages[i] < 6)
{
@ -2722,10 +2721,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_CONFUSE_SPICY:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 8;
gBattleTextBuff1[2] = FLAVOR_SPICY;
gBattleTextBuff1[3] = EOS;
PREPARE_FLAVOUR_BUFFER(gBattleTextBuff1, FLAVOR_SPICY);
gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2742,10 +2739,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_CONFUSE_DRY:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 8;
gBattleTextBuff1[2] = FLAVOR_DRY;
gBattleTextBuff1[3] = EOS;
PREPARE_FLAVOUR_BUFFER(gBattleTextBuff1, FLAVOR_DRY);
gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2762,10 +2757,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_CONFUSE_SWEET:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 8;
gBattleTextBuff1[2] = FLAVOR_SWEET;
gBattleTextBuff1[3] = EOS;
PREPARE_FLAVOUR_BUFFER(gBattleTextBuff1, FLAVOR_SWEET);
gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2782,10 +2775,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_CONFUSE_BITTER:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 8;
gBattleTextBuff1[2] = FLAVOR_BITTER;
gBattleTextBuff1[3] = EOS;
PREPARE_FLAVOUR_BUFFER(gBattleTextBuff1, FLAVOR_BITTER);
gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2802,10 +2793,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_CONFUSE_SOUR:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / 2 && !moveTurn)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 8;
gBattleTextBuff1[2] = FLAVOR_SOUR;
gBattleTextBuff1[3] = EOS;
PREPARE_FLAVOUR_BUFFER(gBattleTextBuff1, FLAVOR_SOUR);
gBattleMoveDamage = gBattleMons[bank].maxHP / bankQuality;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
@ -2823,19 +2812,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_ATTACK_UP:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_ATK] < 0xC)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = STAT_STAGE_ATK;
gBattleTextBuff1[3] = EOS;
gBattleTextBuff2[0] = 0xFD;
gBattleTextBuff2[1] = 0;
gBattleTextBuff2[2] = 0xD2;
gBattleTextBuff2[3] = 0xD2 >> 8;
gBattleTextBuff2[4] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_ATK);
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
gEffectBank = bank;
gBattleScripting.statChanger = 0x10 + STAT_STAGE_ATK;
SET_STATCHANGER(STAT_STAGE_ATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_ATK;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -2845,13 +2826,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_DEFENSE_UP:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_DEF] < 0xC)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = STAT_STAGE_DEF;
gBattleTextBuff1[3] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_DEF);
gEffectBank = bank;
gBattleScripting.statChanger = 0x10 + STAT_STAGE_DEF;
SET_STATCHANGER(STAT_STAGE_DEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_DEF;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -2861,13 +2839,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_SPEED_UP:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPEED] < 0xC)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = STAT_STAGE_SPEED;
gBattleTextBuff1[3] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPEED);
gEffectBank = bank;
gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPEED;
SET_STATCHANGER(STAT_STAGE_SPEED, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPEED;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -2877,13 +2852,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_SP_ATTACK_UP:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPATK] < 0xC)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = STAT_STAGE_SPATK;
gBattleTextBuff1[3] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPATK);
gEffectBank = bank;
gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPATK;
SET_STATCHANGER(STAT_STAGE_SPATK, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPATK;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -2893,13 +2865,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
case HOLD_EFFECT_SP_DEFENSE_UP:
if (gBattleMons[bank].hp <= gBattleMons[bank].maxHP / bankQuality && !moveTurn && gBattleMons[bank].statStages[STAT_STAGE_SPDEF] < 0xC)
{
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = STAT_STAGE_SPDEF;
gBattleTextBuff1[3] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_STAGE_SPDEF);
gEffectBank = bank;
gBattleScripting.statChanger = 0x10 + STAT_STAGE_SPDEF;
SET_STATCHANGER(STAT_STAGE_SPDEF, 1, FALSE);
gBattleScripting.animArg1 = 0xE + STAT_STAGE_SPDEF;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -2929,22 +2898,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
i = Random() % 5;
} while (gBattleMons[bank].statStages[STAT_STAGE_ATK + i] == 0xC);
gBattleTextBuff1[0] = 0xFD;
gBattleTextBuff1[1] = 5;
gBattleTextBuff1[2] = i + 1;
gBattleTextBuff1[3] = EOS;
PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1);
gBattleTextBuff2[0] = 0xFD;
gBattleTextBuff2[1] = 0;
gBattleTextBuff2[2] = 0xD1;
gBattleTextBuff2[3] = 0xD1 >> 8;
gBattleTextBuff2[4] = 0;
gBattleTextBuff2[5] = 0xD2;
gBattleTextBuff2[6] = 0xD2 >> 8;
gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN;
gBattleTextBuff2[1] = B_BUFF_STRING;
gBattleTextBuff2[2] = STRINGID_STATSHARPLY;
gBattleTextBuff2[3] = STRINGID_STATSHARPLY >> 8;
gBattleTextBuff2[4] = B_BUFF_STRING;
gBattleTextBuff2[5] = STRINGID_STATROSE;
gBattleTextBuff2[6] = STRINGID_STATROSE >> 8;
gBattleTextBuff2[7] = EOS;
gEffectBank = bank;
gBattleScripting.statChanger = 0x21 + i;
SET_STATCHANGER(i + 1, 2, FALSE);
gBattleScripting.animArg1 = 0x21 + i + 6;
gBattleScripting.animArg2 = 0;
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
@ -3197,7 +3163,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
}
break;
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < 8; i++)
for (i = 0; i < BATTLE_STATS_NO; i++)
{
if (gBattleMons[bank].statStages[i] < 6)
{