adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[adonthell-wastesedge-commits] Release_0-3-3 f526fd9 09/50: MADE charact


From: Kai Sterker
Subject: [adonthell-wastesedge-commits] Release_0-3-3 f526fd9 09/50: MADE character speech event-driven
Date: Mon, 25 Jul 2016 18:15:30 +0000 (UTC)

tag: Release_0-3-3
commit f526fd9b8620cb6b627528ef49ab76c941fce996
Author: Kai Sterker <address@hidden>
Commit: Kai Sterker <address@hidden>

    MADE character speech event-driven
---
 scripts/schedules/mapcharacters/alek.py       |   19 ++++-----
 scripts/schedules/mapcharacters/bjarn.py      |   20 ++++-----
 scripts/schedules/mapcharacters/erek.py       |   20 ++++-----
 scripts/schedules/mapcharacters/fellnir.py    |   18 ++++----
 scripts/schedules/mapcharacters/frostbloom.py |   19 ++++-----
 scripts/schedules/mapcharacters/janesta.py    |   16 +++----
 scripts/schedules/mapcharacters/jelom.py      |   19 ++++-----
 scripts/schedules/mapcharacters/lucia.py      |   20 ++++-----
 scripts/schedules/mapcharacters/oliver.py     |   20 ++++-----
 scripts/schedules/mapcharacters/orloth.py     |   17 +++-----
 scripts/schedules/mapcharacters/sarin.py      |   19 ++++-----
 scripts/schedules/mapcharacters/schedule.py   |   55 +++++++++++++++++++++++++
 scripts/schedules/mapcharacters/talan.py      |   16 +++----
 scripts/schedules/mapcharacters/tristan.py    |   17 +++-----
 14 files changed, 142 insertions(+), 153 deletions(-)

diff --git a/scripts/schedules/mapcharacters/alek.py 
b/scripts/schedules/mapcharacters/alek.py
index a3ce374..9167e61 100755
--- a/scripts/schedules/mapcharacters/alek.py
+++ b/scripts/schedules/mapcharacters/alek.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -15,19 +15,23 @@
 #    He'll walk between his table and the bar
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class alek:
+class alek (schedule.speak):
     
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("More Ale!"), \
                        _("I'll cut 'em open like ripe fruits."), \
                        _("They should sort out this business like real men!")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
     def run (self):
         myself = self.myself
 
