
function E0090()
    MNA()CMU("CS_Anzen")FAI(0)
end
function E0091()
    MNA()CMU("CS_Anzen")FAI(1)
end
function E0092()
    MNA()CMU("CS_Anzen")FAI(2)
end
function E0093()
    MNA()CMU("CS_Anzen")FAI(3)
end
function E0094()
    MNA()CMU("CS_Anzen")FAI(4)
end

function Door_GoPeaceTown()
    PRI()MM0()SOU("CS_011_door")ANP("Door_GoPeaceTown",0,1)FAO(2)TRA("CS_peace_town","E0090",31,15)
end

function Door_GoMasroRoom()
    KEY()MM0()
    SOU("CS_011_door")
    ANP("Door_GoMasroRoom",0,1)WAI(10)HMC()
    ANP("Door_GoMasroRoom",0,0)
    MOV(32,7)WAI(16)
    SOU("CS_011_door")
    ANP("Door_OutMasroRoom",0,1)SLR(1)SMC()WAI(10)
    ANP("Door_OutMasroRoom",0,0)
end

function Door_OutMasroRoom()
    KEY()MM0()
    SOU("CS_011_door")
    ANP("Door_OutMasroRoom",0,1)WAI(10)HMC()
    ANP("Door_OutMasroRoom",0,0)
    MOV(30,7)WAI(16)
    SOU("CS_011_door")
    ANP("Door_GoMasroRoom",0,1)SLR(0)SMC()WAI(10)
    ANP("Door_GoMasroRoom",0,0)
end

function BarlogCountFirefly()
    KEY()FAC("balrog_normal")CLR()
    MS3("\nLet me see how many you've got.")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")CLR()
    local num = ITC("Firefly")
    if(num >= 20) then
        CAT(""..num.." should be enough.")NOD()
        CAT("\nYou can take these to Misery now~")NOD()
        FLP("GiveToMisery")
        MSR("CatchFirefly","GiveToMisery")
    else
        if(num <= 5) then
            CAT(""..num.." is too few.")NOD()
            CAT("\nYou need to catch 20.")NOD()CLR()
            CAT("\nGo back to the cave")
            CAT("\nand catch some more.")NOD()
        else
            CAT(""..num.." still isn't enough.")NOD()
            CAT("\nYou need to catch 20.")NOD()CLR()
            CAT("\nGo back to the cave") 
            CAT("\nand catch some more.")NOD()
        end
        FLP("FireflyCatch20")
    end
