(version 2)
(include "sci.sh")
(exports
    0 rm570
)
(use "Main")
(use "FPRoom")
(use "CueObj")
(use "n958")
(use "Timer")
(use "Cycle")
(use "View")
(use "Obj")
(script 570)


(local
    local0

)
(instance public rm570 of FPRoom
    (properties
        noun 9
        picture 570
        style $000a
    )

    (method (init)
        (super:init())
        (send gGameMusic1:
            number(570)
            loop(-1)
            play()
        )
        proc958_0(130 1815)
        (if (proc0_2(60))
            (bleedingEar:
                init()
                setCycle(Fwd)
                cycleSpeed(11)
            )
            (send global2:setScript(sFreddyShotKenny))
        )(else
            (kennyGun:
                init()
                setCycle(Fwd)
            )
            (send global2:setScript(sFreddyDead))
        )
        (kennyBody:
            view(
                (if (proc0_2(60))
                    573
                )(else
                    572
                )
)
            init()
            stopUpd()
        )
        (freddyEyes:
            init()
            stopUpd()
        )
        (freddyMouth:
            init()
            stopUpd()
        )
        (redNeckerchief:
            init()
            stopUpd()
        )
        (body:
            init()
            setOnMeCheck(1 4)
        )
        (hat:
            init()
            setOnMeCheck(1 32)
        )
    )


    (method (dispose)
        (super:dispose())
    )

)
(instance sFreddyShotKenny of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (tNeckerchiefTimer:setReal(tNeckerchiefTimer 30 0))
                = cycles 1
            )
            (case 1
                (send gFpMessager:say(2 0 0 0 self))
            )
            (case 2
                (kennySmiles:
                    init()
                    setCycle(CT 2 1 self)
                )
            )
            (case 3
                (kennySmiles:
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 4
                (kennySmiles:dispose())
                (kennyBody:setCycle(End self))
            )
            (case 5
                (kennyBody:dispose())
                (send gGame:handsOn())
                (send gIconBar:disable(0 3))
                (self:dispose())
            )
        )
    )

)
(instance sFreddyMendsEar of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gTimers:delete(tNeckerchiefTimer))
                (send gEgo:put(38))
                (send gInv:curIcon(0))
                (send gIconBar:disable(5))
                (send gGame:points(10))
                (send gGame:setCursor(996 1))
                = cycles 1
            )
            (case 1
                (send gFpMessager:say(5 59 0 0 self))
            )
            (case 2
                = global119 25
                (send global2:newRoom(260))
                (self:dispose())
            )
        )
    )

)
(instance sFreddyDead of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global120 4
                (send gTimers:delete(tNeckerchiefTimer))
                = seconds 4
            )
            (case 1
                (send gFpMessager:say(13 0 0 0 self))
            )
            (case 2
                (kennySmiles:
                    init()
                    setCycle(CT 2 1 self)
                )
            )
            (case 3
                (kennySmiles:
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 4
                (kennySmiles:dispose())
                (kennyGun:dispose())
                (kennyBody:setCycle(End self))
            )
            (case 5
                (kennyBody:dispose())
                = seconds 3
            )
            (case 6
                (freddyEyes:
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 7
                (freddyMouth:
                    cycleSpeed(12)
                    setCycle(End self)
                )
            )
            (case 8
                (freddyEyes:stopUpd())
                (freddyMouth:stopUpd())
                = seconds 2
            )
            (case 9
                = global122 6
                (send global2:newRoom(99))
                (send gGame:setCursor(0 1))
                (self:dispose())
            )
        )
    )

)
(instance sFreddyDies of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gIconBar:disable())
                (send gGame:setCursor(996 1))
                = cycles 1
            )
            (case 1
                (send gFpMessager:say(1 0 0 0 self))
            )
            (case 2
                (bleedingEar:
                    cycleSpeed(10)
                    setCycle(End)
                )
                (freddyEyes:
                    cycleSpeed(10)
                    setCycle(End self)
                )
            )
            (case 3
                (freddyMouth:
                    cycleSpeed(10)
                    setCycle(End)
                )
                = seconds 3
            )
            (case 4
                (freddyEyes:stopUpd())
                (freddyMouth:stopUpd())
                = cycles 1
            )
            (case 5
                = global122 13
                (send gGame:setCursor(0 1))
                (send global2:newRoom(99))
                (self:dispose())
            )
        )
    )

)
(instance bleedingEar of Prop
    (properties
        x 173
        y 145
        noun 11
        view 570
        loop 3
        cel 4
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 59
                (send global2:setScript(sFreddyMendsEar))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance freddyEyes of Prop
    (properties
        x 185
        y 107
        noun 14
        view 570
    )
)
(instance freddyMouth of Prop
    (properties
        x 145
        y 112
        noun 15
        view 570
        loop 1
    )
)
(instance kennySmiles of Prop
    (properties
        x 151
        y 33
        noun 9
        view 571
        loop 2
    )
)
(instance kennyGun of Prop
    (properties
        x 107
        y 64
        noun 9
        view 571
        loop 3
    )
)
(instance kennyBody of Prop
    (properties
        x 146
        y 17
        noun 8
    )
)
(instance redNeckerchief of Prop
    (properties
        x 108
        y 136
        noun 3
        view 570
        loop 2
    )

    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 4
                (self:hide())
                (send gEgo:get(38 redNeckerchief))
                (send gGame:points(5 149))
                (send gIconBar:
                    curIcon((send gIconBar:useIconItem))
                    curInvIcon((send ((send gInv:at(38))):
                            cursor(92)
                            yourself()
                        )
)
                    enable((send gIconBar:at(5)))
                )
                (send ((send gIconBar:curIcon)):cursor(92))
                (send gGame:setCursor((send ((send gIconBar:at(5))):cursor)))
                (send gIconBar:select((send gIconBar:at(5))))
                (bleedingEar:setCycle(End))
                (self:dispose())
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance body of Feature
    (properties
        x 152
        y 130
        noun 4
    )
)
(instance hat of Feature
    (properties
        x 256
        y 98
        noun 7
    )
)
(instance tNeckerchiefTimer of Timer
    (properties)

    (method (cue)
        (send global2:setScript(sFreddyDies))
    )

)
