(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Obj")
(script 950)



(class Class_950_0
    (properties
        theVerb 0
        userCI 0
        userCC 0
    )

    (method (cue)
        (send client:doVerb(theVerb))
    )

)
(class Feature of Obj
    (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
    )

    (method (init param1)
        (if (paramTotal and param1)
            (self:perform(param1))
        )(else
            (if (gSq4FtrInit)
                (self:perform(gSq4FtrInit))
            )
        )
        (if ((self:respondsTo(8)))
            (send gCast:add(self))
        )(else
            (send gFeatures:add(self))
        )
    )


    (method (dispose)
        (send gFeatures:delete(self))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var temp0)
        (if ((send pEvent:claimed))
            return 1
        )(else
            (if (not description)
                return 0
            )(else
                (if (((== (send pEvent:type) 16384) and (self:onMe(pEvent))) and (self:isNotHidden()))
                    (if ((gIconBar and (== (send pEvent:message) 3)) and gInv)
                        (if ((send gIconBar:curInvIcon))
                            (self:doVerb((send pEvent:message) (send gInv:indexOf((send gIconBar:curInvIcon)))))
                        )
                    )(else
                        (self:doVerb((send pEvent:message)))
                    )
                    (send pEvent:claimed(1))
                )
            )
        )
        return (send pEvent:claimed)
    )


    (method (doVerb param1 param2)
        (send (
        (if (gSq4DoVerbCode)
        )(else
            dftDoVerb
        )
):doit(param1 self rest param2))
    )


    (method (notFacing)
        (var temp0)
        (Class_950_0:
            client(self)
            theVerb(1)
        )
        (send gEgo:
            setMotion(0)
            setHeading(GetAngle((send gEgo:x) (send gEgo:y) x y) Class_950_0)
        )
    )


    (method (facingMe param1)
        (var temp0, temp1)
        = temp0 
            (if (paramTotal)
                param1
            )(else
                gEgo
            )
        = temp1 Abs((- GetAngle((send temp0:x) (send temp0:y) x y) (send temp0:heading)))
        (if (> temp1 180)
            = temp1 (- 360 temp1)
        )
        return 
            (if (<= temp1 sightAngle)
                return 1
            )(else
                (self:notFacing())
                return 0
            )
    )


    (method (isNotHidden)
        return 1
    )


    (method (onMe param1 param2)
        (var temp0, temp1)
        (if (IsObject(param1))
            = temp0 (send param1:x)
            = temp1 (send param1:y)
        )(else
            = temp0 param1
            = temp1 param2
        )
        return 
            (if (IsObject(onMeCheck))
                AvoidPath(temp0 temp1 onMeCheck)
            )(else
                (if ((((<= nsLeft temp0) and (<= temp0 nsRight)) and (<= nsTop temp1)) and (<= temp1 nsBottom))
                    (if (<> onMeCheck 26505)
                        & onMeCheck OnControl(4 temp0 temp1)
                    )(else
                        1
                    )
                )
            )
    )

)
(instance dftDoVerb of Code
    (properties)

    (method (doit param1 param2 param3)
        (var temp0)
        = temp0 (send param2:description)
        (switch (param1)
            (case 1
                (if ((send param2:lookStr))
                    Print((send param2:lookStr))
                )(else
                    proc255_4(950 0 temp0 temp0)
                )
            )
            (case 3
                proc255_4(950 1 (send ((send gInv:at(param3))):description) temp0)
            )
            (case 4
                proc255_4(950 2 temp0)
            )
        )
    )

)