end
--柜台（小巴）
function Barlog1()
    if(FLJ("GoFindJenka")) then
        KEY()FAC("balrog_normal")
        MS3("The area where Jenka lives is")
        CAT("\nquite dangerous,")NOD()
        CAT("\nso be careful, you hear?")NOD()
    elseif(FLJ("GiveToMisery")) then
        KEY()FAC("balrog_normal")
        MS3("\nGo ahead and take this to Misery~")NOD()
    elseif(ITJ("Firefly")) then
        if(FLJ("FireflyCatch20")) then
            BarlogCountFirefly()
        else
            KEY()
            FAC("balrog_normal")MS3("Oh, you've already caught") 
            CAT("\nthe fireflies?")NOD()
            ANP("Barlog1","happy")
            FAC("balrog_happy")CAT("\nWell, that went rather smoothly~")NOD()CLR()
            BarlogCountFirefly()
        end
    elseif(FLJ("FireflyCatch20")) then
        KEY()
        FAC("balrog_normal")MS3("The Firefly Cave is outside")
        CAT("\nto the left,")NOD()
        CAT("\nGo catch some in the cave.")NOD()
        CAT("\nYou'll need 20 of them.")NOD()
    elseif(FLJ("CatchFirefly")) then
        KEY()
        FAC("balrog_normal")MS3("I see you've got the") 
        CAT("\ncapture tools now.")NOD()
        ANP("Barlog1","happy")
        FAC("balrog_happy")CAT("\nPretty smooth, huh~")NOD()CLR()
        FAC("jack_normal")CAT("\nSo how many do we need to catch?")NOD()CLR()
        FAC("balrog_normal")CAT("Let me think...")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")
        CAT("\nMaybe about 100...")NOD()CLR()
        FAC("jack_><")CAT("Wait, can we even catch that many?")NOD()
        CAT("\nThere might not even be")
        CAT("\nthat many in the cave.")NOD()CLR()
        FAC("balrog_normal")CAT("\nWell, at least 20 then.")NOD()CLR()
        FAC("jack_normal")CAT("\nI got it. Let's aim for 20.")NOD()CLR()
        FLP("FireflyCatch20")
    elseif(FLJ("ChatWithBalrog_GoodLuck")) then
        KEY()
        FAC("balrog_normal")MS3("Why don't you go around town?")NOD()
        CAT("\nI'm sure you'll find a solution.")NOD()
    elseif(FLJ("GetOutDivination")) then
        KEY()
        FAC("balrog_normal")MS3("You're back already?")NOD()
        ANP("Barlog1","happy")
        FAC("balrog_happy")CAT("\nDid you miss me that much~")NOD()CLR()
        FAC("jack_><")CAT("\nActually, we got kicked out...")NOD()CLR()
        FAC("balrog_normal")CAT("\nThat's not good news.")NOD()CLR()
        CAT("Come to think of it,")NOD()
        CAT("\nshe hasn't been in a good mood")
        CAT("\nsince that incident...")NOD()CLR()
        FAC("jack_normal")CAT("\nDid something happen?")NOD()CLR()
        FAC("balrog_normal")CAT("A customer brought their")
        CAT("\npet in recently")
        CAT("\nand it got scared by the bats,")NOD()
        CAT("\nmaking a complete mess of her shop...")NOD()CLR()
        CAT("Since then, she's banned") 
        CAT("\nall pets from entering.")NOD()CLR()
        CAT("But even Mimiga got kicked out.")NOD()
        CAT("\nSeems like she's really in") 
        CAT("\na bad mood today.")NOD()CLR()
        FAC("jack_normal")CAT("\nIsn't there anything we can do?")NOD()CLR()
        FAC("balrog_normal")CAT("I remember she liked fireflies")
        CAT("\nwhen she was little.")NOD()
        CAT("\nIf you catch some fireflies for her,")NOD()
        CAT("\nher mood might improve.")NOD()CLR()
        FAC("jack_><")CAT("But we don't have any tools") 
        CAT("\nto catch fireflies...")NOD()CLR()
        FAC("balrog_normal")CAT("I'm afraid I can't help with that.")NOD()
        CAT("\nBut I'm sure there's a solution")
        CAT("\nsomewhere in this town.")NOD()CLR()
        ANP("Barlog1","happy")
        FAC("balrog_happy")CAT("\nGood luck~")NOD()
        FLP("ChatWithBalrog_GoodLuck")
        MSR("AskBalrogForHelp","SearchingForMethodsToCaptureFireflies")
    elseif (FLJ("ChatWithBalrog")) then
        KEY()
        FAC("balrog_normal")MS3("I can't leave my business right now,")NOD()
        CAT("\nso I can't help you at the moment...")NOD()
    else
        KEY()
        FAO(0)
        MOV(15,19,PLY())
        MOV(14,19,1-PLY())
        SLR(1)
        AMC("normal")
        AMC("hide_gun")
        FAI(2)
        ANP("Barlog1","happy")
        FAC("balrog_happy")MS3("\nWelcome!")NOD()
        FAC("balrog_normal")CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)CAT(".")WAI(8)
        CLR()CAT("You look like those Mimigas")
        CAT("\nI captured before.")NOD()CLR()
        ANP("Barlog1","happy")
        FAC("balrog_happy")CAT("\nAre you out sightseeing today?")NOD()CLR()
        FAC("jack_><")CAT("I'd like to, ")NOD()
        FAC("jack_normal")CAT("\nbut monsters appeared this morning.")NOD()
        CAT("\nThey captured Toroko and Sue")
        CAT("\nwith bubbles.")NOD()CLR()
        CAT("\nSo we...")NOD()CLR()CMU("XXXX")
        FAC("balrog_normal")CAT("Wait... let me explain...")NOD()
        CAT("\nThat wasn't me! I swear!")NOD()
        CAT("\nI would never do something") 
        CAT("\nlike that again!")NOD()CLR()
        CAT("I'm here running the shop all day,")NOD()
        CAT("\nand I'm incredibly busy!")NOD()CLR()
        ANP("Barlog1","shock")
        FAC("balrog_shock")CAT("If Misery found out I wasn't here,")NOD()
        CAT("\nshe'd turn me into a frog")
        CAT("\nand release me into the ocean!")NOD()CLR()
        ANP("Barlog1","normal")
        FAC("balrog_normal")CAT("\nJust like that...")NOD()CLO()
        ANP("Barlog1","normal",1)
        WAI(20)
        ANP("Barlog1","leave_counter")
        SOU("CS_023_thud")
        WAI(32)
        ANP("Barlog1","back")
        WAI(100)
        AMC("hurt")
        ANP("Barlog1","shock")
        ANP("Barlog1","drawBefore")
        ANP("Counter1","throw")
        WAI(240)
        FAO(0)TRA("CS_peace_town_hotel","Barlog1_chat_end",15,19)
    end
