Prev: 52908 Up: Map Next: 52967
52914: Script routine: (55) Choose new direction and start crawling (worm)
Used by the routine at 48096.
Input
IX Address of complex state data for an entity
52914 CALL 53057 Increase worm's age and, if it has expired, set its depth to zero and return
52917 LD A,20 Load A with a random number, 5-24...
52919 CALL 54222 ...
52922 ADD A,5 ...
52924 LD (IX+12),A ...and set worm's time until direction change to this value
52927 LD A,2 Load A with a random number, 0-1...
52929 CALL 54222 ...
52932 OR A ...and if zero (1 in 2 chance)...
52933 JR NZ,52951 ...then skip ahead to 52951
Have worm move left
52935 CALL 54666 Check worm for collision with another impassable / pushable entity immediately to the left...
52938 JR NC,52961 ...and if a collision occurred, then start worm crawling right
52940 CALL 54348 Move worm into room to the left, if appropriate...
52943 JR NC,52961 ...and if worm can't enter new room then start worm crawling right
52945 LD HL,52765 Point HL at script data for worm, crawling left...
52948 JP 48098 ...and execute
Have worm move right
52951 CALL 54569 Check worm for collision with another impassable / pushable entity immediately to the right...
52954 JR NC,52945 ...and if a collision occurred, then start worm crawling left
52956 CALL 54313 Move worm into room to the right, if appropriate...
52959 JR NC,52945 ...and if worm can't enter new room then start worm crawling left
52961 LD HL,52781 Point HL at script data for worm, crawling right...
52964 JP 48098 ...and execute
Prev: 52908 Up: Map Next: 52967