Prev: C946 Up: Map Next: C9B1
C990: Scripts: elrond
What elrond 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.
ELROND_SCRIPTS C990 DEFB $00 Key 0, an ordinary script: ELROND_A
C991 DEFW ELROND_A
C993 DEFB $0F Key $0F, ATTACK WITH: its reaction, ELROND_ON_ATTACK_WITH
C994 DEFW ELROND_ON_ATTACK_WITH
C996 DEFB $1D Key $1D, GIVE TO: its reaction, ON_GIVE_TO
C997 DEFW ON_GIVE_TO
C999 DEFB $FF End of the table
ELROND_B -- Where the script starts: ELROND_HELLO, then on as ELROND_A.
ELROND_B C99A DEFB $13 Call ELROND_HELLO
C99B DEFW ELROND_HELLO
C99D DEFB $00 Not used
C99E DEFW ELROND_C If it is refused: ELROND_C
ELROND_A -- An ordinary script: ELROND_GIVES_LUNCH, then on as ELROND_C.
ELROND_A C9A0 DEFB $03 Call ELROND_GIVES_LUNCH
C9A1 DEFW ELROND_GIVES_LUNCH
C9A3 DEFB $00 Not used
ELROND_C -- Where a jump or a refusal goes on: Pause: nothing this turn, Pause: nothing this turn, then on as ELROND_ON_ATTACK_WITH.
ELROND_C C9A4 DEFB $04,$FF Pause: nothing this turn
C9A6 DEFB $14,$FF Pause: nothing this turn
C9A8 DEFW ELROND_B If it is refused: ELROND_B
ELROND_ON_ATTACK_WITH -- The reaction to ATTACK WITH: ATTACK WITH, Go to ELROND_ON_ATTACK_WITH.
ELROND_ON_ATTACK_WITH C9AA DEFB $14,$0F ATTACK WITH
C9AC DEFW ELROND_B If it is refused: ELROND_B
C9AE DEFB $0E Go to ELROND_ON_ATTACK_WITH
C9AF DEFW ELROND_ON_ATTACK_WITH
Prev: C946 Up: Map Next: C9B1