Automatic quest timer always returning 0

For all talk about quest development - creation, testing, and quest system.
Post Reply
imsobadatnicknames
Posts: 362
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Automatic quest timer always returning 0

Post by imsobadatnicknames »

I'm writing a quest and I kinda ran into an issue I've never really had before.
Whenever I do a quest where you have to travel somewhere, I always set the time limit as "00:00 0 flag 17 range 0 2" to give a time limit based on travel distance. However, for some reason when I try to use it in this quest I'm writing, it just sets the timer to 0 and the quest immediately ends.

Here's the code

Code: Select all

Quest: BOUNTY1
DisplayName: Bounty
-- Message panels

QRC:
QuestComplete:  [1004]
<ce> %pcn, you said was your name?
<ce> I'll put in a good word for you.
<ce> Here's your reward.

RumorsDuringQuest: [1005]
They say a dangerous criminal is hiding in ___dungeon_
<--->
My cousin says he saw some suspicious things in __house_. Someone came out of _house_ carrying all their possessions in the middle of the night.
<--->
Nice weather!
<--->
%t %rn is a vampire! I'm serious! I have proof!
<--->
Weird things happen at night.
<--->
___dungeon_ was abandoned for years, but some bandit gang is now operating from it.

Message: 1010
<ce> By the authority of %t %rn of %reg,
<ce> general _general_ of __palace_ orders
<ce> the capture of _bandit_, a brigand
<ce> who has been harassing the people of
<ce> %reg for far too long. 
<ce> Last known location: _house_ in __house_
<ce> Bring the criminal to _general_ at 
<ce> the __palace_ palace in the next =timer_ days
<ce> to claim the reward.
<ce> Reward: =gold_ pieces dead.
<ce>  =gold2_ gold pieces alive. 

Message: 1011
No idea
<--->
No, doesn't ring a bell, sorry
<--->
Am I supposed to know who it is?
<--->
No, sorry, don't know.
<--->
_bandit_? I think %g used to own a house in __house_.
<--->
_bandit_... the criminal? %g claimed some abandoned property. ___dungeon_ I think it's called.

Message: 1012
<ce> This seems to be a map to a place called ___dungeon_

Message: 1013
<ce> Okay, okay, no need to get violent.
<ce> I'll give you =gold3_ gold pieces
<ce> and a _gem_ to leave me alone.
<--->
<ce> Let's be reasonable. How about
<ce> I get left alone, and you get =gold3_ gold
<ce> and a gem? Doesn't that sound good?
<--->
<ce> You're here for the reward, right?
<ce> that means you have a price.
<ce> How does =gold3_ gold and a _gem_ sound?

Message: 1014
<ce> Have it your way then.
<--->
<ce> Okay, so be it then.
<--->
<ce> Your loss. Die.

Message: 1015
<ce> Alright, alright! I give up! Don't hurt me!
<--->
<ce> _foe_ falls unconscious from your blow.
<ce> You quickly tie %g2 up before %g wakes up.

Message: 1016
<ce> Good choice, %ra
<--->
<ce> Smart %ra
<ce> Let's forget this ever happened.
<--->
<ce> Good, good. Here you go. Move along then.

Message: 1017
<ce> So you're trying to capture _bandit_?
<ce> There's =timer_ days left for the reward.
<ce> Come back when you have something.

Message: 1018
<ce> You hand the criminal over to _general_

Message: 1019
<ce> You show the body to _general_

Message: 1020
<ce> With _bandit_ dead, you tie
<ce> up the body as best you can.

QBN:
Clock _timer_ 00:00 0 flag 17 range 0 2
Person _general_ faction Random_Knight
Place _palace_ remote palace
Place _house_ remote house1
Foe _enemy_ is Barbarian
Foe _guard_ is 2 Warrior
Person _bandit_ faction Default anyinfo 1011
Place _dungeon_ remote dungeon11
Item _paper_ letter used 1010
Item _map_ letter used 1012
Item _gold_ gold range 500 to 700
Item _gold2_ gold range 1000 to 1500
Item _gold3_ gold range 500 to 1000
Item _gem_ gem
Item _corpse_ dead_body 

--	Quest start-up:
	get item _paper_
	start timer _timer_
	place npc _general_ at _palace_
	place foe _enemy_ at _dungeon_
	restrain foe _enemy_
	_map_ used do _revealdungeon_
	pc at _dungeon_ set _guards_
	make _gem_ permanent

_guards_ task:
	create foe _guard_ every 5 minutes indefinitely with 25% success

_revealdungeon_ task:
	reveal _dungeon_

_timer_ task: 
	end quest

_s0_ task:
    when skill Streetwise is at least 0

_s20_ task:
    when skill Streetwise is at least 20

_s40_ task:
    when skill Streetwise is at least 40

_s60_ task:
    when skill Streetwise is at least 60

