| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 55 |
|
| 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 |
|
| 64 |
if self.myself.posx () == 10: |
| 65 |
self.myself.speak (_("That clock is late again!")) |
| 66 |
delay = "%it" % random.randrange (3, 6) |
| 67 |
|
| 68 |
elif self.myself.posx () == 2: |
| 69 |
delay = "%it" % random.randrange (16, 48) |
| 70 |
|
| 71 |
else: |
| 72 |
delay = "3t" |
| 73 |
|
| 74 |
self.myself.time_callback ("1t", self.put_object, (106, 0)) |
| 75 |
|
| 76 |
self.myself.time_callback ("2t", self.put_object, (107, 1)) |
| 77 |
|
| 78 |
self.myself.time_callback (delay, self.walk) |
| 79 |
|
| 80 |
|
| 81 |
def put_object (self, args): |
| 82 |
object, update = args[:] |
| 83 |
|
| 84 |
|
| 85 |
index = self.myself.get_val ("table_num") |
| 86 |
if index > 0: |
| 87 |
|
| 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) |