(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "PV")
(use "Obj")
(script 50)


(local
    newAct
    local1
    newProp
    newProp_2
    newProp_3

)
(instance theSelection of Sound
    (properties)
)
(instance public Room50 of Rm
    (properties
        picture 50
        style 16
    )

    (method (init)
        (ogressChaseMusic:init())
        (ogressCatchMusic:init())
        Load(rsVIEW 247)
        Load(rsVIEW 245)
        Load(rsVIEW 48)
        Load(rsVIEW 540)
        Load(rsVIEW 647)
        (self:setRegions(602))
        (super:init())
        (if (global100)
            (send ((View:new())):
                view(647)
                loop(2)
                posn(244 96)
                addToPic()
            )
        )
        (send (= newProp (Prop:new())):
            view(540)
            loop(0)
            cel(1)
            posn(160 87)
            init()
            cycleSpeed(2)
            setCycle(Fwd)
        )
        (send (= newProp_2 (Prop:new())):
            view(540)
            loop(2)
            posn(227 83)
            init()
            setCycle(Fwd)
        )
        (send (= newProp_3 (Prop:new())):
            view(540)
            loop(2)
            posn(266 90)
            init()
            setCycle(Fwd)
        )
        (send (= newAct (Act:new())):setScript(ogressChase))
        (send gEgo:
            posn(77 133)
            view(2)
            setStep(2 1)
            init()
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl(0)) $0040)
            (self:newRoom(49))
        )
    )


    (method (dispose)
        (send gSounds:eachElementDo(172))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('look>'))
                    (if (Said('<under/table'))
                        Print(50 0)
                    )(else
                        (if (Said('/table'))
                            Print(50 1)
                        )(else
                            (if (Said('/stove'))
                                Print(50 2)
                            )(else
                                (if (Said('/window'))
                                    Print(50 3)
                                )(else
                                    (if (Said('/buck'))
                                        Print(50 4)
                                    )(else
                                        (if (Said('/caldron'))
                                            Print(50 5)
                                        )(else
                                            (if (Said('/wall'))
                                                Print(50 6)
                                            )(else
                                                (if (Said('/dirt') or Said('<down'))
                                                    Print(50 7)
                                                )(else
                                                    (if (Said('/giantess'))
                                                        Print(50 8)
                                                    )(else
                                                        (if (Said('[<around,at][/room,cottage,kitchen]'))
                                                            Print(50 9)
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('converse/giantess') or Said('converse[/!*]'))
                        (if (== (ogressChase:state()) 0)
                            Print(50 10)
                            (ogressChase:
                                seconds(0)
                                changeState(2)
                            )
                        )(else
                            Print(50 11)
                        )
                    )(else
                        (if (Said('get,rob/buck'))
                            Print(50 12)
                        )(else
                            (if (Said('kill/giantess'))
                                Print(50 13)
                            )(else
                                (if (Said('get,capture/giantess'))
                                    Print(50 14)
                                )(else
                                    (if (Said('help,,/buck'))
                                        Print(50 15)
                                    )(else
                                        (if (Said('deliver>') and (= gInvSaidMe (send gInv:saidMe())))
                                            (if ((send (= gInvSaidMe (send gInv:saidMe())):ownedBy(gEgo)))
                                                Print(50 16)
                                            )(else
                                                (send pEvent:claimed(1))
                                                Print(50 17)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance ogressChase of Script
    (properties)

    (method (doit)
        (super:doit())
        (if ((< (send gEgo:distanceTo(client)) 25) and (== state 0))
            = seconds 0
            (self:cue())
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send client:
                    view(247)
                    loop(0)
                    posn(173 122)
                    cycleSpeed(3)
                    setCycle(Fwd)
                    init()
                )
 = seconds 5  )
            )
            (case 1
                (Print(50 18) (self:cue())  )
            )
            (case 2
                ((theSelection:
                    number(10)
                    loop(1)
                    play()
                )
 = global167 1 (send newAct:
                    view(245)
                    cycleSpeed(0)
                    illegalBits(0)
                    setCycle(Walk)
                    setAvoider(Avoid)
                    setMotion(Chase gEgo 15 self)
                )
  )
            )
            (case 3
                ((theSelection:
                    number(11)
                    loop(1)
                    play()
                )
 (send gEgo:hide()) (send newAct:
                    view(48)
                    setCycle(Walk)
                    setMotion(MoveTo 173 125 self)
                )
  )
            )
            (case 4
                (Print(50 19 134 -1 20) = seconds 5  )
            )
            (case 5
                (= global127 1 )
            )
        )
    )

)
(instance ogressChaseMusic of Sound
    (properties
        number 10
    )
)
(instance ogressCatchMusic of Sound
    (properties
        number 11
    )
)
(instance playMusic of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (
                (switch (theSelection)
                    (case 10
                        ((ogressChaseMusic:
                            loop(1)
                            play(self)
                        )
  )
                    )
                    (case 11
                        ((ogressCatchMusic:
                            loop(1)
                            play(self)
                        )
 )
                    )
                )
  )
            )
            (case 1
                (
                (if (<> theSelection 11)
                    = state -1
                    (self:cue())
                )
 )
            )
        )
    )

)
