<p></p>
<p dir="auto">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).</p>
<p dir="auto"><code class="notranslate">anim_hero</code> animates and positions the hero and the weapon during an attack. Specifically, the second weapon frame:</p>
<pre class="notranslate"><code class="notranslate">   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
</code></pre>
<p dir="auto">(<code class="notranslate">anim_*</code> functions queue up animation commands at the beginning of an attack, and then they are executed by <code class="notranslate">battle_attack_anim_playback</code>.)<br>
Note it doesn't depend on the attack animation, suggesting the weapon position is getting overwritten afterwards.</p>
<p dir="auto">The attack animations are implemented in <code class="notranslate">generate_atkscript</code>, which call <code class="notranslate">anim_hero</code>. 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<br>
<code class="notranslate">   anim_setz 12 + i, projectile_start.z</code><br>
where <code class="notranslate">i</code> is used uninitialised! It turns out the previous use was in a <code class="notranslate">FOR i = 0 to 11</code> loop, so <code class="notranslate">12 + i = 24</code> and that's the cause of the bug.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/ohrrpgce/ohrrpgce/issues/1210#issuecomment-1131640913">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AMWGWZWQWQBP7ETAIPHZDHTVKYZW5ANCNFSM5BNN77BA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AMWGWZVJFY4KQGYUINK2FDLVKYZW5A5CNFSM5BNN77BKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOINZXQUI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><ohrrpgce/ohrrpgce/issues/1210/1131640913</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/ohrrpgce/ohrrpgce/issues/1210#issuecomment-1131640913",
"url": "https://github.com/ohrrpgce/ohrrpgce/issues/1210#issuecomment-1131640913",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>