Prev: C9F0 Up: Map Next: CA5E
CA34: Scripts: hideous troll, vicious troll
What hideous troll, vicious troll 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.
HIDEOUS_TROLL_SCRIPTS CA34 DEFB $00 Key 0, an ordinary script: HIDEOUS_TROLL_A
CA35 DEFW HIDEOUS_TROLL_A
CA37 DEFB $0F Key $0F, ATTACK WITH: its reaction, ON_ATTACK_WITH
CA38 DEFW ON_ATTACK_WITH
CA3A DEFB $FF End of the table
HIDEOUS_TROLL_B -- Where the script starts: TROLLS_TALK, then on as HIDEOUS_TROLL_A.
HIDEOUS_TROLL_B CA3B DEFB $13 Call TROLLS_TALK
CA3C DEFW TROLLS_TALK
CA3E DEFB $00 Not used
CA3F DEFW HIDEOUS_TROLL_B If it is refused: HIDEOUS_TROLL_B
HIDEOUS_TROLL_A -- An ordinary script: TROLLS_EAT, Pause: nothing this turn, TROLLS_EAT, Pause: nothing this turn, TROLLS_EAT, Pause: nothing this turn, TROLLS_EAT, TROLLS_TURN_TO_STONE, Go to HIDEOUS_TROLL_A.
HIDEOUS_TROLL_A CA41 DEFB $03 Call TROLLS_EAT
CA42 DEFW TROLLS_EAT
CA44 DEFB $00 Not used
CA45 DEFB $04,$FF Pause: nothing this turn
CA47 DEFB $03 Call TROLLS_EAT
CA48 DEFW TROLLS_EAT
CA4A DEFB $00 Not used
CA4B DEFB $04,$FF Pause: nothing this turn
CA4D DEFB $03 Call TROLLS_EAT
CA4E DEFW TROLLS_EAT
CA50 DEFB $00 Not used
CA51 DEFB $04,$FF Pause: nothing this turn
CA53 DEFB $03 Call TROLLS_EAT
CA54 DEFW TROLLS_EAT
CA56 DEFB $00 Not used
CA57 DEFB $03 Call TROLLS_TURN_TO_STONE
CA58 DEFW TROLLS_TURN_TO_STONE
CA5A DEFB $00 Not used
CA5B DEFB $0E Go to HIDEOUS_TROLL_A
CA5C DEFW HIDEOUS_TROLL_A
Prev: C9F0 Up: Map Next: CA5E