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

function InitRoom()
    if(FLJ("KanpaGoSaveMahin")) then
        CMU("CS_Escape")
        SNP("CS_quake",1,1,0,"mainLayer","Quake1")
    else
        CMU("CS_Grand")
    end
end

function GoFortressCrashedRoom()
    PRI()FAO(1)TRA("CS_fortress_crashedroom","E0093",7,15)
end

function GoFortressEntrance()
    PRI()
    FAC("curly_normal")MS3("The way back is blocked by gates,")NOD()
    CAT("\nWe have no choice but to")
    CAT("\nmove forward.")NOD()
end

function MonsterXAppear()
    KEY()
    SNP("CS_monsterx_animate",15,55,0,"mainLayer","MonsterX0")
    ANP("MonsterX0","face1")
    CMU("CS_Dr")
    FON("Camera1",1)
    ANP("Kanpa1",204)
    FAI(2)
    WAI(32)
    MS3("What do you mean having both")
    CAT("\nMimiga and the fish,")NOD()ANP("MonsterX0","face2")
    CAT("\nThis is exactly what I meant~")NOD()CLR()ANP("MonsterX0","face1")
    CAT("So when you asked me to find Mahin")
    CAT("\nIt was all a lie...")NOD()CLR()
    ANP("MonsterX0","face2")CAT("You mean that fat Mimiga?")NOD()
    CAT("\nI was the one who kidnapped him.")NOD()CLR()
    CAT("\nAnd I knew you would come looking for him.")NOD()CLR()ANP("MonsterX0","face1")
    CAT("\nWhy did you kidnap Mahin?")NOD()CLR()
    ANP("MonsterX0","face2")CAT("\nBecause I wanted this big fish~")NOD()CLR()ANP("MonsterX0","face1")
    ANP("Sue1","angry")
    FAC("sue_angry")CAT("How terrible! You big bad cat!")NOD()
    CAT("\nQuote and Curly will definitely")
    CAT("\nbeat you up.")NOD()CLO()
    ANP("Sue1","normal")
    WAI(16)
    FAC("sue_normal")MS3("\n!")
    ANP("MonsterX0","sit")
    for i=0,15,1 do
        SOU("CS_026_quake")
        WAI(8)
    end
    NOD()CLR()
    CAT("\nWhat was that sound?")NOD()CLR()
    FAC()CAT("Speak of the devil,")NOD()
    ANP("MonsterX0","face1")CAT("\nThey're about to reach")
    CAT("\nthe trap room I carefully prepared.")NOD()CLR()
    ANP("MonsterX0","face2")CAT("They'll soon be turned into scrap metal,")NOD()
    CAT("\nAnd you'll all become my playthings.")NOD()CLO()ANP("MonsterX0","face1")
    WAI(32)
    WAI(16)
    ANP("MonsterX0","sit")MS3("But since they're here,")
    CAT("\nI can't just sit around waiting,")NOD()CLR()
    ANP("MonsterX0","sit",1)
    CAT("All of you,")NOD()
    CAT("\nKeep an eye on these Mimigas and the fish.")NOD()
    CAT("\nI'll be right back~")NOD()CLR()
    CAT("\nYes, sir!")NOD()CLO()
    FAO(2)
    DNP("MonsterX0")
    FAI(0)
    WAI(32)
    ANP("Shutter1","down")
    WAI(128)
    ANP("Shutter1","stop")
    WAI(32)
    PMU(5)
    FAC("sue_sad")MS3("\nQuote, Curly, please be careful.")NOD()CLR()
    FAC("toroko_><")CAT("\nPraying!")NOD()CLO()
    MOV(10,36)
    FOM()
    WAI(32)
    SMC(0)SMC(1)
    CMU("CS_Grand")
end

function Test1()
    DNP("Test1")
    --PRI()FAO(2)HMC()Escape()
    MOV(42,23)DefeatedMonsterX()
    --PRI()FAO(2)HMC()TRA("CS_fortress","KanpaGoSaveMahin",52,49)
end

