How would you implement an auto-walk function?

Discuss modding questions and implementation details.
jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Tue Sep 18, 2018 3:20 pm

Thanks. In that case I must have broken something quite badly somewhere, because it doesn't log there anymore. I know of that file, but it wasn't up to date, and when I deleted it no new one was created. I'll try launching mod-free and see if it logs again...

jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Tue Sep 18, 2018 10:35 pm

Aha, didn't realise that the log was written to my user folder. It used to be in the the DaggerfallUnity_Data folder at some point.
Not sure how I feel about the potential confusion of not being able to tell which particular install a log file is from, but oh well...

In any case, I found the source of my troubles. Well, the first of them at least, I fully expect them to be more once that is resolved, but this one has me stomped already. Here's what it says:

Code: Select all

Error (1061): Type `DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallHUD' does not contain a definition for `HUDCompass' and no extension method `HUDCompass' of type `DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallHUD' could be found. Are you missing an assembly reference?
I'm very unfamiliar with C#, so I'm not quite sure what "assemblies" are about, exactly. Obviously I'm not missing any namespaces, or the thing wouldn't run in the editor, but I seem to have a dependency problem somewhere. Can anybody tell me how to resolve this kind of error?

Edit: On the other hand, I removed the offending line from the code and now it works, and the compass *still draws*. That seems weird...

jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Wed Sep 19, 2018 10:53 pm

Never mind, the compass does *not* still draw. Guess I was just too darn tired yesterday evening.

In any case, help at resolving that assembly thing would be appreciated.

Another problem has come up which I find myself unable to solve in reasonable time: How can I get the world coordinates of a location? Somehow I can't find anything that would return that. Or are the world coordinates of a location unknown and generated once the player enters the map pixel?

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

Re: How would you implement an auto-walk function?

Post by Interkarma » Thu Sep 20, 2018 7:49 am

jedidia wrote:
Tue Sep 18, 2018 10:35 pm

Code: Select all

Error (1061): Type `DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallHUD' does not contain a definition for `HUDCompass' and no extension method `HUDCompass' of type `DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallHUD' could be found. Are you missing an assembly reference?
Hi jedidia, could you please provide a minimal repro script for the above so I can see what you're doing in context?

Best I can tell from the above message, you are trying using a namespace as a type. If you wish to access the actual DaggerfallHUD and HUDCompass objects used by game at runtime, you'll need a reference to those objects. Fortunately Daggerfall Unity makes this easy with singleton patterns for core classes. Here's an example:

Code: Select all

using UnityEngine;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.UserInterface;
using DaggerfallWorkshop.Game.UserInterfaceWindows;

public class TestBehaviour : MonoBehaviour
{
    private void Start()
    {
        // Get reference to DaggerfallHUD and HUDCompass objects
        DaggerfallHUD hud = DaggerfallUI.Instance.DaggerfallHUD;
        HUDCompass hudCompass = hud.HUDCompass;
    }
}
It's not clear to me what you're attempting with the compass display, or how this relates to your earlier question about auto-walk. But if you can provide more details, either myself or someone else in the community will try to help further. :)

jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Thu Sep 20, 2018 9:58 am

Best I can tell from the above message, you are trying using a namespace as a type.
Hmmm, yes, I definitely should have posted the code along with it. Generally it should be fine, since it works when running the mod from the editor, but not when I run the mod in a regular daggerfall installation. I'll see about a possible repro example in the evening.
t's not clear to me what you're attempting with the compass display, or how this relates to your earlier question about auto-walk.
Yes, I can perfectly understand that. Basically I'm playing around with a travel mod, because I have always disliked the Bethesda teleportation-style fast travel (unless it's literal teleportation in the game, of course). I'm not quite sure yet what the final implementation will look like (or even if there will be one), just playing around with possibilities. And the first (because simplest) possibility that came to mind was to turn the player in the right direction, make him walk, and crank up Unity's timescale. Not sure yet if it will be feasible, because the timescale really cannot be cranked up too much before problems start appearing.
In any case, in this version player control is disabled, and there's a small UI displayed to adjust time compression, interrupt travel etc. That's where it would be really handy to display the compass. Other than that it mostly works (though UI is just a mockup for now), except I keep missing the destination because I can't find a way to get the exact world coordinates of the location (see last post).

jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Fri Sep 21, 2018 7:49 pm

I'm getting some encouraging results, but the inability to get a locations exact world coordinates is killing me. Even when I wait until the location is loaded, its world coordinates are still no more precise than those I get from just resolving the map pixel (I don't know if it's the center or a corner of a map pixel, really, but it's usually not where the location is).

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

Re: How would you implement an auto-walk function?

Post by Hazelnut » Fri Sep 21, 2018 8:18 pm

I'm not completely familiar with this code, but I would expect that what you need is to read the values of WorldX & WorldZ from PlayerGPS. Have you tried that? They get updated from StreamingWorld every frame as you move about the world.

Locations are at a specific map pixel, but I don't know how exactly the coords work within that pixel. From what I've done with large cities I think it comes from the RMB files which have blocks of defined stuff (or nothing) that fill the entire pixel. IIRC it iterates across and then down, but this means that you only can resolve a location to a map pixel. It's been a few months since I was looking so I could be way off, but I hope that helps. Try tracking down blog posts that Interkarma did on the DF world data formats. UESP pages have info as well: https://en.uesp.net/wiki/Daggerfall:MAPS.BSA & https://en.uesp.net/wiki/Daggerfall:BLOCKS.BSA.

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

Re: How would you implement an auto-walk function?

Post by Interkarma » Fri Sep 21, 2018 9:08 pm

Hazelnut is correct that grabbing world coordinates from PlayerGPS is the starting point. I'll update you how to get target location coordinates later today when I'm back behind my PC.

You're probably already aware that DFUnity has two coordinate systems. The world coordinates are measured in Daggerfall units (inches) and span the entire game world. Local coordinates are the positions of everything in Unity scene space (metres). There are several helpers to glue the various coordinates systems together.

There is also a floating origin setup so that scene data is kept close to 0,0,0 at all times while player moves through virtual space and the world streams in around them. It's a bit like running on a treadmill - you can run vast distances in the treadmills virtual world while hardly moving anywhere in the physical world.

jedidia
Posts: 129
Joined: Sat Sep 15, 2018 9:49 am

Re: How would you implement an auto-walk function?

Post by jedidia » Fri Sep 21, 2018 10:02 pm

I would expect that what you need is to read the values of WorldX & WorldZ from PlayerGPS.
That's exactly what I expected, but it turns out that those coordinates only refer to the Map Pixel. I.e. it's always the same for both the map pixel and the location inside that map pixel.

However, I finally figured it out! :D You need to get the location rect from the playerGPS once the location is loaded and then use the center of that as an offset to the locations world coordinates to get the *exact* world coordinates the location is at.

I had figured that probably the exact coordinates might not be available when the location isn't loaded, but I always expected the world coordinates of the generated location to be what I'm looking for. Turns out that is not the case. Not sure if this behavior is intended, if it is I think it should be documented a bit better (something like "world coordinates of the locations map pixel" instead of "world coordinates of the location", because that's really somewhat misleading.

Everything working pretty nicely now. I guess what's left is all the tedious UI work, but first I have to test a bit how long travelling now actually takes. It's really cool on shorter distances, but let's see how long it takes me to traverse the kingdom of daggerfall...

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

Re: How would you implement an auto-walk function?

Post by Jay_H » Fri Sep 21, 2018 10:07 pm

Looking forward to this! Sounds like something people have wanted for awhile :)
Come join the Unofficial Daggerfall Unity Discord.
See the Daggerfall Unity Wiki on the UESP.
Progress on fixing classic quests here.

Post Reply