diff --git a/python/quests/QuestAdvance.py b/python/quests/QuestAdvance.py new file mode 100644 index 000000000..d4d3307e8 --- /dev/null +++ b/python/quests/QuestAdvance.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# CFQuestStartAdvance - A generic script to trigger quest progress +# +# Copyright (C) 2010 The Crossfire Development Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# This script is intended to be bound to event objects in order to speed quests along +# it must always be given the name of the quest as its first argument, followed by +# any number of advance rules. +# an advance rule looks like +# 1>2 +# or +# 2-4>5 +# which will in the first case, move the stated quest from step 1 to step 2 +# in the second case, it will move the quest from step 2, 3 or 4 to step 5 +# if no advance rule applies then nothing happens. +# something like 0>1 may be specified to start the quest. +# each advance rule should be separated by a space, there should be +# no space within the individual rules. + +import Crossfire + +player = Crossfire.WhoIsActivator() +event = Crossfire.WhatIsEvent() +params = Crossfire.ScriptParameters() +args = params.split() +questname = args[0] +currentstep = player.QuestGetState(questname) +for rule in args[1:]: + condition, target = rule.split(">") + if condition.find("-") == -1: + startstep = int(condition) + endstep = startstep + else: + startstep = int(condition.split("-")[0]) + endstep= int(condition.split("-")[1]) + if currentstep >= startstep and currentstep <= endstep: + # update this quest + if currentstep == 0: + player.QuestStart(questname, int(target)) + else: + player.QuestSetState(questname, int(target)) diff --git a/python/quests/QuestEssentialUntil.py b/python/quests/QuestEssentialUntil.py new file mode 100644 index 000000000..509632f80 --- /dev/null +++ b/python/quests/QuestEssentialUntil.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# CFQuestStartAdvance - A generic script to make quest items undisposable. +# +# Copyright (C) 2010 The Crossfire Development Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +# This script is intended to be bound to event_drop in the inventory of quest objects. +# it must always be given the name of the quest as its first argument, followed by +# the stage number it should act until. +# Until the specified stage in the specified quest is reached, the player will not be +# permitted to drop the item, after the stage specified, any attempt to drop the +# item will have it marked as startequip, causing it to disappear. +# This is to prevent quests being bypassed by trading keys, etc. + +import Crossfire +item = Crossfire.WhoAmI() +player = Crossfire.WhoIsActivator() +args = Crossfire.ScriptParameters().split(' ') +questname = args[0] +stagenumber = int(args[1]) +currentstep = player.QuestGetState(questname) +if currentstep == 0: + Crossfire.SetReturnValue(0) +elif currentstep >= stagenumber: + item.GodGiven = True + Crossfire.SetReturnValue(0) +else: + if item.Quantity == 1: + player.Message("You consider dropping the "+ item.Name + " but then decide it would be better to hold on to it for now.") + else: + player.Message("You consider dropping the "+ item.NamePl + " but then decide it would be better to hold on to them for now.") + Crossfire.SetReturnValue(1)