function DefeatedMonsterX()
    KEY()
    ANP("Kanpa1",204)
    FAC("curly_happy")MS3("\nWe defeated it!")NOD()CLO()
    WAI(60)
    SOU("CS_Cat")
    WAI(16)
    MS3("Damn it,")NOD()
    CAT("\nEven if I can't defeat you,")NOD()
    CAT("\nI won't let you get away so easily.")NOD()CLR()
    CAT("I'm retreating for now,")NOD()
    CAT("\nYou're on your own...")NOD()CLR()
    FAC("curly_normal")MS3("\n?")NOD()CLR()
    SOU("CS_043_computer_beep")
    FAC()MS3("[Fortress self-destruct sequence initiated!")NOD()
    CAT("\nExplosion in 5 minutes.]")WAI(16)NOD()CLO()
    SNP("CS_quake",1,1,0,"mainLayer","Quake1")
    FAC("curly_normal")MS3("Quote! We need to find everyone")
    CAT("\nand escape before it explodes.")NOD()
    CAT("\nThey must be somewhere in here!")NOD()CLO()
    ANP("CenterCamera","disable_focus")
    FON("Camera1")
    ANP("Shutter1","reset_pos")
    ANP("Shutter1","down_immed")
    WAI(32)
    CMU("CS_Escape")
    WAI(32)
    HMC()
    FAC("sue_normal")MS3("What's happening!")NOD()
    CAT("\nWhy is everything suddenly shaking?")NOD()CLO()
    ANP("GaudiArmoured2","normal",1)
    WAI(16)
    ANP("GaudiArmoured1","normal",1)
    FAC()MS3("NO! The base is going to self-destruct,")NOD()
    CAT("\nwe need to get out of here.")NOD()CLO()
    ANP("GaudiArmoured2","walk")
    WAI(16)
    ANP("GaudiArmoured1","walk")
    WAI(32)
    ANP("Terminal1","wake_up")
    ANP("GaudiArmoured2","normal")
    WAI(16)
    TUR()MS3("\n[Enter password:")WAI(60)
    CAT("*")WAI(16)CAT("*")WAI(16)
    ANP("GaudiArmoured1","normal")
    CAT("*")WAI(16)CAT("*")WAI(16)CAT("*")WAI(16)CAT("*")WAI(16)CLR()
    CAT("\n[Password correct]")WAI(32)CLR()
    CAT("\n[Opening gate....]")WAI(32)CLO()
    ANP("Shutter1","up")
    WAI(64)
    ANP("GaudiArmoured2","walk")
    WAI(16)
    ANP("GaudiArmoured1","walk")
    WAI(48)
    ANP("Shutter1","stop")
    WAI(48)
    ANP("Sue1","angry")
    FAC("sue_angry")MS3("Hey!")WAI(32)CAT("Come back")WAI(32)
    CAT("\nand open our gate too!")WAI(120)CLO()
    DNP("GaudiArmoured2")
    DNP("GaudiArmoured1")
    ANP("Sue1","back")
    TUR(false)FAC("sue_sad")MS3("\nSigh, we're doomed...")NOD()CLR()
    FAC("toroko_><")CAT("Don't give up, Sue!")NOD()
    CAT("\nThere must be a way out.")NOD()CLR()
    ANP("Sue1","normal")
    FAC("jack_normal")CAT("That's right!")NOD()
    CAT("\nThis gate may be sturdy,")NOD()
    CAT("\nbut its frame was nearly damaged")
    CAT("\nduring the explosion tremors.")NOD()CLR()
    CAT("If we all push together at once")
    CAT("\nwe should be able to break through!")NOD()CLR()
    FAC("sue_normal")CAT("Got it,")NOD()
    CAT("\nlet's all push together!")NOD()CLO()
    WAI(32)
    MS3("\n3..")WAI(32)CAT("2..")WAI(32)CAT("1..")WAI(32)CLO()
    SOU("CS_071_little_crash")
    CMP("cmpLayer_1","bk","CS_pe_smoke")
    WAI(32)
    FAC("sue_normal")MS3("It worked!")NOD()
    ANP("Sue1","angry")
    FAC("sue_angry")CAT("\nLet's get out of this place, quick!")NOD()CLO()
    FAO(2)
    FOM()
    TRA("CS_fortress","Escape",51,49)
end

