[MOD] Galactic Waez navigator

Discussion in 'The Hangar Bay' started by HoberMellow, Sep 16, 2021.

  1. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    Hello everybody,

    Galactic Waez is an in-game navigator that finds the shortest path from your current location to any star--even those you haven't been to. All you have to do is place a marker on the destination star and tell Waez to take you there. It will find a path and place waypoints on your galaxy map.

    I'm looking for folks to try it out and give feedback. Single-player only right now, but I want to do a server version as well.

    How it works:
    Once installed, just load up your save. Once you enter the game, Waez constructs a "galactic highway map" (more on that below) and lets you know when it's ready with a little message.
    upload_2021-9-16_11-58-45.png

    To navigate, place a marker on the star you want to go to. Then enter "/waez to <marker>" in global chat.
    upload_2021-9-16_12-2-18.png

    Here, you can make out a few of the waypoints on the map.
    upload_2021-9-16_12-4-36.png

    And that's pretty much it. If you change your mind and want to remove all those waypoints, use "/waez clear." Also, if your destination star is one you've been to before, you can call it by name without adding a map marker. Oh, and if you're playing Reforged Eden, your upgraded warp range is taken into account. I assume this works for regular Project Eden as well, but haven't tried it (it just relies on the PilotLYRange property).

    Here's a quick rundown of commands:
    /waez status - find out if Waez is ready
    /waez to <name> - plot a course to <name>
    /waez clear - remove waypoints named Waez_*
    /waez help - print help

    Installation:
    Just download the .zip and extract it to Content\Mods in your Empyrion - Galactic Survival folder.

    Known Issue: [as of version 0.5.2, this issue is thought to have been mitigated]
    It's possible that Waez may not find all the stars. I'm not sure of the cause, but you can check for this by bringing up the console:
    upload_2021-9-16_12-26-38.png
    Make sure the highlighted numbers match. If they don't, you can enter "/waez restart" and it will try again.
    I believe it could happen on any load, but galaxy size is a factor as I've only seen it happen twice, and only on my RE save where the galaxy is almost 3 times as large as the one pictured.
     

    Attached Files:

    #1
    Last edited: Sep 25, 2021
    Sup, byo13, KRanKO5 and 7 others like this.
  2. ravien_ff

    ravien_ff Rear Admiral

    Joined:
    Oct 22, 2017
    Messages:
    6,291
    Likes Received:
    11,946
    Wow this could be really useful! Thanks for your hard work making this.
     
    #2
    byo13, KRanKO5 and HoberMellow like this.
  3. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    Very nice, do you have the source code also on GitHub so that I can extend the mod that e.g. it also runs on MP server?
     
    #3
    HoberMellow likes this.
  4. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    #4
  5. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    Just discovered an issue where if you have no map markers anywhere, it would fail to add your route to the db. Fixed it and updated the .zip above.
     
    #5
  6. Homunk

    Homunk Lieutenant

    Joined:
    Mar 22, 2020
    Messages:
    74
    Likes Received:
    26
    @HoberMellow
    Congratulations! :D You made a very nice and useful tool. :thumpUp: And it is easy to use.
    So far I had no problems with it, although it doesn't make use of the increased jump range you get from Reforged Eden. But this a very minor issue and I mention it only, because the first post says it does.;)
     
    #6
    Myrmidon and KRanKO5 like this.
  7. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    Thanks! And no worries, I'm not trying to lie to folks :)
    I just checked, and it's finding jumps >30LY for me, though. If you upgraded since you loaded, you'll have to do "/waez restart" to update its map. Could that be your issue? I'm working on a fix for the not-noticing-upgrades thing.
     
    #7
  8. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    465
    Likes Received:
    340
    @HoberMellow ... wow! I am working on something similar but my solution required marking waypoints to consider as bookmarks. The way you are doing an end run on accessing the stellar map is wild- if I am reading this right you grab the first star and use the x/y/z as a byte-wise finger print, jump to kernel mode and ignore scope to scan the code psect, and then when you find it map your own array on top ... that's SOOOO wrong! Congrats on cracking the problem.
     
    #8
    Myrmidon likes this.
  9. me777

    me777 Commander

    Joined:
    Aug 18, 2020
    Messages:
    406
    Likes Received:
    139
    Took a look at the Code and I must say its better than any C# I ever hacked together :thumpUp: (just self-tough)
    Too bad I play on a Server, but Empyrion Scripting runs better there and I use it a lot.
    looking forward to the server version ;)

    The mod I tried to make was putting waypoints to autominers on the current playfield; I got the autominer positions but failed in creating the waypoints...
     
    #9
    KRanKO5 likes this.
  10. ravien_ff

    ravien_ff Rear Admiral

    Joined:
    Oct 22, 2017
    Messages:
    6,291
    Likes Received:
    11,946
    People seem really happy about the existence of this mod. :D
     
    #10
    KRanKO5 likes this.
  11. LordDread

    LordDread Ensign

    Joined:
    Jul 8, 2018
    Messages:
    1
    Likes Received:
    0
    Oh this looks awesome, will be tryen it out soon .. hope you can work out a server version .
     
    #11
  12. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    @me777 I'd be happy to help you get the waypoints figured out, if you'd like.
    @ravien_ff I'm honored to hear it!

    All these good vibes, y'all got me gushing with pride over here </sap>
     
    #12
    stanley bourdon and ravien_ff like this.
  13. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    @HoberMellow
    I made an attempt to get this code to work in MP....

    but then the problems start:
    - The data of the galaxy can not be full accessed (i think there is no in memory galaxy map in the dedicated process)
    - Events are different or do not work and the code have to be refactored to run in both MP&SP
    - Player data must be taken from the current ChatMessage - i.e. all these methods must be refactored.
    - Some data like e.g. the current SolarSystem coordinates can be determined only over a high programming expenditure because they are only exists in the playfield server process.
    - The algorithm is based on initializing the galaxy once with the jump range of the player which of course has to be done for each player in MP. (for the first tests i fake the GetLocalPlayerWarpRange to 30)
    - ...

    here a small log from the start sequence of my tests
    19-09:08:23.203 11_08 -LOG- Loaded sector file C:\steamcmd\empyrion\DedicatedServer/../Saves/Games/DefaultRE/Sectors/Sectors.yaml with 593 playfields, needed 1681ms
    19-09:08:23.640 11_08 -LOG- Generating stars=44307 took 434
    ...
    19-09:08:24.063 11_08 -LOG- {GalacticWaez} GalacticWaezClient attached.
    19-09:08:24.064 11_08 -LOG- {GalacticWaez} BuildGalaxyMap
    19-09:08:24.064 11_08 -LOG- {GalacticWaez} SaveGameDB
    19-09:08:24.114 11_08 -LOG- {GalacticWaez} GetFirstKnownStarPosition
    19-09:08:24.434 11_08 -LOG- {GalacticWaez} FindStarData
    19-09:08:24.434 11_08 -LOG- {GalacticWaez} GetLocalPlayerWarpRange
    19-09:08:24.537 11_08 -LOG- {GalacticWaez} CreateGalaxy
    19-09:08:24.537 11_08 -LOG- {GalacticWaez} Located 1931 stars in 320ms.
    Constructed galactic highway map: 1931 stars, 158837 warp lines. Took 0,101s.
    19-09:08:24.537 11_08 -LOG- {GalacticWaez} Listening for commands.
    [/CODE]
     
    #13
  14. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    465
    Likes Received:
    340
    @HoberMellow called it out in client based games as well. I did a local build and while I can load all the stars (19K+) in a vanilla game a reforged eden save I made (44K+ stars) is loading only 3,209 of them consistently. He thought it may be a page boundary issue and had some ideas, fingers crossed.

    @Taelyn .. you guys have a number of chunks of private static or slowly changing data that aren't exposed in the API or instantiated in the db (here I'm thinking of domains like facid|faction and similar) ... I know adding those into the db or the api are not only work but in some cases potentially fodder for information exploits and hits performance in ways that you can't control.

    Having said that in this case SolarSystems data is very narrow and <100K rows of db data that is static and deterministic is a pretty great candidate for a preloaded db table (fill factor 100% with whatever indexes make sense). This would expose information that is already available to the player via the UI so the exploit concern isn't there.

    If the current playfield gen code that uses SolarSystems was changed to grab the ssid and use it as opposed to generate one, add a row and then use it it should actually improve the performance of playfield gen and would open up a whole bunch of really great options for mod devs and you guys as well.

    I would cheerfully buy you guys a beer if you could come up with an easy for you way of sharing this data with us, either through static db tables or a console "export <struct> <filename>" sort of console command. (b)eerSmileyHere
     
    #14
    HoberMellow likes this.
  15. HoberMellow

    HoberMellow Lieutenant

    Joined:
    Sep 16, 2021
    Messages:
    12
    Likes Received:
    25
    @imlarry425, @ASTIC since you guys have messed around with this thing, do you mind pulling the region-boundaries branch and try it out? I overhauled the StarFinder and to test, I started 13 new reforged saves, interspersed with reloading my regular save or one of the other new ones, and it found all stars the first time each time.

    Also, to address some of the other problems ASTIC mentioned:
    - for SolarSystemCoordinates, do you think we could have the client detect a request being sent, and send along that data? Or, perhaps the server can deduce it from the PlayerPosHistory table? Hopefully, there's an easier way.
    - I added a parameter to the AstarPathfinder.FindPath method to accept a warpRange. This is so we can build the Galaxy using the maximum range, then limit the search using the appropriate range for the player.
     
    #15
    KRanKO5 likes this.
  16. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    465
    Likes Received:
    340
    @HoberMellow ... an order of magnitude better than 3,219. 8^)

    That said, did get the same "and yet it doesn't work sometimes and not sure how to repo" you saw originally but only once. The one labelled "first run" is first run after game create and then full exit to desktop and restart the game. The one with "second run" is again full exit and restart.

    upload_2021-9-19_15-24-40.png
     
    #16
    Last edited: Sep 20, 2021
  17. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    I can do that.
    - The A* algorithm is actually intended for such wayfinding problems, maybe I'll try it out.
    - The player information IPlayer you get via the "old" V1 Api
    - Have a look at what "first" modifications I made for MP here using ChatMessage for player identification. https://github.com/GitHub-TC/EGS-GalacticWaez
    But this version is not for SP - it will be a significant development and testing effort to get this working for both MP & SP and keep it working :-(
    - Also you should reply on the same chat channel so that you can use the faction chat in MP.
    - But the problem with the InMemory galaxy map will probably remain
    - ...
     
    #17
  18. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    465
    Likes Received:
    340
    Since the same mechanism is used to generate either an MP or an SP galaxy, and given a seed and scenario the resulting maps are deterministic you can do a workaround (albeit a kludgy one) by using a cache after a successful scrape of an SP map.

    @HoberMellow ... if you had an export command that a player could run after the "theyCreated == iFound" and after doing it subsequent runs of DoInit() check for the existence of the cache file before attempting the scrape you only need to succeed once and even if MP was never doable an multiplayer server manage could still copy the cache data for a particular seed/scenario from an SP game as part of their setup housekeeping. Some ugly manual steps for MP but doable.

    I started poking at it but my C# sucks (SQL is the hammer that defines nails for me) so this is a learning experience; I'm working on how to iterate stars out of the map. 8^)


    if (commandText.Equals(CommandToken.Export))
    {
    var file = @"\waez.csv";
    try
    {
    File.Delete(file);
    }
    catch (DirectoryNotFoundException dirNotFound)
    {
    string message = status.ToString();
    modApi.Application.SendChatMessage(new ChatMessage(dirNotFound.Message,
    modApi.Application.LocalPlayer));
    }
    var csv = new StringBuilder();
    foreach (StarType star in galaxy)
    {
    var newLine = string.Format("{0},{1},...", star[0], star[1],...);
    csv.AppendLine(newLine);
    }
    File.WriteAllText(file, csv.ToString());
    return;
    }
     
    #18
  19. ASTIC

    ASTIC Rear Admiral

    Joined:
    Dec 11, 2016
    Messages:
    1,094
    Likes Received:
    735
    The Problem the a local mod not run when you connect to a server.

    Only when the the server not runs with EAC which is not recommended.
     
    #19
  20. imlarry425

    imlarry425 Captain

    Joined:
    Jan 10, 2019
    Messages:
    465
    Likes Received:
    340
    Got ya. I'm working on a local offline client in python to avoid that but was stuck doing SolarSystem UNION Bookmarks to get data ... not really sure what you can do server-side live with or without EAC but I seem to remember that EAH has hooks for some sort of extension system using chat. Not sure what that's build around.
    upload_2021-9-20_11-28-37.png
     
    #20
    Myrmidon and HoberMellow like this.

Share This Page