pokeemerald-expansion/asm/macros/battle_script.inc
2026-01-16 18:55:22 +01:00

2424 lines
46 KiB
PHP

@ commands
.macro attackcanceler
.byte B_SCR_OP_ATTACKCANCELER
.endm
.macro accuracycheck failInstr:req
.byte B_SCR_OP_ACCURACYCHECK
.4byte \failInstr
.endm
.macro printattackstring
.byte B_SCR_OP_PRINTATTACKSTRING
.endm
.macro printselectionstringfromtable ptr:req
.byte B_SCR_OP_PRINTSELECTIONSTRINGFROMTABLE
.4byte \ptr
.endm
.macro critcalc
.warning "critcalc macro has been deprecated, please remove from scripts"
.byte B_SCR_OP_CRITCALC
.endm
.macro damagecalc
.byte B_SCR_OP_DAMAGECALC
.endm
.macro typecalc
.byte B_SCR_OP_TYPECALC
.endm
.macro adjustdamage
.byte B_SCR_OP_ADJUSTDAMAGE
.endm
.macro multihitresultmessage
.byte B_SCR_OP_MULTIHITRESULTMESSAGE
.endm
.macro attackanimation
.byte B_SCR_OP_ATTACKANIMATION
.endm
.macro waitanimation
.byte B_SCR_OP_WAITANIMATION
.endm
.macro healthbarupdate battler:req updateState:req
.byte B_SCR_OP_HEALTHBARUPDATE
.byte \battler
.byte \updateState
.endm
.macro datahpupdate battler:req updateState:req
.byte B_SCR_OP_DATAHPUPDATE
.byte \battler
.byte \updateState
.endm
.macro critmessage
.byte B_SCR_OP_CRITMESSAGE
.endm
.macro effectivenesssound
.byte B_SCR_OP_EFFECTIVENESSSOUND
.endm
.macro resultmessage
.byte B_SCR_OP_RESULTMESSAGE
.endm
.macro printstring id:req
.byte B_SCR_OP_PRINTSTRING
.2byte \id
.endm
.macro printsavedstring
printstring 0
.endm
.macro printselectionstring id:req
.byte B_SCR_OP_PRINTSELECTIONSTRING
.2byte \id
.endm
.macro waitmessage time:req
.byte B_SCR_OP_WAITMESSAGE
.2byte \time
.endm
.macro printfromtable ptr:req
.byte B_SCR_OP_PRINTFROMTABLE
.4byte \ptr
.endm
.macro setpreattackadditionaleffect
.byte B_SCR_OP_SETPREATTACKADDITIONALEFFECT
.endm
.macro setadditionaleffects
.byte B_SCR_OP_SETADDITIONALEFFECTS
.endm
.macro seteffectprimary battler:req, effectBattler:req, moveEffect=0
.if \moveEffect != 0
setmoveeffect \moveEffect
.endif
.byte B_SCR_OP_SETEFFECTPRIMARY
.byte \battler
.byte \effectBattler
.endm
.macro seteffectsecondary battler:req, effectBattler:req, moveEffect=0
.if \moveEffect != 0
setmoveeffect \moveEffect
.endif
.byte B_SCR_OP_SETEFFECTSECONDARY
.byte \battler
.byte \effectBattler
.endm
.macro clearvolatile battler:req, volatile:req
.byte B_SCR_OP_CLEARVOLATILE
.byte \battler
.byte \volatile
.endm
.macro tryfaintmon battler:req
.byte B_SCR_OP_TRYFAINTMON
.byte \battler
.byte FALSE
.4byte NULL
.endm
.macro tryfaintmon_spikes battler:req, instr:req
.byte B_SCR_OP_TRYFAINTMON
.byte \battler
.byte TRUE
.4byte \instr
.endm
.macro dofaintanimation battler:req
.byte B_SCR_OP_DOFAINTANIMATION
.byte \battler
.endm
.macro cleareffectsonfaint battler:req
.byte B_SCR_OP_CLEAREFFECTSONFAINT
.byte \battler
.endm
.macro jumpifstatus battler:req, flags:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFSTATUS
.byte \battler
.4byte \flags
.4byte \jumpInstr
.endm
.macro jumpifvolatile battler:req, volatile:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFVOLATILE
.byte \battler
.byte \volatile
.4byte \jumpInstr
.endm
.macro jumpifability battler:req, ability:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFABILITY
.byte \battler
.2byte \ability
.4byte \jumpInstr
.endm
.macro jumpifsideaffecting battler:req, flags:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFSIDEAFFECTING
.byte \battler
.4byte \flags
.4byte \jumpInstr
.endm
.macro jumpifstat battler:req, comparison:req, stat:req, value:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFSTAT
.byte \battler
.byte \comparison
.byte \stat
.byte \value
.4byte \jumpInstr
.endm
.macro jumpifstatignorecontrary battler:req, comparison:req, stat:req, value:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFSTATIGNORECONTRARY
.byte \battler
.byte \comparison
.byte \stat
.byte \value
.4byte \jumpInstr
.endm
.macro jumpbasedontype battler:req, type:req, jumpIfType:req, jumpInstr:req
.byte B_SCR_OP_JUMPBASEDONTYPE
.byte \battler
.byte \type
.byte \jumpIfType
.4byte \jumpInstr
.endm
.macro jumpiftype battler:req, type:req, jumpInstr:req
jumpbasedontype \battler, \type, TRUE, \jumpInstr
.endm
.macro jumpifnottype battler:req, type:req, jumpInstr:req
jumpbasedontype \battler, \type, FALSE, \jumpInstr
.endm
.macro getexp battler:req
.byte B_SCR_OP_GETEXP
.byte \battler
.endm
.macro checkteamslost jumpInstr:req
.byte B_SCR_OP_CHECKTEAMSLOST
.4byte \jumpInstr
.endm
.macro movevaluescleanup
.byte B_SCR_OP_MOVEVALUESCLEANUP
.endm
.macro setmultihit value:req
.byte B_SCR_OP_SETMULTIHIT
.byte \value
.endm
.macro decrementmultihit loopInstr:req
.byte B_SCR_OP_DECREMENTMULTIHIT
.4byte \loopInstr
.endm
.macro goto instr:req
.byte B_SCR_OP_GOTO
.4byte \instr
.endm
.macro jumpifbyte comparison:req, bytePtr:req, value:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFBYTE
.byte \comparison
.4byte \bytePtr
.byte \value
.4byte \jumpInstr
.endm
.macro jumpifhalfword comparison:req, halfwordPtr:req, value:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFHALFWORD
.byte \comparison
.4byte \halfwordPtr
.2byte \value
.4byte \jumpInstr
.endm
.macro jumpifword comparison:req, wordPtr:req, value:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFWORD
.byte \comparison
.4byte \wordPtr
.4byte \value
.4byte \jumpInstr
.endm
.macro jumpifarrayequal array1:req, array2:req, size:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFARRAYEQUAL
.4byte \array1
.4byte \array2
.byte \size
.4byte \jumpInstr
.endm
.macro jumpifarraynotequal array1:req, array2:req, size:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFARRAYNOTEQUAL
.4byte \array1
.4byte \array2
.byte \size
.4byte \jumpInstr
.endm
.macro setbyte bytePtr:req, value:req
.byte B_SCR_OP_SETBYTE
.4byte \bytePtr
.byte \value
.endm
.macro addbyte bytePtr:req, value:req
.byte B_SCR_OP_ADDBYTE
.4byte \bytePtr
.byte \value
.endm
.macro subbyte bytePtr:req, value:req
.byte B_SCR_OP_SUBBYTE
.4byte \bytePtr
.byte \value
.endm
.macro copyarray dest:req, src:req, size:req
.byte B_SCR_OP_COPYARRAY
.4byte \dest
.4byte \src
.byte \size
.endm
.macro copyarraywithindex dest:req, src:req, indexPtr:req, size:req
.byte B_SCR_OP_COPYARRAYWITHINDEX
.4byte \dest
.4byte \src
.4byte \indexPtr
.byte \size
.endm
.macro orbyte bytePtr:req, value:req
.byte B_SCR_OP_ORBYTE
.4byte \bytePtr
.byte \value
.endm
.macro orhalfword halfwordPtr:req, value:req
.byte B_SCR_OP_ORHALFWORD
.4byte \halfwordPtr
.2byte \value
.endm
.macro orword wordPtr:req, value:req
.byte B_SCR_OP_ORWORD
.4byte \wordPtr
.4byte \value
.endm
.macro bicbyte bytePtr:req, value:req
.byte B_SCR_OP_BICBYTE
.4byte \bytePtr
.byte \value
.endm
.macro bichalfword halfwordPtr:req, value:req
.byte B_SCR_OP_BICHALFWORD
.4byte \halfwordPtr
.2byte \value
.endm
.macro bicword wordPtr:req, value:req
.byte B_SCR_OP_BICWORD
.4byte \wordPtr
.4byte \value
.endm
.macro pause frames:req
.byte B_SCR_OP_PAUSE
.2byte \frames
.endm
.macro setchargingturn
.byte B_SCR_OP_SETCHARGINGTURN
.endm
.macro waitstate
.byte B_SCR_OP_WAITSTATE
.endm
.macro isdmgblockedbydisguise
.byte B_SCR_OP_ISDMGBLOCKEDBYDISGUISE
.endm
.macro return
.byte B_SCR_OP_RETURN
.endm
.macro end
.byte B_SCR_OP_END
.endm
.macro end2
.byte B_SCR_OP_END2
.endm
.macro end3
.byte B_SCR_OP_END3
.endm
.macro call instr:req
.byte B_SCR_OP_CALL
.4byte \instr
.endm
.macro setroost
.byte B_SCR_OP_SETROOST
.endm
.macro jumpifabilitypresent ability:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFABILITYPRESENT
.2byte \ability
.4byte \jumpInstr
.endm
.macro endselectionscript
.byte B_SCR_OP_ENDSELECTIONSCRIPT
.endm
.macro playanimation battler:req, animId:req, argPtr=NULL
.byte B_SCR_OP_PLAYANIMATION
.byte \battler
.byte \animId
.4byte \argPtr
.endm
.macro playanimation_var battler:req, animIdPtr:req, argPtr=NULL
.byte B_SCR_OP_PLAYANIMATION_VAR
.byte \battler
.4byte \animIdPtr
.4byte \argPtr
.endm
.macro jumpfifsemiinvulnerable battler:req, state:req, jumpInstr:req
.byte B_SCR_OP_JUMPFIFSEMIINVULNERABLE
.byte \battler
.byte \state
.4byte \jumpInstr
.endm
.macro trainerslidein position:req
.byte B_SCR_OP_TRAINERSLIDEIN
.byte \position
.endm
.macro moveend endMode:req, endState:req
.byte B_SCR_OP_MOVEEND
.byte \endMode
.byte \endState
.endm
@ Help macros for 5 uses of moveend command
@ All cases
.macro moveendall
setbyte sMOVEEND_STATE, 0
moveend 0, 0
.endm
@ Chosen case
.macro moveendcase case:req
setbyte sMOVEEND_STATE, \case
moveend 1, 0
.endm
@ All cases from (inclusive)
.macro moveendfrom from:req
setbyte sMOVEEND_STATE, \from
moveend 0, 0
.endm
@ All cases from 0 to (not inclusive)
.macro moveendto to:req
setbyte sMOVEEND_STATE, 0
moveend 2, \to
.endm
@ Cases from (inclusive) to (not inclusive)
.macro moveendfromto from:req, to:req
setbyte sMOVEEND_STATE, \from
moveend 2, \to
.endm
.macro sethealblock failInstr:req
.byte B_SCR_OP_SETHEALBLOCK
.4byte \failInstr
.endm
.macro returnatktoball
.byte B_SCR_OP_RETURNATKTOBALL
.endm
.macro getswitchedmondata battler:req
.byte B_SCR_OP_GETSWITCHEDMONDATA
.byte \battler
.endm
.macro switchindataupdate battler:req
.byte B_SCR_OP_SWITCHINDATAUPDATE
.byte \battler
.endm
.macro switchinanim battler:req, dontClearTransform:req, dontClearSubstitute:req
.byte B_SCR_OP_SWITCHINANIM
.byte \battler
.byte \dontClearTransform
.byte \dontClearSubstitute
.endm
.macro jumpifcantswitch battler:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFCANTSWITCH
.byte \battler
.4byte \jumpInstr
.endm
.macro openpartyscreen battler:req, failInstr:req
.byte B_SCR_OP_OPENPARTYSCREEN
.byte \battler
.4byte \failInstr
.endm
.macro switchhandleorder battler:req, state:req
.byte B_SCR_OP_SWITCHHANDLEORDER
.byte \battler
.byte \state
.endm
.macro switchineffects battler:req
.byte B_SCR_OP_SWITCHINEFFECTS
.byte \battler
.endm
.macro switchinevents
.byte B_SCR_OP_SWITCHINEVENTS
.endm
.macro playse song:req
.byte B_SCR_OP_PLAYSE
.2byte \song
.endm
.macro fanfare song:req
.byte B_SCR_OP_FANFARE
.2byte \song
.endm
.macro playfaintcry battler:req
.byte B_SCR_OP_PLAYFAINTCRY
.byte \battler
.endm
.macro endlinkbattle
.byte B_SCR_OP_ENDLINKBATTLE
.endm
.macro returntoball battler:req, changingForm:req
.byte B_SCR_OP_RETURNTOBALL
.byte \battler
.byte \changingForm
.endm
.macro handlelearnnewmove learnedMoveInstr:req, nothingToLearnInstr:req, isFirstMove:req
.byte B_SCR_OP_HANDLELEARNNEWMOVE
.4byte \learnedMoveInstr
.4byte \nothingToLearnInstr
.byte \isFirstMove
.endm
.macro yesnoboxlearnmove forgotMoveInstr:req
.byte B_SCR_OP_YESNOBOXLEARNMOVE
.4byte \forgotMoveInstr
.endm
.macro yesnoboxstoplearningmove noInstr:req
.byte B_SCR_OP_YESNOBOXSTOPLEARNINGMOVE
.4byte \noInstr
.endm
.macro hitanimation battler:req
.byte B_SCR_OP_HITANIMATION
.byte \battler
.endm
.macro getmoneyreward
.byte B_SCR_OP_GETMONEYREWARD
.endm
.macro updatebattlermoves battler:req
.byte B_SCR_OP_UPDATEBATTLERMOVES
.byte \battler
.endm
.macro swapattackerwithtarget
.byte B_SCR_OP_SWAPATTACKERWITHTARGET
.endm
.macro incrementgamestat stat:req
.byte B_SCR_OP_INCREMENTGAMESTAT
.byte \stat
.endm
.macro drawpartystatussummary battler:req
.byte B_SCR_OP_DRAWPARTYSTATUSSUMMARY
.byte \battler
.endm
.macro hidepartystatussummary battler:req
.byte B_SCR_OP_HIDEPARTYSTATUSSUMMARY
.byte \battler
.endm
.macro jumptocalledmove notChosenMove:req
.byte B_SCR_OP_JUMPTOCALLEDMOVE
.byte \notChosenMove
.endm
.macro statusanimation battler:req, status=0, isVolatile=FALSE
.byte B_SCR_OP_STATUSANIMATION
.byte \battler
.4byte \status
.byte \isVolatile
.endm
.macro volatileanimation battler:req, volatile:req
statusanimation \battler, \volatile, TRUE
.endm
.macro futuresighttargetfailure failInstr:req
.byte B_SCR_OP_FUTURESIGHTTARGETFAILURE
.4byte \failInstr
.endm
.macro getpossiblenexttarget jumpInstr:req
.byte B_SCR_OP_GETPOSSIBLENEXTTARGET
.4byte \jumpInstr
.endm
.macro yesnobox
.byte B_SCR_OP_YESNOBOX
.endm
.macro cancelallactions
.byte B_SCR_OP_CANCELALLACTIONS
.endm
.macro setgravity failInstr:req
.byte B_SCR_OP_SETGRAVITY
.4byte \failInstr
.endm
.macro removeitem battler:req
.byte B_SCR_OP_REMOVEITEM
.byte \battler
.endm
.macro atknameinbuff1
.byte B_SCR_OP_ATKNAMEINBUFF1
.endm
.macro drawlvlupbox
.byte B_SCR_OP_DRAWLVLUPBOX
.endm
.macro resetsentmonsvalue
.byte B_SCR_OP_RESETSENTMONSVALUE
.endm
.macro setatktoplayer0
.byte B_SCR_OP_SETATKTOPLAYER0
.endm
.macro makevisible battler:req
.byte B_SCR_OP_MAKEVISIBLE
.byte \battler
.endm
.macro recordability battler:req
.byte B_SCR_OP_RECORDABILITY
.byte \battler
.endm
.macro buffermovetolearn
.byte B_SCR_OP_BUFFERMOVETOLEARN
.endm
.macro jumpifplayerran jumpInstr:req
.byte B_SCR_OP_JUMPIFPLAYERRAN
.4byte \jumpInstr
.endm
.macro hpthresholds battler:req
.byte B_SCR_OP_HPTHRESHOLDS
.byte \battler
.endm
.macro hpthresholds2 battler:req
.byte B_SCR_OP_HPTHRESHOLDS2
.byte \battler
.endm
.macro useitemonopponent
.byte B_SCR_OP_USEITEMONOPPONENT
.endm
.macro unused_0x78
.byte B_SCR_OP_UNUSED_0X78
.endm
.macro setprotectlike
.byte B_SCR_OP_SETPROTECTLIKE
.endm
.macro tryexplosion
.byte B_SCR_OP_TRYEXPLOSION
.endm
.macro setatkhptozero
.byte B_SCR_OP_SETATKHPTOZERO
.endm
.macro jumpifnexttargetvalid jumpInstr:req
.byte B_SCR_OP_JUMPIFNEXTTARGETVALID
.4byte \jumpInstr
.endm
.macro tryhealhalfhealth battler:req, failInstr:req
.byte B_SCR_OP_TRYHEALHALFHEALTH
.byte \battler
.4byte \failInstr
.endm
.macro trymirrormove
.byte B_SCR_OP_UNUSED_0X7E
.endm
.macro setfieldweather
.byte B_SCR_OP_SETFIELDWEATHER
.endm
.macro setreflect
.byte B_SCR_OP_SETREFLECT
.endm
.macro setseeded
.byte B_SCR_OP_SETSEEDED
.endm
.macro manipulatedamage mode:req
.byte B_SCR_OP_MANIPULATEDAMAGE
.byte \mode
.endm
.macro trysetrest
.byte B_SCR_OP_TRYSETREST
.endm
.macro unused_0x82
.byte B_SCR_OP_UNUSED_0X82
.endm
.macro unused_0x83
.byte B_SCR_OP_UNUSED_0X83
.endm
.macro jumpifuproarwakes jumpInstr:req
.byte B_SCR_OP_JUMPIFUPROARWAKES
.4byte \jumpInstr
.endm
.macro stockpile
.byte B_SCR_OP_STOCKPILE
.endm
.macro stockpiletobasedamage
.byte B_SCR_OP_STOCKPILETOBASEDAMAGE
.endm
.macro stockpiletohpheal failInstr:req
.byte B_SCR_OP_STOCKPILETOHPHEAL
.4byte \failInstr
.endm
.macro removestockpilecounters
callnative BS_RemoveStockpileCounters
.endm
.macro unused_0x88
.byte B_SCR_OP_UNUSED_0X88
.endm
.macro statbuffchange battler:req, flags:req, failInstr:req, stats=0
.byte B_SCR_OP_STATBUFFCHANGE
.byte \battler
.2byte \flags
.4byte \failInstr
.byte \stats
.endm
.macro normalisebuffs
.byte B_SCR_OP_NORMALISEBUFFS
.endm
.macro setbide
.byte B_SCR_OP_SETBIDE
.endm
.macro twoturnmoveschargestringandanimation
.byte B_SCR_OP_TWOTURNMOVESCHARGESTRINGANDANIMATION
.4byte 1f @animation then attack string
@default - attack string then animation
printsavedstring
waitmessage B_WAIT_TIME_LONG
attackanimation
waitanimation
goto 2f
1:
attackanimation
waitanimation
printsavedstring
waitmessage B_WAIT_TIME_LONG
2:
.endm
.macro trynonvolatilestatus
.byte B_SCR_OP_TRYNONVOLATILESTATUS
.endm
.macro initmultihitstring
.byte B_SCR_OP_INITMULTIHITSTRING
.endm
.macro forcerandomswitch failInstr:req
.byte B_SCR_OP_FORCERANDOMSWITCH
.4byte \failInstr
.endm
.macro tryconversiontypechange failInstr:req
.byte B_SCR_OP_TRYCONVERSIONTYPECHANGE
.4byte \failInstr
.endm
.macro givepaydaymoney
.byte B_SCR_OP_GIVEPAYDAYMONEY
.endm
.macro setlightscreen
.byte B_SCR_OP_SETLIGHTSCREEN
.endm
.macro tryKO failInstr:req
.byte B_SCR_OP_TRYKO
.4byte \failInstr
.endm
.macro checknonvolatiletrigger nonVolatile:req, failInstr:req
.byte B_SCR_OP_CHECKNONVOLATILETRIGGER
.2byte \nonVolatile
.4byte \failInstr
.endm
.macro copybidedmg
.byte B_SCR_OP_COPYBIDEDMG
.endm
.macro animatewildpokemonafterfailedpokeball battler:req
.byte B_SCR_OP_ANIMATEWILDPOKEMONAFTERFAILEDPOKEBALL
.byte \battler
.endm
.macro tryinfatuating failInstr:req
.byte B_SCR_OP_TRYINFATUATING
.4byte \failInstr
.endm
.macro updatestatusicon battler:req
.byte B_SCR_OP_UPDATESTATUSICON
.byte \battler
.endm
.macro setmist
.byte B_SCR_OP_SETMIST
.endm
.macro setfocusenergy battler:req
.byte B_SCR_OP_SETFOCUSENERGY
.byte \battler
.endm
.macro transformdataexecution
.byte B_SCR_OP_TRANSFORMDATAEXECUTION
.endm
.macro setsubstitute
.byte B_SCR_OP_SETSUBSTITUTE
.endm
.macro mimicattackcopy failInstr:req
.byte B_SCR_OP_MIMICATTACKCOPY
.4byte \failInstr
.endm
.macro setcalledmove
.byte B_SCR_OP_SETCALLEDMOVE
.endm
.macro unused_0x9f
.byte B_SCR_OP_UNUSED_0X9F
.endm
.macro unused_0xA0
.byte B_SCR_OP_UNUSED_0XA0
.endm
.macro unused_0xA1
.byte B_SCR_OP_UNUSED_0XA1
.endm
.macro unused_0xA2
.byte B_SCR_OP_UNUSED_0XA2
.endm
.macro disablelastusedattack failInstr:req
.byte B_SCR_OP_DISABLELASTUSEDATTACK
.4byte \failInstr
.endm
.macro trysetencore failInstr:req
.byte B_SCR_OP_TRYSETENCORE
.4byte \failInstr
.endm
.macro painsplitdmgcalc failInstr:req
.byte B_SCR_OP_PAINSPLITDMGCALC
.4byte \failInstr
.endm
.macro settypetorandomresistance failInstr:req
.byte B_SCR_OP_SETTYPETORANDOMRESISTANCE
.4byte \failInstr
.endm
.macro setalwayshitflag
.byte B_SCR_OP_SETALWAYSHITFLAG
.endm
.macro copymovepermanently failInstr:req
.byte B_SCR_OP_COPYMOVEPERMANENTLY
.4byte \failInstr
.endm
.macro trychoosesleeptalkmove failInstr:req
.byte B_SCR_OP_UNUSED_0XA9
.4byte \failInstr
.endm
.macro trysetdestinybond failInstr:req
.byte B_SCR_OP_UNUSED_AA
.4byte \failInstr
.endm
.macro unused_0xab
.byte B_SCR_OP_UNUSED_0XAB
.endm
.macro settailwind failInstr:req
.byte B_SCR_OP_SETTAILWIND
.4byte \failInstr
.endm
.macro tryspiteppreduce failInstr:req
.byte B_SCR_OP_TRYSPITEPPREDUCE
.4byte \failInstr
.endm
.macro healpartystatus
.byte B_SCR_OP_HEALPARTYSTATUS
.endm
.macro cursetarget failInstr:req
.byte B_SCR_OP_CURSETARGET
.4byte \failInstr
.endm
.macro trysetspikes failInstr:req
.byte B_SCR_OP_TRYSETSPIKES
.4byte \failInstr
.endm
.macro setvolatile battler:req, volatile:req, value=TRUE
.byte B_SCR_OP_SETVOLATILE
.byte \battler
.byte \volatile
.byte \value
.endm
.macro trysetperishsong failInstr:req
.byte B_SCR_OP_TRYSETPERISHSONG
.4byte \failInstr
.endm
.macro unused_0xb3
.byte B_SCR_OP_UNUSED_0XB3
.endm
.macro jumpifconfusedandstatmaxed stat:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFCONFUSEDANDSTATMAXED
.byte \stat
.4byte \jumpInstr
.endm
.macro unused_0xb5
.byte B_SCR_OP_UNUSED_0XB5
.endm
.macro setembargo failInstr:req
.byte B_SCR_OP_SETEMBARGO
.4byte \failInstr
.endm
.macro presentdamagecalculation
.byte B_SCR_OP_PRESENTDAMAGECALCULATION
.endm
.macro setsafeguard
.byte B_SCR_OP_SETSAFEGUARD
.endm
.macro magnitudedamagecalculation
.byte B_SCR_OP_MAGNITUDEDAMAGECALCULATION
.endm
.macro jumpifnopursuitswitchdmg jumpInstr:req
.byte B_SCR_OP_JUMPIFNOPURSUITSWITCHDMG
.4byte \jumpInstr
.endm
.macro tryactivateitem battler:req, flag:req
.byte B_SCR_OP_TRYACTIVATEITEM
.byte \battler
.byte \flag
.endm
.macro halvehp failInstr:req
.byte B_SCR_OP_HALVEHP
.4byte \failInstr
.endm
.macro copyfoestats
.byte B_SCR_OP_COPYFOESTATS
.endm
.macro rapidspinfree
.byte B_SCR_OP_RAPIDSPINFREE
.endm
.macro recoverbasedonsunlight failInstr:req
.byte B_SCR_OP_RECOVERBASEDONSUNLIGHT
.4byte \failInstr
.endm
.macro setstickyweb failInstr:req
.byte B_SCR_OP_SETSTICKYWEB
.4byte \failInstr
.endm
.macro selectfirstvalidtarget
.byte B_SCR_OP_SELECTFIRSTVALIDTARGET
.endm
.macro setfutureattack
.byte B_SCR_OP_SETFUTUREATTACK
.endm
.macro trydobeatup endInstr:req, failInstr:req
.byte B_SCR_OP_TRYDOBEATUP
.4byte \endInstr
.4byte \failInstr
.endm
.macro setsemiinvulnerablebit clear=FALSE
.byte B_SCR_OP_SETSEMIINVULNERABLEBIT
.byte \clear
.endm
.macro clearsemiinvulnerablebit
setsemiinvulnerablebit TRUE
.endm
.macro unused_0xC6
.byte B_SCR_OP_UNUSED_0XC6
.endm
.macro unused_0xC7
.byte B_SCR_OP_UNUSED_0XC7
.endm
.macro unused_c8
.byte B_SCR_OP_UNUSED_C8
.endm
.macro trymemento failInstr:req
.byte B_SCR_OP_TRYMEMENTO
.4byte \failInstr
.endm
.macro setforcedtarget
.byte B_SCR_OP_SETFORCEDTARGET
.endm
.macro unused_0xcb battler:req
.byte B_SCR_OP_UNUSED_0XCB
.byte \battler
.endm
.macro unused_0xCC
.byte B_SCR_OP_UNUSED_0XCC
.endm
.macro curestatuswithmove failInstr:req
.byte B_SCR_OP_CURESTATUSWITHMOVE
.4byte \failInstr
.endm
.macro settorment failInstr:req
.byte B_SCR_OP_SETTORMENT
.4byte \failInstr
.endm
.macro unused_0xcf
.byte B_SCR_OP_UNUSED_0XCF
.endm
.macro settaunt failInstr:req
.byte B_SCR_OP_SETTAUNT
.4byte \failInstr
.endm
.macro trysethelpinghand failInstr:req
.byte B_SCR_OP_TRYSETHELPINGHAND
.4byte \failInstr
.endm
.macro tryswapitems failInstr:req
.byte B_SCR_OP_TRYSWAPITEMS
.4byte \failInstr
.endm
.macro trycopyability battler:req, failInstr:req
.byte B_SCR_OP_TRYCOPYABILITY
.byte \battler
.4byte \failInstr
.endm
.macro trywish failInstr:req
.byte B_SCR_OP_TRYWISH
.4byte \failInstr
.endm
.macro settoxicspikes failInstr:req
.byte B_SCR_OP_SETTOXICSPIKES
.4byte \failInstr
.endm
.macro setgastroacid failInstr:req
.byte B_SCR_OP_SETGASTROACID
.4byte \failInstr
.endm
.macro setyawn failInstr:req
.byte B_SCR_OP_SETYAWN
.4byte \failInstr
.endm
.macro Cmd_unused0xd8
.byte B_SCR_OP_UNUSED0XD8
.endm
.macro setroom
.byte B_SCR_OP_SETROOM
.endm
.macro tryswapabilities failInstr:req
.byte B_SCR_OP_TRYSWAPABILITIES
.4byte \failInstr
.endm
.macro tryimprison failInstr:req
.byte B_SCR_OP_TRYIMPRISON
.4byte \failInstr
.endm
.macro setstealthrock failInstr:req
.byte B_SCR_OP_SETSTEALTHROCK
.4byte \failInstr
.endm
.macro trysetvolatile battler:req, _volatile:req, failInstr:req
.byte B_SCR_OP_TRYSETVOLATILE
.byte \battler
.byte \_volatile
.4byte \failInstr
.endm
.macro assistattackselect failInstr:req
.byte B_SCR_OP_UNUSED_0XDE
.4byte \failInstr
.endm
.macro trysetmagiccoat failInstr:req
.byte B_SCR_OP_TRYSETMAGICCOAT
.4byte \failInstr
.endm
.macro trysetsnatch failInstr:req
.byte B_SCR_OP_TRYSETSNATCH
.4byte \failInstr
.endm
.macro unused2 ptr:req
.byte B_SCR_OP_UNUSED2
.4byte \ptr
.endm
.macro switchoutabilities battler:req
.byte B_SCR_OP_SWITCHOUTABILITIES
.byte \battler
.endm
.macro jumpifhasnohp battler:req, jumpInstr:req
.byte B_SCR_OP_JUMPIFHASNOHP
.byte \battler
.4byte \jumpInstr
.endm
.macro unused_0xE4
.byte B_SCR_OP_UNUSED_0XE4
.endm
.macro pickup
.byte B_SCR_OP_PICKUP
.endm
.macro unused_0xE6
.byte B_SCR_OP_UNUSED_0XE6
.endm
.macro unused_0xE7
.byte B_SCR_OP_UNUSED_0XE7
.endm
.macro settypebasedhalvers failInstr:req
.byte B_SCR_OP_SETTYPEBASEDHALVERS
.4byte \failInstr
.endm
.macro jumpifsubstituteblocks jumpInstr:req
.byte B_SCR_OP_JUMPIFSUBSTITUTEBLOCKS
.4byte \jumpInstr
.endm
.macro tryrecycleitem failInstr:req
.byte B_SCR_OP_TRYRECYCLEITEM
.4byte \failInstr
.endm
.macro settypetoenvironment failInstr:req
.byte B_SCR_OP_SETTYPETOENVIRONMENT
.4byte \failInstr
.endm
.macro pursuitdoubles failInstr:req
.byte B_SCR_OP_PURSUITDOUBLES
.4byte \failInstr
.endm
.macro snatchsetbattlers
.byte B_SCR_OP_SNATCHSETBATTLERS
.endm
.macro unused_0xee
.byte B_SCR_OP_UNUSED_0XEE
.endm
.macro handleballthrow
.byte B_SCR_OP_HANDLEBALLTHROW
.endm
.macro givecaughtmon passInstr:req
.byte B_SCR_OP_GIVECAUGHTMON
.4byte \passInstr
.endm
.macro trysetcaughtmondexflags failInstr:req
.byte B_SCR_OP_TRYSETCAUGHTMONDEXFLAGS
.4byte \failInstr
.endm
.macro displaydexinfo
.byte B_SCR_OP_DISPLAYDEXINFO
.endm
.macro trygivecaughtmonnick
.byte B_SCR_OP_TRYGIVECAUGHTMONNICK
.endm
.macro sortbattlers
.byte B_SCR_OP_SORTBATTLERS
.endm
.macro removeattackerstatus1
.byte B_SCR_OP_REMOVEATTACKERSTATUS1
.endm
.macro finishaction
.byte B_SCR_OP_FINISHACTION
.endm
.macro finishturn
.byte B_SCR_OP_FINISHTURN
.endm
.macro trainerslideout position:req
.byte B_SCR_OP_TRAINERSLIDEOUT
.byte \position
.endm
.macro settelekinesis failInstr:req
.byte B_SCR_OP_SETTELEKINESIS
.4byte \failInstr
.endm
.macro swapstatstages stat:req
.byte B_SCR_OP_SWAPSTATSTAGES
.byte \stat
.endm
.macro averagestats stat:req
.byte B_SCR_OP_AVERAGESTATS
.byte \stat
.endm
.macro jumpifcaptivateaffected jumpInstr:req
.byte B_SCR_OP_JUMPIFCAPTIVATEAFFECTED
.4byte \jumpInstr
.endm
.macro setnonvolatilestatus trigger:req
.byte B_SCR_OP_SETNONVOLATILESTATUS
.byte \trigger
.endm
.macro tryoverwriteability failInstr:req
.byte B_SCR_OP_TRYOVERWRITEABILITY
.4byte \failInstr
.endm
.macro callnative func:req
.byte B_SCR_OP_CALLNATIVE
.4byte \func
.endm
.macro savetarget
callnative BS_SaveTarget
.endm
.macro restoretarget
callnative BS_RestoreTarget
.endm
.macro saveattacker
callnative BS_SaveAttacker
.endm
.macro restoreattacker
callnative BS_RestoreAttacker
.endm
.macro jumpifintimidateabilityprevented
callnative BS_JumpIfIntimidateAbilityPrevented
.endm
.macro allyswitchswapbattlers
callnative BS_AllySwitchSwapBattler
.endm
.macro tryallyswitch jumpInstr:req
callnative BS_TryAllySwitch
.4byte \jumpInstr
.endm
.macro dostockpilestatchangeswearoff, battler:req, statChangeInstr:req
callnative BS_DoStockpileStatChangesWearOff
.byte \battler
.4byte \statChangeInstr
.endm
.macro jumpifmorethanhalfHP battler:req, jumpInstr:req
callnative BS_JumpIfMoreThanHalfHP
.byte \battler
.4byte \jumpInstr
.endm
.macro itemrestorehp jumpInstr:req, restoreBattlerInstr:req
callnative BS_ItemRestoreHP
.4byte \jumpInstr
.4byte \restoreBattlerInstr
.endm
.macro itemcurestatus jumpInstr:req, restoreBattlerInstr:req
callnative BS_ItemCureStatus
.4byte \jumpInstr
.4byte \restoreBattlerInstr
.endm
.macro itemincreasestat
callnative BS_ItemIncreaseStat
.endm
.macro itemrestorepp
callnative BS_ItemRestorePP
.endm
.macro tryrevertweatherform
callnative BS_TryRevertWeatherForm
.endm
.macro trysetoctolock failInstr:req
callnative BS_TrySetOctolock
.4byte \failInstr
.endm
.macro setpledge jumpInstr:req
callnative BS_SetPledge
.4byte \jumpInstr
.endm
.macro setpledgestatus battler:req, sidestatus:req
callnative BS_SetPledgeStatus
.byte \battler
.4byte \sidestatus
.endm
.macro setzeffect
callnative BS_SetZEffect
.endm
@ Used by effects that may proc Symbiosis but do not call removeitem.
.macro trysymbiosis battler:req
callnative BS_TrySymbiosis
.byte \battler
.endm
@ returns B_SIDE_x to gBattleCommunication[0]
.macro getbattlerside battler:req
callnative BS_GetBattlerSide
.byte \battler
.endm
.macro checkparentalbondcounter counter:req, ptr:req
callnative BS_CheckParentalBondCounter
.byte \counter
.4byte \ptr
.endm
.macro jumpifcantloseitem ptr:req
callnative BS_JumpIfCantLoseItem
.4byte \ptr
.endm
.macro handlemegaevo battler:req, case:req
callnative BS_HandleMegaEvolution
.byte \battler
.byte \case
.endm
.macro handleprimalreversion battler:req, case:req
callnative BS_HandlePrimalReversion
.byte \battler
.byte \case
.endm
.macro handleultraburst battler:req, case:req
callnative BS_HandleUltraBurst
.byte \battler
.byte \case
.endm
.macro jumpifshelltrap battler:req, jumpInstr:req
callnative BS_JumpIfShellTrap
.byte \battler
.4byte \jumpInstr
.endm
.macro setterrain failInstr:req
callnative BS_SetTerrain
.4byte \failInstr
.endm
.macro jumpifterrainaffected battler:req, terrainFlags:req, jumpInstr:req
callnative BS_JumpIfTerrainAffected
.byte \battler
.4byte \terrainFlags
.4byte \jumpInstr
.endm
.macro tryreflecttype failInstr:req
callnative BS_TryReflectType
.4byte \failInstr
.endm
@ Used to active a different Max Move effects.
.macro setmaxmoveeffect
callnative BS_SetMaxMoveEffect
.endm
.macro setsteelsurge, failInstr:req
callnative BS_SetSteelsurge
.4byte \failInstr
.endm
.macro trysetparalysis, ptr:req
callnative BS_TrySetParalysis
.4byte \ptr
.endm
.macro trysetpoison, ptr:req
callnative BS_TrySetPoison
.4byte \ptr
.endm
.macro trysetpoisonparalysis, ptr:req
callnative BS_TrySetPoisonParalyzis
.4byte \ptr
.endm
.macro tryseteffectspore, ptr:req
callnative BS_TrySetEffectSpore
.4byte \ptr
.endm
.macro trysetconfusion, ptr:req
callnative BS_TrySetConfusion
.4byte \ptr
.endm
.macro trysetinfatuation, ptr:req
callnative BS_TrySetInfatuation
.4byte \ptr
.endm
.macro trysetescapeprevention, ptr:req
callnative BS_TrySetEscapePrevention
.4byte \ptr
.endm
.macro trysettorment, ptr:req
callnative BS_TrySetTorment
.4byte \ptr
.endm
.macro tryhealsixthhealth, ptr:req
callnative BS_HealOneSixth
.4byte \ptr
.endm
.macro tryrecycleberry, ptr:req
callnative BS_TryRecycleBerry
.4byte \ptr
.endm
.macro updatedynamax
callnative BS_UpdateDynamax
.endm
.macro jumpiftargetdynamaxed, ptr:req
callnative BS_JumpIfDynamaxed
.4byte \ptr
.endm
.macro undodynamax battler:req
callnative BS_UndoDynamax
.byte \battler
.endm
.macro trytrainerslidezmovemsg
callnative BS_TryTrainerSlideZMoveMsg
.endm
.macro trytrainerslidemegaevolutionmsg
callnative BS_TryTrainerSlideMegaEvolutionMsg
.endm
.macro trytrainerslidedynamaxmsg
callnative BS_TryTrainerSlideDynamaxMsg
.endm
.macro tryhealpulse failInstr:req
callnative BS_TryHealPulse
.4byte \failInstr
.endm
.macro trydefog clear:req, failInstr:req
callnative BS_TryDefog
.byte \clear
.4byte \failInstr
.endm
.macro trytriggerstatusform
callnative BS_TryTriggerStatusForm
.endm
.macro tryupperhand failInstr:req
callnative BS_TryUpperHand
.4byte \failInstr
.endm
.macro trytidyup clear:req, jumpInstr:req
callnative BS_TryTidyUp
.byte \clear
.4byte \jumpInstr
.endm
.macro trygulpmissile
callnative BS_TryGulpMissile
.endm
.macro tryactivategulpmissile
callnative BS_TryActivateGulpMissile
.endm
.macro tryquash failInstr:req
callnative BS_TryQuash
.4byte \failInstr
.endm
.macro copyfoesstatincrease battler:req, failInstr:req
callnative BS_CopyFoesStatIncrease
.byte \battler
.4byte \failInstr
.endm
.macro removeweather
callnative BS_RemoveWeather
.endm
.macro applyterastallization
callnative BS_ApplyTerastallization
.endm
.macro jumpifsleepclause jumpInstr:req
callnative BS_JumpIfSleepClause
.4byte \jumpInstr
.endm
.macro ficklebeamdamagecalculation
callnative BS_FickleBeamDamageCalculation
.endm
.macro trytarshot failInstr:req
callnative BS_TryTarShot
.4byte \failInstr
.endm
.macro jumpifnoberry battler:req, jumpInstr:req
callnative BS_JumpIfNoBerry
.byte \battler
.4byte \jumpInstr
.endm
.macro checkteatimetargets failInstr:req
callnative BS_CheckTeaTimeTargets
.4byte \failInstr
.endm
.macro trywindriderpower battler:req, failInstr:req
callnative BS_TryWindRiderPower
.byte \battler
.4byte \failInstr
.endm
.macro activateweatherchangeabilities battler:req
callnative BS_ActivateWeatherChangeAbilities
.byte \battler
.endm
.macro activateterrainchangeabilities battler:req
callnative BS_ActivateTerrainChangeAbilities
.byte \battler
.endm
.macro resetterrainabilityflags
callnative BS_ResetTerrainAbilityFlags
.endm
@ Stores Healing Wish effect.
.macro storehealingwish battler:req
callnative BS_StoreHealingWish
.byte \battler
.endm
.macro tryrevivalblessing, failInstr:req
callnative BS_TryRevivalBlessing
.4byte \failInstr
.endm
.macro jumpifblockedbysoundproof battler:req, failInstr:req
callnative BS_JumpIfBlockedBySoundproof
.byte \battler
.4byte \failInstr
.endm
.macro setmagiccoattarget
callnative BS_SetMagicCoatTarget
.endm
.macro jumpifcommanderactive jumpInstr:req
callnative BS_JumpIfCommanderActive
.4byte \jumpInstr
.endm
.macro checkpokeflute
callnative BS_CheckPokeFlute
.endm
.macro waitfanfare
callnative BS_WaitFanfare
.endm
.macro cantarshotwork failInstr:req
callnative BS_CanTarShotWork
.4byte \failInstr
.endm
.macro removeterrain
callnative BS_RemoveTerrain
.endm
.macro spectralthiefprintstats
callnative BS_SpectralThiefPrintStats
.endm
.macro setmoveresultflags flags:req
callnative BS_SetMoveResultFlags
.2byte \flags
.endm
.macro clearspecialstatuses
callnative BS_ClearSpecialStatuses
.endm
.macro clearmoveresultflags flags:req
callnative BS_ClearMoveResultFlags
.2byte \flags
.endm
.macro jumpifmoveresultflags flags:req failInstr:req
callnative BS_JumpIfMoveResultFlags
.2byte \flags
.4byte \failInstr
.endm
.macro jumpifnotcriticalhit failInstr:req
callnative BS_JumpIfNotCriticalHit
.4byte \failInstr
.endm
.macro jumpifcangigantamax battler:req, jumpInstr:req
callnative BS_JumpIfCanGigantamax
.byte \battler
.4byte \jumpInstr
.endm
.macro tryflingholdeffect
callnative BS_TryFlingHoldEffect
.endm
.macro swapsidestatuses
callnative BS_CourtChangeSwapSideStatuses
.endm
.macro swapstats stat:req
callnative BS_SwapStats
.byte \stat
.endm
.macro restoresavedmove
callnative BS_RestoreSavedMove
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER, \stat | \stages << 3 | \down << 7
.endm
.macro setmoveeffect effect:req
sethword sMOVE_EFFECT, \effect
.endm
.macro sethword dst:req, value:req
setbyte \dst, (\value) & 0xFF
setbyte \dst + 1, ((\value) >> 8) & 0xFF
.endm
.macro setword dst:req, value:req
setbyte \dst, (\value) & 0xFF
setbyte \dst + 1, ((\value) >> 8) & 0xFF
setbyte \dst + 2, ((\value) >> 16) & 0xFF
setbyte \dst + 3, ((\value) >> 24) & 0xFF
.endm
.macro copybyte dst:req, src:req
copyarray \dst, \src, 0x1
.endm
.macro copyhword dst:req, src:req
copyarray \dst, \src, 0x2
.endm
.macro copyword dst:req, src:req
copyarray \dst, \src, 0x4
.endm
.macro jumpifbytenotequal byte1:req, byte2:req, jumpInstr:req
jumpifarraynotequal \byte1, \byte2, 0x1, \jumpInstr
.endm
.macro jumpifbyteequal byte1:req, byte2:req, jumpInstr:req
jumpifarrayequal \byte1, \byte2, 0x1, \jumpInstr
.endm
.macro jumpifmove move:req, jumpInstr:req
jumpifhalfword CMP_EQUAL, gCurrentMove, \move, \jumpInstr
.endm
.macro jumpifnotmove move:req, jumpInstr:req
jumpifhalfword CMP_NOT_EQUAL, gCurrentMove, \move, \jumpInstr
.endm
.macro jumpifnotchosenmove move:req, jumpInstr:req
jumpifhalfword CMP_NOT_EQUAL, gChosenMove, \move, \jumpInstr
.endm
.macro jumpifmovehadnoeffect jumpInstr:req
jumpifmoveresultflags MOVE_RESULT_NO_EFFECT, \jumpInstr
.endm
.macro jumpifside battler:req, side:req, equalJumpInstr:req
getbattlerside \battler
jumpifbyte CMP_EQUAL, gBattleCommunication, \side, \equalJumpInstr
.endm
.macro jumpifbattletype flags:req, jumpInstr:req
jumpifword CMP_COMMON_BITS, gBattleTypeFlags, \flags, \jumpInstr
.endm
.macro jumpifnotbattletype flags:req, jumpInstr:req
jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpInstr
.endm
.macro dmg_1_8_targethp
manipulatedamage DMG_1_8_TARGET_HP
.endm
.macro jumpifflowerveil jumpInstr:req
jumpifnottype BS_TARGET, TYPE_GRASS, 1f
jumpifability BS_TARGET_SIDE, ABILITY_FLOWER_VEIL, \jumpInstr
1:
.endm
.macro jumpifflowerveilattacker jumpInstr:req
jumpifnottype BS_ATTACKER, TYPE_GRASS, 1f
jumpifability BS_ATTACKER_SIDE, ABILITY_FLOWER_VEIL, \jumpInstr
1:
.endm
.macro jumpifabilitycantbereactivated battler:req, jumpInstr:req
callnative BS_JumpIfAbilityCantBeReactivated
.byte \battler
.4byte \jumpInstr
.endm
.macro tryactivateabilityshield battler:req
callnative BS_TryActivateAbilityShield
.byte \battler
.endm
.macro jumpifroarfails jumpInstr:req
callnative BS_JumpIfRoarFails
.4byte \jumpInstr
.endm
.macro jumpifabsent battler:req, jumpInstr:req
callnative BS_JumpIfAbsent
.byte \battler
.4byte \jumpInstr
.endm
.macro jumpifnoholdeffect battler:req, holdEffect:req, jumpInstr:req
jumpifholdeffect \battler, \holdEffect, \jumpInstr, FALSE
.endm
.macro jumpifholdeffect battler:req, holdEffect:req, jumpInstr:req, equal:req
callnative BS_JumpIfHoldEffect
.byte \battler
.byte \holdEffect
.4byte \jumpInstr
.byte \equal
.endm
.macro jumpifnoally battler:req, jumpInstr:req
callnative BS_JumpIfNoAlly
.byte \battler
.4byte \jumpInstr
.endm
.macro setlastuseditem battler:req
callnative BS_SetLastUsedItem
.byte \battler
.endm
.macro trysetfairylock failInstr:req
callnative BS_TrySetFairyLock
.4byte \failInstr
.endm
.macro getstatvalue stat:req
callnative BS_GetStatValue
.byte \stat
.endm
.macro jumpiffullhp battler:req, jumpInstr:req
callnative BS_JumpIfFullHp
.byte \battler
.4byte \jumpInstr
.endm
.macro tryfriskmessage
callnative BS_TryFriskMessage
.endm
.macro settracedability battler:req
callnative BS_SetTracedAbility
.byte \battler
.endm
.macro tryillusionoff battler:req
callnative BS_TryIllusionOff
.byte \battler
.endm
.macro updatenick
callnative BS_UpdateNick
.endm
.macro jumpifnotberry battler:req, jumpInstr:req
callnative BS_JumpIfNotBerry
.byte \battler
.4byte \jumpInstr
.endm
.macro gravityonairbornemons
callnative BS_GravityOnAirborneMons
.endm
.macro tryacupressure failInstr:req
callnative BS_TryAcupressure
.4byte \failInstr
.endm
.macro cancelmultiturnmoves
callnative BS_CancelMultiTurnMoves
.endm
.macro isrunningimpossible
callnative BS_IsRunningImpossible
.endm
.macro getmovetarget
callnative BS_GetMoveTarget
.endm
@ Will jump to script pointer if the specified battler has or has not fainted.
.macro jumpiffainted battler:req, value:req, ptr:req
getbattlerfainted \battler
jumpifbyte CMP_EQUAL, gBattleCommunication, \value, \ptr
.endm
.macro getbattlerfainted battler:req
callnative BS_GetBattlerFainted
.byte \battler
.endm
.macro resetswitchinabilitybits
callnative BS_ResetSwitchInAbilityBits
.endm
.macro updatechoicemoveonlvlup
callnative BS_UpdateChoiceMoveOnLvlUp
.endm
.macro resetplayerfainted
callnative BS_ResetPlayerFainted
.endm
.macro palaceflavortext
callnative BS_PalaceFlavorText
.endm
.macro arenajudgmentwindow
callnative BS_ArenaJudgmentWindow
.endm
.macro arenaopponentmonlost
callnative BS_ArenaOpponentMonLost
.endm
.macro arenaplayermonlost
callnative BS_ArenaPlayerMonLost
.endm
.macro arenabothmonslost
callnative BS_ArenaBothMonsLost
.endm
.macro forfeityesnobox
callnative BS_ForfeitYesNoBox
.endm
.macro drawarenareftextbox
callnative BS_DrawArenaRefTextBox
.endm
.macro erasearenareftextbox
callnative BS_EraseArenaRefTextBox
.endm
.macro arenajudgmentstring id:req
callnative BS_ArenaJudgmentString
.byte \id
.endm
.macro arenawaitmessage
callnative BS_ArenaWaitMessage
.endm
.macro waitcry
callnative BS_WaitCry
.endm
.macro returnopponentmon1toball
callnative BS_ReturnOpponentMon1ToBall
.endm
.macro returnopponentmon2toball
callnative BS_ReturnOpponentMon2ToBall
.endm
.macro volumedown
callnative BS_VolumeDown
.endm
.macro volumeup
callnative BS_VolumeUp
.endm
.macro setalreadystatusedmoveattempt
callnative BS_SetAlreadyStatusedMoveAttempt
.endm
.macro palacetryescapestatus
callnative BS_PalaceTryEscapeStatus
.endm
.macro setteleportoutcome battler:req
callnative BS_SetTeleportOutcome
.byte \battler
.endm
.macro playtrainerdefeatedmusic
callnative BS_PlayTrainerDefeatedMusic
.endm
.macro stattextbuffer
callnative BS_StatTextBuffer
.endm
.macro switchinabilities battler:req
callnative BS_SwitchinAbilities
.byte \battler
.endm
.macro instanthpdrop
callnative BS_InstantHpDrop
.endm
.macro clearstatus battler:req
callnative BS_ClearStatus
.byte \battler
.endm
.macro restoremovepp battler:req
callnative BS_RestoreMovePp
.byte \battler
.endm
.macro tryactivatereceiver battler:req
callnative BS_TryActivateReceiver
.byte \battler
.endm
.macro tryactivatesoulheart
callnative BS_TryActivateSoulheart
.endm
.macro playmoveanimation move:req
callnative BS_PlayMoveAnimation
.2byte \move
.endm
.macro setluckychant failInstr:req
callnative BS_SetLuckyChant
.4byte \failInstr
.endm
.macro tryentrainment failInstr:req
callnative BS_TryEntrainment
.4byte \failInstr
.endm
.macro setlastusedability
callnative BS_SetLastUsedAbility
.endm
.macro invertstatstages
callnative BS_InvertStatStages
.endm
.macro tryelectrify failInstr:req
callnative BS_TryElectrify
.4byte \failInstr
.endm
.macro trysoak failInstr:req
callnative BS_TrySoak
.4byte \failInstr
.endm
.macro handleformchange battler:req, case_:req
callnative BS_HandleFormChange
.byte \battler
.byte \case_
.endm
.macro tryautotomize failInstr:req
callnative BS_TryAutotomize
.4byte \failInstr
.endm
.macro tryinstruct failInstr:req
callnative BS_TryInstruct
.4byte \failInstr
.endm
.macro showabilitypopup
callnative BS_ShowAbilityPopup
.endm
.macro updateabilitypopup
callnative BS_UpdateAbilityPopup
.endm
.macro jumpiftargetally jumpInstr:req
callnative BS_JumpIfTargetAlly
.4byte \jumpInstr
.endm
.macro trypsychoshift failInstr:req sleepClauseFailInstr:req
callnative BS_TryPsychoShift
.4byte \failInstr
.4byte \sleepClauseFailInstr
.endm
.macro curestatus battler:req
callnative BS_CureStatus
.byte \battler
.endm
.macro powertrick
callnative BS_PowerTrick
.endm
.macro tryafteryou failInstr:req
callnative BS_TryAfterYou
.4byte \failInstr
.endm
.macro trybestow failInstr:req
callnative BS_TryBestow
.4byte \failInstr
.endm
.macro handletrainerslidemsg battler:req, case_:req
callnative BS_HandleTrainerSlideMsg
.byte \battler
.byte \case_
.endm
.macro trytrainerslidemsgfirstoff battler:req
callnative BS_TryTrainerSlideMsgFirstOff
.byte \battler
.endm
.macro trytrainerslidemsglaston battler:req
callnative BS_TryTrainerSlideMsgLastOn
.byte \battler
.endm
.macro setauroraveil
callnative BS_SetAuroraVeil
.endm
.macro trythirdtype failInstr:req
callnative BS_TryThirdType
.4byte \failInstr
.endm
.macro destroyabilitypopup
callnative BS_DestroyAbilityPopup
.endm
.macro gettotemboost jumpInstr:req
callnative BS_GetTotemBoost
.4byte \jumpInstr
.endm
.macro activateitemeffects
callnative BS_ActivateItemEffects
.endm
.macro tryroomservice battler:req, failInstr:req
callnative BS_TryRoomService
.byte \battler
.4byte \failInstr
.endm
.macro tryterrainseed battler:req, failInstr:req
callnative BS_TryTerrainSeed
.byte \battler
.4byte \failInstr
.endm
.macro makeinvisible battler:req
callnative BS_MakeInvisible
.byte \battler
.endm
.macro jumpifteamhealthy jumpInstr:req
callnative BS_JumpIfTeamHealthy
.4byte \jumpInstr
.endm
.macro tryhealquarterhealth battler:req, failInstr:req
callnative BS_TryHealQuarterHealth
.byte \battler
.4byte \failInstr
.endm
.macro jumpifunder200 jumpInstr:req
callnative BS_JumpIfUnder200
.4byte \jumpInstr
.endm
.macro setskydrop
callnative BS_SetSkyDrop
.endm
.macro clearskydrop failInstr:req
callnative BS_ClearSkyDrop
.4byte \failInstr
.endm
.macro skydropyawn
callnative BS_SkyDropYawn
.endm
.macro jumpifpranksterblocked jumpInstr:req
callnative BS_JumpIfPranksterBlocked
.4byte \jumpInstr
.endm
.macro trytoclearprimalweather
callnative BS_TryToClearPrimalWeather
.endm
.macro tryendneutralizinggas
callnative BS_TryEndNeutralizingGas
.endm
.macro getrototillertargets failInstr:req
callnative BS_GetRototillerTargets
.4byte \failInstr
.endm
.macro consumeberry battler:req, fromBattler:req
callnative BS_ConsumeBerry
.byte \battler
.byte \fromBattler
.endm
.macro jumpifweatheraffected flags:req, jumpInstr:req
callnative BS_JumpIfWeatherAffected
.2byte \flags
.4byte \jumpInstr
.endm
.macro jumpifspecies species:req, jumpInstr:req
callnative BS_JumpIfSpecies
.2byte \species
.4byte \jumpInstr
.endm
.macro jumpifabilitypreventsrest battler:req, jumpInstr:req
callnative BS_JumpIfAbilityPreventsRest
.byte \battler
.4byte \jumpInstr
.endm
.macro setattackertostickywebuser
callnative BS_SetAttackerToStickyWebUser
.endm
.macro cutonethirdhpandraisestats failInstr:req
callnative BS_CutOneThirdHpAndRaiseStats
.4byte \failInstr
.endm
.macro setpoltergeistmessage failInstr:req
callnative BS_SetPoltergeistMessage
.4byte \failInstr
.endm
.macro tryresetnegativestatstages
callnative BS_TryResetNegativeStatStages
.endm
.macro savebattleritem
callnative BS_SaveBattlerItem
.endm
.macro restorebattleritem
callnative BS_RestoreBattlerItem
.endm
.macro battleritemtolastuseditem
callnative BS_BattlerItemToLastUsedItem
.endm
.macro setallytonexttarget jumpInstr:req
jumpifbyte CMP_GREATER_THAN, gBattlerTarget, 0x1, 1f
addbyte gBattlerTarget, 0x2
goto \jumpInstr
1:
subbyte gBattlerTarget, 0x2
goto \jumpInstr
.endm
.macro setallytonextattacker jumpInstr:req
jumpifbyte CMP_GREATER_THAN, gBattlerAttacker, 0x1, 1f
addbyte gBattlerAttacker, 0x2
goto \jumpInstr
1:
subbyte gBattlerAttacker, 0x2
goto \jumpInstr
.endm
.macro jumpifsafeguard jumpInstr:req
jumpifability BS_ATTACKER, ABILITY_INFILTRATOR, 1f
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, \jumpInstr
1:
.endm
@ Tries to increase or decrease a battler's stat's stat stage by a specified amount. If impossible, jumps to \script.
.macro modifybattlerstatstage battler:req, stat:req, mode:req, amount:req, script:req, animation:req, customString
@ \mode parameters
INCREASE = FALSE
DECREASE = TRUE
@ \animation parameters
ANIM_OFF = FALSE
ANIM_ON = TRUE
setstatchanger \stat, \amount, \mode
.if \animation == FALSE
setbyte sSTAT_ANIM_PLAYED, TRUE
.endif
statbuffchange BS_TARGET, STAT_CHANGE_ALLOW_PTR, \script
.ifnb \customString
printstring \customString
.else
.if \mode == DECREASE
printfromtable gStatDownStringIds
.else
.if \mode == INCREASE
printfromtable gStatUpStringIds
.endif
.endif
.endif
waitmessage B_WAIT_TIME_LONG
.endm
.macro flushtextbox
printstring STRINGID_EMPTYSTRING3
waitmessage 1
.endm
.macro jumpifnowhiteout jumpInstr:req
callnative BS_JumpIfNoWhiteOut
.4byte \jumpInstr
.endm
.macro tryboosterenergy onFieldStatus:req
callnative BS_TryBoosterEnergy
.byte \onFieldStatus
.endm
.macro jumpifgenconfiglowerthan tag:req, gen:req, jumpInstr:req
callnative BS_JumpIfGenConfigLowerThan
.2byte \tag
.byte \gen
.4byte \jumpInstr
.endm
.macro tryactivateabilitywithabilityshield battler:req, switchedItems=FALSE
callnative BS_TryActivateAbilityWithAbilityShield
.byte \battler
.byte \switchedItems
.endm