function Escape()
    KEY()
    DNP("GaudiArmoured1")
    DNP("GaudiArmoured2")
    DNP("Jack1")
    DNP("Santa1")
    DNP("Sue1")
    DNP("Chako1")
    DNP("Toroko1")
    DNP("Kanpa1")

    CMP("cmpLayer_1","bk","CS_pe_smoke")
    SNP("CS_quake",1,1,0,"mainLayer","Quake1")
    local start_x = 50;
    MNP("Pushcart1",start_x,49,0)
    MNP("Fishtank1",start_x+1,48,0)
    ANP("Fishtank1","wink",1)
    ANP("Pushcart1","move",1)
    SNP("CS_mychar_kanpa_animate",47,49,1,"mainLayer","Kanpa1")
    ANP("Kanpa1","walk",1)
    SNP("CS_jack_animate",50,49,1,"mainLayer","Jack1")
    ANP("Jack1","ignoreMovePlatform",1)
    ANP("Jack1","walk",1)
    SNP("CS_santa_animate",start_x+1,49,1,"mainLayer","Santa1")
    ANP("Santa1","ignoreMovePlatform",1)
    ANP("Santa1","walk",1)
    SNP("CS_chako_animate",start_x+2,49,1,"mainLayer","Chako1")
    ANP("Chako1","ignoreMovePlatform",1)
    ANP("Chako1","walk",1)
    SNP("CS_sue_animate",start_x+3,49,1,"mainLayer","Sue1")
    ANP("Sue1","ignoreMovePlatform",1)
    ANP("Sue1","walk",1)
    SNP("CS_toroko_animate",start_x+4,49,1,"mainLayer","Toroko1")
    ANP("Toroko1","ignoreMovePlatform",1)
    ANP("Toroko1","walk",1)
    CMU("CS_Escape")
    FON("Camera2",1)
    ANP("Kanpa1",204)
    FAI(0)
    WAI(64)
    ANP("Kanpa1","normal",1)
    WAI(96)
    ANP("Jack1","normal",0)
    WAI(32)
    FAC("jack_normal")MS3("Kanpachi! Why did you stop?")NOD()
    CAT("\nHurry and escape with us!")NOD()CLR()
    FAC()CAT("\nBut I haven't found Mahin yet...")NOD()CLR()
    FAC("jack_><")CAT("Ah,")NOD()
    CAT("\nI completely forgot about him.")NOD()CLR()
    FAC("jack_normal")CAT("Then go find him quickly!")NOD()
    CAT("\nWe'll wait for you behind.")NOD()CLO()
    ANP("Jack1","walk",1)
    WAI(64)
    FAO(2)
    FOM()
    TRA("CS_fortress","KanpaGoSaveMahin",52,49)
end

function KanpaGoSaveMahin()
    KEY()
    DNP("GaudiArmoured1")
    DNP("GaudiArmoured2")
    DNP("Jack1")
    DNP("Santa1")
    DNP("Sue1")
    DNP("Chako1")
    DNP("Toroko1")
    DNP("Kanpa1")
    DNP("Pushcart1")
    DNP("Fishtank1")
    FLP("KanpaGoSaveMahin")
    CMU("CS_Escape")
    CMP("cmpLayer_1","bk","CS_pe_smoke")
    SNP("CS_quake",1,1,0,"mainLayer","Quake1")
    --创建间八
    SGP("CS_mychar_kanpa",52,49,1,"CS_mychar_kanpa_p1")
    SPL(0,"CS_mychar_kanpa_p1")
    if(GOP() == 2) then
        --再加入一个间八让玩家2控制
        SGP("CS_mychar_kanpa",52,49,1,"CS_mychar_kanpa_p2")
        SPL(1,"CS_mychar_kanpa_p2")
        P2A(false)--禁止玩家2使用AI切换
    else
        --玩家2置为NULL
        SGP("null",73,27,0,"CS_mychar_null_p2")
        SPL(1,"CS_mychar_null_p2")
    end
    WAI(1)
    AMC("show_fishing_rod","CS_mychar_kanpa")
    AMC(204,"CS_mychar_kanpa")
    FAI(0)
    SNP("pe_smog",43,36,0,"mainLayer","null")
    CNP("SavePoint","CS_savepoint",0)
    --设定血量
    if(FLJ("GaveTheFish")) then
        MLP(5)
    end
    if(FLJ("PathLifeCapsule1")) then
        MLP(5)
    end
    if(FLJ("Fishing1")) then
        MLP(1)
    end
    if(FLJ("Fishing2")) then
        MLP(2)
    end
    if(FLJ("Fishing3")) then
        MLP(3)
    end
    if(FLJ("Fishing4")) then
        MLP(2)
    end
    if(FLJ("Fishing1_Normal")) then
        MLP(1)
    end
    if(FLJ("Fishing2_Normal")) then
        MLP(1)
    end
    if(FLJ("Fishing3_Normal")) then
        MLP(2)
    end
    if(FLJ("Fishing4_Normal")) then
        MLP(2)
    end
    if(FLJ("Fishing5_Normal")) then
        MLP(2)
    end
    --清除物品
    ITS()
    ITP("Spikes")
    --设置任务
    MSD()
    MSA("SaveEveryoneKing")
