Debian Codegraph @

scripts/schedules/mapcharacters/intro.py

raw symbols SCIP
1 #
2 # $Id$
3 #
4 # (C) Copyright 2001/2002 Kai Sterker <[email protected]>
5 # Part of the Adonthell Project http://adonthell.linuxgames.com
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY.
11 #
12 # See the COPYING file for more details
13 #
14
15 # -- Schedule for the player to get into the Inn after the intro
16
17 import adonthell
18
19 class intro(object):
20
21 def __init__ (self, mapcharacterinstance):
22 self.myself = mapcharacterinstance
23 self.myself.set_callback (self.goal_reached)
24 adonthell.gamedata_get_quest ("demo").set_val ("intro_on", 1)
25
26 # -- first talk to talan to get into the inn
27 def talk_to_talan (self):
28 talan = adonthell.gamedata_get_character ("Talan Wendth")
29 talan.launch_action (self.myself)
30
31 # -- finally enter the inn
32 def enter_inn (self):
33 # -- start music
34 adonthell.audio_load_background (0, "audio/at-demo-5.ogg")
35 adonthell.audio_play_background (0)
36 adonthell.audio_set_schedule ("in_game")
37 adonthell.audio_set_schedule_active (True)
38
39 self.open_gate ()
40
41 adonthell.gamedata_get_quest ("demo").set_val ("intro_on", 0)
42 self.myself.set_goal (10, 18, adonthell.STAND_EAST)
43
44 # -- inside the inn
45 def goal_reached (self):
46 talan = adonthell.gamedata_get_character ("Talan Wendth")
47 talan.time_callback_string ("3t", "walk")
48
49 self.myself.set_callback (None)
50 self.myself.set_schedule ("keyboard_control")
51 self.myself.set_schedule_active (True)
52 self.close_gate ()
53 self.myself.go_east ()
54
55
56 # -- open the gate
57 def open_gate (self):
58 # Get the mapobjects
59 gate_fore = adonthell.gamedata_engine ().get_landmap ().get_mapobject (90)
60 gate_back = adonthell.gamedata_engine ().get_landmap ().get_mapobject (89)
61
62 # Only open the gate if it's closed...
63 if (gate_fore.get_animation (0).currentframe () == 0):
64 # Plays the gate back animation
65 gate_back.get_animation (0).next_frame ()
66 # Plays the gate fore animation
67 gate_fore.get_animation (0).next_frame ()
68
69 # Update squares walkability
70 sm = adonthell.gamedata_engine ().get_landmap ().get_submap (0)
71 sm.get_square (6, 17).set_walkable_south (False)
72 sm.get_square (7, 17).set_walkable_south (False)
73 sm.get_square (6, 18).set_walkable_west (True)
74 sm.get_square (6, 19).set_walkable_west (True)
75
76 # Close the gate
77 def close_gate (self):
78 # Get the mapobjects
79 gate_fore = adonthell.gamedata_engine ().get_landmap ().get_mapobject (90)
80 gate_back = adonthell.gamedata_engine ().get_landmap ().get_mapobject (89)
81
82 # Only close the gate if it's opened
83 if (gate_fore.get_animation (0).currentframe () == 4):
84 # Plays the gate back animation
85 gate_back.get_animation (0).next_frame ()
86 # Plays the gate fore animation
87 gate_fore.get_animation (0).next_frame ()
88
89 # Update squares walkability
90 sm = adonthell.gamedata_engine ().get_landmap ().get_submap (0)
91 sm.get_square (6, 17).set_walkable (False)
92 sm.get_square (7, 17).set_walkable_south (True)
93 sm.get_square (6, 18).set_walkable_west (False)
94 sm.get_square (6, 19).set_walkable_west (False)
95 sm.get_square (6, 20).set_walkable_west (False)