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

function GoSoapCastleGolemStatue()
    PRI()FAO(1)TRA("CS_soapcastle_golemstatue","E0093",2,17,0,75)
end

function Back()
    if(FLJ("HeroBack")) then
        KEY()
        FAC("curly_normal")MS4("We need to hurry ahead") 
        CAT("\nand find Sue and the others.")NOD()
    else
        KEY()
        FAC("king_normal")MS4("\nI will not retreat.")NOD()
    end
end

function BreakCage()
    KEY()
    MYB(1,PLY())WAS()
    FAC("king_normal")MS3("There are enemies hidden")
    CAT("\nin this hall,")NOD()
    CAT("\nI can't leave just yet.")NOD()
end

function TrapCage1()
    KEY()
    FLP("TrapCage")
    DNP("BreakCage")
    FON("Camera1")
    FAC("king_normal")MS3("Stop with these tricks,")NOD()
    CAT("\na cage won't hold me.")NOD()CLO()
    WAI(60)
    SLR(0)
    AMC("back")
    WAI(32)
    SLR(1)
    AMC("back")
    WAI(32)
    FAC("king_normal")MS3("\nCome out,")NOD()CAT("stop hiding!")NOD()CLO()
    WAI(32)
    --石头在前方先出现
    MNP("GolemRock1",57,-1,0)
    CNP("GolemRock1","CS_enemy_golemrock",0)
    ANP("GolemRock1",1060)
    WAI(60)
    AMC("normal")
    WAI(60)
    --布在后方出现
    MNP("GolemPaper1",21,-1,0)
    CNP("GolemPaper1","CS_enemy_golempaper",0)
    ANP("GolemPaper1",1060)
    WAI(60)
    --剪刀出现
    MNP("GolemScissors1",25,-1,0)
    CNP("GolemScissors1","CS_enemy_golemscissors",0)
    ANP("GolemScissors1",1060)
    SLR(0)
    AMC("normal")
    WAI(120)
    FAC("tap_normal")MS3("Enough,")NOD()
    CAT("\nyou cannot go any further.")NOD()CLR()
    CMU("XXXX")
    FAC("king_normal")CAT("\nWe'll see if you can stop me.")NOD()CLR()
    FAC("tap_normal")CAT("\nEveryone, attack!")NOD()CLO()
    CMU("CS_FireEye")
    ANP("GolemPaper1","action")
    ANP("GolemScissors1","action")
    ANP("GolemRock1","action")
    --左力场
    for i=13,18,1 do
        SNP("CS_forcefield",19,i,0,"mainLayer","ForcefieldL")
    end
    --右力场
    for i=13,18,1 do
        SNP("CS_forcefield",59,i,0,"mainLayer","ForcefieldR")
    end
end

function GolemPaper1()
    FLP("GolemPaper1")
    DefeatePaperScissorsRock()
end

function GolemScissors1()
    FLP("GolemScissors1")
    DefeatePaperScissorsRock()
end

function GolemRock1()
    FLP("GolemRock1")
    DefeatePaperScissorsRock()
end

function DefeatePaperScissorsRock()
    if(FLJ("GolemPaper1") and FLJ("GolemScissors1") and FLJ("GolemRock1")) then
        KEY()
        FAC("king_normal")MS3("That was tough,")NOD()
        CAT("\nbut I managed to defeat them all.")NOD()CLR()
        CAT("I never want to play") 
        CAT("\nrock-paper-scissors again...")CLO()
        --临时保存
        SKP("DefeatePaperScissorsRock")
        FAO(2)
        TRA("CS_soapcastle_golemhall","FightTap",39,18)
    end
end

function FightTap()
    SKP("FightTap")
    KEY()
    --金继续往前走
    CMU("CS_Balcony")
    AMC("normal",1)
    FAI(0)
    WAI(32)
    AMC("walk",1)
    WAI(60)
    MNP("GolemTap1",56,-1,0)
    CNP("GolemTap1","CS_boss_tap",0)
    ANP("GolemTap1","down_look")
    ANP("GolemTap1",1060)
    WAI(32)
    --金停下
    AMC("normal",1)
    WAI(32)
    CMU("XXXX")
    ANP("GolemTap1","left_look")
    FAC("tap_normal")MS3("This is as far as you go!")NOD()
    CAT("\nI'll break your sword") 
    CAT("\nwith my own hands.")NOD()CLR()
    FAC("king_normal")MS3("\nJust try it!")NOD()CLO()
    FON("Camera1")
    --开始战斗
    --左力场
    for i=13,18,1 do
        SNP("CS_forcefield",19,i,0,"mainLayer","ForcefieldL")
    end
    --右力场
    for i=13,18,1 do
        SNP("CS_forcefield",59,i,0,"mainLayer","ForcefieldR")
    end
    ANP("GolemTap1","fight")
    CMU("CS_LastBtl3")
    BSL("GolemTap1")