end

function Terminal1()
    PRI()
    TUR()MS3("\n[Gate Opened]")NOD()
end

function GoFindMahin()
    KEY()
    MYB(1,PLY())
    WAS()
    MS4("\nI must go find Mahin...")NOD()
end

function InitCmpMap()
    DNP("InitCmpMap")
    CMP("cmpLayer_1","bk")
    SNP("CS_quake",1,1,0,"mainLayer","Quake1")
end

function HelloMonsterX()
    KEY()
    DNP("HelloMonsterX")
    --[[
    if true then
        --StartWaterSpaceTrap()
        FightWithMonsterX()
        return
    end
    --]]
    FAO(2)
    MOV(37,23,MCI("CS_mychar_quote"))
    MOV(35,23,MCI("CS_mychar_curly"))
    SLR(1)
    MM0()
    --暂时解除AI
    if(GOP() == 1) then
        if(PLY() == 0) then
            AGP("CS_mychar_curly_p2",false)
        else
            AGP("CS_mychar_quote_p1",false)
        end
    end
    AMC("walk",1)
    FAI(0)
    PMU(5)
    WAI(60)
    AMC("normal")
    ANP("CenterCamera","disable_focus")
    FON("Camera3")
    ANP("Shutter2","down")
    WAI(128)
    ANP("Shutter2","stop")
    SLR(0)
    FON("Camera4")
    ANP("Shutter3","down")
    WAI(128)
    ANP("Shutter3","stop")
    FOM()
    ANP("CenterCamera","enable_focus")
    if(SKJ("SkipRoomTrap")) then
        --启用AI
        if(GOP() == 1) then
            if(PLY() == 0) then
                AGP("CS_mychar_curly_p2",true)
            else
                AGP("CS_mychar_quote_p1",true)
            end
        end
        FightWithMonsterX()
        return
    end
    if(SKJ("SkipHydraulicPress")) then
        --
    else
        WAI(64)
        SLR(1,MCI("CS_mychar_curly"))
        FAC("curly_normal")MS3("This is bad, Quote,")NOD()
        CAT("\nWe're trapped in here.")NOD()CLO()
        WAI(64)
        ANP("Eye","show")
        WAI(32)
        ANP("Eye",1)
        WAI(32)
        ANP("Eye",2)
        WAI(32)
        ANP("Eye","down")
        ANP("Eye",3)
        WAI(16)
        ANP("Eye",4)
        WAI(16)
        ANP("Eye","stop")
        WAI(32)
        MS3("So you're the robot companions")
        CAT("\nwho Mimiga mentioned,")NOD()
        CAT("\nAnd one of you looks somewhat familiar...")NOD()CLO()
        AMC("back")
        WAI(32)
        FAC("curly_normal")MS3("\n!")NOD()CLR()
        CAT("\nWho are you?")NOD()CLR()
        FAC()CAT("\nI'm the one who captured your Mimiga.")NOD()CLR()
        FAC("curly_normal")CAT("\nWhere have you hidden them?")NOD()CLR()
        FAC()CAT("Well,")NOD()
        CAT("\nTelling you wouldn't make any difference.")NOD()CLR()
        CAT("Because you're about to die here,")NOD()
        CAT("\nCatching you was easier than catching mice.")NOD()CLR()
        FAC("curly_normal")CAT("\nMice?")NOD()CLR()
        ANP("Eye",5)
        FAC()CAT("This is a mousetrap,")NOD()
        CAT("\nAnd you are the mice!!")NOD()CLR()
        ANP("Eye",4)
        FAC()CAT("\n.")WAI(16)CAT(".")WAI(16)CAT(".")WAI(16)CAT(".")WAI(16)CAT(".")WAI(16)CAT(".")WAI(16)CLR()
        ANP("Eye",0)
        FAC()CAT("Never mind, I won't explain further,")NOD()
        CAT("\nYou two low-brain-capacity robots,")NOD()
        ANP("Eye",2)
        CAT("\nEnjoy your time in this room...")NOD()CLO()
        WAI(16)
        ANP("Eye",1)
        WAI(16)
        ANP("Eye",0)
        WAI(16)
        ANP("Eye","hide")
        WAI(60)
        AMC("normal")
        WAI(60)
        FAC("curly_normal")MS3("Quote, it looks like everyone")
        CAT("\nmight be nearby,")NOD()
        CAT("\nOnce we get out of this room,")NOD()
        CAT("\nWe should be able to find them.")NOD()CLO()
    end
    --启用AI
    if(GOP() == 1) then
        if(PLY() == 0) then
            AGP("CS_mychar_curly_p2",true)
        else
            AGP("CS_mychar_quote_p1",true)
        end
    end
    WAI(32)
    local smallBlockIndex = math.random(0,19)
    local setX = 22;
    local setY = 6;
    for i=0,19,1 do
        if(i == smallBlockIndex) then
            SNP("CS_fortblock_small",setX,setY+1,0,"mainLayer","FortBlock1")
            SNP("CS_fortblock_small",setX,setY,0,"mainLayer","FortBlock1")
            setX = setX + 1;
        else
            SNP("CS_fortblock",setX,setY,0,"mainLayer","FortBlock1")
            setX = setX + 2;
        end
    end
    ANP("FortBlock1","adjust_pos")
    ANP("FortBlock1","set_smog")
    WAI(30)
    ANP("FortBlock1","press")
    WAI(30)
    AMC("look_up")
    WAI(30)
    CMU("CS_Zonbie")
    if(SKJ("SkipHydraulicPress")) then
    else
        PRI()
        FAC("curly_normal")MS3("It's a hydraulic press!")NOD()
        CAT("\nIt's trying to flatten us")
        CAT("\ninto metal sheets.")NOD()CLR()
        CAT("We need to figure out how")
        CAT("\nto escape this danger")NOD()CLO()
    end
    SKP("SkipHydraulicPress")
    --设置事件延时计时器
    ANP("HydraulicPressCountdown","countdown",1080)
