Prev: C8A1 Up: Map Next: C913
C8E2: Scripts: thorin
What thorin 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.
THORIN_SCRIPTS C8E2 DEFB $00 Key 0, an ordinary script: THORIN_A
C8E3 DEFW THORIN_A
C8E5 DEFB $1D Key $1D, GIVE TO: its reaction, ON_GIVE_TO
C8E6 DEFW ON_GIVE_TO
C8E8 DEFB $0F Key $0F, ATTACK WITH: its reaction, ON_ATTACK_WITH
C8E9 DEFW ON_ATTACK_WITH
C8EB DEFB $FF End of the table
THORIN_A -- An ordinary script: FOLLOW: the player, Go to THORIN_A.
THORIN_A C8EC DEFB $12,$27,$00,$FF FOLLOW: the player
C8F0 DEFW THORIN_B If it is refused: THORIN_B
C8F2 DEFB $0E Go to THORIN_A
C8F3 DEFW THORIN_A
THORIN_B -- Where a jump or a refusal goes on: TAKE: small curious key, THORIN_THRAINS_KEY, then on as THORIN_C.
THORIN_B C8F5 DEFB $12,$13,$02,$FF TAKE: small curious key
C8F9 DEFW THORIN_C If it is refused: THORIN_C
C8FB DEFB $23 Call THORIN_THRAINS_KEY (used up once it works: the game zeroes it)
C8FC DEFW THORIN_THRAINS_KEY
C8FE DEFB $00 Not used
THORIN_C -- Where a jump or a refusal goes on: THORIN_WHERES_THIEF, Pause: nothing this turn, RUN, Go to THORIN_A.
THORIN_C C8FF DEFB $13 Call THORIN_WHERES_THIEF
C900 DEFW THORIN_WHERES_THIEF
C902 DEFB $00 Not used
C903 DEFW THORIN_D If it is refused: THORIN_D
C905 DEFB $04,$FF Pause: nothing this turn
C907 DEFB $04,$24 RUN
C909 DEFB $0E Go to THORIN_A
C90A DEFW THORIN_A
THORIN_D -- Where a jump or a refusal goes on: THORIN_CHATTER, Go to THORIN_A.
THORIN_D C90C DEFB $03 Call THORIN_CHATTER
C90D DEFW THORIN_CHATTER
C90F DEFB $00 Not used
C910 DEFB $0E Go to THORIN_A
C911 DEFW THORIN_A
Prev: C8A1 Up: Map Next: C913