(version 2)
(include "sci.sh")
(exports
    0 rm075
)
(use "Main")
(use "Class_255_0")
(use "Avoid")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "Feature")
(use "Obj")
(script 75)


(local
    local0
    local1
    local2
    local3
    gEgoX
    gEgoY

)
(instance public rm075 of Rm
    (properties
        picture 75
    )

    (method (init)
        (var temp0[50])
        (User:
            canInput(1)
            canControl(1)
        )
        (self:setRegions(600))
        Load(128 94)
        Load(128 99)
        Load(128 100)
        Load(132 33)
        Load(132 45)
        (super:init())
        (send gLongSong:
            number(50)
            loop(-1)
            priority(0)
            play()
        )
        (send global2:setScript(UpLadder))
    )


    (method (doit)
        (var gEgoOnControl, temp1[50])
        (super:doit())
        (if (local0)
            (self:newRoom(74))
        )
        (if ((((((== (send gEgo:onControl()) 8) or (== (send gEgo:onControl()) 24)) and not (send global2:script)) and (== (send gEgo:x) gEgoX)) and (== (send gEgo:y) gEgoY)) and not local1)
            = local1 1
            (send gEgo:setMotion(MoveTo (+ (send gEgo:x) 20) 229))
        )
        = gEgoX (send gEgo:x)
        = gEgoY (send gEgo:y)
        (if (== (send global2:script) 0)
            = gEgoOnControl (send gEgo:onControl())
            (self:setScript(
                (if (== gEgoOnControl 4)
                    walkGreen
                )(else
                    (if (== gEgoOnControl 8)
                        walkCyan
                    )(else
                        (if (== gEgoOnControl 16)
                            fallRed
                        )(else
                            (if ((== gEgoOnControl 2) or (== gEgoOnControl 66))
                                fallBlue
                            )(else
                                (if ((== gEgoOnControl 40) or (== gEgoOnControl 56))
                                    TopLadder
                                )(else
                                    0
                                )
                            )
                        )
                    )
                )
))
        )
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((<> (send pEvent:type) 128) or (send pEvent:claimed))
            return 
        )
        (if (Said('look>'))
            (if (Said('[/area,around]'))
                (if (global256)
                    proc255_0(75 0)
                )(else
                    proc255_0(75 1)
                )
            )(else
                (if (Said('/down,cavity,edge'))
                    (if (== (send gEgo:onControl()) 64)
                        (if (global256)
                            proc255_0(75 2)
                        )(else
                            proc255_0(75 3)
                        )
                    )(else
                        proc255_0(75 4)
                    )
                )(else
                    (if (Said('/moon,pestulon'))
                        proc255_0(75 5)
                    )(else
                        (if (Said('/ladder'))
                            proc255_0(75 6)
                        )(else
                            (if (Said('/device,building,generator'))
                                (if (not global256)
                                    (if (global170)
                                        proc255_0(75 7)
                                    )(else
                                        proc255_0(75 8)
                                    )
                                )(else
                                    (if (global170)
                                        proc255_0(75 9)
                                    )(else
                                        proc255_0(75 10)
                                    )
                                )
                            )(else
                                (if (Said('/beam'))
                                    (if (not global256)
                                        (if (global170)
                                            proc255_0(75 11)
                                        )(else
                                            proc255_0(75 12)
                                        )
                                    )(else
                                        proc255_0(75 13)
                                    )
                                )(else
                                    (if (Said('/lava'))
                                        proc255_0(75 14)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )(else
            (if (Said('jump,enter,go/generator,cavity'))
                proc255_0(75 15)
            )(else
                (if (Said('(climb[<up]),ladder'))
                    proc255_0(75 16)
                )(else
                    (if (Said('down,descend,(climb[<down])[/ladder]'))
                        (if ((send gEgo:inRect(157 98 183 106)))
                            (send global2:setScript(DownLadder))
                        )(else
                            proc255_0(75 17)
                        )
                    )(else
                        (if (Said('cast,drop/detonator,bomb'))
                            (if (global256)
                                proc0_6()
                            )(else
                                (if (not (send gEgo:has(10)))
                                    proc255_0(75 18)
                                )(else
                                    (if ((== (send gEgo:onControl()) 64) or (== (send gEgo:onControl()) 66))
                                        (send global2:setScript(DropBomb))
                                    )(else
                                        proc255_0(75 19)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (not script)
            (if (global256)
                ++global593
            )
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance UpLadder of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (send gEgo:
                    illegalBits(0)
                    posn(313 219)
                    view(99)
                    setStep(3 2)
                    setLoop(0)
                    setMotion(MoveTo 173 113 self)
                    init()
                )
            )
            (case 1
                (send gEgo:
                    view(0)
                    illegalBits(-32768)
                    posn(169 105)
                    setStep(3 2)
                    setLoop(-1)
                )
                = cycles 2
            )
            (case 2
                (send gEgo:loop(1))
                proc0_3()
                = global159 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance TopLadder of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 173 113 self)
                )
            )
            (case 1
                (send gEgo:
                    view(0)
                    illegalBits(-32768)
                    posn(169 105)
                    setStep(3 2)
                    setLoop(-1)
                )
                = cycles 2
            )
            (case 2
                (send gEgo:loop(1))
                = local2 0
                = local3 1
                proc0_3()
                = global159 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance DownLadder of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 169 105 self)
                )
            )
            (case 1
                (send gEgo:
                    posn(173 113)
                    view(99)
                    setLoop(0)
                    setMotion(MoveTo 313 219 self)
                )
            )
            (case 2
                = local0 1
                (send global2:setScript(0))
                = global159 0
                proc0_3()
            )
        )
    )

)
(instance walkCyan of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (not local2)
                    = local2 1
                    = local3 0
                    = local1 0
                    (send gEgo:
                        view(99)
                        setAvoider(Avoid)
                        setLoop(0)
                    )
                )
                (send global2:setScript(0))
            )
        )
    )

)
(instance walkGreen of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (not local3)
                    = local3 1
                    = local2 0
                    (send gEgo:
                        view(0)
                        setAvoider(0)
                        loop(
                            (switch ((send gEgo:heading))
                                (case 0
                                    3
                                )
                                (case 45
                                    0
                                )
                                (case 90
                                    0
                                )
                                (case 135
                                    0
                                )
                                (case 180
                                    2
                                )
                                (case 225
                                    1
                                )
                                (case 270
                                    1
                                )
                                (case 315
                                    1
                                )
                            )
)
                    )
                )
                proc0_10()
                (send gEgo:setLoop(-1))
                (send global2:setScript(0))
            )
        )
    )

)
(instance fallRed of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (not (send gEgo:mover) and (== (falling:prevSignal) -1))
            (self:changeState(1))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (falling:play())
                (send gEgo:
                    view(99)
                    setLoop(1)
                    setStep(6 12)
                    setCycle(0)
                    posn((send gEgo:x) (send gEgo:y))
                    illegalBits(0)
                )
                (if (> (send gEgo:x) 180)
                    (send gEgo:
                        setStep(12 12)
                        setCel(1)
                        setMotion(MoveTo 340 189)
                    )
                )(else
                    (send gEgo:
                        setCel(0)
                        setMotion(MoveTo + (send gEgo:x) 20 229)
                    )
                )
                (ohnoScript:changeState(0))
            )
            (case 1
                proc0_17(0 0 0 1)
            )
        )
    )

)
(instance fallBlue of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (== (falling:prevSignal) -1)
            (self:changeState(1))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (falling:play())
                (send gEgo:
                    setLoop()
                    setCel()
                    setStep(6 12)
                    setCycle(0)
                    setPri(2)
                    illegalBits(0)
                )
                proc0_10()
                (send gEgo:setMotion(MoveTo (send gEgo:x) 229))
                (ohnoScript:changeState(0))
            )
            (case 1
                proc0_17(0 0 0 1)
            )
        )
    )

)
(instance ohnoScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (OhNo:
                    init()
                    setCycle(End self)
                )
            )
            (case 1
                (OhNo:dispose())
            )
        )
    )

)
(instance DropBomb of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (send gEgo:
                    view(100)
                    setLoop(0)
                    setCel(0)
                )
                (bomb:init())
                (send gEgo:put((= cycles 10)))
            )
            (case 1
                (send gEgo:setCel(1))
                (bomb:setMotion(MoveTo (bomb:x) 150 self))
            )
            (case 2
                (send gEgo:setCel(2))
                (bomb:dispose())
                (blowUp:play())
                (flash:
                    init()
                    setCycle(End self)
                )
            )
            (case 3
                ShakeScreen(20 3)
                (blowUp:play())
                (flash:setCycle(End self))
            )
            (case 4
                ShakeScreen(20 3)
                (send gLongSong:stop())
                proc0_10()
                (send gLongSong:
                    number(71)
                    loop(-1)
                    priority(0)
                    play()
                )
                (if (global170)
                    proc255_0(75 20)
                )(else
                    proc255_0(75 21)
                )
                (send gEgo:
                    view(0)
                    setLoop(-1)
                    setCel(-1)
                    cel(0)
                    loop(1)
                )
                (send global1:changeScore(20))
                = global256 1
                = global257 300
                proc0_3()
                = global159 0
                (send global2:setScript(0))
            )
        )
    )

)
(instance OhNo of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(94)
            setLoop(0)
            setCel(0)
            cycleSpeed(1)
            setPri((send gEgo:priority))
            posn((send gEgo:x) - (send gEgo:y) 50)
            ignoreActors(1)
        )
    )

)
(instance bomb of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(100)
            setLoop(0)
            setCel(3)
            setPri(2)
            posn(- (send gEgo:x) 10 - (send gEgo:y) 21)
            setStep(1 4)
            ignoreControl(1)
            ignoreActors(1)
            illegalBits(0)
        )
    )

)
(instance flash of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(100)
            setLoop(1)
            setCel(0)
            setPri(3)
            posn(82 79)
            ignoreActors(1)
        )
    )

)
(instance falling of Sound
    (properties
        number 45
        priority 1
    )
)
(instance blowUp of Sound
    (properties
        number 33
        priority 1
    )
)