end

function HydraulicPressCountdown()
    KEY()
    ANP("FortBlock1","destroy")
    PMU(5)
    WAI(60)
    if(SKJ("SkipLaser")) then
        --
    else
        ANP("Eye","reset_pos")
        ANP("Eye","show")
        WAI(32)
        ANP("Eye",1)
        WAI(32)
        ANP("Eye",2)
        WAI(32)
        ANP("Eye","down")
        ANP("Eye",3)
        WAI(16)
        ANP("Eye",4)
        WAI(16)
        ANP("Eye","stop")
        WAI(32)
        MS3("\nDealing with you isn't as easy as I thought...")NOD()CLR()
        CAT("But that's alright,")NOD()
        CAT("\nI have other traps prepared.")NOD()CLR()
        CAT("\nLook forward to them~")NOD()CLO()
        ANP("Eye",1)
        WAI(16)
        ANP("Eye",0)
        WAI(16)
        ANP("Eye","hide")
        WAI(60)
        FAC("curly_sad")MS3("Looks like we're going to face")
        CAT("\na lot more trouble ahead")NOD()CLR()
        FAC("curly_normal")CAT("Until we defeat it,")
        CAT("\nQuote, we must stay strong!")NOD()CLO()
    end
    WAI(60)
    --放置激光武器
    if(DIF() == 0) then
        local delaycount = 60;
        for i=1,39,5 do
            local eventName = "LasertrapEvent"..i;
            CNP(eventName,"CS_enemy_lasertrap",0)
            ANP(eventName,"set_smog")
            ANP(eventName,"delay",delaycount)
            delaycount = delaycount + 20;
        end
    else
        local delaycount = 60;
        for i=1,39,1 do
            local eventName = "LasertrapEvent"..i;
            CNP(eventName,"CS_enemy_lasertrap",0)
            ANP(eventName,"set_smog")
            ANP(eventName,"delay",delaycount)
            delaycount = delaycount + 20;
        end
    end
    CMU("CS_Gravity")
    SKP("SkipLaser")
end

