;;; Sierra Script 1.0 - (do not remove this comment)
(script# 78)
(include sci.sh)
(use Main)
(use Class_255_0)
(use Sound)
(use Jump)
(use Cycle)
(use Game)
(use InvI)
(use User)
(use Feature)
(use Obj)

(public
	Room78 0
)
(synonyms
	(kiss kiss embrace)
	(cobra cobra)
)

(local
	local0
	local1
	[local2 18]
	gEgoViewer
	newAct
	local22
	newProp_3
	newView
	newProp
	newProp_2
	newProp_4
)
(instance gotFruit of Sound
	(properties)
)

(instance theme of Sound
	(properties)
)

(instance charm of Sound
	(properties
		number 55
	)
)

(instance Room78 of Rm
	(properties
		picture 78
	)
	
	(method (init)
		(= east 78)
		(= west 77)
		(= horizon 40)
		(= global101 0)
		(if global100 (= picture 178))
		(super init:)
		(self setRegions: 513)
		(Load rsVIEW 330)
		(Load rsVIEW 69)
		(Load rsVIEW 59)
		(if (gEgo has: 0)
			(Load rsVIEW 888)
			(Load rsVIEW 55)
			(Load rsSOUND 55)
		)
		(if (gEgo has: 22) (Load rsVIEW 21) (Load rsVIEW 515))
		(Load rsSOUND 50)
		(Load rsSOUND 39)
		(Load rsSOUND 40)
		(Load rsVIEW 508)
		(= newProp (Prop new:))
		(= newProp_2 (Prop new:))
		(newProp
			isExtra: 1
			view: 650
			loop: 3
			cel: 1
			posn: 126 87
			setPri: 0
			setCycle: Fwd
			init:
		)
		(newProp_2
			isExtra: 1
			view: 650
			loop: 5
			cel: 0
			posn: 74 142
			setPri: 0
			setCycle: Fwd
			init:
		)
		(= global105 12)
		(switch gPrevRoomNum
			(west
				(gEgo
					view: 2
					loop: 0
					cel: 0
					posn: 3 166
					setCycle: Walk
					setScript: boardActions
				)
			)
			(0
				(gEgo
					view: 2
					loop: 0
					cel: 0
					posn: 3 166
					setCycle: Walk
					setScript: boardActions
				)
			)
		)
		(gEgo view: 2 xStep: 3 yStep: 2 init:)
		(gEgo edgeHit: 0)
		(= [local2 0] 5)
		(= [local2 1] 167)
		(= [local2 2] 27)
		(= [local2 3] 170)
		(= [local2 4] 42)
		(= [local2 5] 167)
		(= [local2 6] 61)
		(= [local2 7] 169)
		(= [local2 8] 79)
		(= [local2 9] 166)
		(= [local2 10] 98)
		(= [local2 11] 169)
		(= [local2 12] 117)
		(= [local2 13] 170)
		(= [local2 14] 124)
		(= [local2 15] 162)
		(if ((Inv at: 25) ownedBy: 78)
			(= newProp_3 (Prop new:))
			(newProp_3
				view: 508
				posn: 187 146
				setLoop: 0
				cycleSpeed: 1
				setPri: 12
				setScript: fruitActions
				init:
			)
		)
		(= newAct (Act new:))
		(newAct
			view: 330
			posn: 196 163
			cel: 0
			setLoop: 0
			setScript: snakeActions
			init:
		)
		(if ((Inv at: 22) ownedBy: 78)
			((= newView (View new:))
				view: 515
				cel: 0
				loop: 0
				ignoreActors:
				setPri: 12
				posn: 121 168
				init:
			)
			(boardActions state: 3)
		)
		(gRoom setScript: jump)
		(= global205 1)
		(User canInput: 1)
	)
	
	(method (dispose)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp temp0)
		(asm
			pushi    #claimed
			pushi    0
			lap      pEvent
			send     4
			bnt      code_038e
			ldi      1
			ret     
code_038e:
			pushi    #type
			pushi    0
			lap      pEvent
			send     4
			push    
			ldi      128
			eq?     
			bnt      code_08e2
			pushi    1
			lofsa    'hop,hop'
			push    
			callk    Said,  2
			bnt      code_0437
			pushi    #x
			pushi    0
			lag      gEgo
			send     4
			push    
			ldi      109
			gt?     
			bnt      code_03c1
			pushi    2
			pushi    78
			pushi    0
			calle    Print,  4
			jmp      code_08e2
code_03c1:
			lsl      local0
			ldi      5
			eq?     
			bnt      code_0418
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    22
			class    Inv
			send     6
			send     6
			bnt      code_0418
			pushi    #inRect
			pushi    4
			pushi    92
			pushi    164
			pushi    109
			pushi    172
			lag      gEgo
			send     12
			bnt      code_040c
			pushi    #loop
			pushi    0
			lag      gEgo
			send     4
			push    
			ldi      1
			ne?     
			bnt      code_040c
			pushi    2
			pushi    78
			pushi    1
			calle    Print,  4
			jmp      code_08e2
code_040c:
			pushi    #changeState
			pushi    1
			pushi    1
			lofsa    jump
			send     6
			jmp      code_08e2
code_0418:
			lsg      global105
			ldi      13
			eq?     
			bnt      code_042b
			pushi    2
			pushi    78
			pushi    2
			calle    Print,  4
			jmp      code_08e2
code_042b:
			pushi    #changeState
			pushi    1
			pushi    1
			lofsa    jump
			send     6
			jmp      code_08e2
code_0437:
			pushi    1
			lofsa    'play/flute'
			push    
			callk    Said,  2
			bnt      code_04c4
			pushi    #view
			pushi    0
			lag      gEgo
			send     4
			push    
			ldi      2
			eq?     
			bnt      code_04b7
			pushi    #has
			pushi    1
			pushi    0
			lag      gEgo
			send     6
			bnt      code_04ab
			pushi    #state
			pushi    0
			lofsa    snakeActions
			send     4
			push    
			ldi      21
			eq?     
			bnt      code_048a
			pushi    #seconds
			pushi    1
			pushi    0
			lofsa    snakeActions
			send     6
			pushi    2
			pushi    78
			pushi    3
			calle    Print,  4
			pushi    #seconds
			pushi    1
			pushi    15
			lofsa    snakeActions
			send     6
			jmp      code_0494
code_048a:
			pushi    #changeState
			pushi    1
			pushi    20
			lofsa    snakeActions
			send     6
code_0494:
			lag      global155
			not     
			bnt      code_08e2
			pushi    #changeScore
			pushi    1
			pushi    4
			lag      gGame
			send     6
			ldi      1
			sag      global155
			jmp      code_08e2
code_04ab:
			pushi    2
			pushi    800
			pushi    2
			calle    Print,  4
			jmp      code_08e2
code_04b7:
			pushi    2
			pushi    800
			pushi    3
			calle    Print,  4
			jmp      code_08e2
code_04c4:
			pushi    1
			lofsa    'get/fruit'
			push    
			callk    Said,  2
			bnt      code_056a
			pushi    #has
			pushi    1
			pushi    25
			lag      gEgo
			send     6
			bnt      code_04e8
			pushi    2
			pushi    78
			pushi    4
			calle    Print,  4
			jmp      code_08e2
code_04e8:
			lsl      local22
			ldi      2
			eq?     
			bnt      code_0563
			pushi    #inRect
			pushi    4
			pushi    171
			pushi    157
			pushi    195
			pushi    167
			lag      gEgo
			send     12
			bnt      code_0563
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_0557
			pushi    2
			pushi    78
			pushi    5
			calle    Print,  4
			pushi    #number
			pushi    1
			pushi    50
			pushi    42
			pushi    0
			lofsa    gotFruit
			send     10
			pushi    #dispose
			pushi    0
			lal      newProp_3
			send     4
			pushi    #moveTo
			pushi    1
			lsg      gEgo
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			pushi    #changeScore
			pushi    1
			pushi    10
			lag      gGame
			send     6
			jmp      code_08e2
code_0557:
			pushi    2
			pushi    78
			pushi    6
			calle    Print,  4
			jmp      code_08e2
code_0563:
			pushi    0
			callb    proc0_13,  0
			jmp      code_08e2
code_056a:
			pushi    1
			lofsa    'get/board'
			push    
			callk    Said,  2
			bnt      code_05e1
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    22
			class    Inv
			send     6
			send     6
			not     
			bnt      code_0596
			pushi    2
			pushi    78
			pushi    7
			calle    Print,  4
			jmp      code_08e2
code_0596:
			pushi    #x
			pushi    0
			lag      gEgo
			send     4
			push    
			ldi      109
			gt?     
			bnt      code_05af
			pushi    2
			pushi    78
			pushi    0
			calle    Print,  4
			jmp      code_08e2
code_05af:
			pushi    #onControl
			pushi    1
			pushi    1
			lag      gEgo
			send     6
			push    
			ldi      1024
			ne?     
			bt       code_05c8
			lsl      local0
			ldi      5
			ne?     
			bnt      code_05d4
code_05c8:
			pushi    2
			pushi    78
			pushi    8
			calle    Print,  4
			jmp      code_08e2
code_05d4:
			pushi    #changeState
			pushi    1
			pushi    10
			lofsa    boardActions
			send     6
			jmp      code_08e2
code_05e1:
			pushi    1
			lofsa    'lay,place/board'
			push    
			callk    Said,  2
			bnt      code_064b
			pushi    #has
			pushi    1
			pushi    22
			lag      gEgo
			send     6
			not     
			bnt      code_0601
			pushi    0
			callb    proc0_17,  0
			jmp      code_08e2
code_0601:
			pushi    #x
			pushi    0
			lag      gEgo
			send     4
			push    
			ldi      109
			gt?     
			bnt      code_061a
			pushi    2
			pushi    78
			pushi    0
			calle    Print,  4
			jmp      code_08e2
code_061a:
			pushi    #onControl
			pushi    1
			pushi    1
			lag      gEgo
			send     6
			push    
			ldi      1024
			ne?     
			bt       code_0633
			lsl      local0
			ldi      5
			ne?     
			bnt      code_063f
code_0633:
			pushi    2
			pushi    78
			pushi    8
			calle    Print,  4
			jmp      code_08e2
code_063f:
			pushi    #changeState
			pushi    1
			pushi    1
			lofsa    boardActions
			send     6
			jmp      code_08e2
code_064b:
			pushi    1
			lofsa    'deliver/*[/cobra]>'
			push    
			callk    Said,  2
			bnt      code_069e
			pushi    #saidMe
			pushi    0
			lag      gInv
			send     4
			sat      temp0
			bnt      code_068a
			pushi    #has
			pushi    1
			pushi    #indexOf
			pushi    1
			push    
			lag      gInv
			send     6
			push    
			lag      gEgo
			send     6
			bnt      code_0683
			pushi    2
			pushi    78
			pushi    9
			calle    Print,  4
			jmp      code_08e2
code_0683:
			pushi    0
			callb    proc0_17,  0
			jmp      code_08e2
code_068a:
			pushi    2
			pushi    78
			pushi    10
			calle    Print,  4
			pushi    #claimed
			pushi    1
			pushi    1
			lap      pEvent
			send     6
			jmp      code_08e2
code_069e:
			pushi    1
			lofsa    'fling/*[/cobra]>'
			push    
			callk    Said,  2
			bnt      code_06e2
			pushi    #saidMe
			pushi    0
			lag      gInv
			send     4
			sat      temp0
			bnt      code_06e2
			pushi    #has
			pushi    1
			pushi    #indexOf
			pushi    1
			lst      temp0
			lag      gInv
			send     6
			push    
			lag      gEgo
			send     6
			bnt      code_06d7
			pushi    2
			pushi    78
			pushi    11
			calle    Print,  4
			jmp      code_08e2
code_06d7:
			pushi    #claimed
			pushi    1
			pushi    0
			lap      pEvent
			send     6
			jmp      code_08e2
code_06e2:
			pushi    1
			lofsa    'look>'
			push    
			callk    Said,  2
			bnt      code_0858
			pushi    1
			lofsa    '/cobra'
			push    
			callk    Said,  2
			bnt      code_073f
			pushi    #state
			pushi    0
			lofsa    snakeActions
			send     4
			push    
			ldi      21
			eq?     
			bnt      code_0713
			pushi    2
			pushi    78
			pushi    12
			calle    Print,  4
			jmp      code_08e2
code_0713:
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_0733
			pushi    2
			pushi    78
			pushi    13
			calle    Print,  4
			jmp      code_08e2
code_0733:
			pushi    2
			pushi    78
			pushi    14
			calle    Print,  4
			jmp      code_08e2
code_073f:
			pushi    1
			lofsa    '/forest'
			push    
			callk    Said,  2
			bnt      code_0776
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_076a
			pushi    2
			pushi    78
			pushi    15
			calle    Print,  4
			jmp      code_08e2
code_076a:
			pushi    2
			pushi    78
			pushi    16
			calle    Print,  4
			jmp      code_08e2
code_0776:
			pushi    1
			lofsa    '/fruit'
			push    
			callk    Said,  2
			bnt      code_07cb
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_07a1
			pushi    2
			pushi    78
			pushi    17
			calle    Print,  4
			jmp      code_08e2
code_07a1:
			pushi    #has
			pushi    1
			pushi    25
			lag      gEgo
			send     6
			bnt      code_07bf
			pushi    #showSelf
			pushi    0
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     4
			jmp      code_08e2
code_07bf:
			pushi    2
			pushi    78
			pushi    18
			calle    Print,  4
			jmp      code_08e2
code_07cb:
			pushi    1
			lofsa    '/island'
			push    
			callk    Said,  2
			bnt      code_0802
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_07f6
			pushi    2
			pushi    78
			pushi    19
			calle    Print,  4
			jmp      code_08e2
code_07f6:
			pushi    2
			pushi    78
			pushi    20
			calle    Print,  4
			jmp      code_08e2
code_0802:
			pushi    1
			lofsa    '/grass,tuft'
			push    
			callk    Said,  2
			bnt      code_0819
			pushi    2
			pushi    78
			pushi    21
			calle    Print,  4
			jmp      code_08e2
code_0819:
			pushi    1
			lofsa    '[<around][/marsh,room]'
			push    
			callk    Said,  2
			bnt      code_08e2
			pushi    1
			pushi    4
			lea      @global228
			push    
			pushi    78
			pushi    22
			pushi    #ownedBy
			pushi    1
			pushi    78
			pushi    #at
			pushi    1
			pushi    25
			class    Inv
			send     6
			send     6
			bnt      code_0849
			lofsa    {A large, glistening fruit hangs from a small branch.}
			jmp      code_084c
code_0849:
			lofsa    {LOOKUP\_ERROR}
code_084c:
			push    
			callk    Format,  8
			push    
			calle    Print,  2
			jmp      code_08e2
code_0858:
			pushi    1
			lofsa    '*[/cobra]>'
			push    
			callk    Said,  2
			bnt      code_08e2
			pushi    1
			lofsa    'converse'
			push    
			callk    Said,  2
			bnt      code_087c
			pushi    2
			pushi    78
			pushi    23
			calle    Print,  4
			ldi      1
			jmp      code_08dd
code_087c:
			pushi    1
			lofsa    'kill'
			push    
			callk    Said,  2
			bnt      code_0895
			pushi    2
			pushi    78
			pushi    24
			calle    Print,  4
			ldi      1
			jmp      code_08dd
code_0895:
			pushi    1
			lofsa    'get,capture/*'
			push    
			callk    Said,  2
			bnt      code_08ae
			pushi    2
			pushi    78
			pushi    25
			calle    Print,  4
			ldi      1
			jmp      code_08dd
code_08ae:
			pushi    1
			lofsa    'kiss'
			push    
			callk    Said,  2
			bnt      code_08c7
			pushi    2
			pushi    78
			pushi    26
			calle    Print,  4
			ldi      1
			jmp      code_08dd
code_08c7:
			pushi    1
			lofsa    'hit/*'
			push    
			callk    Said,  2
			bnt      code_08e2
			pushi    2
			pushi    78
			pushi    27
			calle    Print,  4
			ldi      1
code_08dd:
			bnt      code_08e2
			ldi      1
code_08e2:
			ret     
		)
	)
)