end

function GolemTap1()
    KEY()
    FOM()
    DNP("ForcefieldL")
    DNP("ForcefieldR")
    FLP("DefeatedTap")
    CMU("XXXX")
    FAC("tap_defeated")MS3("\nI can't believe I lost...")NOD()CLR()
    FAC("king_normal")CAT("Finally defeated him,")NOD()
    CAT("\nI can barely catch my breath.")NOD()CLR()
    SLR(1)
    CAT("Hopefully there aren't any") 
    CAT("\nstronger enemies ahead...")NOD()CLO()
    FAO(2)TRA("CS_soapcastle_golemhall","SoapKingCome",41,18)
end

function SoapKingCome()
    SKP("SoapKingCome")
    KEY()
    for i=0,5,1 do
        SOU("CS_023_thud")
        WAI(16)
    end
    FAC("king_normal")MS3("\nSomeone's coming...")NOD()CLO()
    FAI(0)
    WAI(32)
    FON("Camera2")
    MS3("What the hell are you guys doing?!")NOD()
    CAT("\nThe whole floor is shaking,")NOD()
    CAT("\nI can't even read properly!")NOD()CLO()
    MNP("Soapking1",75,18,0)
    CNP("Soapking1","CS_boss_soapking",0,0)
    FON("Soapking1")
    WAI(32)
    ANP("Soapking1","walk",0)
    WAI(20*16)
    ANP("Soapking1","normal",0)
    MS3("Who are you?")NOD()
    CAT("\nWhy are you causing trouble in my castle?")NOD()CLO()
    WAI(32)
    FOM()
    WAI(32)
    MS3("\nLittle hands, why have you turned pale...")NOD()CLR()
    ---[[
    FAC("king_normal")CAT("\nAre you the leader here?")NOD()CLR()
    FAC()CAT("That's right.")NOD()CLR()
    FAC("king_normal")CAT("\nWhy did you kidnap my villagers?")NOD()CLR()
    FAC()CAT("Kidnap? I did no such thing.")NOD()
    CAT("\nWhy would I want your little rabbits anyway.")NOD()CLR()
    FAC("king_normal")CAT("Liar!")NOD()
    CAT("\nWhen our people were captured,")
    CAT("\nthey left behind a drawing")
    CAT("\nof the monster,")NOD()
    CAT("\na creature with long arms and legs")
    CAT("\nand a square-shaped head.")NOD()CLR()
    FAC()CAT("Ah! That's Tala,")NOD()
    CAT("\none of my subordinates.")NOD()CLR()
    CAT("No wonder I've noticed")
    CAT("\nhim and Puu going out frequently lately,")NOD()
    CAT("\nthey must be up to something behind my back.")NOD()CLR()
    FAC("king_normal")CAT("So can you call back")
    CAT("\nyour subordinates")NOD()
    CAT("\nand return my villagers to me?")NOD()CLR()
    FAC()CAT("That won't be possible,")NOD()
    CAT("\nyou've defeated my knights,")NOD()
    CAT("\nand now I'm very angry.")NOD()CLR()
    --]]
    CAT("\nI'll turn you into a fish now.")NOD()CLR()
    FAC("king_normal")CAT("\nA fish?")NOD()CLO()
    ANP("Soapking1","magicbubble_player1")
    WAI(96)
    FAC("king_normal")MS3("This is bad! I have") 
    CAT("\nno resistance to magic.")NOD()CLR()
    FAC()CAT("If my opponent is a fish,")NOD()
    CAT("\nI can do whatever I want with them.")NOD()CLR()
    CAT("\nFarewell, little fish.")NOD()CLO()
    ANP("Soapking1","lightningstrike_player1")
    WAI(60)
    AMC("knocked_away")
    WAI(240)
    MS3("I just heard thunder!")
    CAT("\nBalrog! Hurry!")NOD()CLO()
    WAI(32)
    SGP("CS_mychar_curly",2,18,1,"CS_mychar_curly_p2")
    WAI(32)
    FAC("curly_normal")MS3("\nWhat happened here...")NOD()CLR()
    FAC("curly_sad")CAT("King! Are you alright?")
    CAT("\nYou look badly hurt.")NOD()CLO()
    --库特出现
    SGP("CS_mychar_quote",2,18,1,"CS_mychar_quote_p1")
    WAI(32)
    AMC("walk",0,"CS_mychar_quote_p1")
    WAI(16)
    SNP("CS_balrog_animate",2,18,1,"mainLayer","Balrog1")
    AMC("normal",1,"CS_mychar_quote_p1")
    WAI(16)
    ANP("Balrog1","walk",1)
    WAI(32)
    ANP("Balrog1","normal",0)
    WAI(32)
    CMU("CS_Curly")
    ANP("Balrog1","happy")
    FAC("balrog_happy")MS3("Don't worry,")
    CAT("\nWe're here now!")NOD()CLR()
    FAC("king_normal")CAT("It's fine,")NOD()
    CAT("\nI can still fight...")NOD()CLR()
    FAC("curly_sad")CAT("King, don't push yourself,")NOD()
    CAT("\nYou should go to the hospital") 
    CAT("\nfor treatment.")NOD()CLR()
    FAC("curly_normal")CAT("Balrog")
    CAT("\nTake King to the hospital")
    CAT("\nright away!")NOD()CLR()
    FAC("balrog_normal")CAT("\nGot it~")NOD()CLR()
    FAC("king_normal")CAT("\nMake sure you save everyone!")NOD()CLR()
    FAC("curly_happy")CAT("Of course we will!")NOD()
    CAT("\nLeave the rest to us.")NOD()CLO()
    FAO(1)
    DNP("Balrog1")
    HMC(0)
    SPL(0,"CS_mychar_quote_p1")
    SPL(1,"CS_mychar_curly_p2")
    ---[[
    if(GOP() == 1) then
        AGP("CS_mychar_curly_p2",true)
    end
    P2A(true)--允许玩家2使用AI切换
    --]]
    MOV(34,18,0)
    MOV(33,18,1)
    FON("Camera1",0)
    WAI(32)
    FAI(3)
    WAI(32)
    FAC()MS3("Two robots this time, huh...")NOD()
    CAT("\nI'll blast you into scraps.")NOD()CLR()
    FAC("curly_normal")CAT("Enough talking,")NOD()
    CAT("\nQuote, use your new dashing")
    CAT("\nequipment to smack him down.")NOD()CLR()
    FAC()MS2("While dashing in the mid-air using booster")
    CAT("\nQuote will become invisible.")NOD()
    CAT("\nDashing into enemies in this state")
    CAT("\ndeals impact damage.")NOD()
     --开始战斗
    --左力场
    for i=13,18,1 do
        SNP("CS_forcefield",19,i,0,"mainLayer","ForcefieldL")
    end
    --右力场
    for i=13,18,1 do
        SNP("CS_forcefield",59,i,0,"mainLayer","ForcefieldR")
    end
    ANP("Soapking1","fight")
    CMU("CS_LastCave")
    BSL("Soapking1")
    --清空所有物品
    ITS()
    --添加库特和卡莉的物品
    ITP("Spur")
    ITP("SuperMissile")
    ITP("MachineGun")
    ITP("Nemesis")
    ITP("LifePot",2)
    ITP("AirTank")
    --添加任务
    MSD()
    MSA("SaveEveryoneCurly")
