From 930183356ee38e94e3172154dfdaf295fcee903e Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Sat, 12 Jun 2010 16:51:54 +0000 Subject: [PATCH] Utility script to let an item be applied only for certain quest steps. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13389 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/quests/QuestApplyIf.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 python/quests/QuestApplyIf.py diff --git a/python/quests/QuestApplyIf.py b/python/quests/QuestApplyIf.py new file mode 100644 index 000000000..839e591a6 --- /dev/null +++ b/python/quests/QuestApplyIf.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# QuestApplyIf.py - A script to let an item be applied only if a quest +# reached a certain step +# Arguments are: +# - quest name +# - a list of steps, either single value (x) or range (x-y) +# If any matches, then the item can be applied, else it is not applied + +import Crossfire + +player = Crossfire.WhoIsActivator() +params = Crossfire.ScriptParameters() +args = params.split() + +questname = args[0] +currentstep = player.QuestGetState(questname) + +# by default, forbid applying +Crossfire.SetReturnValue(1) + +for rule in args[1:]: + if rule.find("-") == -1: + startstep = int(rule) + endstep = startstep + else: + startstep = int(rule.split("-")[0]) + endstep= int(rule.split("-")[1]) + if currentstep >= startstep and currentstep <= endstep: + Crossfire.SetReturnValue(0)