1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#
# (C) Copyright 2001/2002 Kai Sterker <kaisterker@linuxgames.com>
# Part of the Adonthell Project http://adonthell.linuxgames.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY.
#
# See the COPYING file for more details
#
# -- Movement schedule for Erek Stonebreaker
#
# Erek will either be in the parlour or the common room.
# He'll also help the player to get into Bjarn's room.
import adonthell
from schedules.mapcharacters import schedule
import random
def _(message): return message
class erek (schedule.speak):
def __init__ (self, mapcharacterinstance):
self.myself = mapcharacterinstance
# -- make random remarks
self.speech = [_("How could they do that to the Master?"), \
_("This place is so much different from home."), \
_("Who could have taken the gems?")]
self.speech_delay = (20, 40)
schedule.speak.__init__(self)
# -- the coordinates for normal schedule
self.coords = \
[(5, 5, adonthell.STAND_NORTH), \
(10, 6, adonthell.STAND_WEST), \
(5, 3, adonthell.STAND_NORTH), \
(4, 5, adonthell.STAND_SOUTH)]
# -- the coordinates for getting back to common room
self.to_common = \
[(0, 7, adonthell.STAND_WEST), \
(6, 1, adonthell.STAND_NORTH)]
# -- the coordinates for getting back to the 1st floor
self.to_1st = \
[(0, 7, adonthell.STAND_WEST), \
(6, 1, adonthell.STAND_NORTH), \
(12, 1, adonthell.STAND_NORTH), \
(2, 4, adonthell.STAND_SOUTH)]
self.walk_delay = "45t"
if self.myself.get_val ("goto") != 0:
self.myself.set_callback (self.leave_cellar)
else:
self.myself.set_callback (self.goal_reached)
def walk (self):
# -- in common room -> goto parlour
if self.myself.submap () == 1:
self.myself.set_goal (14, 4, adonthell.STAND_EAST)
self.walk_delay = "%it" % random.randrange (36, 108)
# -- in parlour -> goto common room
else:
self.myself.set_goal (0, 4, adonthell.STAND_WEST)
self.walk_delay = "%it" % random.randrange (20, 60)
def goal_reached (self):
# -- reached common room
if self.myself.submap () == 1 and self.myself.posx () == 13:
x, y, dir = self.coords[random.randrange (0, 2)]
self.myself.set_goal (x, y, dir)
# -- reached parlour
elif self.myself.submap () == 2 and self.myself.posx () == 1:
x, y, dir = self.coords[random.randrange (2, 4)]
self.myself.set_goal (x, y, dir)
# -- reached our final destination
else:
self.myself.time_callback (self.walk_delay, self.walk)
# -- leave Bjarn's room
def leave_bjarn (self):
# -- set alternative schedule
self.myself.set_callback (self.leave_cellar)
x, y, dir = self.to_common[0]
self.myself.set_goal (x, y, dir)
self.myself.set_val ("index", 0)
def leave_cellar (self):
index = self.myself.get_val ("index") + 1
goto = self.myself.get_val ("goto")
# -- goto first floor
if goto == 9: coords = self.to_1st
# -- goto common room
else: coords = self.to_common
if index < len (coords):
x, y, dir = coords[index]
self.myself.set_goal (x, y, dir)
self.myself.set_val ("index", index)
# -- arrived
else:
# -- restore normal schedule
self.myself.set_callback (self.goal_reached)
self.myself.set_val ("goto", 0)
if self.myself.submap () == 1:
x, y, dir = self.coords[random.randrange (0, 2)]
self.myself.set_goal (x, y, dir)
else:
self.myself.pause ()
|