Debian Codegraph @

python/quests/QuestApplyIf.py

raw
1 # -*- coding: utf-8 -*-
2 # QuestApplyIf.py - A script to let an item be applied only if a quest
3 # reached a certain step
4 # Arguments are:
5 # - quest name
6 # - a list of steps, either single value (x) or range (x-y)
7 # If any matches, then the item can be applied, else it is not applied
8
9 import Crossfire
10
11 player = Crossfire.WhoIsActivator()
12 params = Crossfire.ScriptParameters()
13 args = params.split()
14
15 # by default, forbid applying
16 Crossfire.SetReturnValue(1)
17
18 if type(player) == Crossfire.Player:
19 questname = args[0]
20 currentstep = player.QuestGetState(questname)
21
22 for rule in args[1:]:
23 if rule.find("-") == -1:
24 startstep = int(rule)
25 endstep = startstep
26 else:
27 startstep = int(rule.split("-")[0])
28 endstep= int(rule.split("-")[1])
29 if currentstep >= startstep and currentstep <= endstep:
30 Crossfire.SetReturnValue(0)