(instance jump of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(if (== (gEgo loop?) 0)
					(++ local0)
					(= local1 (+ local1 2))
				else
					(-- local0)
					(= local1 (- local1 2))
				)
				(if (== local0 -1) (gRoom newRoom: 77) (return))
				(proc0_8)
				(= gEgoViewer (gEgo viewer?))
				(gEgo viewer: 0)
				(gEgo view: 69 cel: 255 setCycle: End self)
			)
			(2
				(gEgo setCycle: CT 1 -1 self)
			)
			(3
				(gEgo xStep: 6 yStep: 4)
				(cond 
					((== (gEgo loop?) 0)
						(gEgo
							setMotion:
								JumpTo
								[local2 local1]
								[local2 (+ (gEgo setLoop: 2 cel: 255 setCycle: End) 1)]
								self
						)
					)
					((== (gEgo loop?) 1)
						(gEgo
							setMotion:
								JumpTo
								[local2 local1]
								[local2 (+ (gEgo setLoop: 3 cel: 255 setCycle: End) 1)]
								self
						)
					)
					((== (gEgo loop?) 2)
						(gEgo viewer: gEgoViewer)
						(gEgo setMotion: JumpTo (gEgo x?) (+ (gEgo y?) 6))
					)
					((== (gEgo loop?) 3)
						(gEgo viewer: gEgoViewer)
						(gEgo setMotion: JumpTo (gEgo x?) (- (gEgo y?) 6))
					)
				)
			)
			(4
				(if (== local0 6) (gEgo viewer: gEgoViewer))
				(if (== (gEgo loop?) 2)
					(gEgo cel: 255 setLoop: -1 loop: 4 setCycle: End self)
				else
					(gEgo cel: 255 setLoop: -1 loop: 5 setCycle: End self)
				)
			)
			(5
				(if (== (gEgo loop?) 4)
					(gEgo view: 2 loop: 0 cel: 0 xStep: 3 yStep: 2)
				else
					(gEgo view: 2 loop: 1 cel: 0 xStep: 3 yStep: 2)
				)
				(proc0_9)
				(gEgo viewer: gEgoViewer)
				(gEgo view: 2 setCycle: Walk)
				(if (and (== local0 5) (== local22 0))
					(snakeActions changeState: 1)
				)
			)
			(10 (Print 78 0))
		)
	)
)

