BEGIN ACGAL

IF ~~ THEN BEGIN 2
SAY @0
++ @1 + 3
++ @2 + 4
END

IF ~~ THEN BEGIN 5a
SAY @3
IF ~~ THEN GOTO 6
END

IF ~~ THEN BEGIN 6
SAY @4
++ @5 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 7 
++ @6 + 6a 
++ @7 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 7 
END

IF ~~ THEN BEGIN 6a
SAY @8
++ @9 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 6b
++ @10 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",3)~ + 6b
++ @11 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 6b
END

IF ~~ THEN BEGIN 6b
SAY @12
IF ~~ THEN GOTO 7
END

IF ~~ THEN BEGIN 7a
SAY @13
++ @14 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 8
++ @15 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 8
++ @16 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",3)~ + 8
END

IF ~~ THEN BEGIN 8
SAY @17
IF ~Global("ACAUDQUEST","GLOBAL",12)~ THEN GOTO 8a
IF ~Global("ACAUDQUEST","GLOBAL",11)~ THEN GOTO 8b
END

IF ~~ THEN BEGIN 8a
SAY @18
++ @19 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 9a
++ @20 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 9b
++ @21 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 9c
END

IF ~~ THEN BEGIN 8b
SAY @22
++ @23 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 9d
++ @20 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 9e
++ @24 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",3)~ + 9f
END

IF ~~ THEN BEGIN 9a
SAY @25
IF ~~ THEN GOTO 10
END

IF ~~ THEN BEGIN 9b
SAY @26
IF ~~ THEN GOTO 10
END

IF ~~ THEN BEGIN 9c
SAY @27
IF ~~ THEN GOTO 10
END

IF ~~ THEN BEGIN 9d
SAY @28
IF ~~ THEN GOTO 10
END

IF ~~ THEN BEGIN 9e
SAY @26
IF ~~ THEN GOTO 10
END

IF ~~ THEN BEGIN 9f
SAY @29
IF ~~ THEN GOTO 10
END

IF ~!Global("ACGALFINALSPEECH","GLOBAL",1)Global("ACAUDQUEST","GLOBAL",13)
OR(3)
!InParty("ACBRE") 
!See("ACBRE") 
StateCheck("ACBRE",CD_STATE_NOTVALID)~ THEN BEGIN NOSTART.2
SAY @30
IF ~~ THEN EXIT
END

CHAIN
IF ~Global("ACAUDQUEST","GLOBAL",13)
InParty("ACBRE") 
See("ACBRE") 
!StateCheck("ACBRE",CD_STATE_NOTVALID)~ THEN ACGAL FINALTALK
@31 DO ~SetGlobal("ACAUDQUEST","GLOBAL",14)~
==ACBREJ @32
==ACGAL @33
==ACBREJ @34
==ACGAL @35 = @36
==ACBREJ @37
==ACAUD002 @38
==ACBREJ @39
==ACAUD002 @40
==ACBREJ @41
==ACGAL @42
==ACBREJ @43
==ACAUD002 @44
==ACBREJ @45
==ACGAL @46
==ACAUD002 IF ~Global("ACBREBIO","GLOBAL",2)~ THEN @47 DO ~GiveItemCreate("ACTEXT3",LastTalkedToBy(),0,0,0)~
==ACAUD002 IF ~Global("ACBREBIO","GLOBAL",3)~ THEN @48 DO ~GiveItemCreate("ACTEXT3",LastTalkedToBy(),0,0,0)~
==ACAUD002 @49
==ACBREJ @50
==ACGAL @51 DO ~EscapeAreaDestroy(90)~
==ACAUD002 @52 DO ~EscapeAreaDestroy(90)~
EXIT

CHAIN
IF ~NumTimesTalkedTo(0)~ THEN ACGAL 1
@53 
==ACGAL IF ~Race(PLAYER1,DWARF)~ THEN @54 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~
==ACGAL IF ~!Race(PLAYER1,DWARF)~ THEN @55
==ACREG IF ~ReputationLT(PLAYER1,10)~ THEN @56 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~
==ACREG IF ~ReputationGT(PLAYER1,9)ReputationLT(PLAYER1,16)~ THEN @56 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~
==ACREG IF ~ReputationGT(PLAYER1,15)~ THEN @56 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",3)~
==ACGAL @57 = @58 = @59
END
++ @60 + 2
++ @61 + 3
++ @2 + 4

CHAIN
IF ~~ THEN ACGAL 3
@62
==ACREG @63
==ACGAL @64
END
++ @65 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 6
++ @66 + 5
++ @67 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 6

CHAIN
IF ~~ THEN ACGAL 5
@68
==ACREG @69
==ACGAL @70
END
++ @71 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",3)~ + 5a
++ @72 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 5a
++ @73 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 5a

