Checking for player character being at a specific place

For all talk about quests. Creating, testing, bugs, and development progress.
Post Reply
haloterm
Posts: 100
Joined: Sat Feb 16, 2019 5:21 am

Checking for player character being at a specific place

Post by haloterm » Mon Feb 03, 2020 10:00 am

Hi,

thanks to Jay_H's great tutorials and after studying a lot of existing quests, I have finally started to write a quest. And I will probably ask a lot of questions in the future here.

I want this quest to start automatically once the player is in Daggerfall City and it is between 17:30 and 22:00. The time condition works fine, but not the place condition.

I tried the following (just a snippet of the relevant parts):

Code: Select all

-- The City of Daggerfall
Place _DaggerfallCity_ permanent DaggerfallCity1

-- needed for the quest to start up immediately
Clock _init_ 0:00

-- needed for the quest to finish shortly after start (as this quest only starts MDBHC001)
Clock _finish_ 0:02


-- ** Tasks **

-- Quest start-up:
start timer _init_

_init_ task:
    when _Evening_ and _InDaggerfallCity_
        say 1027
        start timer _finish_
        pick one of _intro1_ _intro2_ _intro3_
        start quest MDBHC001

_finish_ task:
    end quest


-- this task ensures that the quest only starts in late afternoon and evening
_Evening_ task:
    daily from 17:30 to 22:00

-- this task checks if player is at Daggerfall City and sets the "arrived" task (like a flag)
_InDaggerfallCity_ task:
    pc at _DaggerfallCity_ set _FlagArrived_

-- this empty task is just a flag which is checked in the _init_ task above
_FlagArrived_ task:

Where is my mistake? (For the city name, I also tried DaggerFall2, as listed in the Quest element index, but does not work either.)

haloterm
Posts: 100
Joined: Sat Feb 16, 2019 5:21 am

Re: Checking for player character being at a specific place

Post by haloterm » Mon Feb 03, 2020 11:59 am

Okay, I think I have found a solution (and I also swapped a few lines to make sure the finish timer does not start before the the messages are shown and the other quest has been started):

Code: Select all

-- Quest start-up:
start timer _init_

_init_ task:
    when _Evening_
        pc at _DaggerfallCity_ do _BHCBegin_

_finish_ task:
    end quest

_BHCBegin_ task:
    say 1027
    pick one of _intro1_ _intro2_ _intro3_
    start quest MDBHC001
    start timer _finish_


-- this task ensures that the quest only starts in late afternoon and evening
_Evening_ task:
    daily from 17:30 to 22:00
I don't know really why this variant works and the other not, but anyway...

Using TheLacus' DFTemplate for VSCode I have the impression that DFU is not supporting everything that is described for player location in Donald Tipton's documentation? For example, he mentions:
pc at aPlace do aTask
when pc at aPlace
when pc not at aPlace
pc at anNPC do aTask
when pc at anNPC
when pc not at anNPC
Whenever I try any of these variants, the editor gives me error message; it only seems to accept "pc at" as valid, but none of the variantions with "when" (which would be useful, for checking if I am NOT at a specific place. But I don't know if these are not implemented in DFU or just not in the DFTemplate for VSCode.)

As a side note ... I really wish Daggerfall's script language would be something more like a common programming language.

It would be much easier (for me) to write something like

if (Player.location == Game.locations.DaggerfallCity) and (World.time > "1730") and (World.time < "2200") then (do all the stuff) else (do nothing) end

Anyway, I'll stick with what we have (and am happy that we have it).

User avatar
TheLacus
Posts: 1064
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Checking for player character being at a specific place

Post by TheLacus » Mon Feb 03, 2020 3:08 pm

pc at switches target task to set/unset when player is or is not at a given position.

Code: Select all

-- Main task.
	-- Start running _checkPlace_
	start task _checkPlace_

-- Holds set/unset flag
variable _isAtPlace_

-- Update _isAtPlace_ (only if _checkPlace_ is set!)
_checkPlace_
	pc at _DaggerfallCity_ set _isAtPlace_
	
-- Run when not at place
_example_
	when not _isAtPlace_
Some actions keep being executed when parent task is set (like pc at); other actions are executed once when task changes from unset to set (like say message).
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

haloterm
Posts: 100
Joined: Sat Feb 16, 2019 5:21 am

Re: Checking for player character being at a specific place

Post by haloterm » Mon Feb 03, 2020 7:45 pm

TheLacus wrote:
Mon Feb 03, 2020 3:08 pm
pc at switches target task to set/unset when player is or is not at a given position.

(snip)

Some actions keep being executed when parent task is set (like pc at); other actions are executed once when task changes from unset to set (like say message).
Thank you so much!

Is there somewhere a documentation on the actions which keep being executed?

How accurate in general is the old Tipton documentation of the Template language for DFU? Can one rely on that mostly, or does DFU implement a subset of it, so it's better to stick with Jay_H's tutorials?

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

Re: Checking for player character being at a specific place

Post by Interkarma » Mon Feb 03, 2020 9:08 pm

The Tipton docs are a reasonable reference. But not entirely accurate and don't cover a lot of internal behaviour of the quest system. The best way to learn is by cracking open other quests to see how they work, and by writing lots of quests to build up a library of patterns you can use in different situations.

DFU's quest implementation is a superset of classic. There are many actions & conditions that only exist in DFU. Unfortunately these aren't well documented at this time. It would be nice to someday write an enhanced reference with all the new commands and additional info, such as whether a conditional is a toggle or one-way trigger, or if an action can rearm when its state block toggles off and back on again.

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

Re: Checking for player character being at a specific place

Post by Jay_H » Mon Feb 03, 2020 9:20 pm

Interkarma wrote:
Mon Feb 03, 2020 9:08 pm
The best way to learn is by cracking open other quests to see how they work, and by writing lots of quests to build up a library of patterns you can use in different situations.
Absolutely this. When I write quests, I copy-paste a ton of my old material again and again, and just write new dialogue. You start to memorize how each thing corresponds to another -- and bug-testing will teach you everything you don't know.
Come join Lysandus' Tomb, a Daggerfall Unity fan Discord.
See the Daggerfall Unity Wiki on the UESP.

Post Reply