(instance snakeActions of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(if
		(and (== local22 1) (gEgo inRect: 170 157 217 170))
			(= local22 3)
			(snakeActions changeState: 10)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(theme number: 39 play:)
				(newAct setCycle: End self)
			)
			(2
				(newAct setLoop: 1 setCycle: Fwd)
				(= local22 1)
			)
			(10
				(proc0_8)
				(gSounds eachElementDo: #stop 0)
				(theme number: 40 play:)
				(gEgo viewer: 0)
				(if (< (gEgo x?) 194)
					(newAct cel: 255 setLoop: 2 setCycle: End self)
				else
					(newAct cel: 255 setLoop: 3 setCycle: End self)
				)
			)
			(11
				(gEgo
					view: 59
					illegalBits: 0
					ignoreActors:
					cel: 255
					setCycle: End self
				)
			)
			(12
				(Print 78 28)
				(newAct setLoop: 1 setCycle: Fwd)
				(= seconds 5)
			)
			(13 (= global127 1))
			(20
				(= seconds 0)
				(proc0_8)
				(= global105 0)
				(gEgo view: 55 setMotion: 0 loop: 0 setCycle: Fwd)
				((= newProp_4 (Prop new:))
					view: 888
					setPri: (+ (gEgo priority?) 1)
					cycleSpeed: 1
					setCycle: Fwd
					posn: (+ (gEgo x?) 10) (- (gEgo y?) 27)
					init:
				)
				(gSounds eachElementDo: #stop 0)
				(charm play: self)
				(newAct setLoop: 4 setCycle: Fwd)
				(= local22 2)
			)
			(21
				(Print 78 29 67 -1 10)
				(gEgo view: 2 setCycle: Walk)
				(newProp_4 dispose:)
				(= global105 12)
				(= seconds 15)
				(proc0_9)
			)
			(22 (self changeState: 2))
		)
	)
)