function LasertrapAllDestroy()
    if(DIF() == 0) then
        --检查所有的激光是否被摧毁
        if(FLJ("Lasertrap1") and 
            FLJ("Lasertrap6") and
            FLJ("Lasertrap11") and 
            FLJ("Lasertrap16") and
            FLJ("Lasertrap21") and
            FLJ("Lasertrap26") and 
            FLJ("Lasertrap31") and 
            FLJ("Lasertrap36")) then
            StartWaterSpaceTrap()
        end
    else
        --检查所有的激光是否被摧毁
        if(FLJ("Lasertrap1") and FLJ("Lasertrap2") and FLJ("Lasertrap3") and FLJ("Lasertrap4") and FLJ("Lasertrap5") and
            FLJ("Lasertrap6") and FLJ("Lasertrap7") and FLJ("Lasertrap8") and FLJ("Lasertrap9") and FLJ("Lasertrap10") and
            FLJ("Lasertrap11") and FLJ("Lasertrap12") and FLJ("Lasertrap13") and FLJ("Lasertrap14") and FLJ("Lasertrap15") and
            FLJ("Lasertrap16") and FLJ("Lasertrap17") and FLJ("Lasertrap18") and FLJ("Lasertrap19") and FLJ("Lasertrap20") and
            FLJ("Lasertrap21") and FLJ("Lasertrap22") and FLJ("Lasertrap23") and FLJ("Lasertrap24") and FLJ("Lasertrap25") and
            FLJ("Lasertrap26") and FLJ("Lasertrap27") and FLJ("Lasertrap28") and FLJ("Lasertrap29") and FLJ("Lasertrap30") and
            FLJ("Lasertrap31") and FLJ("Lasertrap32") and FLJ("Lasertrap33") and FLJ("Lasertrap34") and FLJ("Lasertrap35") and
            FLJ("Lasertrap36") and FLJ("Lasertrap37") and FLJ("Lasertrap38") and FLJ("Lasertrap39")) then
            StartWaterSpaceTrap()
        end
    end
end

function LasertrapEvent1()FLP("Lasertrap1")LasertrapAllDestroy()end
function LasertrapEvent2()FLP("Lasertrap2")LasertrapAllDestroy()end
function LasertrapEvent3()FLP("Lasertrap3")LasertrapAllDestroy()end
function LasertrapEvent4()FLP("Lasertrap4")LasertrapAllDestroy()end
function LasertrapEvent5()FLP("Lasertrap5")LasertrapAllDestroy()end
function LasertrapEvent6()FLP("Lasertrap6")LasertrapAllDestroy()end
function LasertrapEvent7()FLP("Lasertrap7")LasertrapAllDestroy()end
function LasertrapEvent8()FLP("Lasertrap8")LasertrapAllDestroy()end
function LasertrapEvent9()FLP("Lasertrap9")LasertrapAllDestroy()end
function LasertrapEvent10()FLP("Lasertrap10")LasertrapAllDestroy()end
function LasertrapEvent11()FLP("Lasertrap11")LasertrapAllDestroy()end
function LasertrapEvent12()FLP("Lasertrap12")LasertrapAllDestroy()end
function LasertrapEvent13()FLP("Lasertrap13")LasertrapAllDestroy()end
function LasertrapEvent14()FLP("Lasertrap14")LasertrapAllDestroy()end
function LasertrapEvent15()FLP("Lasertrap15")LasertrapAllDestroy()end
function LasertrapEvent16()FLP("Lasertrap16")LasertrapAllDestroy()end
function LasertrapEvent17()FLP("Lasertrap17")LasertrapAllDestroy()end
function LasertrapEvent18()FLP("Lasertrap18")LasertrapAllDestroy()end
function LasertrapEvent19()FLP("Lasertrap19")LasertrapAllDestroy()end
function LasertrapEvent20()FLP("Lasertrap20")LasertrapAllDestroy()end
function LasertrapEvent21()FLP("Lasertrap21")LasertrapAllDestroy()end
function LasertrapEvent22()FLP("Lasertrap22")LasertrapAllDestroy()end
function LasertrapEvent23()FLP("Lasertrap23")LasertrapAllDestroy()end
function LasertrapEvent24()FLP("Lasertrap24")LasertrapAllDestroy()end
function LasertrapEvent25()FLP("Lasertrap25")LasertrapAllDestroy()end
function LasertrapEvent26()FLP("Lasertrap26")LasertrapAllDestroy()end
function LasertrapEvent27()FLP("Lasertrap27")LasertrapAllDestroy()end
function LasertrapEvent28()FLP("Lasertrap28")LasertrapAllDestroy()end
function LasertrapEvent29()FLP("Lasertrap29")LasertrapAllDestroy()end
function LasertrapEvent30()FLP("Lasertrap30")LasertrapAllDestroy()end
function LasertrapEvent31()FLP("Lasertrap31")LasertrapAllDestroy()end
function LasertrapEvent32()FLP("Lasertrap32")LasertrapAllDestroy()end
function LasertrapEvent33()FLP("Lasertrap33")LasertrapAllDestroy()end
function LasertrapEvent34()FLP("Lasertrap34")LasertrapAllDestroy()end
function LasertrapEvent35()FLP("Lasertrap35")LasertrapAllDestroy()end
function LasertrapEvent36()FLP("Lasertrap36")LasertrapAllDestroy()end
function LasertrapEvent37()FLP("Lasertrap37")LasertrapAllDestroy()end
function LasertrapEvent38()FLP("Lasertrap38")LasertrapAllDestroy()end
function LasertrapEvent39()FLP("Lasertrap39")LasertrapAllDestroy()end

