Prev: 8F40 Up: Map Next: 8F9E
8F5F: THROW AT
The default handler for THROW X AT Y. After checking that the actor can lift the thing thrown (8C86), it becomes an attack: if the target is alive, the fight routine (90DB, ATTACK) is used, otherwise the breaking routine (9257, STRIKE), in both cases with the thrown object as the weapon (9E93). Afterwards the thrown object lands at the target's feet (its holder is cleared) and the target reacts as if attacked (953F).
8F5F CALL $8C86 Can the actor actually lift the thing being thrown (the target)?
8F62 LD HL,$90DB Assume the thing being thrown AT is alive: HL = the fight routine, action 15 (ATTACK)
8F65 LD A,$0F
8F67 LD IX,($B5FA) IX = the record of whatever is being thrown at (currently the "instrument", via AT)
8F6B BIT 6,(IX+$07) Is it actually alive?
8F6F JR NZ,$8F76 Yes: keep the fight routine
8F71 LD HL,$9257 No (e.g. a window): HL = the breaking routine instead, action 11 (STRIKE)
8F74 LD A,$0B
8F76 LD ($B5D8),A This becomes the action to carry out
8F79 CALL $9E93 Run it with target and instrument swapped, so the thing thrown AT becomes the new target, and the thing thrown becomes the weapon
8F7C LD A,$2A Restore the action number to THROW AT itself, for the rest of the turn
8F7E LD ($B5D8),A
8F81 LD A,($B5EB) Did this really happen (not just a trial)?
8F84 CP $01
8F86 RET NZ Only a trial: nothing more to do
8F87 LD IX,($B5F8) It really happened: IX = the thrown object's own record
8F8B LD (IX+$01),$FF It falls to the ground, held by nobody
8F8F LD A,$0F Let whatever it hit react as if attacked
8F91 LD ($B5D8),A
8F94 LD A,($B5D9)
8F97 JP $953F
8F9A LD (IX+$01),$FF (unreachable leftover code)
Prev: 8F40 Up: Map Next: 8F9E