@@ -61,12 +65,3 @@ class alek:
 
                 myself.set_val ("delay", delay)
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (40, 80) * 25
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/bjarn.py 
b/scripts/schedules/mapcharacters/bjarn.py
index f0af870..f180b5d 100644
--- a/scripts/schedules/mapcharacters/bjarn.py
+++ b/scripts/schedules/mapcharacters/bjarn.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -15,18 +15,23 @@
 #    He'll busy himself in his room
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class bjarn:
+class bjarn (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
+        
+        # -- make random remarks
         self.speech = [_("Ha! A tradesman is an honourable person, they 
say!"), \
                        _("Why don't they just take that Silverhair woman to 
prison!?"), \
                        _("Elves! The head in the sky and the mind full of 
clouds!")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
         self.coords = [(7, 5, adonthell.STAND_WEST), \
                        (2, 4, adonthell.STAND_SOUTH), \
                        (7, 3, adonthell.STAND_NORTH), \
@@ -70,12 +75,3 @@ class bjarn:
 
                 myself.set_val ("delay", delay)
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp <= 0:
-            myself.speak (self.speech[random.randint (0, 2)])
-            delay = random.randint (20, 40) * 40
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/erek.py 
b/scripts/schedules/mapcharacters/erek.py
index e705e09..d69cd0d 100755
--- a/scripts/schedules/mapcharacters/erek.py
+++ b/scripts/schedules/mapcharacters/erek.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -16,19 +16,23 @@
 #    He'll also help the player to get into Bjarn's room.
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class erek:
+class erek (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
 
+        # -- make random remarks
         self.speech = [_("How could they do that to the Master?"), \
                   _("This place is so much different from home."), \
                   _("Who could have taken the gems?")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
         # -- the coordinates for normal schedule
         self.coords = \
             [(5, 5, adonthell.STAND_NORTH), \
@@ -148,13 +152,3 @@ class erek:
                 # -- reached our final destination
                 else:
                     myself.set_val ("todo", 0)
-
-
-        # -- do some random babbling
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 2)])
-            delay = random.randrange (60, 180) * 15
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/fellnir.py 
b/scripts/schedules/mapcharacters/fellnir.py
index 3b873ba..b22a11b 100644
--- a/scripts/schedules/mapcharacters/fellnir.py
+++ b/scripts/schedules/mapcharacters/fellnir.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -15,16 +15,21 @@
 #    He'll busy himself in his room
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class fellnir:
+class fellnir (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
+        
+        # -- make random remarks
         self.speech = [_("Master Orloth should throw out that brute!"), \
                        _("Take equal parts of vitriol, nitre and sal ammoniac 
...")]
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
 
         self.coords = [(2, 5, adonthell.STAND_EAST), \
                        (4, 4, adonthell.STAND_SOUTH), \
@@ -60,12 +65,3 @@ class fellnir:
 
                 myself.set_val ("delay", delay)
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp <= 0:
-            myself.speak (self.speech[random.randrange (0, 2)])
-            delay = random.randrange (20, 40) * 40
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/frostbloom.py 
b/scripts/schedules/mapcharacters/frostbloom.py
index d39d4ff..62eac43 100755
--- a/scripts/schedules/mapcharacters/frostbloom.py
+++ b/scripts/schedules/mapcharacters/frostbloom.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -15,11 +15,12 @@
 #    She just walks around the tree in the yard
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class frostbloom:
+class frostbloom (schedule.speak):
     
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
@@ -30,10 +31,13 @@ class frostbloom:
         self.min_y = 21
         self.max_y = 29
 
+        # -- make random remarks
         self.speech = [_("This tree is so inspiring."), \
                   _("I wonder why everybody seems so excited."), \
                   _("Do you know a creature more lovely than the yeti?")]
-
+        self.speech_delay = (20, 55)
+        schedule.speak.__init__(self)
+        
     def run (self):
         myself = self.myself
         
@@ -65,12 +69,3 @@ class frostbloom:
         elif todo == 2:
             if myself.follow_path () == 1:
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (50, 150) * 20
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/janesta.py 
b/scripts/schedules/mapcharacters/janesta.py
index 03f4616..528bfe7 100644
--- a/scripts/schedules/mapcharacters/janesta.py
+++ b/scripts/schedules/mapcharacters/janesta.py
@@ -15,18 +15,23 @@
 #    She'll busy herself in Silverhair's room
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class janesta:
+class janesta (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
+        
+        # -- make random remarks
         self.speech = [_("Oh, dear. Oh, dear."), \
                        _("What will happen to us if they take the Mistress?"), 
\
                        _("I must do something about this awful room."), \
                        _("Oh, how do they expect us to live decently in a 
place like this?")]
+        self.speech_delay = (25, 45)
+        schedule.speak.__init__(self)
 
         self.coords = [(1, 3, adonthell.STAND_NORTH), \
                        (6, 3, adonthell.STAND_NORTH), \
@@ -62,12 +67,3 @@ class janesta:
 
                 myself.set_val ("delay", delay)
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp <= 0:
-            myself.speak (self.speech[random.randrange (0, 4)])
-            delay = random.randrange (50, 75) * 35
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/jelom.py 
b/scripts/schedules/mapcharacters/jelom.py
index 8fcc96a..dc09984 100644
--- a/scripts/schedules/mapcharacters/jelom.py
+++ b/scripts/schedules/mapcharacters/jelom.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -15,20 +15,24 @@
 #    He guards the door to Lady Silverhair's room
 
 import adonthell
+import schedule
 import random
 
 # -- pygettext support
 def _(message): return message
 
-class jelom:
+class jelom (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("Someone fetch me a drink!"), \
                        _("That'll teach them fancy Elves a lesson!"), \
                        _("Send them to the cursed island, I say!")]
-
+        self.speech_delay = (30, 60)
+        schedule.speak.__init__(self)
+        
     def run (self):
         myself = self.myself
         
@@ -61,12 +65,3 @@ class jelom:
             if myself.follow_path ():
                 myself.set_val ("delay", random.randrange (30, 60) * 20)
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp <= 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (75, 150) * 20
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/lucia.py 
b/scripts/schedules/mapcharacters/lucia.py
index 754d2b1..41fe420 100644
--- a/scripts/schedules/mapcharacters/lucia.py
+++ b/scripts/schedules/mapcharacters/lucia.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Alexandre Courbot <address@hidden>
+#  (C) Copyright 2001/2002 Alexandre Courbot <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -16,19 +16,23 @@
 # complaining about her life.
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class lucia:
+class lucia (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("When can I finally rest a bit?"), \
                        _("I told Orloth this place would bring us nothing but 
trouble!"), \
                        _("This smoke! I'm dying!")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
         self.coords = [(3, 3, adonthell.STAND_NORTH), \
                   (6, 3, adonthell.STAND_EAST)]
 
@@ -71,13 +75,3 @@ class lucia:
                     myself.set_val ("delay", 1000 + random.randrange (0, 2000))
                                     
                 myself.set_val ("todo", 0)
-
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (50, 100) * 20
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/oliver.py 
b/scripts/schedules/mapcharacters/oliver.py
index 8579aaf..61f1a68 100755
--- a/scripts/schedules/mapcharacters/oliver.py
+++ b/scripts/schedules/mapcharacters/oliver.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -16,18 +16,22 @@
 #    When summoned by Orloth, he'll show the player to his room
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class oliver:
+class oliver (schedule.speak):
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("It's so exciting. An Elven Lady, here at Waste's 
Edge!"), \
                   _("I gotta hurry before mother complains again."), \
                   _("Why can't I have a little dog!?")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
         # -- the tiles around Orloth
         self.offsets = [(1,1),(1,-1),(-1,1),(-1,-1),(1,0),(0,1),(-1,0),(0,-1)]
 
@@ -111,13 +115,3 @@ class oliver:
         elif todo == 2:
             if myself.follow_path () == 1:
                 myself.set_val ("todo", 0)
-
-
-        # -- do some random babbling
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (80, 160) * 10
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/orloth.py 
b/scripts/schedules/mapcharacters/orloth.py
index 5f15597..f5353dc 100755
--- a/scripts/schedules/mapcharacters/orloth.py
+++ b/scripts/schedules/mapcharacters/orloth.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -16,18 +16,22 @@
 #    From time to time he'll complain about the grandfather clock
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class orloth:
+class orloth (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("I gotta clean this mug!"), \
                   _("That barrel is leaking."), \
                   _("I hope they'll find the thief!")]
+        self.speech_delay = (25, 60)
+        schedule.speak.__init__(self)
 
         self.coords = [(10, 3, adonthell.STAND_NORTH), \
                   (3, 5, adonthell.STAND_SOUTH), \
@@ -94,15 +98,6 @@ class orloth:
                 myself.set_val ("todo", 0)
 
 
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (50, 150) * 20
-            myself.set_val ("say_something", delay)
-
-
     # -- put/remove something from the table we're standing next to
     def put_object (self, object, update):
         myself = self.myself
diff --git a/scripts/schedules/mapcharacters/sarin.py 
b/scripts/schedules/mapcharacters/sarin.py
index 863c1b2..38db345 100755
--- a/scripts/schedules/mapcharacters/sarin.py
+++ b/scripts/schedules/mapcharacters/sarin.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -17,11 +17,12 @@
 
 from adonthell import WALK_NORTH, WALK_SOUTH, WALK_EAST, WALK_WEST, \
      STAND_NORTH, STAND_SOUTH, STAND_WEST, STAND_EAST
+import schedule 
 import random
 
 def _(message): return message
 
-class sarin:
+class sarin (schedule.speak):
     
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
@@ -32,11 +33,14 @@ class sarin:
         self.min_y = 2
         self.max_y = 6
 
+        # -- make random remarks
         self.speech = [_("Ruffinans, the lot of them!"), \
                        _("How dare they imprison one better than they?"), \
                        _("This is an insult to all of the High Born."), \
                        _("I cannot believe such disrespect. Barbarians!")]
-
+        self.speech_delay = (20, 40)
+        schedule.speak.__init__(self)
+        
     def run (self):
         myself = self.myself
 
@@ -109,12 +113,3 @@ class sarin:
                 myself.set_val ("switch_direction", delay)
 
                 myself.set_val ("todo", 0)
-
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp == 0:
-            myself.speak (self.speech[random.randrange (0, 4)])
-            delay = random.randrange (50, 150) * 15
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/schedule.py 
b/scripts/schedules/mapcharacters/schedule.py
new file mode 100644
index 0000000..df341c0
--- /dev/null
+++ b/scripts/schedules/mapcharacters/schedule.py
@@ -0,0 +1,55 @@
+#
+#  (C) Copyright 2002 Kai Sterker <address@hidden>
+#  Part of the Adonthell Project http://adonthell.linuxgames.com
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License.
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY.
+#
+#  See the COPYING file for more details
+#
+
+# -- various low level schedule base classes
+
+import adonthell
+import random
+import types
+
+# -- let NPC utter random remarks
+#    requires the NPC schedule to have the members 
+#
+#    speech, an array of remarks for the NPC, and 
+#    speech_delay, a tuple with the minimum and maximum delay 
+#        between two remarks
+#
+#    The derived schedule needs to call speak.__init__ (self) after
+#    setting the above values.
+class speak:
+    def __init__ (self):
+        # -- sanity checks
+        if type (self.speech) != types.ListType:
+            print "*** speak::__init__: 'speech' list not found!"
+        if type (self.speech_delay) != types.TupleType:
+            print "*** speak::__init__: 'speech_delay' tuple not found!"
+        if len (self.speech_delay) != 2:
+            print "*** speak::__init__: 'speech_delay' has wrong size!"
+            
+        # -- member initialization
+        self.speech_length = len (self.speech)
+        
+        # -- register first speech
+        delay = "%it" % random.randrange (self.speech_delay[0], 
self.speech_delay[1])
+        self.speak_event = adonthell.time_event (delay)
+        self.speak_event.set_callback (self.speak)
+        adonthell.event_handler_register_event (self.speak_event)
+
+        
+    # -- make remark and set delay for the next one
+    def speak (self):
+        self.myself.speak (self.speech[random.randrange (0, 
self.speech_length)])
+
+        delay = "%it" % random.randrange (self.speech_delay[0], 
self.speech_delay[1])
+        self.speak_event = adonthell.time_event (delay)
+        self.speak_event.set_callback (self.speak)
+        adonthell.event_handler_register_event (self.speak_event)
diff --git a/scripts/schedules/mapcharacters/talan.py 
b/scripts/schedules/mapcharacters/talan.py
index 222a6bf..e27d988 100755
--- a/scripts/schedules/mapcharacters/talan.py
+++ b/scripts/schedules/mapcharacters/talan.py
@@ -1,5 +1,5 @@
 #
-#  (C) Copyright 2001 Kai Sterker <address@hidden>
+#  (C) Copyright 2001/2002 Kai Sterker <address@hidden>
 #  Part of the Adonthell Project http://adonthell.linuxgames.com
 #
 #  This program is free software; you can redistribute it and/or modify
@@ -16,17 +16,21 @@
 
 import adonthell
 import random
+import schedule
 
 def _(message): return message
 
-class talan:
+class talan (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
         
+        # -- make random remarks
         self.speech = [_("Halt! Who goes there?"), \
                        "\"Ai! laurie lantar lassi surinen ...\"", \
                        _("Nobody may pass through the gate!")]
+        self.speech_delay = (30, 60)
+        schedule.speak.__init__(self)
 
     def run (self):
         # Caching this often used variable for faster access
@@ -60,11 +64,3 @@ class talan:
             if myself.follow_path ():
                 myself.set_val ("delay", random.randrange (25, 50) * 20)
                 myself.set_val ("todo", 0)
-
-        # -- utter a random remark
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-        if tmp <= 0:
-            myself.speak (self.speech[random.randrange (0, 3)])
-            delay = random.randrange (50, 150) * 20
-            myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/mapcharacters/tristan.py 
b/scripts/schedules/mapcharacters/tristan.py
index 98f984c..55ca37d 100644
--- a/scripts/schedules/mapcharacters/tristan.py
+++ b/scripts/schedules/mapcharacters/tristan.py
@@ -16,19 +16,22 @@
 
 
 import adonthell
+import schedule
 import random
 
 def _(message): return message
 
-class tristan:
+class tristan (schedule.speak):
 
     def __init__ (self, mapcharacterinstance):
         self.myself = mapcharacterinstance
 
+        # -- make random remarks
         self.speech = [_("Don't they know that I am losing money by the 
hour!?"), \
                        _("What a fuss about a few worthless gems!"), \
                        _("Ye gods! It cannot be that hard to find the thief!")]
-
+        self.speech_delay = (20, 55)
+        schedule.speak.__init__(self)
 
     def run (self):
         myself = self.myself
@@ -74,13 +77,3 @@ class tristan:
                 # -- reached our final destination
                 else:
                     myself.set_val ("todo", 0)
-
-
-        # -- do some random babbling
-        tmp = myself.get_val ("say_something")
-        myself.set_val ("say_something", tmp - 1)
-
-        if tmp == 0:
-            myself.speak (self.speech[random.randint (0, 2)])
-            delay = random.randint (50, 150) * 22
-            myself.set_val ("say_something", delay)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]