Prev: 52582 Up: Map Next: 52695
52616: Deal with creature in room - create footstep sounds and check for missile collisions
Used by the routine at 51359.
Play/trigger sounds for creature footsteps and check if any creatures are being destroyed by Maroc's spells or servant-wielded weapons.
Trigger footstep sound effect (for certain creatures):
52616 LD A,(60572) Check FREEZE spell timer counter
52619 CP 0
52621 JR NZ,52646 If it's > 0, the FREEZE spell is still in place so skip the footsteps check
Create short intervals between footsteps
52623 LD A,(60074) Game timer
52626 AND 3 Check if either bit 0 or 1 are set
52628 JR NZ,52646 If so, skip the footstep sounds (this creates a short interval in the sound, to mimic a footstep effect)
Check creature type (60230). Prepare footstep sound effects for Guardian of Chaos (creature type = 8), goblin warrior (9), and goblin missile thrower (10).
Warlocks (1-7), wraiths (11) and demons (12) make no sound when they move.
52630 LD A,(60230) Check creature type number
52633 CP 8
52635 JR C,52646 Creature number < 8 - warlock
52637 CP 11
52639 JR NC,52646 Creature number >= 11 - a wraith or a demon
52641 LD A,16 If the creature type is 8, 9, or 10, set the byte at 60246 to start with the speaker bit on (bit 4).
52643 LD (60246),A
Copy the 8 bytes of data for this creature type at 27772/27828 into working creature data buffer at 60325, along with a couple of other bytes:
52646 LD HL,(60228) Pointer to data set at 27772/27828
52649 LD BC,8 Copy 8 bytes to creature data buffer at 60325
52652 LD DE,60325
52655 LDIR
52657 LD A,(60325) Creature attribute/colour byte - first byte of current creature set at 27828
52660 LD (60072),A Copy into room item working data buffer
Check if any creatures have been destroyed (e.g. by a missile fired by Maroc)
52663 LD A,(60238) Item (creature) properties byte
52666 LD C,A Temp store in C register
52667 AND 224 Check top 3 bits (bits 5-7)
If any of these are set, it means the creature is disintegrating or materializing
52669 JP NZ,53145 If so, don't run any more checks for this creature - skip out of this routine
52672 LD A,C Retrieve item/creature properties byte
52673 AND 1 Check bit 0 - if set, it means the creature is on-screen/visible
52675 JR Z,52695 Skip the next instructions if creature isn't visible on-screen as creatures need to be on-screen to be destroyed by missiles etc.
Run collision checks for Maroc's spells vs creatures
52677 LD A,(60329) Collision/event check type (wraiths/demons = 7, other creatures = 3)
This indicates which spells or weapons can destroy these sorts of creature
For warlocks this is a value matching the missile/bolt type that destroys them (from byte 5 in the warlock table at 27772)
52680 LD C,A Store in C register, which is used as the event value to check in the following CALL
52681 CALL 57293 Check if Maroc has destroyed a creature with a missile/bolt or wraithbane
52684 CP 0 The A register is returned with 0 (no collision) or 1 (positive collision detected)
52686 JP NZ,53372 Positive collision (flag = 1), e.g. a wraith touching Maroc while WRAITHBANE is active, or a missile hitting a creature that it destroys - so destroy the creature.
52689 LD A,(60330) Otherwise get event/collision value for for creatures opening/closing doors (17)
52692 CALL 58032 ...and add this to the collision/event set in the table at 32691 ready for checking next game cycle
Prev: 52582 Up: Map Next: 52695