[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[adonthell-wastesedge-commits] Release_0-3-1 c6dcf69 044/237: Using path
From: |
Kai Sterker |
Subject: |
[adonthell-wastesedge-commits] Release_0-3-1 c6dcf69 044/237: Using pathfinding methods for Talan schedule. |
Date: |
Mon, 25 Jul 2016 18:14:55 +0000 (UTC) |
tag: Release_0-3-1
commit c6dcf69ccdfd227d2c58b2a520d1c7d1b3a3a121
Author: adondev <adondev>
Commit: adondev <adondev>
Using pathfinding methods for Talan schedule.
---
scripts/init.py | 276 +++++++++++++++++----------------
scripts/schedules/alek.py | 2 +-
scripts/schedules/keyboard_control.py | 2 +-
scripts/schedules/talan.py | 60 +++----
4 files changed, 174 insertions(+), 166 deletions(-)
diff --git a/scripts/init.py b/scripts/init.py
index 22c4308..29c1ac2 100755
--- a/scripts/init.py
+++ b/scripts/init.py
@@ -1,145 +1,147 @@
-from main_menu import *
-import time
-
-bag_o = image ()
-bag_c = image ()
-bag_t = image ()
-bag_o.load_pnm ("gfx/cutscene/jewelbag_open.pnm")
-bag_c.load_pnm ("gfx/cutscene/jewelbag_closed.pnm")
-bag_t.load_pnm ("gfx/cutscene/adonthell_03.pnm")
-
-bag_o.set_alpha (0)
-bag_c.set_alpha (0)
-bag_t.set_alpha (255)
-
-
-# Fade in/out multiple pictures
-# Returns current alpha of last picture
-# Usage fade (pic1, ..., picN, step1, ..., stepN)
-def fade (*args):
- pics = args[:len (args)/2]
- vals = args[len (args)/2:]
- alpha = 0
- for i in range (len (pics)):
- alpha = pics[i].alpha () + vals[i]
- if alpha < 0: alpha = 0
- if alpha > 255: alpha = 255
- pics[i].set_alpha (alpha)
- pics[i].draw (0,0)
- return alpha
+##from main_menu import *
+##import time
+
+##bag_o = image ()
+##bag_c = image ()
+##bag_t = image ()
+##bag_o.load_pnm ("gfx/cutscene/jewelbag_open.pnm")
+##bag_c.load_pnm ("gfx/cutscene/jewelbag_closed.pnm")
+##bag_t.load_pnm ("gfx/cutscene/adonthell_03.pnm")
+
+##bag_o.set_alpha (0)
+##bag_c.set_alpha (0)
+##bag_t.set_alpha (255)
+
+
+### Fade in/out multiple pictures
+### Returns current alpha of last picture
+### Usage fade (pic1, ..., picN, step1, ..., stepN)
+##def fade (*args):
+## pics = args[:len (args)/2]
+## vals = args[len (args)/2:]
+## alpha = 0
+## for i in range (len (pics)):
+## alpha = pics[i].alpha () + vals[i]
+## if alpha < 0: alpha = 0
+## if alpha > 255: alpha = 255
+## pics[i].set_alpha (alpha)
+## pics[i].draw (0,0)
+## return alpha
-alpha = 0
-
-audio_load_background (0, "audio/at-menu-full.ogg")
-audio_load_background (1, "audio/at-dummy-1.ogg")
-audio_load_wave (0, "audio/select.wav")
-audio_load_wave (1, "audio/switch.wav")
-audio_load_wave (2, "audio/unselect.wav")
-
-audio_play_background (0)
-gametime_start_action ()
-
-k=0
-
-# Fade in closed bag
-while alpha < 255:
- for k in range (gametime_frames_to_do()): pass
- screen_clear ()
- alpha = fade (bag_c, k+1)
- bag_c.draw(0,0)
- screen_show ()
- gametime_update()
+##alpha = 0
+
+##audio_load_background (0, "audio/at-menu-full.ogg")
+##audio_load_background (1, "audio/at-dummy-1.ogg")
+##audio_load_wave (0, "audio/select.wav")
+##audio_load_wave (1, "audio/switch.wav")
+##audio_load_wave (2, "audio/unselect.wav")
+
+##audio_play_background (0)
+##gametime_start_action ()
+
+##k=0
+
+### Fade in closed bag
+##while alpha < 255:
+## for k in range (gametime_frames_to_do()): pass
+## screen_clear ()
+## alpha = fade (bag_c, k+1)
+## bag_c.draw(0,0)
+## screen_show ()
+## gametime_update()
-bag_t.draw (33, 86)
-screen_show ()
-gametime_update ()
-
-# wait ~2.5 seconds
-for i in range (25):
- time.sleep (0.1)
- screen_show ()
- gametime_update()
-
-alpha = 0
-
-# fade in open bag
-while alpha < 255:
- for k in range (gametime_frames_to_do()): pass
- screen_clear ()
- bag_c.draw (0, 0)
- bag_t.draw (33, 86)
- alpha = fade (bag_o, k+1)
- screen_show ()
- gametime_update ()
+##bag_t.draw (33, 86)
+##screen_show ()
+##gametime_update ()
+
+### wait ~2.5 seconds
+##for i in range (25):
+## time.sleep (0.1)
+## screen_show ()
+## gametime_update()
+
+##alpha = 0
+
+### fade in open bag
+##while alpha < 255:
+## for k in range (gametime_frames_to_do()): pass
+## screen_clear ()
+## bag_c.draw (0, 0)
+## bag_t.draw (33, 86)
+## alpha = fade (bag_o, k+1)
+## screen_show ()
+## gametime_update ()
-del bag_c
-del bag_t
-
-class title_screen:
- def __init__ (self, background):
- self.quit = 0
- self.bgimage = win_image ()
- self.bgimage.move (0, 0)
- image_copy (self.bgimage, background)
- self.bgimage.pack ()
+##del bag_c
+##del bag_t
+
+##class title_screen:
+## def __init__ (self, background):
+## self.quit = 0
+## self.bgimage = win_image ()
+## self.bgimage.move (0, 0)
+## image_copy (self.bgimage, background)
+## self.bgimage.pack ()
- self.window = win_container ()
- self.window.move (0, 0)
- self.window.resize (320, 240)
- self.window.set_visible_border (0)
- self.window.add (self.bgimage)
- self.window.set_visible_all (1)
-
- win_manager_add (self.window)
-
- self.menu = main_menu (0, 0)
- self.menu.thisown = C
- self.menu.py_signal_connect (self.on_menu_close, win_event_CLOSE)
+## self.window = win_container ()
+## self.window.move (0, 0)
+## self.window.resize (320, 240)
+## self.window.set_visible_border (0)
+## self.window.add (self.bgimage)
+## self.window.set_visible_all (1)
+
+## win_manager_add (self.window)
+
+## self.menu = main_menu (0, 0)
+## self.menu.thisown = C
+## self.menu.py_signal_connect (self.on_menu_close, win_event_CLOSE)
- win_manager_add (self.menu)
- win_manager_set_focus (self.menu)
- self.menu = None
-
- # on to the main menu
- def on_menu_close (self, retval):
- self.quit = retval
-
-
- def loop (self):
- self.cont = 0
- while self.cont == 0:
- input_update ()
-
- for k in range (gametime_frames_to_do()+1):
- win_manager_input_update ()
- win_manager_update ()
-
- win_manager_draw ()
- screen_show ()
- gametime_update()
-
- self.cont = self.quit
-
- self.window.remove (self.bgimage)
- win_manager_remove (self.window)
- alpha = 255
- bag_o.set_alpha(255)
- gametime_start_action()
- while alpha > 0:
- for k in range (gametime_frames_to_do()): pass
- screen_clear ()
- alpha = fade (bag_o, (-(k+1)*2))
- screen_show ()
- gametime_update()
-
-
-# -- Main --
-title = title_screen (bag_o)
-title.loop ()
-retval = title.quit
-del bag_o
-
-audio_pause_music ()
+## win_manager_add (self.menu)
+## win_manager_set_focus (self.menu)
+## self.menu = None
+
+## # on to the main menu
+## def on_menu_close (self, retval):
+## self.quit = retval
+
+
+## def loop (self):
+## self.cont = 0
+## while self.cont == 0:
+## input_update ()
+
+## for k in range (gametime_frames_to_do()+1):
+## win_manager_input_update ()
+## win_manager_update ()
+
+## win_manager_draw ()
+## screen_show ()
+## gametime_update()
+
+## self.cont = self.quit
+
+## self.window.remove (self.bgimage)
+## win_manager_remove (self.window)
+## alpha = 255
+## bag_o.set_alpha(255)
+## gametime_start_action()
+## while alpha > 0:
+## for k in range (gametime_frames_to_do()): pass
+## screen_clear ()
+## alpha = fade (bag_o, (-(k+1)*2))
+## screen_show ()
+## gametime_update()
+
+
+### -- Main --
+##title = title_screen (bag_o)
+##title.loop ()
+##retval = title.quit
+##del bag_o
+
+##audio_pause_music ()
+
+retval = 1
if retval < 5:
if retval == 1:
diff --git a/scripts/schedules/alek.py b/scripts/schedules/alek.py
index 7d7fccf..e943508 100755
--- a/scripts/schedules/alek.py
+++ b/scripts/schedules/alek.py
@@ -25,7 +25,7 @@ todo = myself.get_val ("switch_direction")
# -- calculate a new direction
if todo == 0:
- # -- the time we stay at one side of the gata
+ # -- the time we stay at the same place
delay = random.randint (60, 150) * 20
# -- walk to table
diff --git a/scripts/schedules/keyboard_control.py
b/scripts/schedules/keyboard_control.py
index 2cd8222..6d1498d 100755
--- a/scripts/schedules/keyboard_control.py
+++ b/scripts/schedules/keyboard_control.py
@@ -47,7 +47,7 @@ def close_gate ():
sm.get_square (6, 19).set_walkable_west (0)
sm.get_square (6, 20).set_walkable_west (0)
-#print "%d %d %d" % (myself.submap (), myself.posx (), myself.posy ())
+print "%d %d %d" % (myself.submap (), myself.posx (), myself.posy ())
if input_has_been_pushed (SDLK_o):
open_gate ()
diff --git a/scripts/schedules/talan.py b/scripts/schedules/talan.py
index 8d54f70..a5d5aa3 100755
--- a/scripts/schedules/talan.py
+++ b/scripts/schedules/talan.py
@@ -14,44 +14,50 @@
#
# He guards the gate
-import schedules
-import random
-
speech = ["Halt! Who goes there?", \
"\"Ai! laurie lantar lassi surinen ...\"", \
"Nobody may pass through the gate!"]
-todo = myself.get_val ("switch_direction")
+todo = myself.get_val ("todo")
-# -- calculate a new direction
+# If standing
if todo == 0:
- # -- the time we stay at one side of the gata
- delay = random.randint (25, 50) * 20
-
- # -- walk downwards
+ 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)
+
+# Moving, follow the path until it is reached.
+elif todo == 2:
+ # Reached the goal? Wait a while then...
+ if myself.follow_path ():
+ if myself.posy () == 17: myself.stand_south ()
+ else: myself.stand_north ()
+ import random
+ myself.set_val ("delay", random.randint (25, 50) * 20)
+ myself.set_val ("todo", 0)
+
+
+# Engage a new movement
+elif todo == 1:
+ # Choose where to move, if destination is already occupied we'll
+ # fall into the wait state (0) again automatically next time
if myself.posy () == 17:
- myself.set_val ("switch_direction", -delay)
-
- # -- walk upwards
+ myself.set_goal (11, 20)
else:
- myself.set_val ("switch_direction", delay)
-
-# -- walk downwards
-elif todo < 0:
- myself.set_val ("switch_direction", todo + 1)
- if schedules.simple_goto_xy (myself, 11, 20) == 1:
- myself.stand_north ()
-
-# -- walk upwards
-else:
- myself.set_val ("switch_direction", todo - 1)
- if schedules.simple_goto_xy (myself, 11, 17) == 1:
- myself.stand_south ()
+ myself.set_goal (11, 17)
+
+ # Next time we'll actually move!
+ myself.set_val ("todo", 2)
# -- utter a random remark
tmp = myself.get_val ("say_something")
myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
+if tmp <= 0:
+ import schedules
+ import random
schedules.speak (myself, speech[random.randint (0, 2)])
- delay = random.randint (40, 120) * 15
+ delay = random.randint (50, 150) * 20
myself.set_val ("say_something", delay)
- [adonthell-wastesedge-commits] Release_0-3-1 1dac4d8 019/237: Those are the most recent versions of those dialogues - the ones on the ftp are a lot older, (continued)
- [adonthell-wastesedge-commits] Release_0-3-1 1dac4d8 019/237: Those are the most recent versions of those dialogues - the ones on the ftp are a lot older, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 8b0c1e0 042/237: Slight fix to Alek's dialogue, Kai Sterker, 2016/07/25
- [adonthell-wastesedge-commits] Release_0-3-1 d2a86c9 030/237: Added some more characters and dialogues, Kai Sterker, 2016/07/25
- [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 <=
- [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, 2016/07/25
- [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