eliasdoehne / stellaris-dashboard

A graph dashboard and event log for Stellaris.
123 stars 14 forks source link

Anomaly logging #94

Open Abolohit opened 1 year ago

Abolohit commented 1 year ago

Is it possible to log the date and time and location when an anomaly is discovered by a science ship, and a description of the anomaly as shown by the game? Plus, when the anomaly gets researched, and the results of the research?

eliasdoehne commented 1 year ago

Yes, with changes from the recent updates it may be possible to add some anomaly information. Previously, this was not really an option because the save files only contain some technical IDs so there was no way to show any useful anomaly name or description. But in recent updates, it seems that Stellaris devs have been moving the text into some text files that can actually be accessed and parsed.

eliasdoehne commented 1 year ago

So it will probably be added at some point but it seems like quite a lot of work, so I can't say when

Abolohit commented 1 year ago

Thanks for the update!

This issue can be kept open as a probable feature to be added later, converting it into a feature request?

eliasdoehne commented 1 year ago

Yes let's keep it open 👍

MichaelMakesGames commented 4 months ago

I did some investigation into this. tldr seems real tricky.

Countries have data like the following:

        events=
        {
            next_special_project_id=14
            completed_event_chain="market_founding_chain"
            anomalies=
            {
                2709 2711 9292 9304 
            }
        }

anomalies is a list of planet IDs that have unresearched anomalies

Those planets have an anomaly entries like anomaly="DISTAR_MERCURY_CAT"

We can look up the name of an anomaly with the loc key of the same name (eg DISTAR_MERCURY_CAT). By convention, descriptions use keys like DISTAR_MERCURY_CAT_DESC, but technically, anomaly definitions (in common/anomalies) define their description like desc = "DISTAR_MERCURY_CAT_DESC", so that format is just a convention and not 100% reliable.

All of that is just the name and description of the unresearched anomaly. To get the outcome, we need to check countries for flags like anomaly_outcome_happened_distar.150=63355872. I think the numeric value might be some sort of timestamp. The distar.150 part is an event ID. We can look up the name with distar.150.name, but again, that's a convention, not 100% reliable. The descriptions are conventionally distar.150.desc, but they would be very difficult to properly render, as they often contain scope changes and scripted loc, which would essentially require a full Stellaris script parser and interpreter.

There is nothing in just the save data linking eg DISTAR_MERCURY_CAT to distar.150. If we wanted to establish a link between them, we would need to parse data in common/anomalies.

Also a note, anomaly_outcome_happened_<EVENT_ID> flags will just give us the event ID of the immediate outcome, but that could be the start of an event chain that happens outside the bounds of what is technically considered an "anomaly".

MichaelMakesGames commented 4 months ago

If we want to avoid implementing a full script parser, here's what we could do:

MichaelMakesGames commented 4 months ago

Some more thoughts: we could also get more info from event_chain and special_project entries in countries' events data. These are often related to anomalies (though I'm guessing we wouldn't want to log all the debris special projects; that seems like it would add a lot of "noise" to the event log).

A separate thought: we could get more info by modding in some on_action events, which log info to game.log which we then parse. This could open up a lot of things beyond just anomalies that we can't do with save parsing alone. This would change the checksum though (so no achievements, and required for all players in multiplayer), so if we do it, it should be an optional companion mod. A neat side effect, other mods could log their own events in some standard format to get them included in the dashboard, with no implementation needed on our side.

@chennin curious if you have thoughts on any of the above (earlier posts too)