Prev: C83B Up: Map Next: C8E2
C8A1: Scripts: gandalf
What gandalf does, turn by turn. CHARACTERS_ACT runs one step of a character's script each turn it can, and a step is an action the character tries as if it had typed it: RUN, TAKE, GIVE TO. A step that names nothing acts on whatever fits.
First comes the script table: one entry per script, a key and the script's address. Key 0 is an ordinary script -- the ones a character wanders between, picked at random by a 'switch at random' step. Any other key is an action code, and that script is the character's reaction when that is done to it: attacked, given something, captured.
Then the scripts, one step to a line. A step's first byte says what it is: its low four bits $00-$03 an action with objects (or, $01 and $03, a routine to call), $04 an action with none, $0E go to, $0F switch at random, $0C switch to a reaction. $10 added means an address follows, where the script goes on if the step is refused; $20 that the step is used up once it works (SCRIPT_DO zeroes its first byte); $40 that an order from the player cannot interrupt it. So $14 is an action with no objects, with somewhere to go if it is refused. The Characters page has every script written out.
GANDALF_SCRIPTS C8A1 DEFB $00 Key 0, an ordinary script: GANDALF_A
C8A2 DEFW GANDALF_A
C8A4 DEFB $00 Key 0, an ordinary script: GANDALF_B
C8A5 DEFW GANDALF_B
C8A7 DEFB $00 Key 0, an ordinary script: GANDALF_C
C8A8 DEFW GANDALF_C
C8AA DEFB $00 Key 0, an ordinary script: GANDALF_D
C8AB DEFW GANDALF_D
C8AD DEFB $00 Key 0, an ordinary script: GANDALF_E
C8AE DEFW GANDALF_E
C8B0 DEFB $1D Key $1D, GIVE TO: its reaction, ON_GIVE_TO
C8B1 DEFW ON_GIVE_TO
C8B3 DEFB $30 Key $30, CAPTURE: its reaction, GANDALF_ON_CAPTURE
C8B4 DEFW GANDALF_ON_CAPTURE
C8B6 DEFB $0F Key $0F, ATTACK WITH: its reaction, ON_ATTACK_WITH
C8B7 DEFW ON_ATTACK_WITH
C8B9 DEFB $FF End of the table
GANDALF_F -- Where the script starts: GIVE TO: curious map, the player, OPEN: round green door, then on as GANDALF_A.
GANDALF_F C8BA DEFB $02,$1D,$03,$00 GIVE TO: curious map, the player
C8BE DEFB $02,$10,$05,$FF OPEN: round green door
GANDALF_A -- An ordinary script: RUN, TAKE, GANDALF_WHATS_THIS, CLOSE, GIVE TO, then on as GANDALF_B.
GANDALF_A C8C2 DEFB $04,$24 RUN
C8C4 DEFB $14,$13 TAKE
C8C6 DEFW GANDALF_B If it is refused: GANDALF_B
C8C8 DEFB $03 Call GANDALF_WHATS_THIS
C8C9 DEFW GANDALF_WHATS_THIS
C8CB DEFB $00 Not used
C8CC DEFB $04,$0C CLOSE
C8CE DEFB $04,$1D GIVE TO
GANDALF_B -- An ordinary script: RUN, DROP, then on as GANDALF_C.
GANDALF_B C8D0 DEFB $04,$24 RUN
C8D2 DEFB $04,$0D DROP
GANDALF_C -- An ordinary script: RUN, GANDALF_CHATTER, then on as GANDALF_D.
GANDALF_C C8D4 DEFB $04,$24 RUN
C8D6 DEFB $03 Call GANDALF_CHATTER
C8D7 DEFW GANDALF_CHATTER
C8D9 DEFB $00 Not used
GANDALF_D -- An ordinary script: RUN, GIVE TO, then on as GANDALF_E.
GANDALF_D C8DA DEFB $04,$24 RUN
C8DC DEFB $04,$1D GIVE TO
GANDALF_E -- An ordinary script: OPEN, switch at random among its first 4.
GANDALF_E C8DE DEFB $04,$10 OPEN
C8E0 DEFB $0F,$04 Switch to one of its first 4 scripts at random
Prev: C83B Up: Map Next: C8E2