_s80_ task:
    when skill Streetwise is at least 80

_0to20_ task:
    when _s0_ and not _s20_

_20to40_ task:
    when _s20_ and not _s40_

_40to60_ task:
    when _s40_ and not _s60_

_60to80_ task:
    when _s60_ and not _s80_

_80to100_ task:
    when _s80_

_bribe_ task:
	clicked foe _enemy_
	prompt 1013 yes _bribed_ no _refuse_

_bribed_ task:
	say 1016
	get item _gold3_
	get item _gem_
	end quest

_refuse_ task:
	say 1014
	unrestrain foe _enemy_

_hit_ task:
	injured _enemy_
	
_chance1_ task:
	when _0to20_ and _hit_
	pick one of _capture_ _nocapture_ _nocapture_ _nocapture_ _nocapture_

_chance2_ task:
	when _20to40_ and _hit_
	pick one of _capture_ _capture_ _nocapture_ _nocapture_ _nocapture_

_chance3_ task:
	when _40to60_ and _hit_
	pick one of _capture_ _capture_ _capture_ _nocapture_ _nocapture_

_chance4_ task:
	when _60to80_ and _hit_
	pick one of _capture_ _capture_ _capture_ _capture_ _nocapture_

_chance5_ task:
	when _80to100_ and _hit_
	pick one of _capture_ _capture_ _capture_ _capture_ _capture_ _capture_ _capture_ _capture_ _capture_ _capture_ _nocapture_

_capture_ task:
	say 1015
	remove foe _enemy_
	add _bandit_ face

_killed_ task:
	killed _enemy_
	remove foe _enemy_
	add item _corpse_

_nocapture_ task:

_qclicked_ task:
	clicked npc _general_

_clearclick_ task:
	when _qclicked_ and not _capture_ and not _havecorpse_
	say 1017
	clear _qcklicked_ _clearclick_

_reward1_ task:
	when _qclicked_ and _capture_
	say 1018
	give pc _gold2_
	end quest

_reward2_ task:
	when _qclicked_ and _killed_
	say 1019
	give pc _gold_
	end quest

I tried copying and pasting that specific line to test it in other quests and it works as intended (gives a time limit based on distance). I also tried to replace it with a static time limit on this specific quest and that also works fine. Not sure what about this specific quest is causing it to always return 0.
Can anyone check if this happens when you try to run it too or it's just a problem with my install?
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

User avatar
Jay_H
Posts: 3881
Joined: Tue Aug 25, 2015 1:54 am
Contact:

Re: Automatic quest timer always returning 0

Post by Jay_H »

I tested it, and the same thing happens with me. The quest timers in DFU are a bit nebulous, not something completely figured out. However, no matter what I tried here, I couldn't get a proper timer working. It's the same timer I use in my quests, so I can't imagine what the problem is.

User avatar
Hazelnut
Posts: 2970
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Automatic quest timer always returning 0

Post by Hazelnut »

My first thought is that there are 3 places defined and I don't know how the timer would know which one to calculate time for the distance for. Looking at the code it seems to add distance times for each place and then multiply by 2.5 to allow for the return journeys.

Maybe one of the places is causing this calc to fail. Do you see anything in the log lines of the console?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Jay_H
Posts: 3881
Joined: Tue Aug 25, 2015 1:54 am
Contact:

Re: Automatic quest timer always returning 0

Post by Jay_H »

I changed the order of each place and pruned them down to one, and no matter what permutations I tried, it always returned timer zero. This is a very odd case.

User avatar
pango
Posts: 3146
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Automatic quest timer always returning 0

Post by pango »

For me, what made a difference was to put the Clock declaration after Place declarations.
I don't know the quest engine well, but could clock deadline be computed after all declarations have been processed, so that it doesn't matter?
Cheaper but less convenient fix would be to require declarations to happen in a specific order in the quest file
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 6896
Joined: Sun Mar 22, 2015 1:51 am

Re: Automatic quest timer always returning 0

Post by Interkarma »

If timer is dependent on some Place, it makes sense that Place should be declared first. Good catch, and thank you Pango.

I think declaring timers after place resources is a good "best practice" to follow.

imsobadatnicknames
Posts: 362
Joined: Sun Jun 02, 2019 4:28 pm
Location: Colombia

Re: Automatic quest timer always returning 0

Post by imsobadatnicknames »

Ooooh that makes sense. Looking at the other quests where I've used that timer, I do indeed usually put it at (or near) the end of the declarations section, not sure why this time I put it at the start, probably because it was the part of the quest that required the least effort to set up :p Thank you for finding the issue
Released mods: https://www.nexusmods.com/users/5141135 ... files&BH=0
Daggerfall isn't the only ridiculously intrincate fantasy world simulator with the initials DF that I make mods for: http://www.bay12forums.com/smf/index.php?topic=177071.0

Post Reply