/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 124)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(local
over1
yyy
over2
over3
xxx1
nav
cy
dying
)
/******************************************************************************/
(instance public rm124 of Rm
	(properties
		picture 122
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))

		(switch(gPreviousRoomNumber)
			(default
				(send gEgo:
					posn(217 77)
					loop(2)
				)
			)
		)
		SetUpEgo()
		(send gEgo:init())
    (if(== power 1)
    = power 0
     (send gTheMusic:
			prevSignal(0)
			stop()
			number(997)
			loop(0)
			play()
		)
    )
  (aDoor: init()x(-4) y(50))
  (if(woodPlaced)
  (aWood: init())
  )
     (if(not(send gEgo: has(INV_STONE)))
      (aStone: init())
   )
   (if(send gEgo: has(INV_STONE))
    = gTimeSeconds 0
 )
 )
)
/******************************************************************************/
(instance RoomScript of Script
	(properties)
  (method (handleEvent pEvent)
   (super:handleEvent(pEvent))
      (if(Said('take,remove/wood,board'))
   (if(woodPlaced)
   Print("You don't need that wooden board anymore.")
   )
   Print("What? Where?")
   )
   (if(Said('take/water'))
   (if(placedWater)
   Print("You can't take that bottle back even if you wanted. It would probably activate some trap.")
   )
   Print("What water?")
   )
   (if(Said('look>'))
(if(Said('/door,doorway'))
Print("It leads to another room. Another doorway is leading left.")
Print("On closer look on the left door, you discover that it may fell shut on any stronger vibration.")
)
(if(Said('/floor'))
Print("There floor doesn't look interesting.")
)
(if(Said('/stone,(moon<stone)'))
Print("It's probably the Moon Stone. You better pick it up.")
)
(if(Said('/podium,slab'))
(if(send gEgo: has(INV_STONE))
(if(placedWater)
Print("There's a bottle of water on the podium.")
return
)
Print("This podium looks emtpy.")
return
)
Print("On closer look you discover that there's a stone on it. Could it be the Moon Stone?")
)
(if(Said('/wall'))
Print("There are some scratches on the wall. These are not important.")
)
(if(Said('/'))
(if(send gEgo: has(INV_STONE))
Print("This room does look interesting, but you should better get going.")
return
)
Print("You're in some room that looks like the end of the maze. There's something on a podium. A doorway is leading left.")
)
)
   
    (if(Said('use,place/water,bottle,(water<bottle)'))
    (if(==(send gEgo: onControl()) ctlSILVER)
    (if(send gEgo: has(INV_WATER))
    (if(== wc 3)
    = placedWater TRUE
     Print("This is a good idea. Replacing the stone with the water bottle with the same weight might prevent possible threats.")
    += gScore 3
    (aWater: init())
        (send gEgo: put(INV_EMPTY_BOTTLE))
    (send gEgo: put(INV_WATER))
    return
    )
    Print("Could you tell me, why should I do it? At least, at the moment.")
    return
    )
    Print("You don't have water. Just an empty bottle.")
   return
   )
  Print("You're not close enough.")
    )
(if(Said('use,place/wood,board/door') or (if(Said('block/door'))))
(if(==(send gEgo: onControl()) ctlCYAN or ctlYELLOW)
(if(woodPlaced)
Print("It's already in place.")
return
)
(if(not(send gEgo: has(INV_BOARD)))
Print("That would be a great idea, if you had some wood.")
return
)
Print("That's a good idea. When the door may fell shut, it prevents from going all the way down.")
+= gScore 4
(send gEgo: put(INV_BOARD))
= woodPlaced TRUE
  (aWood: init())
return
)
Print("You're too far away from the door.")

      )
      (if(Said('use,place/wood,board'))
Print("Yeah. But where?")
)
  (if(Said('replace'))
   (if(==(send gEgo: onControl()) ctlSILVER)
      (if(send gEgo: has(INV_STONE))
      Print("You have already taken the stone. Now just place something else there.")
      return
      )
   = placedWater TRUE
     Print("This is a good idea. Taking the stone and replacing it with the water bottle with the same weight might prevent possible threats.")
    += gScore 7
    (aWater: init())
        (send gEgo: put(INV_EMPTY_BOTTLE))
    (send gEgo: put(INV_WATER))
    return
   )
     Print("You're not close enough.")
  )
    (if(Said('take,use/stone,(moon<stone)'))
   (if(==(send gEgo: onControl()) ctlSILVER)
   (if(send gEgo: has(INV_STONE))
   Print("You already took it.")
   return
   )
   Print("Ok")
   += gScore 4
   (aStone: hide())
   = gTimeSeconds 0
   (send gEgo: get(INV_STONE))
   Print("There's probably some trap that will soon activate without the stone. Try replacing it with something.")
 = wc 3 // some old variable, I can use it again
 return
   )
   Print("You're not close enough.")
    )
   )
 (method(doit)
  (if(==(send gEgo: onControl()) ctlRED)
     = nav FALSE
   = cy FALSE
  (if(== wc 3)
  (if(not(woodPlaced))
   (aDoor: ignoreControl(ctlWHITE) posn(5 106))
   = dying ScriptID(DYING_SCRIPT)
 ProgramControl()
   (send dying:
    caller(3)
    register("Looks like the door fell shut. Maybe next time, try preventing this from happening.")
  )
  (send gGame:setScript(dying))
   )

 ) )

  (if(== gTimeSeconds 5)
   (if(send gEgo: has(INV_STONE))
   (if(not(placedWater))
    (if(not(over1))
  ShakeScreen(9 ssFULL_SHAKE)
  = dying ScriptID(DYING_SCRIPT)
 ProgramControl()
   (send dying:
    caller(3)
    register("The cavern fell in. It's probably because you took the Moon Stone, but didn't replace it with anything.")
  )
  (send gGame:setScript(dying))
 )
 
 
   )
  )
  )
    (if(==(send gEgo: onControl()) ctlYELLOW)
     = nav FALSE
   = cy FALSE
   )
  (if(==(send gEgo: onControl()) ctlCYAN)
  (if(not(cy))
  = cy TRUE
    (if(send gEgo: has(INV_STONE))
  (if(placedWater)
  (send gRoom: newRoom(125))
  return
  )
  Print("You should replace the stone with something to balance the weight.")
  (send gEgo: setMotion(MoveTo 27 125))
  return
  )
  Print("You can't leave without the stone.")
  (send gEgo: setMotion(MoveTo 27 125))
  )
  )
  (if(==(send gEgo: onControl()) ctlBLACK)
   = nav FALSE
   = cy FALSE
  )
  (if(==(send gEgo: onControl()) ctlNAVY)
(send gRoom: newRoom(123))
  )
 )
)
(instance aStone of Prop
(properties
view 108
x 162
y 177
))
(instance aWater of Prop
(properties
view 110
x 162
y 177
))
(instance aDoor of Act
(properties
view 356
x 5
y 106
))
(instance aWood of Act
(properties
view 357
x 10
y 100
))
/******************************************************************************/
