Crossfire Server, Trunk
QuestTriggerConnect.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # QuestTriggerConnect.py - A generic script to trigger connections based on Quest progress
3 #
4 # Copyright (C) 2010 The Crossfire Development Team
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #
20 #
21 # This script is intended to be bound to event objects in order to conditionally trigger
22 # connections based on the status of a quest, used correctly it can reduce the need for
23 # markers to use checkinvs on.
24 # Usage: /python/quests/QuestTriggerConnect.py QUEST STATE CONNECTION [EDGE]
25 # QUEST - quest identifier string
26 # STATE - stages to trigger on
27 # CONNECTION - connection number
28 # EDGE - optional trigger edge, 1 (release) by default
29 
30 import Crossfire
31 
32 def trigger_connected(conn, state, player):
33  if state == 0:
34  name = "push"
35  else:
36  name = "release"
37  Crossfire.Log(Crossfire.LogDebug, "QuestTriggerConnect.py: triggering connection number %d (%s)" % (conn, name))
38  Crossfire.WhoAmI().Map.TriggerConnected(conn, state, player)
39 
40 def trigger():
41  player = Crossfire.WhoIsActivator()
42  params = Crossfire.ScriptParameters()
43  args = params.split()
44  edge = 1 # transition type, 0 for push, 1 for release
45  if len(args) < 3:
46  raise IndexError("QuestTriggerConnect used with incorrect number of arguments")
47  if len(args) >= 4:
48  edge = int(args[3])
49  conn = int(args[2])
50  if type(player) != Crossfire.Player:
51  return
52  questname = args[0]
53  currentstep = player.QuestGetState(questname)
54  condition = args[1]
55  if condition.find("-") == -1:
56  startstep = int(condition)
57  endstep = startstep
58  else:
59  startstep = int(condition.split("-")[0])
60  endstep= int(condition.split("-")[1])
61  if currentstep >= startstep and currentstep <= endstep:
62  trigger_connected(conn, edge, player)
63 
64 trigger()
make_face_from_files.int
int
Definition: make_face_from_files.py:32
trigger
Definition: trigger.py:1
QuestTriggerConnect.trigger_connected
def trigger_connected(conn, state, player)
Definition: QuestTriggerConnect.py:32
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
QuestTriggerConnect.trigger
def trigger()
Definition: QuestTriggerConnect.py:40