[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[adonthell-wastesedge-commits] Release_0-3-1 51e5413 051/237: Updated fr
From: |
Kai Sterker |
Subject: |
[adonthell-wastesedge-commits] Release_0-3-1 51e5413 051/237: Updated frostbloom and sarin to new pathfinding code |
Date: |
Mon, 25 Jul 2016 18:14:56 +0000 (UTC) |
tag: Release_0-3-1
commit 51e5413a92aed0949bc7aaa69398cc3424b6b4a7
Author: adondev <adondev>
Commit: adondev <adondev>
Updated frostbloom and sarin to new pathfinding code
---
scripts/schedules/frostbloom.py | 65 ++++++++++--------
scripts/schedules/sarin.py | 138 +++++++++++++++++++++------------------
2 files changed, 115 insertions(+), 88 deletions(-)
diff --git a/scripts/schedules/frostbloom.py b/scripts/schedules/frostbloom.py
index 267bd97..b65d628 100755
--- a/scripts/schedules/frostbloom.py
+++ b/scripts/schedules/frostbloom.py
@@ -14,9 +14,6 @@
#
# She just walks around the tree in the yard
-import schedules
-import random
-
# -- Borders of the area she will stay in
min_x = 16
max_x = 24
@@ -27,29 +24,45 @@ speech = ["This tree is so inspiring.", \
"I wonder why everybody seems so excited.", \
"Do you know a creature more lovely than the yeti?"]
-todo = myself.get_val ("stand_still")
+todo = myself.get_val ("todo")
-# -- calculate a new position
+# -- 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 movement target
+elif todo == 1:
+ from random import randint
+
# -- the position we want to reach
- myself.set_val ("goal_x", random.randint (min_x, max_x))
- myself.set_val ("goal_y", random.randint (min_y, max_y))
-
- delay = random.randint (30, 90) * 30
- myself.set_val ("stand_still", delay)
-
-# -- walk to the new position and wait a while
-else:
- x = myself.get_val ("goal_x")
- y = myself.get_val ("goal_y")
-
- schedules.simple_goto_xy (myself, x, y)
- myself.set_val ("stand_still", todo - 1)
-
- # -- 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 (50, 150) * 20
- myself.set_val ("say_something", delay)
+ x = randint (min_x, max_x)
+ y = randint (min_y, max_y)
+
+ myself.set_goal (x, y, NO_MOVE)
+
+ delay = randint (30, 90) * 30
+ myself.set_val ("delay", delay)
+ myself.set_val ("todo", 2)
+
+# -- walk to the new position
+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:
+ from schedules import speak
+ from random import randint
+
+ speak (myself, speech[randint (0, 2)])
+ delay = randint (50, 150) * 20
+ myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/sarin.py b/scripts/schedules/sarin.py
index 604733c..5e38d8c 100755
--- a/scripts/schedules/sarin.py
+++ b/scripts/schedules/sarin.py
@@ -15,8 +15,6 @@
# He walks from one end of the room to the other. From time to
# to time he'll stop and chose another direction
-import schedules
-import random
# -- Borders of the area he should stay in
min_x = 1
@@ -29,73 +27,89 @@ speech = ["Ruffinans, the lot of them!", \
"This is an insult to all of the High Born.", \
"I cannot believe such disrespect. Barbarians!"]
-todo = myself.get_val ("switch_direction")
-# -- calculate a new direction
-if todo == 0:
- # -- wait until we're completely on the tile
- if schedules.simple_goto_xy (myself, myself.posx (), myself.posy ()) == 1:
- # -- get the current direction ...
- dir = myself.get_val ("direction")
+# -- delay for orientation change
+delay = myself.get_val ("delay")
- # -- ... and set the new one accordingly
- if dir == WALK_EAST or dir == WALK_WEST:
- myself.set_val ("direction", random.randint (WALK_NORTH,
WALK_SOUTH))
- else:
- myself.set_val ("direction", random.randint (WALK_WEST, WALK_EAST))
+# -- switch orientation
+if delay == 0:
+ from random import randint
- # -- wait a little on the current tile
- delay = random.randint (30, 50) * 10
- myself.set_val ("switch_direction", -delay)
-
- # -- time until the next direction change
- delay = random.randint (100, 200) * 15
- myself.set_val ("delay", delay)
-
-# -- wait a moment
-elif todo < 0:
- myself.set_val ("switch_direction", todo + 1)
- if todo == -1:
- delay = myself.get_val ("delay")
- myself.set_val ("switch_direction", delay)
+ # -- get the current direction ...
+ dir = myself.get_val ("direction")
+
+ # -- ... and set the new one accordingly
+ if dir == WALK_EAST or dir == WALK_WEST:
+ dir = randint (WALK_NORTH, WALK_SOUTH)
+ else:
+ dir = randint (WALK_WEST, WALK_EAST)
+
+ # -- time until the next orientation change
+ delay = randint (100, 200) * 15
+ myself.set_val ("direction", dir)
+ myself.set_val ("delay", delay)
+ myself.set_val ("todo", 1)
-# -- walk up to the wall, wait a little, then turn around
else:
- myself.set_val ("switch_direction", todo - 1)
+ myself.set_val ("delay", delay - 1)
+
+
+todo = myself.get_val ("todo")
+
+# -- waiting
+if todo == 0:
+ # -- delay for direction change
+ delay = myself.get_val ("switch_direction")
+
+ if delay == 0:
+ myself.set_val ("todo", 1)
+ else:
+ myself.set_val ("switch_direction", delay - 1)
+
+# -- get movement target
+elif todo == 1:
+ # -- get the current direction ...
dir = myself.get_val ("direction")
+ # -- switch direction
if dir == WALK_NORTH:
- if schedules.simple_goto_xy (myself, myself.posx (), min_y) == 1:
- myself.set_val ("direction", WALK_SOUTH)
- myself.set_val ("switch_direction", random.randint (-300, -150))
- myself.set_val ("delay", todo)
- myself.stand_south ()
-
+ goal = (myself.posx (), min_y, STAND_SOUTH, 0, 1)
elif dir == WALK_SOUTH:
- if schedules.simple_goto_xy (myself, myself.posx (), max_y) == 1:
- myself.set_val ("direction", WALK_NORTH)
- myself.set_val ("switch_direction", random.randint (-300, -150))
- myself.set_val ("delay", todo)
- myself.stand_north ()
-
- elif dir == WALK_WEST:
- if schedules.simple_goto_xy (myself, min_x, myself.posy ()) == 1:
- myself.set_val ("direction", WALK_EAST)
- myself.set_val ("switch_direction", random.randint (-300, -150))
- myself.set_val ("delay", todo)
- myself.stand_east ()
-
+ goal = (myself.posx (), max_y, STAND_NORTH, 0, -1)
+ elif dir == WALK_EAST:
+ goal = (max_x, myself.posy(), STAND_WEST, -1, 0)
else:
- if schedules.simple_goto_xy (myself, max_x, myself.posy ()) == 1:
- myself.set_val ("direction", WALK_WEST)
- myself.set_val ("switch_direction", random.randint (-300, -105))
- myself.set_val ("delay", todo)
- myself.stand_west ()
-
- # -- 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, 3)])
- delay = random.randint (50, 150) * 10
- myself.set_val ("say_something", delay)
+ goal = (min_x, myself.posy (), STAND_EAST, 1, 0)
+
+ x, y, d = goal[:3]
+ myself.set_val ("direction", d + 4)
+
+ while not myself.set_goal (x, y, d):
+ offx, offy = goal [-2:]
+ x = x + offx
+ y = y + offy
+
+ myself.set_val ("todo", 2)
+
+# -- move
+elif todo == 2:
+ if myself.follow_path () == 1:
+ from random import randint
+
+ # -- wait a little on the current tile
+ delay = randint (15, 30) * 10
+ 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:
+ from schedules import speak
+ from random import randint
+
+ speak (myself, speech[randint (0, 3)])
+ delay = randint (50, 150) * 10
+ myself.set_val ("say_something", delay)
- [adonthell-wastesedge-commits] Release_0-3-1 de03633 047/237: Commited my own files again! :/, (continued)
- [adonthell-wastesedge-commits] Release_0-3-1 de03633 047/237: Commited my own files again! :/, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 fe87ce5 041/237: Stupid kdevelop!!!, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 56fe2ff 046/237: Fixed Oliver's teleport bug., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 edbcb94 007/237: Added autoconf/automake support., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 89ba59b 024/237: Continued map rooms., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 78ff7bc 049/237: More schedules converted to the new pathfinding code, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 a4f92b4 055/237: Ooppps! Fixed an error of my own, sorry., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 c6dcf69 044/237: Using pathfinding methods for Talan schedule., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 9cb9bdd 048/237: Converted Orloth to new pathfinding, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 22178ae 058/237: Map gets only updated if the main_menu or data_screen aren't displayed., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 51e5413 051/237: Updated frostbloom and sarin to new pathfinding code,
Kai Sterker <=
- [adonthell-wastesedge-commits] Release_0-3-1 d304dc6 069/237: Updated Orloth's and Erek's dialogue, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 842c4b9 076/237: Oops! Forgot this file., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 4bcc0dd 066/237: FIXED bugs in automake, silverhair's room connection script and, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 5719e8c 078/237: Updated Silverhair's bed., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 aad3c95 098/237: Fixed missing installation target, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 feeadbf 099/237: FIXED data installation, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 4330c0d 053/237: Removed in-game imports, which are now done at init time., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 177b48f 060/237: Changed map - it now has a member to prevent NPCs to be accidentally, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 0f70295 082/237: Added some events., Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 52a5f4c 038/237: Completed map and connections., Kai Sterker, 2016/07/25