end
---[[
function FightSoapKing()
    KEY()
    SGP("CS_mychar_quote",2,18,1,"CS_mychar_quote_p1")
    SGP("CS_mychar_curly",2,18,1,"CS_mychar_curly_p2")
    --
    if(GOP() == 1) then
        AGP("CS_mychar_curly_p2",true)
    end
    --
    HMC(0)
    SPL(0,"CS_mychar_quote_p1")
    SPL(1,"CS_mychar_curly_p2")
    MOV(34,18,0)
    MOV(33,18,1)
    FON("Camera1",0)
    MNP("Soapking1",75,18,0)
    CNP("Soapking1","CS_boss_soapking",0,0)
    MNP("Soapking1",55,18,0)
    CMU("CS_Curly")
    FAI(3)
    WAI(32)
    FAC()MS3("Two robots this time, huh...")NOD()
    CAT("\nI'll blast you into scraps.")NOD()CLR()
    FAC("curly_normal")CAT("Enough talking,")NOD()
    CAT("\nQuote, use your new dashing")
    CAT("\nequipment to smack him down.")NOD()CLR()
    FAC()MS2("While dashing in the mid-air using booster")
    CAT("\nQuote will become invisible.")NOD()
    CAT("\nDashing into enemies in this state")
    CAT("\ndeals impact damage.")NOD()
    --开始战斗
    --左力场
    for i=13,18,1 do
        SNP("CS_forcefield",19,i,0,"mainLayer","ForcefieldL")
    end
    --右力场
    for i=13,18,1 do
        SNP("CS_forcefield",59,i,0,"mainLayer","ForcefieldR")
    end
    ANP("Soapking1","fight")
    CMU("CS_LastCave")
    BSL("Soapking1")
    --清空所有物品
    ITS()
    --添加库特和卡莉的物品
    ITP("Spur")
    ITP("SuperMissile")
    ITP("MachineGun")
    ITP("Nemesis")
    ITP("LifePot",2)
    ITP("AirTank")
    --添加任务
    MSD()
    MSA("SaveEveryoneCurly")
end
--]]

