Crossfire Server, Trunk
QuestAdvance.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # QuestAdvance.py - A generic script to trigger 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 speed quests along
22 # it must always be given the name of the quest as its first argument, followed by
23 # any number of advance rules.
24 # an advance rule looks like
25 # 1>2
26 # or
27 # 2-4>5
28 # which will in the first case, move the stated quest from step 1 to step 2
29 # in the second case, it will move the quest from step 2, 3 or 4 to step 5
30 # if no advance rule applies then nothing happens.
31 # something like 0>1 may be specified to start the quest.
32 # each advance rule should be separated by a space, there should be
33 # no space within the individual rules.
34 
35 import Crossfire
36 
37 def handle():
38  player = Crossfire.WhoIsActivator()
39  event = Crossfire.WhatIsEvent()
40  who = Crossfire.WhoAmI()
41 
42  if event.Subtype == Crossfire.EventType.APPLY and who.Type == Crossfire.Type.BOOK:
43  # when reading something, ensure the level is high enough before starting the quest
44  skill = player.CheckArchInventory("skill_literacy")
45  if skill == None:
46  return
47  if who.Level > skill.Level + 5:
48  return
49 
50  # If no player, return.
51  if player is None:
52  return
53  # if a spell was used, then the killer is the spell object, find the owner
54  if player.Type != Crossfire.Type.PLAYER:
55  # If the non-player has no owner, then no quest changes.
56  if player.Owner is None:
57  return
58  player = player.Owner
59 
60  if player.Type != Crossfire.Type.PLAYER:
61  return
62 
63  params = Crossfire.ScriptParameters()
64  args = params.split()
65  questname = args[0]
66  currentstep = player.QuestGetState(questname)
67  for rule in args[1:]:
68  condition, target = rule.split(">")
69  if condition.find("-") == -1:
70  startstep = int(condition)
71  endstep = startstep
72  else:
73  startstep = int(condition.split("-")[0])
74  endstep= int(condition.split("-")[1])
75  if currentstep >= startstep and currentstep <= endstep:
76  # update this quest
77  if currentstep == 0:
78  player.QuestStart(questname, int(target))
79  else:
80  player.QuestSetState(questname, int(target))
81 
82 handle()
QuestAdvance.handle
def handle()
Definition: QuestAdvance.py:37
make_face_from_files.int
int
Definition: make_face_from_files.py:32