Debian Codegraph @

python/quests/QuestTriggerConnect.py

raw
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 # it must always be given the following arguments:
25 # name of the quest
26 # stage(s) to trigger on
27 # connection to trigger
28 # the quest must exist, and the connection must be present on the map.
29
30 import Crossfire
31
32 def trigger():
33 player = Crossfire.WhoIsActivator()
34 if player.Type != Crossfire.Type.PLAYER:
35 return
36 params = Crossfire.ScriptParameters()
37 args = params.split()
38 questname = args[0]
39 currentstep = player.QuestGetState(questname)
40 condition = args[1]
41 if condition.find("-") == -1:
42 startstep = int(condition)
43 endstep = startstep
44 else:
45 startstep = int(condition.split("-")[0])
46 endstep= int(condition.split("-")[1])
47 if currentstep >= startstep and currentstep <= endstep:
48 Crossfire.Log(Crossfire.LogDebug, "QuestTriggerConnect.py: triggering connection number %s." % args[2])
49 player.Map.TriggerConnected(int(args[2]), 1, player)
50
51 trigger()