pokeemerald/asm/macros/battle_anim_script.inc
ghoulslash 4b64433816
Add Battle Anim cmds for dynamic Task, Sprite creation + Misc. Anim Fixes (#2649)
* add createvisualtaskontargets, createspriteontargets to fix electroweb, fiery wrath anims

* add missing semicolon

* add Cmd_createspriteontargets_onpos for heal block, fix heal block targeting

* remove duplicate func

* improve origin pulse anim

* fix IsDoubleBattle call

* venom drench acid uses average battler positions

* add GetSubpriorityForMoveAnim

* add GetBattleAnimMoveTargets for CreateSpriteOnTargets and Cmd_createvisualtaskontargets

---------

Co-authored-by: ghoulslash <pokevoyager0@gmail.com>
2023-02-19 11:48:12 +01:00

389 lines
7.5 KiB
C++

@ commands
.macro loadspritegfx tag:req
.byte 0x0
.2byte \tag
.endm
.macro unloadspritegfx tag:req
.byte 0x1
.2byte \tag
.endm
.macro createsprite template:req, anim_battler:req, subpriority_offset:req, argv:vararg
.byte 0x02
.4byte \template
.if \anim_battler == ANIM_TARGET
.byte ANIMSPRITE_IS_TARGET | (\subpriority_offset & 0x7F)
.else
.byte (\subpriority_offset & 0x7F)
.endif
.byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2
.Lsprite_\@_1:
.2byte \argv
.Lsprite_\@_2:
.endm
.macro createvisualtask addr:req, priority:req, argv:vararg
.byte 0x03
.4byte \addr
.byte \priority
.byte (.Lcreatetask_\@_2 - .Lcreatetask_\@_1) / 2
.Lcreatetask_\@_1:
.2byte \argv
.Lcreatetask_\@_2:
.endm
.macro delay frames:req
.byte 0x4
.byte \frames
.endm
.macro waitforvisualfinish
.byte 0x5
.endm
.macro nop
.byte 0x6
.endm
.macro nop2
.byte 0x7
.endm
.macro end
.byte 0x8
.endm
.macro playse se:req
.byte 0x9
.2byte \se
.endm
.macro monbg battler:req
.byte 0xa
.byte \battler
.endm
.macro clearmonbg battler:req
.byte 0xb
.byte \battler
.endm
.macro setalpha eva:req, evb:req
.byte 0x0C
.2byte ((\evb) << 8) | (\eva)
.endm
.macro blendoff
.byte 0xd
.endm
.macro call ptr:req
.byte 0xe
.4byte \ptr
.endm
.macro return
.byte 0xf
.endm
.macro setarg argId:req, value:req
.byte 0x10
.byte \argId
.2byte \value
.endm
.macro choosetwoturnanim ptr1:req, ptr2:req
.byte 0x11
.4byte \ptr1
.4byte \ptr2
.endm
.macro jumpifmoveturn value:req, ptr:req
.byte 0x12
.byte \value
.4byte \ptr
.endm
.macro goto ptr:req
.byte 0x13
.4byte \ptr
.endm
.macro fadetobg bg:req
.byte 0x14
.byte \bg
.endm
.macro restorebg
.byte 0x15
.endm
.macro waitbgfadeout
.byte 0x16
.endm
.macro waitbgfadein
.byte 0x17
.endm
.macro changebg bg:req
.byte 0x18
.byte \bg
.endm
.macro playsewithpan se:req, pan:req
.byte 0x19
.2byte \se
.byte \pan
.endm
.macro setpan pan:req
.byte 0x1a
.byte \pan
.endm
.macro panse se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x1b
.2byte \se
.byte \currentPan
.byte \targetPan
.byte \incrementPan
.byte \delay
.endm
.macro loopsewithpan se:req, pan:req, wait:req, times:req
.byte 0x1c
.2byte \se
.byte \pan
.byte \wait
.byte \times
.endm
.macro waitplaysewithpan se:req, pan:req, wait:req
.byte 0x1d
.2byte \se
.byte \pan
.byte \wait
.endm
.macro setbldcnt bldcnt:req
.byte 0x1e
.2byte \bldcnt
.endm
.macro createsoundtask addr:req, argv:vararg
.byte 0x1F
.4byte \addr
.byte (.Lcreatetask_1F_\@_2 - .Lcreatetask_1F_\@_1) / 2
.Lcreatetask_1F_\@_1:
.2byte \argv
.Lcreatetask_1F_\@_2:
.endm
.macro waitsound
.byte 0x20
.endm
.macro jumpargeq argId:req, value:req, ptr:req
.byte 0x21
.byte \argId
.2byte \value
.4byte \ptr
.endm
.macro monbg_static battler:req
.byte 0x22
.byte \battler
.endm
.macro clearmonbg_static battler:req
.byte 0x23
.byte \battler
.endm
.macro jumpifcontest ptr:req
.byte 0x24
.4byte \ptr
.endm
.macro fadetobgfromset bgOpponent:req, bgPlayer:req, bgContest:req
.byte 0x25
.byte \bgOpponent
.byte \bgPlayer
.byte \bgContest
.endm
.macro panse_adjustnone se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x26
.2byte \se
.byte \currentPan
.byte \targetPan
.byte \incrementPan
.byte \delay
.endm
.macro panse_adjustall se:req, currentPan:req, targetPan:req, incrementPan:req, delay:req
.byte 0x27
.2byte \se
.byte \currentPan
.byte \targetPan
.byte \incrementPan
.byte \delay
.endm
.macro splitbgprio battler:req
.byte 0x28
.byte \battler
.endm
.macro splitbgprio_all
.byte 0x29
.endm
.macro splitbgprio_foes battler:req
.byte 0x2a
.byte \battler
.endm
.macro invisible battler:req
.byte 0x2b
.byte \battler
.endm
.macro visible battler:req
.byte 0x2c
.byte \battler
.endm
.macro teamattack_moveback battler:req
.byte 0x2d
.byte \battler
.endm
.macro teamattack_movefwd battler:req
.byte 0x2e
.byte \battler
.endm
.macro stopsound
.byte 0x2f
.endm
@ same as createvisualtask except takes in battlerargindex, which is the battle anim arg index of the battler to loop through
.macro createvisualtaskontargets addr:req, priority:req, battlerargindex:req, argv:vararg
.byte 0x30
.4byte \addr
.byte \priority
.byte \battlerargindex
.byte (.Lcreatetask_\@_2 - .Lcreatetask_\@_1) / 2 @ num_args
.Lcreatetask_\@_1:
.2byte \argv
.Lcreatetask_\@_2:
.endm
@ same as createsprite except takes in battlerargindex, which is the battle anim arg index of the battler to loop through
.macro createspriteontargets template:req, anim_battler:req, subpriority_offset:req, battlerargindex:req, argv:vararg
.byte 0x31
.4byte \template
.if \anim_battler == ANIM_TARGET
.byte 0x80 | (\subpriority_offset & 0x7F)
.else
.byte (\subpriority_offset & 0x7F)
.endif
.byte \battlerargindex
.byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2
.Lsprite_\@_1:
.2byte \argv
.Lsprite_\@_2:
.endm
@ does not overwrite gBattleAnimArgs[battlerargindex], some sprite templates are too dependent on the value (e.g. heal block)
.macro createspriteontargets_onpos template:req, anim_battler:req, subpriority_offset:req, battlerargindex:req, argv:vararg
.byte 0x32
.4byte \template
.if \anim_battler == ANIM_TARGET
.byte 0x80 | (\subpriority_offset & 0x7F)
.else
.byte (\subpriority_offset & 0x7F)
.endif
.byte \battlerargindex
.byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2
.Lsprite_\@_1:
.2byte \argv
.Lsprite_\@_2:
.endm
@ useful macros
.macro jumpreteq value:req, ptr:req
jumpargeq ARG_RET_ID, \value, \ptr
.endm
.macro jumprettrue ptr:req
jumpreteq TRUE, \ptr
.endm
.macro jumpretfalse ptr:req
jumpreteq FALSE, \ptr
.endm
.macro jumpifdoublebattle ptr:req
createvisualtask AnimTask_IsDoubleBattle, 0
jumprettrue \ptr
.endm
@ keep CFRU macros cause I'm lazy. todo: update to createsprite and createvisualtask, respectively
.macro launchtemplate launchtemplatePtr launchtemplatePriority launchtemplateArgsNo launchtemplatearg0 launchtemplatearg1 launchtemplatearg2 launchtemplatearg3 launchtemplatearg4 launchtemplatearg5 launchtemplatearg6 launchtemplatearg7 launchtemplatearg8
.byte 0x2
.word \launchtemplatePtr
.byte \launchtemplatePriority
.byte \launchtemplateArgsNo
.hword \launchtemplatearg0
.hword \launchtemplatearg1
.hword \launchtemplatearg2
.hword \launchtemplatearg3
.hword \launchtemplatearg4
.hword \launchtemplatearg5
.hword \launchtemplatearg6
.hword \launchtemplatearg7
.hword \launchtemplatearg8
.endm
.macro launchtask launchtaskPtr launchtaskPriority launchtaskArgsNo launchtaskarg0 launchtaskarg1 launchtaskarg2 launchtaskarg3 launchtaskarg4 launchtaskarg5 launchtaskarg6 launchtaskarg7 launchtaskarg8
.byte 0x3
.word \launchtaskPtr
.byte \launchtaskPriority
.byte \launchtaskArgsNo
.hword \launchtaskarg0
.hword \launchtaskarg1
.hword \launchtaskarg2
.hword \launchtaskarg3
.hword \launchtaskarg4
.hword \launchtaskarg5
.hword \launchtaskarg6
.hword \launchtaskarg7
.hword \launchtaskarg8
.endm
.macro setblends setblends_value
.byte 0xC
.hword \setblends_value
.endm
.macro launchsoundtask launchsoundtaskPtr launchsoundtaskArgsNo launchsoundtaskarg0 launchsoundtaskarg1 launchsoundtaskarg2 launchsoundtaskarg3 launchsoundtaskarg4 launchsoundtaskarg5 launchsoundtaskarg6 launchsoundtaskarg7 launchsoundtaskarg8
.byte 0x1F
.word \launchsoundtaskPtr
.byte \launchsoundtaskArgsNo
.hword \launchsoundtaskarg0
.hword \launchsoundtaskarg1
.hword \launchsoundtaskarg2
.hword \launchsoundtaskarg3
.hword \launchsoundtaskarg4
.hword \launchsoundtaskarg5
.hword \launchsoundtaskarg6
.hword \launchsoundtaskarg7
.hword \launchsoundtaskarg8
.endm