end

function Barlog1_chat_end()
    KEY()
    MOV(15,19,PLY())
    MOV(14,19,1-PLY())
    MV0()
    SLR(1)
    CMU("CS_Anzen")
    FAI(2)
    FAC("balrog_normal")MS3("Sorry for getting so worked up...")NOD()
    CAT("\nI didn't scare you, did I")NOD()CLR()
    FAC("jack_><")CAT("We just want to rescue them.")NOD()
    CAT("\nDo you have any suggestions?")NOD()CLR()
    FAC("balrog_normal")CAT("Why not ask Misery?")NOD()
    CAT("\nThe fortune-telling shop") 
    CAT("\nshould be open today,")NOD()
    CAT("\nand it's business hours now.")NOD()
    CAT("\nIf she's in a good mood,")
    CAT("\nshe might help you.")NOD()CLR()
    FAC("jack_normal")CAT("\nGot it. Thanks!")NOD()CLR()
    FAC("balrog_normal")CAT("\nYou're welcome")NOD()CLR()
    ANP("Barlog1","happy")
    FAC("balrog_happy")CAT("By the way, would you two")
    CAT("\nlike to check in?~")NOD()CLR()
    FAC("jack_><")CAT("No thanks! We don't need to!")NOD()
    CAT("\nWe're in a hurry!")NOD()CLR()
    FAC("jack_normal")CAT("\nSanta, let's go!")NOD()CLO()
    AMC("walk",1,PLY())
    WAI(48)
    AMC("walk",1,1-PLY())
    WAI(110)
    AMC("back",1,PLY())
    WAI(16)
    SOU("CS_011_door")ANP("Door_GoPeaceTown",0,1)
    WAI(16)
    HMC(PLY())
    WAI(32)
    AMC("back",1,1-PLY())
    WAI(16)
    HMC(1-PLY())
    WAI(16)
    SOU("CS_011_door")ANP("Door_GoPeaceTown",0,0)
    WAI(64)
    FAC("balrog_normal")MS3("\nIt's so boring when no one talks...")NOD()CLO()
    FAO(0)
    FLP("DivinationOpen")
    FLP("ChatWithBalrog")
    MSA("AskMiseryForHelp")
    TRA("CS_peace_town","ChatWithBalrog",30,15)
end


function Masro1()
    KEY()
    MS4("This red fox looks quite busy...")NOD()
    CAT("\nMuttering something to himself...")NOD()CLR()
    TUR()CAT("“Pixel-sama — our kami!")NOD()
end

