Prev: 39801 Up: Map Next: 39865
39817: Update Foam Entity
Updates an entity of the type 10 which is made from the first kind of creature at CreatureTemplates. Roughly once in every 32 frames it flips bits of field 29 and once in every 64 frames it chooses a new direction towards the player.
Input
IX The entity
UpdateFoamEntity 39817 LD A,(24475) Fetch the random number from 24475.
39820 AND %00011111 Use bits 0-4.
39822 JR NZ,UpdateFoamEntity_Test Jump to UpdateFoamEntity_Test unless they are all zero.
39824 LD A,(IX+29) Read field 29 of the entity.
39827 XOR %11000100 Flip bits 2, 6 and 7.
39829 LD (IX+29),A Store it in field 29 of the entity.
UpdateFoamEntity_Test 39832 CALL TestEntityRemoval Call TestEntityRemoval to test whether the entity should be removed.
39835 CALL IncreaseEntityCounter Call IncreaseEntityCounter.
39838 BIT 7,(IX+35) Test bit 7 of field 35 of the entity.
39842 CALL NZ,ResetEntityMovement Call ResetEntityMovement if it is set.
39845 LD A,(24474) Fetch the low byte of the seed from RandomNumber_Seed.
39848 AND %00111111 Use bits 0-5.
39850 CALL Z,FacePlayer Call FacePlayer to choose the direction towards the player if they are all zero.
39853 LD B,1 Set the size of the step to 1.
39855 CALL TurnEntity Call TurnEntity to turn the entity towards the wanted heading.
39858 SET 7,(IX+17) Set bit 7 of the heading of the entity.
39862 JP UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity.
Prev: 39801 Up: Map Next: 39865