Prev: 40757 Up: Map Next: 40941
40826: UpdateAndroid
Per-frame Android activation check. Once TriggerAlienEvent has set AlienActiveFlag — the crew has wounded the alien 6+ times — this routine pulls the alien_target slot into action state 7 (attack), turning the Android from a normal-looking crew member into a hostile actor that wounds the crew in its room.
Returns immediately if any of:
  • AlienActiveFlag == 0 (the trigger has not fired)
  • alien_target's byte +0 != 0 (mid-cycle; the activation stamp at 40849 arms +0, so the routine stays out until that countdown has run back down to 0)
  • alien_target's byte +7 != 0 (lockout sentinel — CrewHitsAndroid's collapse path at 41039 writes +7 = 2, and that prevents re-activation if the Android has been defeated)
In other words: the routine re-fires every time the Android's countdown parks at 0 while AlienActiveFlag is set — once per attack/wander cycle, not once per game — until the collapse lockout lands. (LongGameCrewInit issues every slot with +0 = +7 = 0, so the first firing is the frame the trigger is set.)
When all guards pass:
  • 1. IX = alien_target record; stamp (IX+0) = 80 (activation marker and timer that also holds this branch shut while it counts down).
  • 2. Cache AlienTargetID into CrewIndex for downstream message enqueues.
  • 3. CALL 37876 — gather up to two other crew standing in the Android's room into NearestCrewA/B (its victim pool).
  • 4. If at least one of them is alive: enqueue message #30 "{actor} is attacking {target}" with actor = AlienTargetID (the Android's name, e.g. "Ash is attacking Lambert"), put the alien_target into action state 7 with timer 40, then return.
  • 5. If nobody is there to attack, fall through to 36717 (wander) and reset the Android to action state 1.
Once the Android is in state 7, subsequent ResetCrewTimers frames dispatch it through CrewAction7_Handler which wounds a live crew member in its room and can collapse them via 39400 (msg #21 "{actor} has collapsed").
This routine is NOT the alien's own attack: the alien kills crew that end up in its room (slot 0 record byte +1) — see the attack tick at 39328.
Used by the routine at 36457.
40826 LD A,(33704) A = AlienActiveFlag
40829 AND A alien loose on ship?
40830 RET Z no: no encounter yet, nothing to activate
40831 LD HL,(33701) HL = alien_target record (AlienTargetPtr)
40834 LD A,(HL) A = byte +0
40835 AND A Android already activated (+0 stamped to 80)?
40836 RET NZ yes: this routine has already fired once, skip
40837 LD DE,7 offset to byte +7 (defeated-lockout sentinel)
40840 ADD HL,DE HL → +7
40841 CP (HL) A=0 here; Z iff byte +7 == 0 (template, not defeated)
40842 RET NZ +7 != 0: Android collapsed earlier, stay dormant
40843 PUSH IX save caller's IX
40845 LD IX,(33701) IX = Android record (= alien_target)
40849 LD (IX+0),80 stamp +0 = 80 — activation marker / blocks re-entry
40853 LD A,(33703) A = AlienTargetID (= Android slot index)
40856 LD (33700),A CrewIndex = AlienTargetID (Android's slot)
40859 CALL 37876 gather up to two other crew standing in the Android's room as its victims
40862 LD A,(33696) A = first room-mate (33696)
40865 CP 255 $FF = nobody there
40867 JR Z,40906 no primary target: wander
40869 LD C,A C = victim slot
40870 ADD A,A A × 8 (crew record size)
40871 ADD A,A
40872 ADD A,A
40873 LD E,A
40874 LD D,0
40876 LD HL,29573 HL -> that slot's status byte
40879 ADD HL,DE (+7, base $7385)
40880 XOR A alive (status 0)?
40881 CP (HL)
40882 JR Z,40920 yes: attack him
40884 LD A,(33697) A = second room-mate
40887 CP 255
40889 JR Z,40906 no secondary target either: wander
40891 LD C,A C = victim slot
40892 ADD A,A HL -> his status byte (+7)
40893 ADD A,A
40894 ADD A,A
40895 LD E,A
40896 LD D,0
40898 LD HL,29573
40901 ADD HL,DE
40902 XOR A alive (status 0)?
40903 CP (HL)
40904 JR Z,40920 yes: attack him
40906 CALL 36717 nobody to attack: pick a room to
40909 LD (IX+3),1 wander to (action state 1)
40913 LD (IX+0),60 with timer 60 frames
40917 POP IX
40919 RET
40920 LD H,C H = the victim slot (message target)
40921 LD A,(33703) A = AlienTargetID
40924 LD L,A L = Android slot index (message actor)
40925 LD A,30 A = message #30 "{actor} is attacking {target}"
40927 CALL 37176 enqueue: "{Android name} is attacking {nearest}"
40930 LD (IX+3),7 Android slot → action state 7 (attack)
40934 LD (IX+0),40 with timer 40 frames (next dispatch runs the attack)
40938 POP IX
40940 RET
Prev: 40757 Up: Map Next: 40941