/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 86)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "feature")
(use "game")
(use "main")
(use "obj")
(use "wander")
(use "dpath")
(local
spee
shot
dotX
dotY
dyingScript
manX
manY
cor1
cor2
escaped
lefttt
)
/******************************************************************************/
(instance public rm086 of Rm
	(properties
		picture 86
		north 0
		east 0
		south 0
		west 0
	)
	(method (init)
		(super:init())
		(self:setScript(RoomScript))


       = shotsLeft 4
  (aAmmo: init() cel(shotsLeft))
        (aDot: init())
        SetUpEgo()
        (aDude: init() setCycle(Walk) setMotion(Wander) observeControl(ctlBLUE))
        (send gGame: setSpeed(6))
		(send gEgo: init() posn(158 138) view(137))
       (send gTheMusic:
			prevSignal(0)
			stop()
			number(16)
			loop(-1)
			play())
                   Print("Press ENTER to fire weapon.")


	)
)
/******************************************************************************/

(instance RoomScript of Script
	(properties)

 (method (changeState newState)
  = state newState
(switch (state)
    (case 1
(aDot2: init() posn(106 29) setMotion(MoveTo 127 29 RoomScript))
)
(case 2
= colorN 7
(send gEgo: view(0) posn(106 110))
DisposeScript(980)
DisposeScript(983)
(send gRoom: newRoom(127))
)
)
)
 (method(doit)
 (if(aDude:inRect(147 60 177 76))
 = escaped TRUE
 (aDude: hide())
 )

 (if(escaped)
 Wait(50)
    = dyingScript ScriptID(DYING_SCRIPT)
  (send dyingScript:
    caller(3)
    register("Lord Bather escaped. Nicely done!  ....   not!")
  )
  (send gGame:setScript(dyingScript))
 )
(if(not(shot))
= manX (aDude: x)
= manY (aDude: y)
= cor2 (aDude: y)
= cor1 (aDude: x)
+= manX 8
-= manY 10
-= cor1 9
-= cor2 45
= dotX (send gEgo: x)
= dotY (send gEgo: y)
-= dotX 11
-= dotY 66
(aDot: init() posn(dotX dotY))
)
(if(shot)
(if(>= dotX cor1)
(if(<= dotX manX)
(if(>= dotY cor2)
(if(<= dotY manY)
(if(not(killed))
(if(not(escaped))
= killed TRUE
(aDude2: init() posn((aDude: x) (aDude: y)) view(143) loop(0) cel(0) setCycle(End RoomScript))
(aDude: dispose())
))
))))
= shot FALSE
(if(not(killed))
(if(not(lefttt))
= lefttt TRUE
(aDude: ignoreControl(ctlBLUE) ignoreActors())
(aDude: moveSpeed(0) setMotion(DPath
131 87
143 67
165 68
))
))
(if(==(aDot: onControl())ctlRED)
(if(== shotsLeft 4)
+= dotY 10
(aS1: init() posn(dotX dotY))
(send gGame:setSpeed(8))
return
)
(if(== shotsLeft 3)
+= dotY 10
(aS2: init() posn(dotX dotY))
(send gGame:setSpeed(8))
return
)
(if(== shotsLeft 2)
+= dotY 10
(aS3: init() posn(dotX dotY))
(send gGame:setSpeed(8))
return
)
(if(== shotsLeft 1)
+= dotY 10
(aS4: init() posn(dotX dotY))
(send gGame:setSpeed(8))
return
)
(if(== shotsLeft 0)
+= dotY 10
(aS5: init() posn(dotX dotY))
(send gGame:setSpeed(8))

return
)
)

)
)
(method (handleEvent pEvent)
(super:handleEvent(pEvent))
   (if(Said('look>'))
   Print("No time to look anything. This may be your only chance to eliminate Lord Bather.")
   )
   (if(Said('back,leave,(go<back),exit,quit,(close<window)'))
   Print("You can't go back before Lord Bather is eliminated.")
   )
(if( not (send pEvent:claimed) )
(if( (== (send pEvent:type) evKEYBOARD) and (== (send pEvent:message) KEY_RETURN) )
(if(== shotsLeft 0)
Print("You're out of ammo. So just load your game and try again. Hehehe!")
return
)
(if(not(shot))
= shot TRUE
-= shotsLeft 1
  (aAmmo: cel(shotsLeft))
     (send gTheSoundFX:
prevSignal(0)
stop()
number(889)
loop(1)
play())
ShakeScreen(1 ssUPDOWN)
)
)

 )
 )
)
(instance aDot of Act
(properties
view 138
x 1
y 1
))
(instance aDot2 of Act
(properties
view 138
x 1
y 1
))
(instance aS1 of Act
(properties
view 139
priority 15
))
(instance aS2 of Act
(properties
priority 15
view 139
))
(instance aS3 of Act
(properties
view 139
priority 15
))
(instance aS4 of Act
(properties
view 139
priority 15
))
(instance aS5 of Act
(properties
view 139
priority 15
))
(instance aAmmo of Prop
(properties
view 140
x 20
y 180
priority 15
))
(instance aDude of Act
(properties
view 100
x 85
y 81
priority 15
moveSpeed 0
cycleSpeed 0
))
(instance aDude2 of Act
(properties
view 143
x 85
y 81
priority 15
))
//  -- 143 ---
/******************************************************************************/
