File: quest.py

package info (click to toggle)
crossfire-maps 1.75.0%2Bdfsg1-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 275,656 kB
  • sloc: python: 7,711; sql: 92; sh: 73; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
#quest.py
# This is one of the files that can be called by an npc_dialog,
# The following code runs when a dialog has a pre rule of 'quest'
# The syntax is ["quest", "questname", "queststage"]
# All arguments are required, questname must be a quest that is
# defined by one of the .quests files.
# Queststage can be in one of the following forms:
# 1) A number - eg "20" - The player must be at or past step 20 on questname
# 2) = A number - eg "=20" - The player must be at exactly step 20 on questname
# 3) = A range of numbers - eg "10-30" - The player must be betwen steps 10 and 30 on questname
# To deliver a True verdict, the player must be at the right stage in the quest.
## DIALOGCHECK
## MINARGS 2
## MAXARGS 2
## .*
## (=|)\d+(|-\d+)
## ENDDIALOGCHECK


questname = args[0]
stage = args[1]
if stage.find("-") == -1:
    if stage[0] == "=":
        startstep = int(stage[1:])
        endstep = startstep
    else:
        startstep = int(stage)
        endstep = -1
else:
    startstep = int(stage.split("-")[0])
    endstep= int(stage.split("-")[1])

currentstep = character.QuestGetState(questname)
if currentstep < startstep:
    verdict = False
if endstep > -1 and currentstep > endstep:
    verdict = False