| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import adonthell |
| 16 |
import random |
| 17 |
|
| 18 |
class to_cellar(object): |
| 19 |
|
| 20 |
def __init__ (self, mapcharacterinstance): |
| 21 |
self.myself = mapcharacterinstance |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
self.exits = \ |
| 28 |
[(18, 13, adonthell.STAND_NORTH), \ |
| 29 |
(9, 1, adonthell.STAND_NORTH), \ |
| 30 |
(0, 4, adonthell.STAND_WEST), \ |
| 31 |
(6, 6, adonthell.STAND_SOUTH), \ |
| 32 |
(10, 7, adonthell.STAND_EAST), \ |
| 33 |
(4, 7, adonthell.STAND_SOUTH), \ |
| 34 |
(6, 6, adonthell.STAND_EAST), \ |
| 35 |
(-1, -1, -1), \ |
| 36 |
(7, 3, adonthell.STAND_EAST), \ |
| 37 |
(8, 1, adonthell.STAND_NORTH), \ |
| 38 |
(0, 3, adonthell.STAND_WEST), \ |
| 39 |
(5, 3, adonthell.STAND_EAST), \ |
| 40 |
(5, 1, adonthell.STAND_NORTH), \ |
| 41 |
(5, 1, adonthell.STAND_NORTH), \ |
| 42 |
(4, 1, adonthell.STAND_SOUTH)] |
| 43 |
|
| 44 |
self.myself.set_callback (self.walk) |
| 45 |
|
| 46 |
|
| 47 |
def walk (self): |
| 48 |
x, y, dir = self.exits[self.myself.submap ()] |
| 49 |
|
| 50 |
|
| 51 |
if x == -1: |
| 52 |
self.myself.set_callback (self.goal_reached) |
| 53 |
|
| 54 |
submap = self.myself.mymap ().get_submap (self.myself.submap ()) |
| 55 |
x = random.randint (2, 5) |
| 56 |
y = random.randint (5, 9) |
| 57 |
|
| 58 |
while not submap.get_square (x, y).is_free () or (y == 5 and x > 2): |
| 59 |
x = random.randint (2, 5) |
| 60 |
y = random.randint (5, 9) |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
if x + y < 10: |
| 65 |
if x + 3 > y: dir = adonthell.STAND_SOUTH |
| 66 |
else: dir = adonthell.STAND_EAST |
| 67 |
|
| 68 |
else: |
| 69 |
if y - (x + 3) > 0: dir = adonthell.STAND_NORTH |
| 70 |
else: dir = adonthell.STAND_WEST |
| 71 |
|
| 72 |
if not self.myself.set_goal (x, y, dir): |
| 73 |
self.myself.time_callback ("1t", self.walk) |
| 74 |
|
| 75 |
|
| 76 |
def warp (self): |
| 77 |
x, y, dir = self.exits[self.myself.submap ()] |
| 78 |
self.myself.jump_to (self.myself.submap (), x, y, dir) |
| 79 |
self.myself.time_callback ("1t", self.walk) |
| 80 |
|
| 81 |
|
| 82 |
def goal_reached (self): |
| 83 |
if self.myself.get_name () == adonthell.gamedata_player ().get_name (): |
| 84 |
self.myself.set_schedule ("keyboard_control") |
| 85 |
bjarn = adonthell.gamedata_get_character ("Bjarn Fingolson") |
| 86 |
bjarn.set_dialogue ("dialogues.extro") |
| 87 |
bjarn.pause () |
| 88 |
bjarn.stop_moving () |
| 89 |
bjarn.set_offset (0, 0) |
| 90 |
bjarn.launch_action (self.myself) |
| 91 |
|
| 92 |
else: |
| 93 |
if self.myself.posx () == 1 and self.myself.posy () == 7: |
| 94 |
self.walk () |
| 95 |
else: |
| 96 |
self.myself.pause () |