Aaaand the torso gets to fight back too, not only sit put.
Time to reuse existing code again. The torso will spit out bats just like the last two bossed did. SPRITE_MODE_POS is used to stop the attacking mode and revert back to movement.
A contains the number of boss parts killed (so 4 = 2 legs plus 2 arms):
cmp #4
bne +
;attack with bats
lda SPRITE_CHAR_POS_X,x
sta PARAM1
lda SPRITE_CHAR_POS_Y,x
clc
adc #4
sta PARAM2
inc PARAM2
stx PARAM10
jsr GenerateRandomNumber
and #$01
beq .NoBatLeft
jsr FindEmptySpriteSlot
beq ++
lda #TYPE_BAT_ATTACKING
sta PARAM3
jsr SpawnObject
lda #0
sta SPRITE_DIRECTION,x
.NoBatLeft
jsr GenerateRandomNumber
and #$01
beq .NoBatRight
jsr FindEmptySpriteSlot
beq ++
jsr SpawnObject
lda #1
sta SPRITE_DIRECTION,x
++
.NoBatRight
ldx CURRENT_INDEX
lda SPRITE_MODE_POS,x
cmp #20
bne +++
dec SPRITE_STATE,x
lda #0
sta SPRITE_MODE_POS,x
+++
rts
+
That's all there is for this step :)