CHAIN
IF ~~ THEN ACGAL 7
@74
==ACBREP @75
==ACGAL @76 = @77
END
++ @78 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",1)~ + 8
++ @79 + 7a 
++ @16 DO ~IncrementGlobal("ACGALDESCIDES","GLOBAL",2)~ + 8

CHAIN
IF ~~ THEN ACGAL 4
@80
==ACBREP @81
==ACAUD002 @82
==ACGAL @83 
END
++ @84 + 3
++ @85 + END.BAD

/* for debugging 
CHAIN
IF WEIGHT #-1
~GlobalLT("ACAUDQUEST","GLOBAL",13)~ THEN ACGAL 10
*/
CHAIN
IF ~~ THEN ACGAL 10
@86
==ACBREP IF ~GlobalLT("ACGALDESCIDES","GLOBAL",9)~ THEN @87
==ACBREP IF ~GlobalGT("ACGALDESCIDES","GLOBAL",8)~ THEN @88
==ACREG @89
==ACGAL @90
END
IF ~GlobalLT("ACGALDESCIDES","GLOBAL",9)~ THEN GOTO END.BAD
IF ~GlobalGT("ACGALDESCIDES","GLOBAL",8)GlobalLT("ACGALDESCIDES","GLOBAL",12)~ THEN GOTO END.TRAD
IF ~GlobalGT("ACGALDESCIDES","GLOBAL",11)~ THEN GOTO END.BEST

CHAIN
IF ~~ THEN ACGAL END.BAD
@91
==ACREG @92
==ACBREP @93
==ACGAL @94
==ACBREP @95
==ACGAL @96 = @97
==ACAUD002 @98
==ACGAL @99
==ACBREP @100
==ACGAL @101 = @102 
==ACBREP @103
==ACGAL @104
==ACREG @105 DO ~GiveItemCreate("ACTEXT3",LastTalkedToBy(),0,0,0)~
==ACBREP @106
==ACAUD002 @107
==ACGAL @108 = @109 DO ~SetGlobal("ACAUDQUEST","GLOBAL",13)SetGlobal("ACBREBIO","GLOBAL",1)ClearAllActions()StartCutSceneMode()StartCutScene("ACCUT12a")~
EXIT

CHAIN
IF ~~ THEN ACGAL END.TRAD
@91
==ACREG @92
==ACBREP @93
==ACGAL @110
==ACGAL IF ~Global("ACAUDQUEST","GLOBAL",12)~ THEN @111
==ACGAL IF ~Global("ACAUDQUEST","GLOBAL",11)~ THEN @112
==ACGAL @113
==ACBREP @114
==ACAUD002 @115
==ACGAL @116
==ACREG @117
==ACGAL @118
==ACREG @119
==ACGAL @120
==ACREG @121
==ACGAL @122
==ACREG @123
END
IF ~~ THEN DO ~SetGlobal("ACBREBIO","GLOBAL",3)ActionOverride("ACREG",ENEMY())~ EXIT

CHAIN
IF ~~ THEN ACGAL END.BEST
@91
==ACREG @92
==ACBREP @93
==ACGAL @110
==ACGAL IF ~Global("ACAUDQUEST","GLOBAL",12)~ THEN @111
==ACGAL IF ~Global("ACAUDQUEST","GLOBAL",11)~ THEN @112
==ACGAL @113
==ACBREP @114
==ACAUD002 @115
==ACGAL @116
==ACREG @117
==ACGAL @118
==ACREG @119
==ACGAL @120
==ACREG @121
==ACGAL @122
==ACREG @123
==ACBREP @124
==ACREG @125
==ACBREP @126
==ACGAL @127
==ACBREP @128
==ACGAL @95
==ACBREP IF ~Global("ACAUDQUEST","GLOBAL",12)~ THEN @129
==ACBREP IF ~Global("ACAUDQUEST","GLOBAL",11)~ THEN @130
==ACREG @131
==ACGAL @132
==ACBREP @133
==ACREG @95
==ACBREP @134 = @135
==ACGAL @136
==ACBREP @137
==ACGAL @138
==ACREG @139
==ACAUD002 @140
==ACBREP @141
==ACGAL @142 = @143
END
IF ~~ THEN DO ~SetGlobal("ACAUDQUEST","GLOBAL",13)SetGlobal("ACBREBIO","GLOBAL",2)ClearAllActions()StartCutSceneMode()StartCutScene("ACCUT_12")~ EXIT

CHAIN
IF ~Global("ACGALFINALSPEECH","GLOBAL",1)~ THEN ACGAL FINALSPEECH
@144 DO ~SetGlobal("ACGALFINALSPEECH","GLOBAL",2)~
==ACAUD002 @145
==ACBREP @146
==ACGAL @142 = @143
END
IF ~~ THEN DO ~ClearAllActions()StartCutSceneMode()StartCutScene("ACCUT_12")~ EXIT