Prev: 39865 Up: Map Next: 40056
39962: Update Bat Entity
Updates an entity of the type 11 which is made from the second kind of creature at CreatureTemplates. Field 35 is a countdown which is set from the random number when the entity is stopped.
Input
IX The entity
UpdateBatEntity 39962 CALL TestEntityRemoval Call TestEntityRemoval to test whether the entity should be removed.
39965 CALL IncreaseEntityCounter Call IncreaseEntityCounter.
39968 BIT 7,(IX+35) Test bit 7 of field 35 of the entity.
39972 CALL NZ,ResetEntityMovement Call ResetEntityMovement if it is set.
39975 BIT 7,(IX+30) Jump to UpdateEntity_Move to carry on updating the entity if bit 7 of the flags is not set.
39979 JP Z,UpdateEntity_Move
39982 LD (IX+1),1 Set the frame of the entity to 1.
39986 LD (IX+16),0 Set the speed to 0.
39990 LD (IX+17),0 Set the heading of the entity to 0.
39994 LD A,(IX+35) Read field 35 of the entity.
39997 AND A Test it.
39998 JR Z,UpdateBatEntity_Delay Jump to UpdateBatEntity_Delay if it is zero.
40000 DEC A Decrease the countdown by one.
40001 LD (IX+35),A Store it in field 35 of the entity.
40004 JP NZ,UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity unless it is zero.
40007 CALL FacePlayer Call FacePlayer to choose the direction towards the player.
40010 LD A,(IX+32) Read field 32 of the entity.
40013 OR %10000000 Set bit 7.
40015 LD (IX+17),A Set the heading.
40018 LD A,(24475) Fetch the random number from 24475 and keep it in B.
40021 LD B,A
40022 AND %00010000 Keep bit 4.
40024 ADD A,16 Add 16.
40026 LD (IX+16),A Set the speed.
40029 LD A,B Fetch the random number.
40030 AND %00000011 Use bits 0-1.
40032 ADD A,3 Add 3.
40034 LD (IX+18),A Store it in field 18 of the entity.
40037 LD (IX+19),0 Set field 19 of the entity to 0.
40041 JP UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity.
UpdateBatEntity_Delay 40044 LD A,(24475) Fetch the random number from 24475.
40047 AND %00011110 Use bits 1-4.
40049 INC A Add one.
40050 LD (IX+35),A Store it as the countdown in field 35 of the entity.
40053 JP UpdateEntity_Move Jump to UpdateEntity_Move to carry on updating the entity.
Prev: 39865 Up: Map Next: 40056