Document battle animation scripts #2070
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Local aliases for
gBattleAnimArgsUses a
CMD_ARGSmacro similar to rh-hideout#2529, which allows the developer to name the arguments.CMD_ARGS(x, y);is similar in purpose to our#define tX data[0],#define tY data[1]pattern for naming task data.Example:
static void AnimHitSplatBasic(struct Sprite *sprite) { - StartSpriteAffineAnim(sprite, gBattleAnimArgs[3]); - if (gBattleAnimArgs[2] == ANIM_ATTACKER) + CMD_ARGS(x, y, relativeTo, animation); + + StartSpriteAffineAnim(sprite, cmd->animation); + if (cmd->relativeTo == ANIM_ATTACKER) InitSpritePosToAnimAttacker(sprite, TRUE); else InitSpritePosToAnimTarget(sprite, TRUE);Wrapper macros for
createsprite/createvisualtask/createsoundtaskCreates wrappers with the same names as the arguments used in
CMD_ARGS. The arguments are passed by namename=...rather than by position; exceptions:anim_battlerandsubpriority_offsetforcreatespritewrappers are passed by position.createspritewrappers which really represent tasks rather than sprites (e.g.simplepaletteblend) try to defaultunused_anim_battlerandunused_subpriority_offsetto whatever is used in the majority of cases. Sometimes GF decided to specify those values, which forces me to specify them for matching purposes (see also the mess ofshakemonorterrain). Downstream projects such as RHH Expansion could consider removing these arguments and parameters.Question: should I introduce warnings for specifying any parameters which have no purpose except matching? Possibly gated behind some define?
createvisualtaskwrappers which are always called with the samepriorityspecify that priority as a default (e.g.shakebattleterraindefaults topriority=2).The usages of the macros do not reorder the arguments so that it's simpler for downstream users to migrate to the wrapper macros if they want to.
Example:
Special cases
TODO: Document how these don't fit the usual pattern.
shakemonorterrain: optional argument.tintpalettes: takescolorand splits it up.metallicshine: nouseColor, optionalcolor.setgrayscalepal&setoriginalpal: split up fromAnimTask_SetGrayscaleOrOriginalPal.TODO
A second pass over everything to make the names consistent. In particular, I think a lot of
xs andys will becomex_offsets andy_offsets, and I want to verify thatrelative_tois only used in contexts where all the coordinates are relative to that battler (and if not, the names of parameters should specify which battler argument they're relative to).