Battle Script Reference
Battle Script Reference
# 00 A = B
# 01 A != B
# 02 A > B
# 03 A < B
# 04 A & B <- at least one common bit
# 05 A &~ B <- no common bits
# general macros
chosen.status1.animation 66 battler.bs_battlers 00 param::
# Plays regular status animation for the battler. Seemingly unused.
chosen.status2.animation 66 battler.bs_battlers 01 param::
# Plays secondary status animation for the battler.
if.status3.goto 21 battler.bs_battlers status3:: 00 ptr<`bse`>
# If a certain battler has a certain status3, goto another address or section.
if.not.status3.goto 21 battler.bs_battlers status3:: 01 ptr<`bse`>
# If a certain battler does not have a certain status3, goto another address or
section.
[AXPE_AXVE] set.stat.changer 2E 1E 60 01 02 stat.bs_statchanger
# Sets what stat should be changed and how much it should increase/decrease.
[AXPE_AXVE] set.move.effect 2E 21 4D 02 02 effect.bs_moveeffects
# Sets a certain effect for a battle script like burn/confusion/stat drop, not to
be confused with move effects for moves themselves
[AXPE_AXVE] if.move.goto 2A 00 E6 4B 02 02
move:data.pokemon.moves.names ptr<`bse`> # Compares gCurrentMove with the move
being checked.
# moveend macros
[AXPE_AXVE] moveend.all 2E 0C 60 01 02 00 49 00 00 # does all cases for
moveend
[AXPE_AXVE] moveend.case 2E 0C 60 01 02 case. 49 01 00 # does a specific
case for moveend
[AXPE_AXVE] moveend.from 2E 0C 60 01 02 from. 49 00 00 # does all cases
from a specific point for moveend
[AXPE_AXVE] moveend.to 2E 0C 60 01 02 00 49 02 to. # does all cases up
to a specific point for moveend
[AXPE_AXVE] moveend.from.to 2E 0C 60 01 02 from. 49 02 to. # does all cases
from and up to specific points for moveend
[BPRE_BPGE] moveend.all 2E D8 3F 02 02 00 49 00 00 # does all cases for
moveend
[BPRE_BPGE] moveend.case 2E D8 3F 02 02 case. 49 01 00 # does a specific
case for moveend
[BPRE_BPGE] moveend.from 2E D8 3F 02 02 from. 49 00 00 # does all cases
from a specific point for moveend
[BPRE_BPGE] moveend.to 2E D8 3F 02 02 00 49 02 to. # does all cases up
to a specific point for moveend
[BPRE_BPGE] moveend.from.to 2E D8 3F 02 02 from. 49 02 to. # does all cases
from and up to specific points for moveend
[BPEE] moveend.all 2E 88 44 02 02 00 49 00 00 # does all cases for
moveend
[BPEE] moveend.case 2E 88 44 02 02 case. 49 01 00 # does a specific
case for moveend
[BPEE] moveend.from 2E 88 44 02 02 from. 49 00 00 # does all cases
from a specific point for moveend
[BPEE] moveend.to 2E 88 44 02 02 00 49 02 to. # does all cases up
to a specific point for moveend
[BPEE] moveend.fromto 2E 88 44 02 02 from. 49 02 to. # does all cases
from and up to specific points for moveend
# various macros
cancel.multi.turn.moves 76 battler.bs_battlers 00 # Cancels
any multi-turn moves prematurely for the battler
set.magiccoat.target 76 battler.bs_battlers 01 # Sets the
target of a move if bounced back by Magic Bounce based on battler
get.cant.run 76 01 02 # Checks if
player cannot run and puts result in gBattleCommunication
get.move.target 76 01 03 # Sets the
target of a move to the normal target(s) of gCurrentMove
get.battler.fainted 76 battler.bs_battlers 04 # Checks if
the battler is fainted and puts result in gBattleCommunication
reset.intimidate.trace.bits 76 battler.bs_battlers 05 # Resets
intimidate and trace statuses for the battler
update.choice.move.lvlup 76 battler.bs_battlers 06 # Resets
the locked move from choice items if overwritten on level-up
[BPRE_BPGE_BPEE] reset.player.fainted 76 01 07 # Resets
player fainted bit for regular trainer battles
[BPRE_BPGE] get.battlers.recall 76 01 08 # Checks
trainers lost to in the Trainer Tower for FRLG
[BPRE_BPGE] return.foe.mon1.ball 76 01 09 # Returns
foe's first (only in singles) mon to trainer visually
[BPRE_BPGE] return.foe.mon2.ball 76 01 0A # Returns
foe's second (if any) mon to trainer visually
[BPRE_BPGE] check.pokeflute 76 01 0B # Checks
any mon affected by the Pokeflute on the field and in both fields' parties?
[BPRE_BPGE] wait.fanfare 76 01 0C # Blocks
script execution until any playing fanfare finishes
[BPEE] palace.flavor.text 76 battler.bs_battlers 08 # Grabs
specific Palace flavor text if possible and puts resulting index in
gBattleCommunication[MULTISTRING_CHOOSER]
[BPEE] arena.judgment.window 76 01 09 # Shows the
judgement window for Arena battles
[BPEE] arena.foe.mon.lost 76 01 0A # Sets foe
mon to lose in an arena battle
[BPEE] arena.player.mon.lost 76 01 0B # Sets
player mon to lose in an arena battle
[BPEE] arena.both.mon.lost 76 01 0C # Sets both
foe and player mons to lose in a draw in an arena battle
[BPEE] forfeit.yesno.box 76 battler.bs_battlers 0D # Pulls up
a yes/no box that is only used in forfeiting a match in the Battle Frontier
[BPEE] arena.show.ref.textbox 76 01 0E # Shows the
arena reference textbox in Arena battles
[BPEE] arena.hide.ref.textbox 76 01 0F # Hides the
arena reference textbox in Arena battles
[BPEE] arena.judgment.string 76 id. 10 # Prints
specific judgement string for Arena battles
[BPEE] arena.wait.message 76 id. 11 # Waits
until specific judgement string is done printing
[BPEE] wait.cry 76 01 12 # Halts
script execution until cry is over
[BPEE] return.foe.mon1.ball 76 01 13 # Returns
foe's first (only in singles) mon to trainer visually
[BPEE] return.foe.mon2.ball 76 01 14 # Returns
foe's second (if any) mon to trainer visually
[BPEE] volume.down 76 01 15 # Sets
music volume to a low amount
[BPEE] volume.up 76 01 16 # Sets
music volume to the normal amount
[BPEE] set.already.status.attempt 76 battler.bs_battlers 17 # Sets bit
for the battler if using a status-inflicting move on a mon who already has the
status
[BPEE] palace.try.cure.sleep.freeze 76 battler.bs_battlers 18 # Checks if
mon in a Battle Palace battle is unable to attack due to sleep/freeze and try to
heal those statuses
[BPEE] set.outcome.teleport 76 battler.bs_battlers 19 # Sets
battle outcome to whoever used Teleport for overworld scripting
[BPEE] play.trainer.defeat.bgm 76 battler.bs_battlers 1A # Plays the
trainer defeat bgm for use with Trainer Tower link battles
00 attackcanceler
01 accuracycheck ptr<`bse`> param1:
02 attackstring
03 ppreduce
04 critcalc
05 damagecalc
06 typecalc
07 adjustnormaldamage
08 adjustnormaldamage2
09 attackanimation
0a waitanimation
0b healthbarupdate battler.bs_battlers
0c datahpupdate battler.bs_battlers
0d critmessage
0e effectivenesssound
0f resultmessage
10 printstring id:
11 printselectionstring id:
12 waitmessage param0:
13 printfromtable ptr<>
14 printselectionstringfromtable ptr<>
15 seteffectwithchance
16 seteffectprimary
17 seteffectsecondary
18 clearstatusfromeffect battler.bs_battlers
19 tryfaintmon battler.bs_battlers fromMove. ptr<>
1a dofaintanimation battler.bs_battlers
1b cleareffectsonfaint battler.bs_battlers
1c jumpifstatus battler.bs_battlers status1:: ptr<`bse`>
1d jumpifstatus2 battler.bs_battlers status2:: ptr<`bse`>
1e jumpifability battler.bs_battlers ability.data.abilities.names ptr<`bse`>
1f jumpifsideaffecting battler.bs_battlers sidestatus: ptr<`bse`>
20 jumpifstat battler.bs_battlers ifflag.battle_compare stat.bs_stats
value.stat_stages ptr<`bse`>
21 jumpifstatus3condition battler.bs_battlers status3:: param2. ptr<`bse`>
22 jumpiftype battler.bs_battlers type.data.pokemon.type.names ptr<`bse`>
23 getexp battler.
24 checkteamslost ptr<`bse`>
25 movevaluescleanup
26 setmultihit value.
27 decrementmultihit ptr<`bse`>
28 goto ptr<`bse`>
29 jumpifbyte ifflag.battle_compare param1:: param2. ptr<`bse`>
2a jumpifhalfword ifflag.battle_compare address:: value: ptr<`bse`>
2b jumpifword ifflag.battle_compare param1:: param2:: ptr<`bse`>
2c jumpifarrayequal param0:: param1:: param2. ptr<`bse`>
2d jumpifarraynotequal param0:: param1:: param2. ptr<`bse`>
2e setbyte ram:: param1.
2f addbyte ram:: param1.
30 subbyte ram:: param1.
31 copyarray param0:: param1:: param2.
32 copyarraywithindex param0:: param1:: param2:: param3.
33 orbyte ram:: param1.
34 orhalfword ram:: param1:
35 orword ram:: param1::
36 bicbyte ram:: param1.
37 bichalfword ram:: param1:
38 bicword ram:: param1::
39 pause param0:
3a waitstate
3b healthbar_update battler.bs_battlers
3c return
3d end
3e end2
3f end3
40 jumpifaffectedbyprotect ptr<`bse`>
41 call ptr<`bse`>
42 jumpiftype2 battler.bs_battlers type.data.pokemon.type.names ptr<`bse`>
43 jumpifabilitypresent ability.data.abilities.names ptr<`bse`>
44 endselectionscript
45 playanimation battler.bs_battlers animation.effectanimations param2::
46 playanimation_var battler.bs_battlers param1:: param2::
47 setgraphicalstatchangevalues
48 playstatchangeanimation battler.bs_battlers param1.statanimation param2.
49 moveend param0. param1.
4a typecalc2
4b returnatktoball
4c getswitchedmondata battler.bs_battlers
4d switchindataupdate battler.bs_battlers
4e switchinanim battler.bs_battlers dontclearsubstitutebit.
4f jumpifcantswitch battler.bs_battlers ptr<`bse`>
50 openpartyscreen param0. ptr<`bse`>
51 switchhandleorder battler.bs_battlers param1.
52 switchineffects battler.bs_battlers
53 trainerslidein battler.bs_battlers
54 playse song:songnames
55 fanfare song:songnames
56 playfaintcry battler.bs_battlers
57 endlinkbattle
58 returntoball battler.bs_battlers
59 handlelearnnewmove param0<`bse`> param1<`bse`> param2.
5a yesnoboxlearnmove ptr<`bse`>
5b yesnoboxstoplearningmove ptr<`bse`>
5c hitanimation battler.bs_battlers
[BPRE_BPGE] 5d getmoneyreward ptr<`bse`>
[BPEE_AXPE_AXVE] 5d getmoneyreward
5e updatebattlermoves battler.bs_battlers
5f swapattackerwithtarget
60 incrementgamestat param0.
61 drawpartystatussummary battler.bs_battlers
62 hidepartystatussummary battler.bs_battlers
63 jumptocalledmove param0.
64 statusanimation battler.bs_battlers
65 status2animation battler.bs_battlers status2::
66 chosenstatusanimation battler.bs_battlers param1. param2::
67 yesnobox
68 cancelallactions
69 adjustsetdamage
6a removeitem battler.bs_battlers
6b atknameinbuff1
6c drawlvlupbox
6d resetsentmonsvalue
6e setatktoplayer0
6f makevisible battler.bs_battlers
70 recordlastability battler.bs_battlers
71 buffermovetolearn
72 jumpifplayerran ptr<`bse`>
73 hpthresholds battler.bs_battlers
74 hpthresholds2 battler.bs_battlers
75 useitemonopponent
76 various battler.bs_battlers param1.
77 setprotectlike
78 tryexplosion
79 setatkhptozero
7a jumpifnexttargetvalid ptr<`bse`>
7b tryhealhalfhealth ptr<`bse`> battler.bs_battlers
7c trymirrormove
7d setrain
7e setreflect
7f setseeded
80 manipulatedamage param0.
81 trysetrest ptr<`bse`>
82 jumpifnotfirstturn ptr<`bse`>
83 nop
84 jumpifcantmakeasleep ptr<`bse`>
85 stockpile
86 stockpiletobasedamage ptr<`bse`>
87 stockpiletohpheal ptr<`bse`>
88 negativedamage
89 statbuffchange stat. ptr<`bse`>
8a normalisebuffs
8b setbide
8c confuseifrepeatingattackends
8d setmultihitcounter param0.
8e initmultihitstring
8f forcerandomswitch ptr<`bse`>
90 tryconversiontypechange ptr<`bse`>
91 givepaydaymoney
92 setlightscreen
93 tryKO ptr<`bse`>
94 damagetohalftargethp
95 setsandstorm
96 weatherdamage
97 tryinfatuating ptr<`bse`>
98 updatestatusicon battler.bs_battlers
99 setmist
9a setfocusenergy
9b transformdataexecution
9c setsubstitute
9d mimicattackcopy ptr<`bse`>
9e metronome
9f dmgtolevel
a0 psywavedamageeffect
a1 counterdamagecalculator ptr<`bse`>
a2 mirrorcoatdamagecalculator ptr<`bse`>
a3 disablelastusedattack ptr<`bse`>
a4 trysetencore ptr<`bse`>
a5 painsplitdmgcalc ptr<`bse`>
a6 settypetorandomresistance ptr<`bse`>
a7 setalwayshitflag
a8 copymovepermanently ptr<`bse`>
a9 trychoosesleeptalkmove ptr<`bse`>
aa setdestinybond
ab trysetdestinybondtohappen
ac remaininghptopower
ad tryspiteppreduce ptr<`bse`>
ae healpartystatus
af cursetarget ptr<`bse`>
b0 trysetspikes ptr<`bse`>
b1 setforesight
b2 trysetperishsong ptr<`bse`>
b3 rolloutdamagecalculation
b4 jumpifconfusedandstatmaxed stat.bs_stats ptr<`bse`>
b5 furycuttercalc
b6 happinesstodamagecalculation
b7 presentdamagecalculation
b8 setsafeguard
b9 magnitudedamagecalculation
ba jumpifnopursuitswitchdmg ptr<`bse`>
bb setsunny
bc maxattackhalvehp ptr<`bse`>
bd copyfoestats ptr<`bse`>
be rapidspinfree
bf setdefensecurlbit
c0 recoverbasedonsunlight ptr<`bse`>
c1 hiddenpowercalc
c2 selectfirstvalidtarget
c3 trysetfutureattack ptr<`bse`>
c4 trydobeatup ptr0<`bse`> ptr1<`bse`>
c5 setsemiinvulnerablebit
c6 clearsemiinvulnerablebit
c7 setminimize
c8 sethail
c9 trymemento ptr<`bse`>
ca setforcedtarget
cb setcharge
cc callterrainattack
cd cureifburnedparalysedorpoisoned ptr<`bse`>
ce settorment ptr<`bse`>
cf jumpifnodamage ptr<`bse`>
d0 settaunt ptr<`bse`>
d1 trysethelpinghand ptr<`bse`>
d2 tryswapitems ptr<`bse`>
d3 trycopyability ptr<`bse`>
d4 trywish param0. param1<`bse`>
d5 trysetroots ptr<`bse`>
d6 doubledamagedealtifdamaged
d7 setyawn ptr<`bse`>
d8 setdamagetohealthdifference ptr<`bse`>
d9 scaledamagebyhealthratio
da tryswapabilities ptr<`bse`>
db tryimprison ptr<`bse`>
dc trysetgrudge ptr<`bse`>
dd weightdamagecalculation
de assistattackselect ptr<`bse`>
df trysetmagiccoat ptr<`bse`>
e0 trysetsnatch ptr<`bse`>
e1 trygetintimidatetarget ptr<`bse`>
e2 switchoutabilities battler.bs_battlers
e3 jumpifhasnohp battler.bs_battlers ptr<`bse`>
e4 getsecretpowereffect
e5 pickup
e6 docastformchangeanimation
e7 trycastformdatachange
e8 settypebasedhalvers ptr<`bse`>
e9 setweatherballtype
ea tryrecycleitem ptr<`bse`>
eb settypetoterrain ptr<`bse`>
ec pursuitdoubles ptr<`bse`>
ed snatchsetbattlers
ee removelightscreenreflect
ef handleballthrow
f0 givecaughtmon
f1 trysetcaughtmondexflags ptr<`bse`>
f2 displaydexinfo
f3 trygivecaughtmonnick ptr<`bse`>
f4 subattackerhpbydmg
f5 removeattackerstatus1
f6 finishaction
f7 finishturn
[BPEE] f8 trainerslideout battler.bs_battlers
# helpful macros
#XX sethword {dst} {value}
# setbyte {dst} {value} & 0xFF
# setbyte {dst} + 1 ({value} >> 8) & 0xFF
#XX setword {dst} {value}
# setbyte {dst}, {value} & 0xFF
# setbyte {dst} + 1 ({value} >> 8) & 0xFF
# setbyte {dst} + 2 ({value} >> 16) & 0xFF
# setbyte {dst} + 3 ({value} >> 24) & 0xFF
#XX copybyte {dst} {src}
# copyarray {dst} {src} 0x1
#XX copyhword {dst} {src}
# copyarray {dst} {src} 0x2
#XX copyword {dst} {src}
# copyarray {dst} {src} 0x4
#XX jumpifbytenotequal {byte1} {byte2} {jumpptr}
# jumpifarraynotequal {byte1} {byte2} 1 {jumpptr}
#XX jumpifbyteequal {byte1} {byte2} {jumpptr}
# jumpifarrayequal {byte1} {byte2} 1 {jumpptr}