Prev: 41498 Up: Map Next: 41617
41550: Script routine: (63) Have skeleton advance or retreat based upon positions of Berk and yellow skull
The skeleton will step forward once, and then step back, if Berk is close enough and the yellow skull is in a room to the right. If the yellow skull is in the skeleton's room, or a room to the left of this, then the skeleton will step forward repeatedly while Berk is close enough and will only back off when Berk moves out of range. The range is nine, so if the distance between Berk's right edge and the skeleton's left edge is less than nine then the skeleton will advance. A distance of nine or more will see the skeleton retreat. Note that the calculated range is based upon the skeleton's state data at 45404, in which the x-coordinates of his left and right edges do not match his apparent position or width graphically.
Used by the routine at 48096.
Input
IX Address of complex state data for an entity
Output
HL New address in script data
41550 LD IY,(34240) Load IY with address of current level's complex state data for Berk
41554 LD A,(IY+0) If Berk's current room is 3 (skeleton's room)...
41557 CP 3 ...
41559 JR Z,41580 ...then jump to 41580
Berk is not in skeleton's room, or yellow skull is in a room right of the skeleton's room
41561 LD A,(IX+5) If x-coordinate of skeleton's left edge is at least 128...
41564 CP 128 ...
41566 JR NC,41574 ...then skip ahead to 41574
41568 LD HL,41318 Point HL at script data for skeleton stepping back (right)...
41571 JP 48098 ...and execute
41574 LD HL,41232 Point HL at script data for skeleton idling...
41577 JP 48098 ...and execute
Berk is in skeleton's room
41580 BIT 0,(IX+9) If skeleton's must-process-current-script-data flag is reset...
41584 JR Z,41597 ...then skip ahead to 41597
41586 RES 0,(IX+9) Reset skeleton's must-process-current-script-data flag
41590 LD A,(45430) If yellow skull is in a room with index of 4 or more (room above pit, or pit)...
41593 CP 4 ...
41595 JR NC,41561 ...then jump back to 41561 (move skeleton back)
41597 LD A,(IX+5) If x-coordinate of skeleton's left edge...
41600 SUB 9 ...is at least nine characters to the right of Berk's right edge...
41602 CP (IY+7) ...
41605 JR NC,41561 ...then jump back to 41561 (move skeleton back)
41607 SET 0,(IX+9) Set skeleton's must-process-current-script-data flag
41611 LD HL,41280 Point HL at script data for skeleton stepping forward (left)...
41614 JP 48098 ...and execute
Prev: 41498 Up: Map Next: 41617