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



(instance hissing of Sound
    (properties)
)
(instance aSnake of Act
    (properties)
)
(instance tongue of Prop
    (properties)
)
(instance snakeSound of Sound
    (properties)
)
(instance public Room53 of Rm
    (properties
        picture 53
    )

    (method (init)
        = north gNorth
        = global109 0
        Load(132 36)
        Load(132 37)
        Load(132 88)
        Load(132 89)
        (self:setRegions(501))
        (super:init())
        proc0_1()
        (send gLongSong:stop())
        (User:
            canControl(0)
            canInput(1)
        )
        (send gEgo:
            posn(155 95)
            view(0)
            init()
            setMotion(MoveTo 155 105)
        )
        (aSnake:
            view(77)
            posn(-40 150)
            setPri(14)
            setLoop(0)
            cel(0)
            setStep(4 3)
            ignoreActors(1)
            ignoreHorizon()
            illegalBits(0)
            init()
        )
        (aSnake:setScript(snakeActions))
        (send global2:setScript(Actions))
    )


    (method (dispose)
        DisposeScript(991)
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )
        return 
            (if (== (send pEvent:type) 128)
                (if (Said('look>'))
                    (if ((Said('/area') or Said('/around')) or Said('[<around][/!*]'))
                        proc255_0(53 0)
                    )(else
                        (if (Said('/cruncher'))
                            proc255_0(53 1)
                        )(else
                            (if (Said('/snake'))
                                proc255_0(53 2)
                            )
                        )
                    )
                )(else
                    (if (Said('kiss/cruncher'))
                        proc255_0(53 3)
                    )(else
                        (if (Said('attack/cruncher'))
                            proc255_0(53 4)
                        )(else
                            (if (Said('jog'))
                                proc255_0(53 5)
                            )(else
                                (if (Said('feed/cruncher'))
                                    proc255_0(53 6)
                                )(else
                                    (if (Said('converse/cruncher'))
                                        proc255_0(53 7)
                                    )(else
                                        (if (Said('bridle/cruncher'))
                                            proc255_0(53 8)
                                            (send global1:changeScore(-5))
                                        )(else
                                            (if (Said('charm/cruncher'))
                                                proc255_0(53 9)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom newRoomNumber)
        (send gLongSong:
            number(22)
            priority(0)
            loop(-1)
            play()
        )
        proc0_3()
        = global104 0
        (super:newRoom(newRoomNumber))
    )

)
(instance Actions of Script
    (properties)

    (method (changeState)
    )

)
(instance snakeActions of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (<> global11 global13)
            return 
        )
        (if (== state 4)
            (if ((<> (send gEgo:x) 155) or (> (send gEgo:y) 105))
                (User:
                    canControl(0)
                    canInput(1)
                )
                = seconds 0
                (self:changeState(5))
            )(else
                (if ((<= (send gEgo:y) 95) and (== global11 global13))
                    (User:
                        canControl(0)
                        canInput(1)
                    )
                    (self:changeState(10))
                )
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (aSnake:setMotion(MoveTo -22 94 self))
            )
            (case 1
                (aSnake:setMotion(MoveTo -43 55 self))
            )
            (case 2
                (aSnake:setMotion(MoveTo 0 62 self))
            )
            (case 3
                (if (IsObject((send gEgo:mover)))
                    --state
                    = cycles 2
                )(else
                    (self:cue())
                )
            )
            (case 4
                (tongue:
                    view(77)
                    loop(2)
                    posn(133 83)
                    setPri(13)
                    setCycle(Fwd)
                    setScript(hiss)
                    init()
                )
                proc0_3()
                = seconds 12
            )
            (case 5
                proc0_2()
                (hissing:stop())
                (hiss:changeState(3))
                (tongue:
                    setScript(0)
                    dispose()
                )
                (aSnake:setCycle(End self))
                (snakeSound:
                    priority(19)
                    number(89)
                    play()
                )
            )
            (case 6
                (aSnake:cel(0))
                (send global2:horizon(0))
                (send gEgo:
                    view(77)
                    setLoop(3)
                    posn(141 89)
                    ignoreActors()
                    setCycle(Fwd)
                    setStep(1 1)
                    moveSpeed(2)
                    setMotion(MoveTo 126 87)
                )
                = seconds 7
            )
            (case 7
                (send gEgo:
                    setLoop(4)
                    setCel(0)
                    posn(137 88)
                )
                (snakeSound:
                    priority(19)
                    number(88)
                    play()
                )
                (aSnake:cel(1))
                = seconds 1
            )
            (case 8
                (send gEgo:hide())
                (aSnake:cel(0))
                = seconds 3
            )
            (case 9
                proc0_17(901 0 13 19)
            )
            (case 10
                (tongue:dispose())
                (send gEgo:setMotion(MoveTo (send gEgo:x) 70 self))
            )
            (case 11
                (send global2:newRoom(gNorth))
            )
        )
    )

)
(instance hiss of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (hissing:
                    number(37)
                    priority(10)
                    loop(2)
                    play(self)
                )
            )
            (case 1
                = state -1
                = seconds 4
            )
        )
    )

)