function StartWaterSpaceTrap()
    KEY()
    PMU(5)
    WAS()
    WAI(60)
    if(SKJ("SkipWaterTrap")) then
        --
    else
        FAC("curly_normal")MS3("\nPhew, we managed to survive")NOD()CLO()
        WAI(60)
        ANP("Eye","reset_pos")
        ANP("Eye","show")
        WAI(32)
        ANP("Eye",1)
        WAI(32)
        ANP("Eye",2)
        WAI(32)
        ANP("Eye","down")
        ANP("Eye",3)
        WAI(16)
        ANP("Eye",4)
        WAI(16)
        ANP("Eye","stop")
        WAI(32)
        MS3("\nIt's not over yet!")NOD()CLR()
        CAT("Next up are the piranhas...")NOD()CLO()
        ANP("Eye",1)
        WAI(16)
        ANP("Eye",0)
        WAI(16)
        ANP("Eye","hide")
        WAI(60)
        FAC("curly_normal")MS3("Fish this time...")NOD()
        CAT("\nBut in such an empty place...")NOD()CLO()
    end
    SNP("CS_pe_waterfallbase",22,5,0,"mainLayer","Waterfallbase1")ANP("Waterfallbase1","set_style",0)
    SNP("CS_pe_waterfallbase",23,5,0,"mainLayer","Waterfallbase2")ANP("Waterfallbase2","set_style",1)
    SNP("CS_pe_waterfallbase",24,5,0,"mainLayer","Waterfallbase3")ANP("Waterfallbase3","set_style",2)
    SNP("CS_pe_waterfallbase",58,5,0,"mainLayer","Waterfallbase1")ANP("Waterfallbase1","set_style",0)
    SNP("CS_pe_waterfallbase",59,5,0,"mainLayer","Waterfallbase2")ANP("Waterfallbase2","set_style",1)
    SNP("CS_pe_waterfallbase",60,5,0,"mainLayer","Waterfallbase3")ANP("Waterfallbase3","set_style",2)
    SNP("CS_stream_noise",0,0,0,"mainLayer","StreamNoise1")
    WAI(120)
    if(SKJ("SkipWaterTrap")) then
        --
    else
        FAC("curly_sad")TUR()MS3("\nSo that's how it is...")WAI(120)CLO()
    end
    KEY(false)
    ANP("Waterlevel1","up")
    WAI(60)
    for i=22,60,2 do
        SNP("CS_pe_bubble_base",i,23,0,"mainLayer","PeBubbleBase1")
    end
    WAI(200)
    ANP("Waterlevel1","stop")
    DNP("Waterfallbase1")
    DNP("Waterfallbase2")
    DNP("Waterfallbase3")
    DNP("Waterfallbase4")
    DNP("Waterfallbase5")
    DNP("Waterfallbase6")
    WAI(60)
    DNP("StreamNoise1")
    if(DIF() == 0) then
        ANP("PiranhaSetter1","set_npc_type")ANP("PiranhaSetter1","CS_enemy_piranha")
        ANP("PiranhaSetter1","set_npc_num",5)
        ANP("PiranhaSetter1","set_npc_interval",120)
        ANP("PiranhaSetter1","start")
        ANP("PiranhaSetter2","set_npc_type")ANP("PiranhaSetter2","CS_enemy_piranha")
        ANP("PiranhaSetter2","set_npc_num",5)
        ANP("PiranhaSetter2","set_npc_interval",120)
        ANP("PiranhaSetter2","start")
    else
        ANP("PiranhaSetter1","set_npc_type")ANP("PiranhaSetter1","CS_enemy_piranha")
        ANP("PiranhaSetter1","set_npc_num",10)
        ANP("PiranhaSetter1","set_npc_interval",60)
        ANP("PiranhaSetter1","start")
        ANP("PiranhaSetter2","set_npc_type")ANP("PiranhaSetter2","CS_enemy_piranha")
        ANP("PiranhaSetter2","set_npc_num",10)
        ANP("PiranhaSetter2","set_npc_interval",60)
        ANP("PiranhaSetter2","start")
    end
    CMU("CS_OppressionBetaExtra")
    SKP("SkipWaterTrap")
end