(instance boardActions of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(if (== state 3)
			(if
				(gEgo
					inRect: 101 (- (newView y?) 3) 150 (+ (newView y?) 3)
				)
				(= global132 1)
			else
				(= global132 0)
			)
		else
			(= global132 0)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(gEgo view: 21 loop: 0 cel: 255 setCycle: End self)
				(if (not global201)
					(= global201 1)
					(gGame changeScore: 2)
				)
			)
			(2
				(= newView (View new:))
				(newView
					view: 515
					cel: 0
					loop: 0
					ignoreActors:
					setPri: 12
					posn: 121 (gEgo y?)
					init:
				)
				((Inv at: 22) moveTo: 78)
				(gEgo setCycle: Beg self)
			)
			(3
				(gEgo view: 2 setCycle: Walk)
				(proc0_9)
			)
			(10
				(proc0_8)
				(gEgo view: 21 loop: 0 cel: 255 setCycle: End self)
			)
			(11
				(newView dispose:)
				((Inv at: 22) moveTo: gEgo)
				(gEgo setCycle: Beg self)
			)
			(12
				(gEgo view: 2 loop: 1 setCycle: Walk)
				(proc0_9)
			)
		)
	)
)

(instance fruitActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds (Random 2 10)))
			(1
				(newProp_3 cel: 255 setCycle: End self)
			)
			(2
				(newProp_3 cel: 0)
				(self changeState: 0)
			)
		)
	)
)
