| 1 |
# -*- coding: utf-8 -*- |
| 2 |
#quest.py |
| 3 |
# This is one of the files that can be called by an npc_dialog, |
| 4 |
# The following code runs when a dialog has a pre rule of 'quest' |
| 5 |
# The syntax is ["quest", "questname", "queststage"] |
| 6 |
# All arguments are required, questname must be a quest that is |
| 7 |
# defined by one of the .quests files. |
| 8 |
# Queststage can be in one of the following forms: |
| 9 |
# 1) A number - eg "20" - The player must be at or past step 20 on questname |
| 10 |
# 2) = A number - eg "=20" - The player must be at exactly step 20 on questname |
| 11 |
# 3) = A range of numbers - eg "10-30" - The player must be betwen steps 10 and 30 on questname |
| 12 |
# To deliver a True verdict, the player must be at the right stage in the quest. |
| 13 |
## DIALOGCHECK |
| 14 |
## MINARGS 2 |
| 15 |
## MAXARGS 2 |
| 16 |
## .* |
| 17 |
## (=|)\d+(|-\d+) |
| 18 |
## ENDDIALOGCHECK |
| 19 |
|
| 20 |
|
| 21 |
questname = args[0] |
| 22 |
stage = args[1] |
| 23 |
if stage.find("-") == -1: |
| 24 |
if stage[0] == "=": |
| 25 |
startstep = int(stage[1:]) |
| 26 |
endstep = startstep |
| 27 |
else: |
| 28 |
startstep = int(stage) |
| 29 |
endstep = -1 |
| 30 |
else: |
| 31 |
startstep = int(stage.split("-")[0]) |
| 32 |
endstep= int(stage.split("-")[1]) |
| 33 |
|
| 34 |
currentstep = character.QuestGetState(questname) |
| 35 |
if currentstep < startstep: |
| 36 |
verdict = False |
| 37 |
if endstep > -1 and currentstep > endstep: |
| 38 |
verdict = False |