| 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 sarin (schedule.speak): |
| 25 |
|
| 26 |
def __init__ (self, mapcharacterinstance): |
| 27 |
self.myself = mapcharacterinstance |
| 28 |
|
| 29 |
|
| 30 |
self.min_x = 1 |
| 31 |
self.max_x = 6 |
| 32 |
self.min_y = 2 |
| 33 |
self.max_y = 6 |
| 34 |
|
| 35 |
self.direction = self.myself.get_val ("direction") |
| 36 |
|
| 37 |
|
| 38 |
self.speech = [_("Ruffians, the lot of them!"), \ |
| 39 |
_("How dare they imprison one better than they?"), \ |
| 40 |
_("This is an insult to all of the High Born."), \ |
| 41 |
_("I cannot believe such disrespect. Barbarians!")] |
| 42 |
self.speech_delay = (20, 40) |
| 43 |
schedule.speak.__init__(self) |
| 44 |
|
| 45 |
self.myself.set_callback (self.goal_reached) |
| 46 |
|
| 47 |
def switch_direction (self): |
| 48 |
|
| 49 |
if self.direction == adonthell.WALK_EAST or self.direction == adonthell.WALK_WEST: |
| 50 |
self.direction = random.randrange (adonthell.WALK_NORTH, adonthell.WALK_SOUTH + 1) |
| 51 |
else: |
| 52 |
self.direction = random.randrange (adonthell.WALK_WEST, adonthell.WALK_EAST + 1) |
| 53 |
|
| 54 |
delay = "%it" % random.randrange (30, 60) |
| 55 |
self.myself.time_callback (delay, self.switch_direction) |
| 56 |
self.walk () |
| 57 |
|
| 58 |
def walk (self): |
| 59 |
|
| 60 |
if self.direction == adonthell.WALK_NORTH: |
| 61 |
goal = (self.myself.posx (), self.min_y, adonthell.STAND_SOUTH, 0, 1) |
| 62 |
elif self.direction == adonthell.WALK_SOUTH: |
| 63 |
goal = (self.myself.posx (), self.max_y, adonthell.STAND_NORTH, 0, -1) |
| 64 |
elif self.direction == adonthell.WALK_EAST: |
| 65 |
goal = (self.max_x, self.myself.posy (), adonthell.STAND_WEST, -1, 0) |
| 66 |
else: |
| 67 |
goal = (self.min_x, self.myself.posy (), adonthell.STAND_EAST, 1, 0) |
| 68 |
|
| 69 |
x, y, d = goal[:3] |
| 70 |
self.direction = d + 4 |
| 71 |
|
| 72 |
while not self.myself.set_goal (x, y, d): |
| 73 |
offx, offy = goal [-2:] |
| 74 |
x = x + offx |
| 75 |
y = y + offy |
| 76 |
|
| 77 |
def goal_reached (self): |
| 78 |
delay = "%it" % random.randrange (3, 6) |
| 79 |
self.myself.time_callback (delay, self.walk) |