--得到幽灵火球后准备去寻找珍卡
function GoFindJenka()
    KEY()
    MOV(15,19,MCI("CS_mychar_jack"))
    MOV(14,19,MCI("CS_mychar_santa"))
    SLR(1)
    WAI(64)
    FAI()
    WAI(32)
    CMU("CS_Anzen")
    FAC("balrog_normal")MS3("So, ")NOD()
    CAT("\nyou're leaving town")
    CAT("\nto find Jenka, huh.")NOD()CLR()
    FAC("jack_normal")CAT("Yes, Toroko and the others are still")
    CAT("\nwaiting for us to rescue them.")NOD()
    CAT("\nAnd thank you for all your help")
    CAT("\naround town.")NOD()CLR()
    ANP("Barlog1","happy")
    FAC("balrog_happy")MS3("Well, come visit our town again")
    CAT("\nwhen you have time~")NOD()CLR()
    FAC("jack_normal")MS3("\nI definitely will.")NOD()CLO()
    FLP("GoFindJenka")
    MSR("GiveToMisery","GoFindJenka")
end

function KazumaAndSue()
    KEY()
    HMC()
    MNP("Masro1",36,7,0)
    ANP("Masro1","sleep")
    ANP("ComputerMasro1",0,0)
    DNP("Barlog1")
    SNP("CS_kazuma_animate",1,13,0,"mainLayer","Kazuma1")
    SNP("CS_sakamoto_sue_animate",3,13,1,"mainLayer","SakamotoSue1")
    SNP("CS_skydragon_animate",5,13,0,"mainLayer","SkyDragon1")
    ANP("Kazuma1","computer")
    CMU("CS_Anzen")
    FAI(0)
    WAI(60)
    KEY()FAC("kazuma_normal")MS3("Ok! I've received") 
    CAT("\nthe puppy's coordinates,")NOD()
    CAT("\nProfessor Booster and")
    CAT("\nthe rescue robot are already") 
    CAT("\non their way.")NOD()CLR()
    CAT("You can focus on rescuing") 
    CAT("\neveryone else.")NOD()CLO()
    FAO(0)
    TRA("CS_sky","ProfessorBoosterWithRobot",19,13)
end

function KazumaAndSue2()
    KEY()
    MNP("Masro1",36,7,0)
    ANP("Masro1","sleep")
    ANP("ComputerMasro1",0,0)
    DNP("Barlog1")
    SNP("CS_kazuma_animate",1,13,0,"mainLayer","Kazuma1")
    SNP("CS_sakamoto_sue_animate",3,13,1,"mainLayer","SakamotoSue1")
    SNP("CS_skydragon_animate",5,13,0,"mainLayer","SkyDragon1")
    ANP("Kazuma1","computer")
    RMU()
    FAI(0)
    WAI(30)
    ANP("SakamotoSue1","angry",0)
    FAC("sakamotosue_angry")MS3("Brother! Why do we have to come to")
    CAT("\nplaces with dangerous creatures")
    CAT("\nagain...")NOD()CLR()
    FAC("kazuma_normal")CAT("Well, Quote and I are good friends~")NOD()
    CAT("\nHe asked me to provide") 
    CAT("\nbackup support.")NOD()CLR()
    CAT("Besides, you're the one who insisted")
    CAT("\non coming along...")NOD()CLR()
    ANP("SakamotoSue1","normal",1)
    FAC("sakamotosue_normal")CAT("But you said we were") 
    CAT("\ngoing on vacation...")NOD()CLR()
    FAC("kazuma_normal")CAT("We are~")NOD()
    CAT("\nWe're actually staying at a hotel")
    CAT("\nin a very safe")
    CAT("\ntown protected by a barrier.")NOD()CLR()
    CAT("But the main reason is,")NOD()
    FAC("kazuma_good")CAT("\nQuote is covering all our") 
    CAT("\nvacation expenses.")NOD()CLR()
    ANP("SakamotoSue1","normal",0)
    FAC("sakamotosue_normal")CAT("\nSo that's it...")NOD()CLO()
    PMU(5)
    WAI(60)
    FAO(2)
    SMC(0)SMC(1)
    TRA("CS_soapcastle_kingbedroom","ContinueRescue",9,15)
end

function LockedDoor()
    PRI()
    MS4("\nThe door is locked.")NOD()
end