(version 2)
(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "StopWalk")
(use "DCIcon")
(use "Gauge")
(use "Cycle")
(use "User")
(use "Obj")
(script 997)



(procedure (localproc_0558 param1 param2)
    (if (> paramTotal 1)
        Format((User:inputLineAddr) rest param2)
    )
    (send param1:
        claimed(0)
        type(4)
        message((User:echo))
    )
)


(class MenuBar of Class_255_0
    (properties
        state $0000
    )

    (method (init)
        AddMenu("  " " About KQI`^a: Help`#1 ")
        AddMenu(" File " " Save Game`#5: Restore Game`#7: --!: Restart Game`#9: Quit`^q ")
        AddMenu(" Action " " Duck`#4: Jump`#6: --!: Pause Game`^p: Inventory`^I: Retype`#3 ")
        AddMenu(" Speed " " Change...`^s: --!: Faster`+: Normal`=: Slower`- ")
        AddMenu(" Sound " 
            (if (DoSound(sndSET_SOUND))
                " Volume...`^v: Turn sound Off`#2=1 "
            )(else
                " Volume...`^v: Turn sound On`#2=0 "
            )
)
        SetMenu(258 109 'aid[<!*][/!*]')
        SetMenu(513 109 'save[/game]')
        SetMenu(514 109 'restore[/game]')
        SetMenu(516 109 'restart[/game]')
        SetMenu(517 109 'quit[/game]')
        SetMenu(772 109 'pause[/game]')
        SetMenu(769 109 'duck')
        SetMenu(770 109 'jump[<!*][/!*]')
        SetMenu(773 109 'inventory')
        SetMenu(1028 109 'normal')
    )


    (method (handleEvent pEvent)
        (var temp0, temp1, temp2, temp3[300])
        (switch ((super:handleEvent(pEvent (User:blocks))))
            (case 257
                proc255_0(Format(@temp3 997 0 global28) 30 1 70 180 33 global23 67 -1 20)
                proc255_0(Format(@temp3 997 1) 30 1 70 180 33 global23 67 -1 20)
                proc255_0(Format(@temp3 997 2) 30 1 70 180 33 global23 67 -1 20)
            )
            (case 258
                proc255_0(997 3 33 global23)
            )
            (case 513
                (send gGame:save())
            )
            (case 514
                (send gGame:restore())
            )
            (case 516
                (if (proc255_0(997 4 80 "Restart" 33 0 82 movingIcon 81 "Restart" 1 81 "Oops" 0))
                    (send gGame:restart())
                )
            )
            (case 517
                = global4 proc255_0(997 5 80 "Quit" 33 0 82 movingIcon 81 "Quit" 1 81 "Oops" 0)
            )
            (case 769
                (if (global130)
                    proc255_0(997 6)
                )(else
                    (if (GetMenu(769 113))
                        (send ((send global2:script)):cue())
                    )(else
                        (if ((send global2:script))
                            proc0_22()
                        )(else
                            (if (proc0_12(1))
                                proc255_0(997 7)
                            )(else
                                (send global2:setScript(duckScript))
                            )
                        )
                    )
                )
            )
            (case 770
                (if ((== gNumber 12) or (== gNumber 49))
                    (send pEvent:
                        claimed(0)
                        type(128)
                    )
                    Parse("jump" pEvent)
                    (send global2:handleEvent(pEvent))
                    (if (not (send pEvent:claimed))
                        (send global2:setScript(jumpEgo))
                        (send pEvent:claimed(1))
                    )
                )(else
                    (if (global130)
                        proc255_0(997 8)
                    )(else
                        (if ((send global2:script))
                            proc0_22()
                        )(else
                            (send global2:setScript(jumpEgo))
                        )
                    )
                )
            )
            (case 772
                proc255_0(997 9 80 "This game is paused." 33 0 82 movingIcon 81 "Let's continue." 1)
            )
            (case 773
                (if (<u MemoryInfo(0) 1550)
                    proc255_0(997 10)
                )(else
                    (send gInv:showSelf(gEgo))
                )
            )
            (case 774
                localproc_0558(pEvent)
            )
            (case 1025
                = temp1 6
                = temp1 proc255_3("Speed (1 - 16)?" gNewSpeed)
                (if (<> temp1 -1)
                    (send gGame:setSpeed(proc0_17(16 temp1 1)))
                )
            )
            (case 1027
                (if (> gNewSpeed 1)
                    (send gGame:setSpeed(--gNewSpeed))
                )
            )
            (case 1028
                (send gGame:setSpeed(
                    (switch (global101)
                        (case 0
                            1
                        )
                        (case 1
                            3
                        )
                        (default 
                            5
                        )
                    )
))
            )
            (case 1029
                (if (< gNewSpeed 16)
                    (send gGame:setSpeed(++gNewSpeed))
                )
            )
            (case 1281
                = temp1 (send ((Gauge:new())):
                        description("Use the mouse or right and left arrow keys to set the sound volume.")
                        text("Sound Volume")
                        minimum(0)
                        normal(12)
                        maximum(15)
                        higher("Louder")
                        lower("Softer")
                        doit(DoSound(sndVOLUME))
                    )
                DoSound(sndVOLUME temp1)
                DisposeScript(987)
            )
            (case 1282
                (if (GetMenu(1282 113))
                    DoSound(sndSET_SOUND 0)
                    SetMenu(1282 113 0 110 " Turn sound On")
                )(else
                    DoSound(sndSET_SOUND 1)
                    SetMenu(1282 113 1 110 " Turn sound Off")
                )
            )
        )
    )

)
(instance movingIcon of DCIcon
    (properties
        view 699
        loop 2
    )

    (method (init)
        (super:init())
        (self:cycleSpeed(
            (if (> global101 2)
                10
            )(else
                6
            )
))
    )

)
(instance duckScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canControl(0))
                (send gEgo:
                    view(
                        (if (proc0_12(0))
                            23
                        )(else
                            16
                        )
)
                    cel(0)
                    setCycle(End)
                    setMotion(0)
                )
                SetMenu(769 113 1 110 " Stand" 109 'stand')
            )
            (case 1
                (send gEgo:setCycle(Beg self))
            )
            (case 2
                (send gEgo:
                    view(
                        (if (proc0_12(1))
                            (if (proc0_12(0))
                                38
                            )(else
                                36
                            )
                        )(else
                            (if (proc0_12(0))
                                4
                            )(else
                                0
                            )
                        )
)
                    setCycle(StopWalk 
                        (if (proc0_12(1))
                            (if (proc0_12(0))
                                39
                            )(else
                                37
                            )
                        )(else
                            (if (proc0_12(0))
                                7
                            )(else
                                2
                            )
                        )
)
                    setMotion(0)
                )
                (User:canControl(1))
                SetMenu(769 113 0 110 " Duck" 109 'duck')
                (self:dispose())
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
            )(else
                (if (== (send pEvent:type) 128)
                    (if (Said('stand,(get,get<up)'))
                        (self:changeState(1))
                    )(else
                        (if (Said('duck'))
                            proc255_0(997 11)
                        )(else
                            (if (Said('look,look'))
                                (send pEvent:claimed(0))
                            )(else
                                (if (Said('talk,speak'))
                                    (send pEvent:claimed(0))
                                )(else
                                    proc255_0(997 12)
                                    (send pEvent:claimed(1))
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance jumpEgo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (proc0_12(17))
                    (if (proc0_12(1))
                        proc255_0(997 13)
                    )(else
                        proc255_0(997 14)
                    )
                    proc0_11(1)
                    proc0_11(17)
                    proc0_8(5)
                )
                (send gEgo:
                    view(
                        (if (proc0_12(0))
                            17
                        )(else
                            15
                        )
)
                    setLoop(0)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (send gEgo:setCycle(Beg self))
            )
            (case 2
                (send gEgo:
                    view(
                        (if (proc0_12(1))
                            (if (proc0_12(0))
                                38
                            )(else
                                36
                            )
                        )(else
                            (if (proc0_12(0))
                                4
                            )(else
                                0
                            )
                        )
)
                    setCycle(StopWalk 
                        (if (proc0_12(1))
                            (if (proc0_12(0))
                                39
                            )(else
                                37
                            )
                        )(else
                            (if (proc0_12(0))
                                7
                            )(else
                                2
                            )
                        )
)
                    setMotion(0)
                    setLoop(-1)
                    loop(2)
                )
                proc0_3()
                (self:dispose())
            )
        )
    )

)
