Prev: 36859 Up: Map Next: 37176
37018: UpdateAlienAI — give the idle alien its next action
Despite the old "UpdateCrewAI" name, this is the ALIEN's brain (IX -> slot 0; crew get their actions from the player). When the alien's countdown is parked (0), pick its next move from the ROM script:
  • crew share its room -> action state 5 (attack tick, timer 60)
  • alone with the grille still in place -> 3-in-16 chance to rip the grille out itself (state 3, timer 50)
  • alone, grille open -> 6-in-16 chance to slip through it into / out of the ducts (state 2, timer 50)
  • otherwise wander to an adjacent room (state 1, timer 80); when the roll leaves it where it stands, it damages the room instead (+1 damage point — the alien trashes whatever it is lurking in)
The entry goes through AIActionSelect, which first rescues the alien from spot 98 (ducts "over" the Narcissus, an escape artifact — see that routine).
Used by the routine at 36457.
37018 PUSH IX save caller's IX
37020 LD IX,29566 IX -> the alien's record (slot 0)
37024 XOR A is its action countdown parked (0)?
37025 CP (IX+0)
37028 JR Z,37033 yes: pick a new action
37030 POP IX no: it is busy
37032 RET
37033 JP 45721 duct-escape guard, then FindVictims
This entry point is used by the routine at 45721.
37036 LD HL,65535 NearestCrewC/A = 255/255
37039 LD (33695),HL
37042 LD DE,33695 collect crew on the alien's spot
37045 LD HL,29575 (A = its room byte, from AIActionSelect)
37048 LD BC,1793 B = 7 slots, C = slot 1
37051 CP (HL) on the same spot?
37052 JR NZ,37058
37054 EX DE,HL record the slot in
37055 LD (HL),C NearestCrewC, then A, then B
37056 EX DE,HL
37057 INC DE
37058 INC C
37059 PUSH DE
37060 LD DE,8 next record's room byte
37063 ADD HL,DE
37064 POP DE
37065 DJNZ 37051
37067 LD A,(33695) anyone there?
37070 CP 255
37072 JR Z,37085 no: movement options
37074 LD (IX+0),60 yes: attack them —
37078 LD (IX+3),5 action state 5, timer 60
37082 POP IX
37084 RET
37085 LD A,(IX+1) alien alone: is this room's
37088 AND 63 grille still in place?
37090 LD E,A
37091 LD D,0
37093 LD HL,30076 RoomGrilleState[room]
37096 ADD HL,DE
37097 LD A,(HL)
37098 CP 255
37100 JR NZ,37122 no: it may slip through
37102 CALL 33589 yes: roll the script —
37105 CALL 36763 direction 0 (3 in 16)?
37108 AND A
37109 JR NZ,37151 no: wander instead
37111 LD (IX+0),50 yes: the alien rips the grille
37115 LD (IX+3),3 out itself (state 3, timer 50)
37119 POP IX
37121 RET
37122 CALL 33589 roll the script —
37125 CALL 36763 direction 0 or 1 (6 in 16)?
37128 CP 2
37130 JR NC,37151 no: wander
This entry point is used by the routine at 45721.
37132 LD A,(IX+1) yes: through the open grille —
37135 XOR 64 same room, other side
37137 LD (IX+2),A
37140 LD (IX+0),50 timer = 50 frames
37144 LD (IX+3),2 action state = 2 (duct transit)
37148 POP IX
37150 RET
37151 CALL 36717 pick an adjacent room
37154 LD (IX+0),80 timer = 80 frames
37158 LD (IX+3),1 action state = 1 (move/idle)
37162 LD A,(IX+1) going nowhere (dest = current)?
37165 CP (IX+2)
37168 LD A,1 then the alien trashes the room:
37170 CALL Z,38182 +1 damage point
37173 POP IX
37175 RET
Prev: 36859 Up: Map Next: 37176