adonthell-commits
[Top][All Lists]
Advanced

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

[adonthell-wastesedge-commits] Release_0-3-1 78ff7bc 049/237: More sched


From: Kai Sterker
Subject: [adonthell-wastesedge-commits] Release_0-3-1 78ff7bc 049/237: More schedules converted to the new pathfinding code
Date: Mon, 25 Jul 2016 18:14:56 +0000 (UTC)

tag: Release_0-3-1
commit 78ff7bcbca716fa007b7b6ccf9faef44ef74274d
Author: adondev <adondev>
Commit: adondev <adondev>

    More schedules converted to the new pathfinding code
---
 scripts/schedules/alek.py       |   51 +++++++++--------
 scripts/schedules/erek.py       |  118 +++++++++++++++++++++++----------------
 scripts/schedules/silverhair.py |   77 +++++++++++++------------
 3 files changed, 140 insertions(+), 106 deletions(-)

diff --git a/scripts/schedules/alek.py b/scripts/schedules/alek.py
index e943508..dc778c3 100755
--- a/scripts/schedules/alek.py
+++ b/scripts/schedules/alek.py
@@ -14,44 +14,51 @@
 #
 #    He'll walk between his table and the bar
 
-import schedules
-import random
 
-speech = ["   More Ale!", \
+speech = ["More Ale!", \
           "I'll cut 'em open like ripe fruits.", \
           "They should sort out this business like real men!"]
 
-todo = myself.get_val ("switch_direction")
+todo = myself.get_val ("todo")
 
-# -- calculate a new direction
+# -- waiting
 if todo == 0:
-    # -- the time we stay at the same place
-    delay = random.randint (60, 150) * 20
+    delay = myself.get_val ("delay")
+    # If standing delay expired, move around next time
+    if delay == 0:
+        myself.set_val ("todo", 1)
+    else:
+        myself.set_val ("delay", delay - 1)
 
+# -- engage a new movement
+elif todo == 1:
     # -- walk to table
     if myself.posx () == 1:
-        myself.set_val ("switch_direction", -delay)
-
+        myself.set_goal (12, 5, STAND_NORTH)
     # -- walk to bar
     else:
-        myself.set_val ("switch_direction", delay)
+        myself.set_goal (1, 3, STAND_SOUTH)
+
+    myself.set_val ("todo", 2)
 
-# -- walk to table
-elif todo < 0:
-    myself.set_val ("switch_direction", todo + 1)
-    if schedules.simple_goto_xy (myself, 12, 5) == 1:
-        myself.stand_north ()
+# -- moving
+elif todo == 2:
+    if myself.follow_path () == 1:
+        # -- the time we stay at the same place
+        from random import randint
+        delay = randint (60, 150) * 20
+
+        myself.set_val ("delay", delay)
+        myself.set_val ("todo", 0)
 
-# -- walk to bar
-else:
-    myself.set_val ("switch_direction", todo - 1)
-    if schedules.simple_goto_xy (myself, 1, 3) == 1:
-        myself.stand_south ()
 
 # -- utter a random remark
 tmp = myself.get_val ("say_something")
 myself.set_val ("say_something", tmp - 1)
 if tmp == 0:
-    schedules.speak (myself, speech[random.randint (0, 2)])
-    delay = random.randint (40, 80) * 25
+    from schedules import speak
+    from random import randint
+
+    speak (myself, speech[randint (0, 2)])
+    delay = randint (40, 80) * 25
     myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/erek.py b/scripts/schedules/erek.py
index 434d5a3..c8f4cb5 100755
--- a/scripts/schedules/erek.py
+++ b/scripts/schedules/erek.py
@@ -15,8 +15,6 @@
 #    Erek will either be in the parlour or the common room.
 #    He'll also help the player to get into Bjarn's room.
 
-import schedules
-import random
 
 speech = ["How could they do that to the Master?", \
           "This place is so much different from home.", \
@@ -40,63 +38,89 @@ elif myself.get_val ("leave_bjarn") == 1:
 
     # -- in Bjarn's room
     if submap == 7:
-        schedules.simple_goto_xy (myself, 0, 7)
+        myself.set_goal (0, 7, STAND_WEST)
+        myself.set_val ("leave_bjarn", 2)
 
     # -- in the Cellar
     elif submap == 4:
-        schedules.simple_goto_xy (myself, 6, 1)
+        myself.set_goal (6, 1, STAND_NORTH)
+        myself.set_val ("leave_bjarn", 2)
 
     # -- hopefully in the common room
     else:
+        from random import randint
         myself.set_val ("leave_bjarn", 0)
-        myself.set_val ("goal", random.randint (0, 1))
+        x, y, dir = coords[randint (0, 1)]
+        myself.set_goal (x, y, dir)
+
+    myself.set_val ("todo", 2)
+
 
 # -- "normal" schedule
-else:
-    todo = myself.get_val ("goto_parlour")
+todo = myself.get_val ("todo")
+
+# -- waiting
+if todo == 0:
+    delay = myself.get_val ("delay")
+
+    # If standing delay expired, move around next time
+    if delay == 0:
+        myself.set_val ("todo", 1)
+    else:
+        myself.set_val ("delay", delay - 1)
 
-    # switch places
-    if todo == 0:
+# -- get movement target
+elif todo == 1:
+    # -- on our way back from bjarn's room
+    if myself.get_val ("leave_bjarn") == 2:
+        myself.set_val ("leave_bjarn", 1)
+
+    # -- switch places
+    else:
         # -- in common room -> goto parlour
-        if myself.submap () == 1 \
-        and schedules.simple_goto_xy (myself, 13, 4) == 1:
-            # since simple_goto_xy only returns 1 if the character
-            # completely occupies the tile, but the enter event is
-            # raised before, we have to do the last step manually.
-            myself.go_east ()
-            delay = random.randint (50, 150) * -30
-            myself.set_val ("goto_parlour", delay)
-            myself.set_val ("goal", random.randint (2, 3))
+        if myself.submap () == 1:
+            myself.set_goal (14, 4, STAND_EAST)
 
         # -- in parlour -> goto common room
-        elif schedules.simple_goto_xy (myself, 1, 4) == 1:
-            myself.go_west ()
-            delay = random.randint (50, 150) * 20
-            myself.set_val ("goto_parlour", delay)
-            myself.set_val ("goal", random.randint (0, 1))
+        else:
+            myself.set_goal (0, 4, STAND_WEST)
 
-    # -- walk up to the new pos and stay there
-    else:
-        # -- In parlour
-        if todo < 0:
-            myself.set_val ("goto_parlour", todo + 1)
-        # -- In common room
+    myself.set_val ("todo", 2)
+
+# -- move
+elif todo == 2:
+    if myself.follow_path () == 1:
+        from random import randint
+
+        # -- reached common room
+        if myself.submap () == 1 and myself.posx () == 13:
+            x, y, dir = coords[randint (0, 1)]
+            myself.set_goal (x, y, dir)
+
+            delay = randint (50, 150) * 20
+            myself.set_val ("delay", delay)
+
+        # -- reached parlour
+        elif myself.submap () == 2 and myself.posx () == 1:
+            x, y, dir = coords[randint (2, 3)]
+            myself.set_goal (x, y, dir)
+
+            delay = randint (60, 180) * 30
+            myself.set_val ("delay", delay)
+
+        # -- reached our final destination
         else:
-            myself.set_val ("goto_parlour", todo - 1)
-
-        goal = myself.get_val ("goal")
-        x, y, dir = coords[goal]
-
-        if schedules.simple_goto_xy (myself, x, y) == 1:
-            if dir == STAND_NORTH: myself.stand_north ()
-            elif dir == STAND_EAST: myself.stand_east ()
-            elif dir == STAND_SOUTH: myself.stand_south ()
-            else: myself.stand_west ()
-
-    # -- do some random babbling
-    tmp = myself.get_val ("say_something")
-    myself.set_val ("say_something", tmp - 1)
-    if tmp == 0:
-        schedules.speak (myself, speech[random.randint (0, 2)])
-        delay = random.randint (60, 180) * 15
-        myself.set_val ("say_something", delay)
+            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:
+    from schedules import speak
+    from random import randint
+
+    speak (myself, speech[randint (0, 2)])
+    delay = randint (60, 180) * 15
+    myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/silverhair.py b/scripts/schedules/silverhair.py
index 4d80201..15c248f 100755
--- a/scripts/schedules/silverhair.py
+++ b/scripts/schedules/silverhair.py
@@ -15,57 +15,60 @@
 #    She will mainly stand still, but occasionally walk up to the
 #    window and make a remark about the weather.
 
-import schedules
-import random
-
 speech = ["In truth, Sarin, it is no bother. I am not offended.", \
           "Janesta, dear, worry not. I am content here.", \
           "Janesta, please bring my figurine. I wish to see it more closely.", 
\
           "It truly is a lovely day. I expect we will have time yet to enjoy 
it."]
 
-todo = myself.get_val ("say_something")
+todo = myself.get_val ("todo")
 
-# -- utter some remark
+# -- waiting
 if todo == 0:
+    delay = myself.get_val ("delay")
+
+    # If standing delay expired, move around next time
+    if delay == 0:
+        myself.set_val ("todo", 1)
+    else:
+        myself.set_val ("delay", delay - 1)
 
-    # -- get a random remark
-    index = random.randint (0, 3)
+# -- get movement target
+elif todo == 1:
+    from random import randint
 
     # -- goto the window
-    if index == 3:
-        delay = random.randint (33, 66) * 10
-        myself.set_val ("say_something", -delay)
+    if myself.posx () == 4:
+        # ... and speak about the weather
+        say = randint (33, 66) * 10
+        delay = randint (50, 75) * 15
+        myself.set_val ("say_something", say)
+        myself.set_goal (6, 4, STAND_EAST)
 
+    # -- go back to our normal position
     else:
-        # -- speak
-        schedules.speak (myself, speech[index])
+        delay = randint (100, 200) * 35
+        myself.set_goal (4, 5, STAND_SOUTH)
 
-        # -- wait a while before saying something else
-        delay = random.randint (50, 150) * 20
-        myself.set_val ("say_something", delay)
+    myself.set_val ("say_something", say)
+    myself.set_val ("delay", delay)
+    myself.set_val ("todo", 2)
 
-# -- walk up to the window and wait a little
-elif todo < 0:
-    if schedules.simple_goto_xy (myself, 6, 4) == 1:
-        myself.stand_east ()
+# -- move
+elif todo == 2:
+    if myself.follow_path () == 1:
+        myself.set_val ("todo", 0)
 
-        # -- speak
-        if todo == -250:
-            myself.stand_east ()
-            schedules.speak (myself, speech[3])
+# -- speak
+say = myself.get_val ("say_something")
+myself.set_val ("say_something", say - 1)
+if say == 0:
+    from schedules import speak
+    from random import randint
 
-        # -- leave the window
-        if todo == -1:
-            delay = random.randint (50, 150) * 10
-            myself.set_val ("say_something", delay)
-        # -- wait
-        else:
-            myself.set_val ("say_something", todo + 1)
-
-# -- leave the window
-else:
-    myself.set_val ("say_something", todo - 1)
+    if myself.posx () == 6:
+        speak (myself, speech[3])
+    else:
+        speak (myself, speech[randint (0, 2)])
 
-    # -- reached the middle of the room
-    if schedules.simple_goto_xy (myself, 4, 4) == 1:
-        myself.stand_south ()
+    say = randint (50, 150) * 20
+    myself.set_val ("say_something", say)



reply via email to

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