Debian Codegraph @

scripts/schedules/mapcharacters/oliver.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 Oliver Redwyne
14 #
15 # He'll walk around in the stable and yard.
16 # When summoned by Orloth, he'll show the player to his room
17
18 import adonthell
19 from schedules.mapcharacters import schedule
20 import random
21
22 def _(message): return message
23
24 class oliver (schedule.speak):
25 def __init__ (self, mapcharacterinstance):
26 self.myself = mapcharacterinstance
27
28 # -- make random remarks
29 self.speech = [_("It's so exciting. An Elven Lady, here at Waste's Edge!"), \
30 _("I gotta hurry before mother complains again."), \
31 _("Why can't I have a little dog!?")]
32 self.speech_delay = (20, 40)
33 schedule.speak.__init__(self)
34
35 # -- the tiles around Orloth
36 self.offsets = [(1,1),(1,-1),(-1,1),(-1,-1),(1,0),(0,1),(-1,0),(0,-1)]
37
38 self.myself.set_callback (self.goal_reached)
39
40 # -- summoned to the common room player to his room
41 def goto_common_room (self):
42 # -- beam directly to common room, as it is faster that way
43 self.myself.jump_to (1, 13, 7, adonthell.STAND_NORTH)
44
45 # -- find a free spot near Orloth and the player
46 orloth = adonthell.gamedata_get_character ("Orloth Redwyne")
47 for (x, y) in self.offsets:
48 x = x + orloth.posx ()
49 y = y + orloth.posy ()
50
51 if self.myself.set_goal (x, y):
52 break
53
54 # -- leave the player's room and goto the barn
55 def goto_barn (self):
56 location = self.myself.submap ()
57
58 # -- Player's room
59 if location == 12:
60 self.myself.set_goal (5, 1)
61
62 # -- First floor
63 elif location == 9:
64 self.myself.set_goal (8, 1)
65
66 # -- Second floor (this shouldn't happen, but it once did ...)
67 elif location == 14:
68 self.myself.set_goal (4, 1)
69
70 # -- Common Room
71 elif location == 1:
72 self.myself.set_goal (13, 8)
73
74 # -- Yard, our final goal (for now)
75 elif location == 0:
76 self.myself.set_goal (25, 15)
77 self.myself.goto_barn = 0
78
79 def goal_reached (self):
80 if self.myself.get_val ("goto_barn") == 1:
81 self.goto_barn ()