| 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 erek (schedule.speak): |
| 25 |
|
| 26 |
def __init__ (self, mapcharacterinstance): |
| 27 |
self.myself = mapcharacterinstance |
| 28 |
|
| 29 |
|
| 30 |
self.speech = [_("How could they do that to the Master?"), \ |
| 31 |
_("This place is so much different from home."), \ |
| 32 |
_("Who could have taken the gems?")] |
| 33 |
self.speech_delay = (20, 40) |
| 34 |
schedule.speak.__init__(self) |
| 35 |
|
| 36 |
|
| 37 |
self.coords = \ |
| 38 |
[(5, 5, adonthell.STAND_NORTH), \ |
| 39 |
(10, 6, adonthell.STAND_WEST), \ |
| 40 |
(5, 3, adonthell.STAND_NORTH), \ |
| 41 |
(4, 5, adonthell.STAND_SOUTH)] |
| 42 |
|
| 43 |
|
| 44 |
self.to_common = \ |
| 45 |
[(0, 7, adonthell.STAND_WEST), \ |
| 46 |
(6, 1, adonthell.STAND_NORTH)] |
| 47 |
|
| 48 |
|
| 49 |
self.to_1st = \ |
| 50 |
[(0, 7, adonthell.STAND_WEST), \ |
| 51 |
(6, 1, adonthell.STAND_NORTH), \ |
| 52 |
(12, 1, adonthell.STAND_NORTH), \ |
| 53 |
(2, 4, adonthell.STAND_SOUTH)] |
| 54 |
|
| 55 |
self.walk_delay = "45t" |
| 56 |
|
| 57 |
if self.myself.get_val ("goto") != 0: |
| 58 |
self.myself.set_callback (self.leave_cellar) |
| 59 |
else: |
| 60 |
self.myself.set_callback (self.goal_reached) |
| 61 |
|
| 62 |
def walk (self): |
| 63 |
|
| 64 |
if self.myself.submap () == 1: |
| 65 |
self.myself.set_goal (14, 4, adonthell.STAND_EAST) |
| 66 |
self.walk_delay = "%it" % random.randrange (36, 108) |
| 67 |
|
| 68 |
|
| 69 |
else: |
| 70 |
self.myself.set_goal (0, 4, adonthell.STAND_WEST) |
| 71 |
self.walk_delay = "%it" % random.randrange (20, 60) |
| 72 |
|
| 73 |
def goal_reached (self): |
| 74 |
|
| 75 |
if self.myself.submap () == 1 and self.myself.posx () == 13: |
| 76 |
x, y, dir = self.coords[random.randrange (0, 2)] |
| 77 |
self.myself.set_goal (x, y, dir) |
| 78 |
|
| 79 |
elif self.myself.submap () == 2 and self.myself.posx () == 1: |
| 80 |
x, y, dir = self.coords[random.randrange (2, 4)] |
| 81 |
self.myself.set_goal (x, y, dir) |
| 82 |
|
| 83 |
else: |
| 84 |
self.myself.time_callback (self.walk_delay, self.walk) |
| 85 |
|
| 86 |
|
| 87 |
def leave_bjarn (self): |
| 88 |
|
| 89 |
self.myself.set_callback (self.leave_cellar) |
| 90 |
|
| 91 |
x, y, dir = self.to_common[0] |
| 92 |
self.myself.set_goal (x, y, dir) |
| 93 |
self.myself.set_val ("index", 0) |
| 94 |
|
| 95 |
def leave_cellar (self): |
| 96 |
index = self.myself.get_val ("index") + 1 |
| 97 |
goto = self.myself.get_val ("goto") |
| 98 |
|
| 99 |
|
| 100 |
if goto == 9: coords = self.to_1st |
| 101 |
|
| 102 |
else: coords = self.to_common |
| 103 |
|
| 104 |
if index < len (coords): |
| 105 |
x, y, dir = coords[index] |
| 106 |
self.myself.set_goal (x, y, dir) |
| 107 |
self.myself.set_val ("index", index) |
| 108 |
|
| 109 |
|
| 110 |
else: |
| 111 |
|
| 112 |
self.myself.set_callback (self.goal_reached) |
| 113 |
self.myself.set_val ("goto", 0) |
| 114 |
|
| 115 |
if self.myself.submap () == 1: |
| 116 |
x, y, dir = self.coords[random.randrange (0, 2)] |
| 117 |
self.myself.set_goal (x, y, dir) |
| 118 |
else: |
| 119 |
self.myself.pause () |