From cc07cbaa847786e3dfb04bf121208dc592525f8b Mon Sep 17 00:00:00 2001 From: ryo_saeba Date: Sat, 19 May 2012 15:43:19 +0000 Subject: [PATCH] Don't start a quest if the player can't read a book. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@18128 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/quests/QuestAdvance.py | 58 +++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/python/quests/QuestAdvance.py b/python/quests/QuestAdvance.py index 35be0185c..522373f75 100644 --- a/python/quests/QuestAdvance.py +++ b/python/quests/QuestAdvance.py @@ -34,28 +34,40 @@ import Crossfire -player = Crossfire.WhoIsActivator() +def handle(): + player = Crossfire.WhoIsActivator() + event = Crossfire.WhatIsEvent() + who = Crossfire.WhoAmI() -# if a spell was used, then the killer is the spell object, find the owner -if player.Type != Crossfire.Type.PLAYER: - player = player.Owner + if event.Subtype == Crossfire.EventType.APPLY and who.Type == Crossfire.Type.BOOK: + # when reading something, ensure the level is high enough before starting the quest + skill = player.CheckArchInventory("skill_literacy") + if skill == None: + return + if who.Level > skill.Level + 5: + return -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)) + # if a spell was used, then the killer is the spell object, find the owner + if player.Type != Crossfire.Type.PLAYER: + player = player.Owner + + 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)) + +handle()