[Ohrrpgce] [ohrrpgce/ohrrpgce] Sequential projectile animation alters weapon position (#1210)

Ralph Versteegen notifications at github.com
Thu May 19 05:45:34 PDT 2022


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.






-- 
Reply to this email directly or view it on GitHub:
https://github.com/ohrrpgce/ohrrpgce/issues/1210#issuecomment-1131640913
You are receiving this because you are subscribed to this thread.

Message ID: <ohrrpgce/ohrrpgce/issues/1210/1131640913 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20220519/fee8fd21/attachment.html>


More information about the Ohrrpgce mailing list