Debian Codegraph @

scripts/schedules/mapcharacters/orloth.py

raw symbols SCIP
1 #
2 # (C) Copyright 2001/2002 Kai Sterker <[email protected]>
3 # Part of the Adonthell Project http://adonthell.linuxgames.com
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY.
9 #
10 # See the COPYING file for more details
11 #
12
13 # -- Movement schedule for Orloth Redwyne
14 #
15 # He'll walk up to a table occasionally and either set or clean it
16 # From time to time he'll complain about the grandfather clock
17
18 import adonthell
19 from schedules.mapcharacters import schedule
20 import random
21
22 def _(message): return message
23
24 class orloth (schedule.speak):
25
26 def __init__ (self, mapcharacterinstance):
27 self.myself = mapcharacterinstance
28
29 # -- make random remarks
30 self.speech = [_("I gotta clean this mug!"), \
31 _("That barrel is leaking."), \
32 _("I hope they'll find the thief!")]
33 self.speech_delay = (25, 60)
34 schedule.speak.__init__(self)
35
36 self.coords = [(10, 3, adonthell.STAND_NORTH), \
37 (3, 5, adonthell.STAND_SOUTH), \
38 (7, 6, adonthell.STAND_EAST), \
39 (12, 3, adonthell.STAND_SOUTH), \
40 (7, 4, adonthell.STAND_WEST), \
41 (3, 7, 0), \
42 (9, 7, 0), \
43 (12, 5, 0), \
44 (6, 5, 0)]
45
46 self.myself.set_callback (self.goal_reached)
47
48 def walk (self):
49 # -- return to bar
50 if self.myself.posx () != 2:
51 self.myself.set_goal (2, 2, adonthell.STAND_SOUTH)
52 self.myself.set_val ("table_num", 0)
53
54 # -- when we are at the bar, then wait a while before
55 # moving again
56 else:
57 index = random.randrange (0, 5)
58 x, y, dir = self.coords[index]
59 self.myself.set_goal (x, y, dir)
60 self.myself.set_val ("table_num", index)
61
62 def goal_reached (self):
63 # -- standing in front of the clock
64 if self.myself.posx () == 10:
65 self.myself.speak (_("That clock is late again!"))
66 delay = "%it" % random.randrange (3, 6)
67 # -- standing at the bar
68 elif self.myself.posx () == 2:
69 delay = "%it" % random.randrange (16, 48)
70 # -- standing at a table
71 else:
72 delay = "3t"
73 # -- put/take first mug
74 self.myself.time_callback ("1t", self.put_object, (106, 0))
75 # -- put/take second mug
76 self.myself.time_callback ("2t", self.put_object, (107, 1))
77
78 self.myself.time_callback (delay, self.walk)
79
80 # -- put/remove something from the table we're standing next to
81 def put_object (self, args):
82 object, update = args[:]
83
84 # -- the table we're next to
85 index = self.myself.get_val ("table_num")
86 if index > 0:
87 # -- see whether table is laid or not
88 key = "table%i_set" % index
89 val = self.myself.get_val (key)
90
91 x, y = self.coords[index+4][:2]
92 if val == 0:
93 adonthell.gamedata_engine ().get_landmap ().put_mapobject (1, x, y, object)
94 if update == 1: self.myself.set_val (key, 1)
95 else:
96 adonthell.gamedata_engine ().get_landmap ().remove_mapobject (1, x, y, object)
97 if update == 1: self.myself.set_val (key, 0)