--击败了Soapking1
function Soapking1()
    KEY()
    CMU("XXXX")
    DNP("ForcefieldL")
    DNP("ForcefieldR")
    WAI(60)
    FLP("DefeatedSoapKing")
    MS3("No....")NOD()
    CAT("\nI don't want to turn into a statue!!!!")NOD()CLO()
    WAI(30)
    ANP("Soapking1","defeated")
    WAI(60)
    FAC("curly_happy")MS3("\nWe defeated him~")NOD()CLR()
    FAC("curly_normal")CAT("Now let's hurry and find") 
    CAT("\nSue and the others,")NOD()
    CAT("\nI'm worried about them.")NOD()
    FLP("HeroBack")
    FLP("PuppyAppear")
    FOM()
    CMU("CS_Balcony")
end

function ProfessorBoosterCheckStatue()
    KEY()
    HMC()
    CMU("CS_Vivi")
    ---[[
    FAI(3)
    WAI(32)
    SNP("CS_bluerobot_animate",3,18,1,"mainLayer","BlueRobot1")
    WAI(16)
    ANP("BlueRobot1","walk",1)
    WAI(32)
    ANP("BlueRobot1","normal",1)
    WAI(16)
    SNP("CS_professor_booster_animate",3,18,1,"mainLayer","ProfessorBooster1")
    ANP("ProfessorBooster1","walk",1)
    WAI(16)
    ANP("ProfessorBooster1","normal",1)
    WAI(16)
    SNP("CS_bluerobot_animate",3,18,1,"mainLayer","BlueRobot2")
    WAI(32)
    FAC("professorbooster_normal")MS3("We've finally arrived at this place,")NOD()
    CAT("\nIt gives me that same strange feeling")
    CAT("\nI had when I first came to the") 
    CAT("\nfloating island.")NOD()CLR()
    CAT("I hope there's nothing")
    CAT("\ndangerous here...")NOD()CLO()
    FAO(2)
    MOV(41,18)
    FON("ProfessorBooster1",1)
    MNP("BlueRobot1",35,18,0)
    MNP("ProfessorBooster1",34,18,0)
    MNP("BlueRobot2",32,18,0)
    ANP("BlueRobot1","walk",1)
    ANP("BlueRobot2","walk",1)
    ANP("ProfessorBooster1","walk",1)
    FAI(2)
    WAI(96)
    ANP("ProfessorBooster1","normal",1)
    WAI(16)
    ANP("BlueRobot2","normal",1)
    WAI(32)
    ANP("BlueRobot1","normal",1)
    WAI(16)
    ANP("ProfessorBooster1","back",1)
    WAI(32)
    ANP("BlueRobot2","normal",0)
    WAI(16)
    FAC("professorbooster_normal")MS3("Are these statues?")NOD()
    CAT("\nThey look so intact.")NOD()CLR()
    ANP("ProfessorBooster1","back",0)
    CAT("Not a single sign of weathering,")NOD()
    CAT("\nIt's as if they were just completed.")NOD()CLO()
    ANP("ProfessorBooster1","back",1)
    WAI(120)
    ANP("ProfessorBooster1","normal",1)
    FAC("professorbooster_normal")MS3("This isn't the time to linger here,")NOD()
    CAT("\nI need to find the puppy quickly...")NOD()CLO()
    FAO(2)
    FOM()
    --]]
    TRA("CS_soapcastle_kingbedroom","ProfessorBoosterSavePuppy",32,16)
end

