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


(local
    local0
    newProp_5
    local2
    local3
    local4
    local5
    newProp_3
    newProp_4
    local8
    newProp
    newProp_2
    local11[3]

)
(instance public Room24 of Rm
    (properties
        picture 24
    )

    (method (init)
        = north 18
        = south 30
        = west 23
        = east 70
        = horizon 85
        = global101 0
        (if (global100)
            = picture 124
        )
        (send gEgo:edgeHit(0))
        = global205 0
        (super:init())
        (self:setRegions(501 512 511 508))
        Load(rsVIEW 8)
        Load(rsVIEW 680)
        Load(rsVIEW 370)
        Load(rsVIEW 371)
        Load(rsVIEW 372)
        Load(rsVIEW 377)
        = newProp (Prop:new())
        = newProp_2 (Prop:new())
        = newProp_3 (Prop:new())
        (send newProp_3:
            isExtra(1)
            view(651)
            loop(1)
            cel(3)
            posn(272 58)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        = newProp_4 (Prop:new())
        (send newProp_4:
            isExtra(1)
            view(651)
            loop(2)
            cel(2)
            posn(268 95)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (send newProp:
            isExtra(1)
            view(651)
            loop(4)
            cel(2)
            posn(262 146)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (send newProp_2:
            isExtra(1)
            view(651)
            loop(5)
            cel(2)
            posn(249 166)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (switch (gPicture)
            (case north
                ((send gEgo:
                    view(2)
                    x(47)
                    y(+ horizon (+ (send gEgo:yStep()) 1))
                )
  )
            )
            (case west
                ((send gEgo:
                    view(2)
                    x(1)
                )
 
                (if (<= (send gEgo:y()) horizon)
                    (send gEgo:y((+ horizon (+ (send gEgo:yStep()) 1))))
                )
 )
            )
            (case south
                ((send gEgo:
                    view(2)
                    y(188)
                )
 
                (if (> (send gEgo:x()) 214)
                    (send gEgo:x(214))
                )
 )
            )
            (case east
                ((send gEgo:
                    view(8)
                    loop(1)
                    posn(207 160)
                )
  )
            )
            (case 0
                ((send gEgo:
                    x(200)
                    y(188)
                )
 )
            )
        )
        (send gEgo:init())
    )


    (method (doit)
        (super:doit())
        (if (((& (send gEgo:onControl(0)) $0010) and (== (send gEgo:view()) 8)) and (== (send gEgo:script()) 0))
            (send gEgo:setScript(swept))
        )
    )


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


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('look>'))
                    (if (Said('<in/falls'))
                        Print(24 0)
                    )(else
                        (if (Said('<under/pool,water,falls'))
                            (if (<> (send gEgo:view()) 8)
                                Print(24 1)
                            )(else
                                Print(24 2)
                            )
                        )(else
                            (if (Said('<in,in/water,pool'))
                                Print(24 3)
                            )(else
                                (if (Said('<behind/falls'))
                                    Print(24 4)
                                )(else
                                    (if (Said('/falls'))
                                        Print(24 5)
                                    )(else
                                        (if (Said('<in/pool'))
                                            Print(24 6)
                                        )(else
                                            (if (Said('/pool'))
                                                Print(24 7)
                                            )(else
                                                (if (Said('[<around][/room]'))
                                                    Print(24 8)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('enter<behind/falls'))
                        Print(24 9)
                    )(else
                        (if (Said('bathe,dive<under/pool,water,falls'))
                            (if (== (send gEgo:view()) 8)
                                Print(24 10)
                            )(else
                                (if (<> (send gEgo:view()) 2)
                                    Print(24 11)
                                )(else
                                    Print(24 12)
                                )
                            )
                        )(else
                            (if (Said('bathe,dive,wade'))
                                (if (== (send gEgo:view()) 2)
                                    Print(24 13)
                                )(else
                                    (if (== (send gEgo:view()) 8)
                                        Print(24 14)
                                    )(else
                                        Print(24 15)
                                    )
                                )
                            )(else
                                (if (Said('dennis,place/crown'))
                                    (if ((send gEgo:has(10)))
                                        (if (== (send gEgo:view()) 2)
                                            (send gEgo:setScript(egoFrogActions))
                                            (egoFrogActions:changeState(1))
                                            (if (== global200 0)
                                                (send gGame:changeScore(5))
                                                = global200 1
                                            )
                                        )(else
                                            Print(24 16)
                                        )
                                    )(else
                                        proc0_19()
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom param1)
        (send gEgo:viewer(0))
        (super:newRoom(param1))
    )

)
(instance egoFrogActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() (send gEgo:setMotion(0)) (send ((Sound:new())):
                    number(59)
                    play()
                )
 = newProp_5 (Prop:new()) (send newProp_5:
                    posn((send gEgo:x()) (send gEgo:y()))
                    setPri(+ (send gEgo:priority()) 1)
                    view(680)
                    cel(0)
                    loop(0)
                    ignoreActors()
                    setCycle(CT 5 1 self)
                    init()
                )
  )
            )
            (case 2
                ((send newProp_5:setCycle(End self)) (send gEgo:
                    view(370)
                    setCycle(Fwd)
                    setMotion(0)
                )
  )
            )
            (case 3
                ((Timer:setReal(self 3)) (send newProp_5:dispose())  )
            )
            (case 4
                ((send gEgo:
                    view(372)
                    setCycle(Walk)
                    setAvoider(Avoid)
                )
 (send gEgo:viewer(frogViewer)) 
                (if ((send gEgo:inRect(0 84 54 137)) or (send gEgo:inRect(0 84 78 96)))
                    (send gEgo:setMotion(MoveTo 38 (send gEgo:y()) self))
                )(else
                    (if ((send gEgo:inRect(53 95 155 115)))
                        (send gEgo:setMotion(MoveTo 64 (send gEgo:y()) self))
                    )(else
                        (if ((send gEgo:inRect(0 115 229 148)))
                            (send gEgo:setMotion(MoveTo 151 (send gEgo:y()) self))
                        )(else
                            (if ((send gEgo:inRect(0 137 79 168)))
                                (send gEgo:setMotion(MoveTo 63 164 self))
                                (self:changeState(10))
                            )(else
                                (if (> (send gEgo:y()) 171)
                                    (self:changeState(10))
                                )(else
                                    (self:changeState(20))
                                )
                            )
                        )
                    )
                )
 )
            )
            (case 5
                ((send gEgo:setMotion(MoveTo 151 141 self))  )
            )
            (case 6
                ((send gEgo:setMotion(MoveTo 193 166 self))  )
            )
            (case 7
                ((self:changeState(20))  )
            )
            (case 10
                ((send gEgo:setMotion(MoveTo 217 182 self))  )
            )
            (case 11
                ((self:changeState(20))  )
            )
            (case 20
                ((send gEgo:setMotion(MoveTo 223 168 self))  )
            )
            (case 21
                ((send gEgo:hide()) = global205 1 proc0_11() (send global2:newRoom(70)) )
            )
        )
    )

)
(instance frogViewer of Script
    (properties)

    (method (doit)
        (super:doit())
        = local4 (= local3 (send gEgo:onControl(1)))
        (if (& local3 $0001)
            (send gEgo:view(371))
        )(else
            (send gEgo:view(377))
        )
    )

)
(instance swept of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() 
                (if (< (send gEgo:x()) 255)
                    (send gEgo:
                        setLoop(0)
                        xStep(4)
                        setMotion(MoveTo - (send gEgo:x()) 15 (send gEgo:y()) self)
                    )
                )(else
                    (send gEgo:
                        setLoop(3)
                        illegalBits(0)
                        xStep(4)
                        yStep(3)
                        setMotion(MoveTo - (send gEgo:x()) 5 + (send gEgo:y()) 7 self)
                    )
                )
 = local2 (Timer:setReal(self 3))  )
            )
            (case 1
                (
                (if (IsObject(local2))
                    (send local2:
                        dispose()
                        delete()
                    )
                )
 Print(24 17) (send gEgo:
                    xStep(2)
                    yStep(1)
                    illegalBits(32768)
                    setLoop(-1)
                    setScript(0)
                )
 proc0_11() )
            )
        )
    )

)
