;;; rm13


(script# 13)

(public rm13 0)


					;[logics for room 13 -- rmToilet
					;[	"Leisure Suit Larry in the Land of the Lounge Lizards"
					;[	by Al Lowe
(include rm13.msg)
(include gamedefs.h)
(define _WATER_CYCLE 8)
(define _nearToilet _lf0)
(define _toiletOverflowing _lf2)
(define _doorOpenDone _lf4)
(define _doorCloseDone _lf7)
(define _nearDoor _lf8)
(define _nearSink _lf9)
(define _paperCycling _lf10)
(define _waterY _lv0)
(define _waterCycle _lv1)
(define _toiletTimer _lv2)
(define _pissTimer _lv3)
(define _graffitiCount _lv4)
(define _paperCycles _lv5)
(define	_aDoor	act1)				;object
(define	_aFountain	act2)				;object
(define	_aRing	act3)				;object



(instance rm13 of Room

(method (doit)
(if
(OneSet _initLog)

(Load VIEW _vEgoOnToilet)
(Load VIEW _vToiletOverflowing)
(Load VIEW _vToiletFountain)
(Load VIEW _vToiletDoor)
(Load VIEW _vRing)
(Load VIEW _vEgoDrowning)
(Load SOUND _sPissing)
(Load SOUND _sFart)
(Load PICTURE _currentRoom)
(DrawPic _currentRoom DISSOLVE)

(_aDoor init:)
(_aDoor ignoreHorizon:)
(_aDoor ignoreBlocks:)
(_aDoor ignoreActors:)
(_aDoor posn: (* 2 52) 137)
(_aDoor view: _vToiletDoor)
(= _work (_aDoor lastCel:))
(_aDoor cel: _work)
(_aDoor setPri: 10)
(= _work _DOOR_CYCLE_TIME)
(_aDoor cycleSpeed: _work)
(_aDoor show:)
(_aDoor setCycle: BegLoop _doorCloseDone)
(_aFountain init:)
(_aFountain ignoreHorizon:)
(_aFountain ignoreBlocks:)
(_aFountain ignoreActors:)
(_aFountain posn: (* 2 71) 123)
(_aFountain view: _vToiletFountain)
(_aFountain setPri: 6)
(if
((Inventory at:_iRing) ownedBy: _currentRoom)

(_aRing init:)
(_aRing ignoreBlocks:)
(_aRing ignoreActors:)
(_aRing view: _vRing)
(_aRing setPri: 12)
(_aRing posn: (* 2 101) 116)
(_aRing show:)
(_aRing stopUpd:)
)
(SetFlag _programControl)
(_ego canMove: FALSE)
(_ego posn: (* 2 56) 136)
(_ego show:)
(Refresh)
(return)
					;[	end initLOG
)
(ResetFlag _nearDoor)
(if
(ego inRect: (* 2 50) 132 (* 2 60) 140)

(SetFlag _nearDoor)
)
(ResetFlag _nearSink)
(if
(ego inRect: (* 2 89) 129 (* 2 110) 160)

(SetFlag _nearSink)
)
(ResetFlag _nearToilet)
(if
(ego inRect: (* 2 65) 125 (* 2 84) 131)

(SetFlag _nearToilet)
					;[*****
)
;============ label :handleInput
					;[*****
(if
(NoneSet _haveInput)

;============ goto noInput
)
(if
(or
(Said ' look')
(Said ' look, room')
)

(Print
"You are in Lefty's one and only restroom.
The stench is overpowering, there is
graffiti on the walls, and you doubt
that the sink was clean even when it
was installed. Even roaches can't survive
in this place!"
)
)
(if
(or
(Said ' take, ring')
(Said ' take, ring, from, sink')
(Said ' take, ring, sink')
)

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(if
(not
((Inventory at:_iRing) ownedBy: _currentRoom)
)

(SetFlag _alreadyGotIt)
else
(_aRing startUpd:)
(_aRing hide:)
(ego get: _iRing)
(+= _currentScore 3)
(Print
"Got it!\
\
You briefly consider an attempt to find
the ring's owner, but return to your
normal self and pocket it instead."
)
)
)
)
(if
(or
(Said ' look$in, sink')
(Said ' look, sink')
)

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(if
(not
((Inventory at:_iRing) ownedBy: _currentRoom)
)

(Print
"A small, neatly lettered sign reminds
you:\
\
\"Since we can't clean up after every
customer, please rinse out this sink
when you are finished.\""
)
(Print
"Evidently, you are the first customer
who can read."
)
else
(Print
"Why, look! Some woman removed her diamond
ring to wash her hands, and forgot to
take it with her."
)
)
)
					;[	Handle finding the ring and the graffiti.
)
(if
(Said ' look, wall')

(Inc @_graffitiCount)
(if
(== _graffitiCount 1)

(Print
"%m8Scott me up, Beamie!\""
)
)
(if
(== _graffitiCount 2)

(Print
"%m8Attention arcade game players: please
don't eat the urinal cakes!\""
)
)
(if
(== _graffitiCount 3)

(Print
"%m8It takes leather balls to play rugby!\""
)
)
(if
(> _graffitiCount 3)

(Print
"Say, here's an interesting one:\
\
\"The password is: 'Ken sent me.'\""
)
(if
(NoneSet _knowsPassword)

(SetFlag _knowsPassword)
(+= _currentScore 2)
)
)
)
(if
(Said ' smell, rol')

(Print
"Lefty must be running low on air freshener."
)
					;[	Handle ego dumping.
)
(if
(or
(Said ' get, up')
(Said ' leave')
(Said ' stop, crap')
(Said ' get, paper')
(Said ' use, paper')
(Said ' get, toilet, paper')
(Said ' use, toilet, paper')
(Said ' wipe')
(Said ' wipe, ass')
(Said ' stand, up')
(Said ' stand')
)

(if
(!= _currentStatus _ON_TOILET)

(Print
"NOW??"
)
else
(Print
"Carefully finishing your duties, you
wipe and toss the newspaper behind the
toilet for the next user."
)
(SetFlag _toiletPaperOnShoe)
(= _currentStatus _NORMAL)
(_ego view: _vEgo)
(_ego cycleSpeed: _one)
(_ego forceUpd:)
(_ego canMove: TRUE)
(ResetFlag _programControl)
(ResetFlag _keepCycling)
(= _toiletTimer 0)
(= _paperCycles 0)
(return)
)
)
(if
(and
(== _currentStatus _ON_TOILET)
(NoneSet _haveMatch)
)

(SetFlag _haveMatch)
(Print
"NOW??"
)
)
(if
(or
(Said ' take, crap')
(Said ' sit, toilet')
(Said ' sit, stool')
(Said ' sit, on, toilet')
(Said ' sit, on, stool')
(Said ' go, toilet')
(Said ' use, toilet')
(Said ' sit')
(Said ' crap')
)

(if
(!= _currentStatus _NORMAL)

(Print
"NOW??"
)
else
(if
(NoneSet _nearToilet)

(SetFlag _notCloseEnough)
else
(= _currentStatus _ON_TOILET)
(_ego view: _vEgoOnToilet)
(_ego posn: (* 2 72) 126)
(SetFlag _programControl)
(SetFlag _keepCycling)
(_ego canMove: FALSE)
(_ego forceUpd:)
(Print
"You grab an ancient copy of the \"Ball
Street Journal,\" and settle in to \"sit
and think!\""
)
(= _toiletTimer 14)
(= _paperCycles 3)
(if
(NoneSet _poopedInCan)

(SetFlag _poopedInCan)
(+= _currentScore 1)
)
(return)
)
)
)
(if
(or
(Said ' drink, water, rol')
(Said ' get, drink, rol')
)

(Print
"No one would drink from ANY fixture in
here!"
)
)
(if
(or
(Said ' turn, on, water')
(Said ' turn, water, on, sink')
(Said ' turn, on, sink')
(Said ' turn, on, water, sink')
(Said ' wash, hands, rol')
)

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(Print
"Ok."
)
(Print
"Say, there's no soap."
)
(Print
"There's no towels."
)
(Print
"Your hands are still dirty, but now they're
wet!"
)
)
)
(if
(Said ' wash, face, rol')

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(Print
"Ok."
)
(Print
"Say, there's no soap."
)
(Print
"There's no towels."
)
(Print
"Your face is still dirty, but at least
it's now dripping with water."
)
)
)
(if
(or
(Said ' dry, rol')
(Said ' shake, rol')
(Said ' wipe, face, rol')
(Said ' wipe, hands, rol')
(Said ' wipe, my, face, rol')
(Said ' wipe, my, hands, rol')
)

(Print
"Ok. You're dry (but your keyboard is
still damp)!"
)
)
(if
(or
(Said ' rinse, sink')
(Said ' rinse, out, sink')
)

(Print
"It's nice of you to try, but this sink
is too far gone to save!"
)
)
(if
(or
(Said ' piss, rol')
(Said ' go, bathroom, rol')
(Said ' take, piss, rol')
)

(if
(!= _currentStatus _NORMAL)

(Print
"NOW??"
)
else
(if
(NoneSet _nearToilet)

(SetFlag _notCloseEnough)
else
(SetFlag _OK)
(= _currentStatus _PISSING)
(_ego loop: _FACING_BACK)
(_ego posn: (* 2 74) 127)
(_ego forceUpd:)
(SetFlag _programControl)
(_ego canMove: FALSE)
(= _pissTimer 5)
(Sound number: _sPissing, play: _done)
)
)
)
(if
(Said ' throw, up')

(Print
"Been drinking Lefty's liquor again, eh?"
)
)
(if
(or
(Said ' knock, anyword, door')
(Said ' knock, door, anyword')
(Said ' knock, door')
(Said ' knock')
)

(if
(NoneSet _nearDoor)

(SetFlag _notCloseEnough)
else
(Print
"Funny. No one knocks back."
)
)
)
(if
(Said ' open, door')

(if
(NoneSet _nearDoor)

(Print
"Move closer to the handle."
)
else
(_ego canMove: FALSE)
(SetFlag _programControl)
(_aDoor startUpd:)
(_aDoor setCycle: EndLoop _doorOpenDone)
)
)
(if
(or
(Said ' look, mirror')
(Said ' look$in, mirror')
)

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(Print
"You see a handsome, dashing, macho, sexy,
young man. (Obviously, this mirror has
quite a bit of distortion!)"
)
)
)
(if
(or
(Said ' look, behind, mirror')
(Said ' open, mirror')
(Said ' move, mirror')
(Said ' open, cabinet')
)

(if
(NoneSet _nearSink)

(SetFlag _notCloseEnough)
else
(Print
"Nice idea, but the mirror is firmly attached
to the wall."
)
)
)
(if
(or
(Said ' open, toilet, rol')
(Said ' look$in, toilet, tank')
)

(Print
"Yuck!"
)
)
(if
(or
(Said ' look, toilet, paper')
(Said ' get, toilet, paper')
(Said ' use, toilet, paper')
)

(if
(NoneSet _nearToilet)

(SetFlag _notCloseEnough)
else
(Print
"The toilet paper is only there for official
purposes."
)
)
)
(if
(or
(Said ' look$in, toilet')
(Said ' look, toilet')
)

(if
(NoneSet _nearToilet)

(SetFlag _notCloseEnough)
else
(Print
"It's not a pretty sight!"
)
)
					;[	Do the water filling stunt.
)
(if
(or
(Said ' flush, toilet')
(Said ' flush')
)

(if
(NoneSet _nearToilet)

(SetFlag _notCloseEnough)
else
(User canInput: FALSE)
(SetFlag _programControl)
(_ego canMove: FALSE)
(SetFlag _toiletOverflowing)
(= _waterY 148)
(_aFountain show:)
(= _waterCycle _WATER_CYCLE)
(Print
"Realizing your mistake, you quickly jiggle
the handle, attempting to stem the onrushing
tide of water."
)
(Print
"It doesn't work."
)
)
)
(if
(or
(Said ' get, paper')
(Said ' read, paper')
)

(Print
"You only read while \"enthroned.\""
)
)
(if
(and
(ego has: _iMagazine)
(Said ' look, magazine, rol')
)

(Print
"No wonder your eyesight is so bad!"
)
)
(if
(Said ' wipe, hand, on, pants')

(SetFlag _OK)
)
(if
(Said ' anyword, toilet, rol')

(Print
"My, my. Aren't we the little sick-o!"
)
					;[*****
)
;============ label :noInput
					;[*****
(if
(OneSet _aSecondPassed)

(Dec @_toiletTimer)
(if
(== _toiletTimer 6)

(Print
"You feel a great relief!"
)
)
(if
(== _toiletTimer 1)

(Sound number: _sFart, play: _done)
(Print
"What's that aroma?"
)
)
(Dec @_pissTimer)
(if
(== _pissTimer 1)

(Print
"Ahhhhhhh."
)
(= _currentStatus _NORMAL)
(_ego canMove: TRUE)
(ResetFlag _programControl)
)
)
(Dec @_paperCycles)
(if
(== _paperCycles 1)

(ToggleFlag _paperCycling)
(if
(OneSet _paperCycling)

(_ego loop: 1)
					;[	Turn the page.
(_ego cycleSpeed: _one)
(= _paperCycles (Random 7 12))
else
(_ego loop: 0)
					;[	Look at the pages.
(_ego cycleSpeed: _five)
(= _paperCycles (Random 19 33))
)
)
(if
(OneSet _doorCloseDone)

(ResetFlag _doorCloseDone)
(_aDoor stopUpd:)
(ResetFlag _programControl)
(_ego canMove: TRUE)
)
(Dec @_waterCycle)
(if
(== _waterCycle 1)

(if
(and
(OneSet _toiletOverflowing)
(== _waterY 100)
)

(Print
"Your life passes before your eyes."
)
(Print
"You doze briefly."
)
(_ego view: _vEgoDrowning)
(SetFlag _keepCycling)
)
(if
(and
(OneSet _toiletOverflowing)
(== _waterY 40)
)

(Print
"Bad idea, eh Larry?"
)
(SetFlag _certainDeath)
)
(if
(and
(OneSet _toiletOverflowing)
(> _waterY 36)
)

(= _view 59)
(= _loop 0)
(= _cell 0)
(= _x 47)
(= _priority 15)
((= -sysTmp- (PicView new:))
view: _view,
loop: _loop,
cel: _cell,
x: _x,
y: _waterY,
priority: _priority
)
(-sysTmp- doit:)
					;[view, loop, cel,  x,   y, obj priority, box priority
(-= _waterY 4)
(= _waterCycle _WATER_CYCLE)
)
					;[*****
)
;============ label :exit
					;[	test for leaving the room
					;[*****
(if
(OneSet _doorOpenDone)

(ResetFlag _programControl)
(= _newRoom _rmHallway)
)
)
)