function ProfessorBoosterGetWand()
    KEY()
    SNP("CS_professor_booster_animate",49,18,0,"mainLayer","ProfessorBooster1")
    SNP("CS_bluerobot_animate",54,18,1,"mainLayer","BlueRobot2")
    ANP("ProfessorBooster1","walk",0)
    ANP("BlueRobot2","walk",0)
    FON("ProfessorBooster1",1)
    FAI(1)
    WAI(96)
    ANP("ProfessorBooster1","normal",0)
    WAI(32)
    ANP("BlueRobot2","normal",0)
    WAI(32)
    ANP("ProfessorBooster1","back",0)
    WAI(32)
    FAC("professorbooster_normal")MS3("Hmm,")NOD()
    CAT("\nI'm still quite intrigued")
    CAT("\nby these statues.")NOD()CLR()
    ANP("ProfessorBooster1","back",1)
    CAT("Especially this one,")NOD()
    CAT("\nIs that wand in its hand the real deal?")NOD()
    CAT("\nI suddenly really want to") 
    CAT("\ntake it for a spin...")NOD()CLR()
    CAT("After all, a wand's no crown,")NOD() 
    CAT("\nNot as dangerous as that thing")
    CAT("\nsome folks had back in the day,")NOD()
    CAT("\nI've come all this way,")NOD()
    CAT("\nso playing with it a bit")
    CAT("\nshould be fine.")NOD()CLO()
    WAI(32)
    ANP("DefeatedSoapKing1","hide_wand")
    ANP("ProfessorBooster1","show_wand")
    WAI(32)
    ANP("ProfessorBooster1","normal")
    WAI(32)
    ANP("ProfessorBooster1","normal",0)
    WAI(32)
    FAC("professorbooster_normal")MS3("This wand is quite large,")NOD()
    CAT("\nits power must be substantial too.")NOD()
    CAT("\nLet's give it a try.")NOD()CLR()
    ANP("ProfessorBooster1","magic",0)
    CAT("\nReveal your power to me!")NOD()CLO()
    ANP("ProfessorBooster1","flash")
    WAI(16)
    ANP("ProfessorBooster1","set_target")
    ANP("ProfessorBooster1","BlueRobot2")
    WAI(60)
    ANP("ProfessorBooster1","normal",0)
    WAI(32)
    ANP("ProfessorBooster1","normal",1)
    WAI(32)
    FAC("professorbooster_normal")MS3("Hmm,")NOD()CAT("it seems this is") 
    CAT("\nindeed the real thing.")NOD()
    CAT("\nBut it only transforms targets")
    CAT("\ninto fish...")NOD()
    CAT("\nHow boring,")NOD()
    CAT("\nI'll take it back for") 
    CAT("\nresearch anyway.")NOD()CLO()
    WAI(60)
    SOU("CS_043_computer_beep")
    WAI(16)
    SOU("CS_043_computer_beep")
    WAI(16)
    SOU("CS_043_computer_beep")
    WAI(16)
    ANP("ProfessorBooster1","normal",0)
    WAI(16)
    FAC("professorbooster_normal")MS3("Hm? A call from Kazuma...")NOD()
    CAT("\nPerfect timing,") 
    CAT("\nI need to report my findings anyway.")NOD()CLR()
    ANP("ProfessorBooster1","back",0)
    CAT("\nWhat is it, Kazuma?")NOD()CLO()
    FAO(2)
    FOM()
    TRA("CS_peace_town_divination","KazumaMSG",20,12)
end

function ProfessorBoosterGoGaudiCity()
    KEY()
    SNP("CS_professor_booster_animate",41,18,0,"mainLayer","ProfessorBooster1")
    SNP("CS_bluerobot_animate",44,18,0,"mainLayer","BlueRobot2")
    ANP("BlueRobot2","transform_fish")
    ANP("DefeatedSoapKing1","hide_wand")
    ANP("ProfessorBooster1","show_wand")
    FON("ProfessorBooster1",1)
    CMU("CS_Vivi")
    FAI(2)
    WAI(32)
    FAC("professorbooster_normal")MS3("It seems this wand,")NOD()
    CAT("\nI have no choice but to take it") 
    CAT("\nwith me as a weapon now.")NOD()
    ANP("ProfessorBooster1","magic",0)
    CAT("\nPerhaps this is fate's way")
    CAT("\nof telling me to use magic.")NOD()CLO()
    WAI(32)
    FAO(0)
    FOM()
    SMC(0)SMC(1)
    TRA("CS_fortress_entrance","E0093",4,27)
end