function PiranhaSetter1()
    FLP("PiranhaSetter1")
    PiranhaSetterAllDestroy()
end

function PiranhaSetter2()
    FLP("PiranhaSetter2")
    PiranhaSetterAllDestroy()
end

function PiranhaSetterAllDestroy()
    if(FLJ("PiranhaSetter1") and FLJ("PiranhaSetter2")) then
        --水位下降
        PMU(5)
        ANP("Waterlevel1","down")
        WAI(200)
        DNP("PeBubbleBase1")
        WAI(60)
        ANP("Waterlevel1","stop")
        WAI(60)
        KEY()
        if(SKJ("SkipBombTrap")) then
            --
        else
            ANP("Eye","reset_pos")
            ANP("Eye","show")
            WAI(32)
            ANP("Eye",1)
            WAI(32)
            ANP("Eye",2)
            WAI(32)
            ANP("Eye","down")
            ANP("Eye",3)
            WAI(16)
            ANP("Eye",4)
            WAI(16)
            ANP("Eye","stop")
            WAI(32)
            MS3("I can't believe you've dealt with")
            CAT("\nall the fish...")NOD()CLR()
            CAT("Next is the final one...")NOD()CLO()
            ANP("Eye",1)
            WAI(16)
            ANP("Eye",0)
            WAI(16)
            ANP("Eye","hide")
            WAI(60)
            FAC("curly_normal")MS3("The final one...")NOD()
            CAT("\nI have a bad feeling about this...")NOD()CLO()
            WAI(60)
        end
        if(DIF() == 0) then
            ANP("BombSetter1","set_npc_type")ANP("BombSetter1","CS_enemy_trackingbomb")
            ANP("BombSetter1","set_npc_num",5)
            ANP("BombSetter1","set_npc_interval",120)
            ANP("BombSetter1","start")
            ANP("BombSetter2","set_npc_type")ANP("BombSetter2","CS_enemy_trackingbomb")
            ANP("BombSetter2","set_npc_num",5)
            ANP("BombSetter2","set_npc_interval",120)
            ANP("BombSetter2","start")
        else
            ANP("BombSetter1","set_npc_type")ANP("BombSetter1","CS_enemy_trackingbomb")
            ANP("BombSetter1","set_npc_num",10)
            ANP("BombSetter1","set_npc_interval",60)
            ANP("BombSetter1","start")
            ANP("BombSetter2","set_npc_type")ANP("BombSetter2","CS_enemy_trackingbomb")
            ANP("BombSetter2","set_npc_num",10)
            ANP("BombSetter2","set_npc_interval",60)
            ANP("BombSetter2","start")
        end
        CMU("CS_ironH")
        SKP("SkipBombTrap")
    end
end

function BombSetter1()
    FLP("BombSetter1")
    BombSetterAllDestroy()
end

function BombSetter2()
    FLP("BombSetter2")
    BombSetterAllDestroy()
end

function BombSetterAllDestroy()
    if(FLJ("BombSetter1") and FLJ("BombSetter2")) then
        WAI(300)
        FightWithMonsterX()
    end
end

function FightWithMonsterX()
    KEY()
    PMU(5)
    WAS()
    WAI(60)
    if(SKJ("SkipRoomTrap")) then
        --
    else
        FAC("curly_happy")MS3("\nWe made it through!")NOD()CLO()
    end
    WAI(60)
    ANP("Eye","reset_pos")
    ANP("Eye","show")
    WAI(32)
    ANP("Eye",1)
    WAI(32)
    ANP("Eye",2)
    WAI(32)
    MS3("Unbelievable,")NOD()
    CAT("\nI'll have to deal with you myself!")NOD()CLO()
    ANP("MonsterX1","fight")
    ANP("Eye","hide")
    BSL("MonsterX1")
    CMU("CS_FireEye")
    SKP("SkipRoomTrap")
end

function ScreenShattered()
    ANP("MonsterXScreen1",1,0)
end

function MonsterXSecondForm()
    KEY()
    PMU(5)
    WAS()
    WAI(60)
    FAC()MS3("Why won't you fall already,")NOD()
    CAT("\nNow I'm getting angry!") 
    CAT("\nRAAAWWRR————————!")NOD()CLO()
    CMU("CS_LastBtl3")
    ANP("MonsterX1","second_form")
end

function MonsterX1()
    PMU(5)
    ANP("MonsterXScreen1","defeated")
    WAI(100)
    DNP("MonsterX1")
    WAI(60)
    DefeatedMonsterX()
end