(version 2)
(include "sci.sh")
(exports
    0 bazaarR
    1 proc51_1
    2 proc51_2
    3 proc51_3
)
(use "Main")
(use "TargFeature")
(use "Game")
(use "View")
(use "Obj")
(script 51)



(procedure public (proc51_1)
    (var temp0, temp1, temp2, temp3, temp4)
    = temp0 0
    = temp2 999
    = temp4 0
    (while (< temp4 (send gGQg3KDHandler:size))
        (if (((send ((send gGQg3KDHandler:at(temp4))):isKindOf(
            (if (Actor)
            )(else
                TargActor
            )
)) and (<> (= temp1 (send gGQg3KDHandler:at(temp4))) gOwner)) and (< (= temp3 GetDistance((send gOwner:x) (send gOwner:y) (send temp1:x) (send temp1:y))) temp2))
            = temp2 temp3
            = temp0 temp1
        )
        ++temp4
    )
    (send temp0:)
)


(procedure public (proc51_2 param1)
    (var temp0)
    = temp0 (send gInv:at(param1))
    return == (send temp0:realOwner) global2
)


(procedure public (proc51_3 param1 param2 param3)
    (var temp0, temp1, temp2, temp3[40])
    = temp1 (send gInv:at(0))
    = temp0 (+ global410 (* 100 (send temp1:amount)))
    = temp2 (* param2 
        (if (== 100 (send ((send ((send param3:goods)):at(param1))):denomination))
            (* 100 (send ((send ((send param3:goods)):at(param1))):price))
        )(else
            (send ((send ((send param3:goods)):at(param1))):price)
        )
)
    (if (< temp2 global410)
        = global410 (- global410 temp2)
    )(else
        = temp0 (- temp0 temp2)
        (send ((send gInv:at(0))):amount((/ temp0 100)))
        = global410 (% temp0 100)
    )
    (send ((send ((send param3:goods)):at(param1))):quantity((- (send ((send ((send param3:goods)):at(param1))):quantity) param2)))
)


(instance public bazaarR of Rgn
    (properties)

    (method (init param1)
        (if (not global121 and not proc0_6(135))
            (if ((> global120 2650) and not proc0_6(81))
                proc0_5(6)
            )
            (if (proc0_6(81))
                proc0_4(121)
                PalVary(pvPAUSE_RESUME 1)
            )
        )
        (super:init(rest param1))
    )


    (method (doit)
        (if (((proc0_6(6) and not proc0_6(135)) and (> global120 2650)) and not global121)
            proc0_5(6)
        )
    )


    (method (dispose)
        (if (proc0_6(121))
            proc0_5(121)
            PalVary(pvPAUSE_RESUME 0)
        )
        (if (not proc999_5(gNewRoomNumber 230 240 250 260))
            proc0_4(6)
            DisposeScript(51)
        )
    )


    (method (newRoom newRoomNumber)
        (if (not proc0_6(6))
            (if ((((== newRoomNumber 230) or (== newRoomNumber 240)) or (== newRoomNumber 250)) or (== newRoomNumber 260))
                proc0_4(135)
                (send gLongSong:stop())
            )
            proc0_4(6)
        )
    )

)
(class MerchantActor of Actor
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck $6789
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view -1
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        scaleSignal $0000
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        illegalBits $8000
        xLast 0
        yLast 0
        xStep 3
        origStep 770
        moveSpeed 6
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        lastAnswerDay 0
    )

    (method (init param1)
        (super:init(rest param1))
    )


    (method (dispose param1)
        (super:dispose(rest param1))
    )


    (method (newGreeting)
        (var temp0)
    )


    (method (newRumor)
        (var temp0[2])
    )


    (method (newTellResponse)
    )

)
