Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequential projectile animation alters weapon position #1210

Closed
CronosZX opened this issue Aug 2, 2021 · 2 comments
Closed

Sequential projectile animation alters weapon position #1210

CronosZX opened this issue Aug 2, 2021 · 2 comments
Labels
animations attacks bug Yeah... that's broken

Comments

@CronosZX
Copy link

CronosZX commented Aug 2, 2021

This is something I noticed happening on all my characters whenever I used the sequential projectile animation.
Their weapons would be correctly aligned during the first frame but lowered on the second one, don't know if this is intentional or not, seeing as it only happens with sequential projectiles.
image

@rversteegen rversteegen added animations attacks bug Yeah... that's broken labels Aug 5, 2021
@rue9x
Copy link

rue9x commented May 19, 2022

Confirmed this issue myself. Took a stab at trying to fix it, but I'll need a walkthrough of bmod.rbas to identify weapon placement.

@rversteegen
Copy link
Contributor

In battles, the state of heroes, enemies, attack graphics and the weapon are stored in the bslot() array, which is an array of BattleSprites. bslot 0-3 are heroes, 4-11 enemies, 12-23 attack sprites (just 12 is used for most attacks), and bslot(24) is the weapon. (BattleSprite has a huge amount of state including a lot of data copied from EnemyDef, but only the graphical stuff is relevant to attacks and weapons).

anim_hero animates and positions the hero and the weapon during an attack. Specifically, the second weapon frame:

   hand = gam.hero(who).hand_pos(1)
   wep = bslot(24).hand(1)
   wepoff = hand - wep

   anim_align2 24, who, 0, 0, wepoff.x, 16  # Sets weapon X and Y relative to the attacker, 'who'
   anim_setz 24, 16 - wepoff.y
   anim_setframe 24, 1

(anim_* functions queue up animation commands at the beginning of an attack, and then they are executed by battle_attack_anim_playback.)
Note it doesn't depend on the attack animation, suggesting the weapon position is getting overwritten afterwards.

The attack animations are implemented in generate_atkscript, which call anim_hero. Looking at the implementation of Sequential Projectile for places it affects BattleSprite 24, there is one such obvious line. However I also noticed the line
anim_setz 12 + i, projectile_start.z
where i is used uninitialised! It turns out the previous use was in a FOR i = 0 to 11 loop, so 12 + i = 24 and that's the cause of the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
animations attacks bug Yeah... that's broken
Projects
None yet
Development

No branches or pull requests

3 participants