Prev: 993D Up: Map Next: 99C7
995F: Set Up Creature
Used by the routine at CreateRandomCreature.
Sets up an entity as one of four kinds of creature, using the templates at CreatureTemplates. The first level has only two kinds of creature and the second level has no kind 03.
Input
A The kind of creature (00-03)
C The mask for the random heading
IX The entity
SetUpCreature 995F LD B,A Copy the kind of creature into B.
9960 LD A,($DEDF) Fetch the number of the level from LevelNumber.
9963 AND A Test it.
9964 JR NZ,SetUpCreature_Level Jump to SetUpCreature_Level unless this is the first level.
9966 RES 1,B Reset bit 1 of the kind, so that only the kinds 00 and 01 are used.
SetUpCreature_Level 9968 DEC A Decrease the level by one.
9969 JR NZ,SetUpCreature_Template Jump to SetUpCreature_Template unless this is the second level.
996B LD A,B Fetch the kind of creature.
996C CP $03 Jump to SetUpCreature_Template unless it is 03.
996E JR NZ,SetUpCreature_Template
9970 LD B,$02 Use the kind 02 instead.
SetUpCreature_Template 9972 LD A,B Fetch the kind of creature.
9973 ADD A,A Multiply it by four...
9974 ADD A,A
9975 LD B,A ...and keep it in B.
9976 ADD A,A Multiply it by eight...
9977 ADD A,B ...and add the four times to make twelve times the kind, the size of a template.
9978 LD HL,$99C7 Point HL at CreatureTemplates.
997B CALL AddToAddress Add the offset of the kind to find its template.
997E LD A,(HL) Fetch the type of the creature.
997F LD (IX+$00),A Set the type of the entity.
9982 INC HL Move onto the next byte of the template.
9983 LD A,(HL) Fetch the frame of the creature.
9984 LD (IX+$01),A Set field 01 of the entity.
9987 INC HL Move onto the next byte of the template.
9988 LD A,(HL) Fetch the third byte of the template.
9989 LD (IX+$10),A Set the speed.
998C INC HL Move onto the next byte of the template.
998D LD A,(HL) Fetch the fourth byte of the template.
998E LD (IX+$14),A Set field 14 of the entity.
9991 INC HL Move onto the next byte of the template.
9992 LD A,(HL) Fetch the fifth byte of the template.
9993 LD (IX+$15),A Set field 15 of the entity.
9996 INC HL Move onto the next byte of the template.
9997 LD A,(HL) Fetch the sixth byte of the template.
9998 LD (IX+$1C),A Set field 1C of the entity.
999B INC HL Move onto the next byte of the template.
999C LD A,(HL) Fetch the seventh byte of the template.
999D LD (IX+$1D),A Set field 1D of the entity.
99A0 INC HL Move onto the next byte of the template.
99A1 LD A,(HL) Fetch the eighth byte of the template.
99A2 LD (IX+$23),A Set field 23 of the entity.
99A5 INC HL Move onto the next byte of the template.
99A6 LD A,(HL) Fetch the ninth byte of the template.
99A7 LD (IX+$0B),A Set the x extent.
99AA INC HL Move onto the next byte of the template.
99AB LD A,(HL) Fetch the tenth byte of the template.
99AC LD (IX+$0C),A Set the y extent.
99AF INC HL Move onto the next byte of the template.
99B0 LD A,(HL) Fetch the eleventh byte of the template.
99B1 LD (IX+$0D),A Set the z extent.
99B4 INC HL Move onto the next byte of the template.
99B5 LD A,(HL) Fetch the twelfth byte of the template.
99B6 LD (IX+$1B),A Set field 1B of the entity.
99B9 LD (IX+$13),$00 Set field 13 of the entity to 00.
99BD LD A,($5F9B) Fetch the random number from 5F9B.
99C0 AND C Mask it with the heading mask.
99C1 LD (IX+$11),A Set the heading.
99C4 JP SetEntitySize Jump to SetEntitySize to set the sprite of the entity.
Prev: 993D Up: Map Next: 99C7