(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Class_950_0")
(use "User")
(use "Obj")
(script 708)


(local
    local0 = 65535
    UserControls
    local2[4]
    local6[68] = (2602 2683 2728 2739 2774 2804 2899 2963 3000 3039 3071 3224 3277 3286 3346 3394 3453 3487 3545 3582 3659 3730 3788 3900 3949 3960 3967 3988 4071 4125 4145 4182 4223 4230 4369 4464 4556 4623 4698 4804 4832 4956 4992 5034 5118 5157 5237 5264 5325 5430 5604 5629 5669 5740 5797 5841 5908 6051 6088 6129 6172 6213 6761 6853 6937 7074 7121 7219 )
    local74[12] = (99 0 9 18 26 34 41 49 56 61 63 68 )
    local86
    local87
    local88 = 14
    local89[14]
    local103 = 65535
    local104

)
(procedure (localproc_03b2 param1 param2)
    (var temp0, temp1)
    (while ((= temp0 FirstNode((send param1:elements))) and IsObject((= temp1 NodeValue((= temp0 FirstNode((send param1:elements)))))))
        (send param2:add(temp1))
        (send param1:delete(temp1))
    )
)


(procedure (localproc_03ea param1 param2)
    (var temp0, temp1, temp2, temp3, temp4)
    (if (proc999_5(param1 0 5 11 17 23 28 33 38 40 45 49 54 56 62 64 66))
        localproc_0741(param1 param2 local86)
        = temp0 0
    )(else
        TextSize(@local2 local6[param1] 30 140)
        = temp1 (- (+ local86 local2[0]) 3)
        = temp2 (- (+ param2 local2[1]) 3)
        = temp4 (+ local86 local2[2])
        = temp3 (+ param2 local2[3])
        localproc_0693(temp1 temp2 temp4 temp3)
        Display("" 105 30 100 - param2 12 - local86 1)
        = local89[++local103] (send (Clone(bulletFeat)):
                x((- param2 9))
                y((+ local86 2))
                nsLeft((- param2 13))
                nsTop((- local86 1))
                nsRight((- param2 5))
                nsBottom((+ local86 5))
                who(param1)
                whoX(param2)
                whoY(local86)
                yourself()
            )
        (send local89[local103]:init())
        (if (& global163[(/ param1 16)] (>> $8000 (% param1 16)))
            localproc_0741(param1 param2 local86)
        )
        = temp0 2
    )
    TextSize(@local2 local6[param1] 30 140)
    = local86 (+ local86 (+ (+ local2[2] 3) temp0))
)


(procedure (localproc_053a)
    (var temp0, temp1, temp2[2])
    Graph(11 11 0 175 157 3 gBack 15)
    Graph(12 11 0 175 157 1)
    Graph(11 11 160 189 317 3 gBack 15)
    Graph(12 11 160 189 317 1)
    = temp0 0
    (while (< temp0 14)
        (if (IsObject(local89[temp0]))
            (send local89[temp0]:dispose())
        )
        = local89[temp0] 0
        ++temp0
    )
    = local103 -1
    (if (> local87 9)
        Format(@temp2 708 2 local87)
    )(else
        Format(@temp2 708 3 local87)
    )
    Display(@temp2 105 30 103 gBack 100 25 3)
    (if (> local87 8)
        Format(@temp2 708 2 + local87 1)
    )(else
        Format(@temp2 708 3 + local87 1)
    )
    Display(@temp2 105 30 103 gBack 100 310 3)
    = local86 14
    = temp0 local74[local87]
    (while (< temp0 local74[(+ local87 1)])
        localproc_03ea(temp0 14)
        ++temp0
    )
    ++local87
    = local86 14
    = temp0 local74[local87]
    (while (< temp0 local74[(+ local87 1)])
        localproc_03ea(temp0 174)
        ++temp0
    )
)


(procedure (localproc_0693 param1 param2 param3 param4)
    Graph(4 param1 param2 param1 param4 gColor -1 -1)
    Graph(4 param1 param4 param3 param4 gColor -1 -1)
    Graph(4 param3 param2 param3 param4 gColor -1 -1)
    Graph(4 param1 param2 param3 param2 gColor -1 -1)
    Graph(12 param1 param2 + param3 1 + param4 1 1)
)


(procedure (localproc_06fc param1 param2 param3 param4)
    (var temp0, temp1, temp2, temp3)
    = temp0 (send param1:nsTop)
    = temp1 (send param1:nsLeft)
    = temp2 (send param1:nsBottom)
    = temp3 (send param1:nsRight)
    localproc_0693(temp0 temp1 temp2 temp3)
    Display(param4 105 30 100 param2 param3)
)


(procedure (localproc_0741 param1 param2 param3)
    Display(local6[param1] 105 30 106 140 100 param2 param3)
)


(instance public hintBookScript of Script
    (properties)

    (method (doit)
        (if (GameIsRestarting())
            = start 2
            --local87
            (self:init())
        )
        (super:doit())
    )


    (method (dispose)
        (var temp0)
        (send gFeatures:release())
        (send global2:drawPic(register 30))
        = global36 local0
        (if (<> global36 -1)
            DrawPic(global36 30 0 global40)
        )
        = temp0 0
        (while (< temp0 14)
            (if (IsObject(local89[temp0]))
                (send local89[temp0]:dispose())
            )
            = local89[temp0] 0
            ++temp0
        )
        (if (== local104 999)
            localproc_03b2(aList gAddToPics)
            localproc_03b2(fList gFeatures)
            localproc_03b2(cList gCast)
            (send gAddToPics:doit())
        )
        (aList:
            eachElementDo(103)
            eachElementDo(84)
            release()
            dispose()
        )
        (fList:
            eachElementDo(99 fdc)
            release()
            dispose()
        )
        (cList:
            eachElementDo(103)
            eachElementDo(84)
            dispose()
        )
        (User:canControl(UserControls))
        (super:dispose())
    )


    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                = local87 1
                = local86 0
                (send gEgo:setMotion(0))
                = UserControls (User:controls)
                (User:canControl(0))
                = cycles 2
            )
            (case 1
                = register (send global2:picture)
                = local0 global36
                localproc_03b2(gAddToPics aList)
                localproc_03b2(gFeatures fList)
                localproc_03b2(gCast cList)
                (send global2:drawPic(699 30))
                = cycles 2
            )
            (case 2
                (bulletFeat:init())
                = temp1 GetPort()
                Graph(4 0 159 189 159 gColor -1 -1)
                Graph(12 0 159 190 160 1)
                Display(708 0 105 30 100 50 3)
                Display(708 0 105 30 100 200 3)
                Display(708 1 105 30 100 5 3)
                Display(708 1 105 30 100 290 3)
                SetPort(temp1)
                (exitBut:init())
                (nextBut:init())
                (prevBut:init())
                localproc_06fc(exitBut + (exitBut:nsLeft) 1 + (exitBut:nsTop) 2 "exit")
                localproc_06fc(nextBut + (nextBut:nsLeft) 1 + (nextBut:nsTop) 2 "next")
                localproc_06fc(prevBut + (prevBut:nsLeft) 1 + (prevBut:nsTop) 2 "prev")
                localproc_053a()
                (send gGame:setCursor((send ((send gInv:curIcon)):cursor) 1))
            )
            (case 3
                = local104 999
                (self:dispose())
            )
        )
    )

)
(instance fdc of Code
    (properties)

    (method (doit param1)
        (if ((send param1:respondsTo(84)))
            (send param1:
                signal(& (send param1:signal) $ffdf)
                dispose()
                delete()
            )
        )(else
            (send param1:dispose())
        )
    )

)
(instance aList of Collect
    (properties)
)
(instance fList of Collect
    (properties)
)
(instance cList of Collect
    (properties)
)
(instance exitBut of Feature
    (properties
        x 14
        y 183
        nsTop 178
        nsLeft 4
        nsBottom 188
        nsRight 24
        description "exit button"
        sightAngle 180
        lookStr "Press this button to put the hint book away."
    )

    (method (doVerb param1)
        (var temp0)
        (switch (param1)
            (case 2
                = temp0 1
            )
            (case 3
                = temp0 1
            )
            (default 
                (super:doVerb(param1))
            )
        )
        (if (temp0)
            (hintBookScript:cue())
        )
    )

)
(instance prevBut of Feature
    (properties
        x 41
        y 183
        nsTop 178
        nsLeft 29
        nsBottom 188
        nsRight 49
        description "previous page button"
        sightAngle 180
        lookStr "Press this button to turn back one page."
    )

    (method (doVerb param1)
        (var temp0)
        (switch (param1)
            (case 2
                = temp0 1
            )
            (case 3
                = temp0 1
            )
            (default 
                (super:doVerb(param1))
            )
        )
        (if (temp0 and (> local87 3))
            = local87 (- local87 3)
            localproc_053a()
        )
    )

)
(instance nextBut of Feature
    (properties
        x 54
        y 183
        nsTop 178
        nsLeft 54
        nsBottom 188
        nsRight 74
        description "next page button"
        sightAngle 180
        lookStr "Press this button to turn to the next page."
    )

    (method (doVerb param1)
        (var temp0)
        (switch (param1)
            (case 2
                = temp0 1
            )
            (case 3
                = temp0 1
            )
            (default 
                (super:doVerb(param1))
            )
        )
        (if (temp0 and (< local87 10))
            ++local87
            localproc_053a()
        )
    )

)
(class BulletFeat of Feature
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 26505
        actions 26505
        onMeCheck 26505
        lookStr 0
        who 0
        whoX 0
        whoY 0
    )
)
(instance bulletFeat of BulletFeat
    (properties
        description "hint activation button"
        lookStr "Press this with the Reveal-O-Matic Hint Revealer and a hint will be revealed."
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 2
                Print("You'll need the Reveal-O-Matic Hint Revealer.")
            )
            (case 3
                (if (<> param2 9)
                    (super:doVerb(param1 param2))
                )(else
                    (if (> global168 100)
                        Print("Sorry. Your Reveal-O-Matic seems to have exhausted its power supply. You'll have to contact the now defunct supplier for a replacement.")
                    )(else
                        (if (& global163[(/ who 16)] (>> $8000 (% who 16)))
                            0
                        )(else
                            = global163[(/ who 16)] (| global163[(/ who 16)] (>> $8000 (% who 16)))
                            localproc_0741(who whoX whoY)
                            (if (== who 32)
                                Animate((send gCast:elements) 0)
                                Print("Oh, great! Only half the answer showed! It must be a defective hint module.")
                            )
                            ++global168
                        )
                    )
                )
            )
            (default 
                (super:doVerb(param1 param2))
            )
        )
    )

)
