Prev: 53057 Up: Map Next: 53159
53083: Attempt to spawn a new worm
Used by the routine at 52860.
Input
IX Address of complex state data (current level) for worm
53083 LD A,60 Load A with a random number, 0-59...
53085 CALL 54222 ...
53088 OR A If random number is not zero (59 in 60 chance)...
53089 RET NZ ...then return
53090 LD A,(34218) Set worm's current room to same as current character's...
53093 LD (IX+0),A ...
53096 CALL 53848 Store room size data for worm's current room
53099 LD A,(34235) Load A with width of current room (chars) + 99...
53102 SUB 100 ...and subtract 100 to get x-coordinate (zero-based) of right side of the room
53104 CALL 54222 Load A with a random x-coordinate within current room
53107 ADD A,100 Add 100 to restore coordinate system
53109 LD (IX+5),A Set this as the worm's left x-coordinate
53112 ADD A,2 Add two to this...
53114 LD (IX+7),A ...and set as the worm's right x-coordinate
53117 LD A,2 Load A with a random number, 1-2...
53119 CALL 54222 ...
53122 INC A ...
53123 LD (IX+1),A ...and assign the worm this depth
53126 LD A,124 Load A with 124 (y-coordinate of character row below bottom of room)
53128 SUB (IX+1) Subtract worm's depth value to get its bottom y-coordinate...
53131 LD (IX+6),A ...and assign
53134 PUSH AF Store AF (A = bottom y-coordinate of worm)
53135 LD (IX+4),121 Set worm's top y-coordinate to 121
53139 CALL 54768 Check entity at IX for collision with another entity at same depth whose interaction-(11,6) flag is set
53142 POP BC Store AF (B = bottom y-coordinate of worm)
53143 JR NC,53154 If a collision occurred then set worm's depth to zero and return
53145 LD (IX+4),B Set worm's top y-coordinate to same as its bottom y-coordinate
53148 LD HL,52735 Point HL at script data for worm rising from floor...
53151 JP 48098 ...and execute
53154 LD (IX+1),0 Set worm's depth to zero
53158 RET Return
Prev: 53057 Up: Map Next: 53159