Jump to content

Map sharing mod feasibility.


Recommended Posts

Hi,

 

This would be my first mod so I do not know a lot about the game inner workings. I've done some searching but did not find an API specification, is there one? I know most of the game's code is in the lua files, but what I really want to know is the C/Lua interface and that I could not find.

 

The final mod would be some kind of cartography item that could be crafted and used to share the map portions the player knew when crafting it. For now I would be quite content with a "players share minimap knowledge" toggle mod.

 

I've been looking for a way to share the discovered portions of the map between clients but had little success so far. Most data about the revealed parts of the map seems to be in the native part.

 

I've stumbled upon some code that seems to say that the revealed map data is not stored in the serve side. That shouldn't really matter right now, but it is nice to know. There is a "{player_id?}_minimap" file inside the '/Documents/Don't Starve Together/save/sessions/{world_id?}/" folder but it uses some unknown binary format. I guess it must be a texture for the revealed map area and an ID list for the entities found so far.

 

The only success I had was with this function:

TheWorld.minimap.MiniMap:ShowArea(float x, float y, float z, float range)

It does reveal the circle defined by that position and range and I think this could be used to make a first version of the mod. It does not add any objects to the revealed portion of the map, only the terrain. That is controlled in the objects themselves I think. I did not test the function on a client, only on the server.

 

That is all I got till now, so what do you think?

Is any version of this idea possible with the current API?

 

 

Link to comment
Share on other sites

@ZehZehZeh, Believe me, if this were easy to do, it would've been done already. It's been the most requested feature in DST so far.

 

There is no API for the C++ code at the moment. Working with the map is extremely hit-or-miss. It would be possible to have it sync player locations globally, then use ShowArea to reveal areas around them, but map revealed this way appears to not be serialized when you leave (doesn't get saved).

 

One of the things PeterA and MarkL are planning to do at some point would be to provide an API for the C++ code, which may help a great deal here. Otherwise, the best we can do for now is look at places that the C++ code gets called from the Lua, or to decompile the C++ code and look at the functions for the LuaProxy objects. I have little experience decompiling C/C++, but it appears that to do it fully is extremely labor-intensive, so getting anything beyond the function names is pretty much impossible.

 

I did a pass through the Lua code to see what I could find on the minimap userdata (C++) object:

RebuildLayer(tile_type, x, y) --this is used when tiles are changed, e.g with pitchforkEnableFogOfWar(enable) -- setting this to false seems to reveal the entire map (until reenabled)ContinuouslyClearRevealedAreas(hide_revealed) -- not sure what this is for (??)ClearRevealedAreas() -- presumably one-time version of above?EnablePlayerMinimapUpdate(enable) -- this is what gets toggled when you become a ghostDrawForgottenFogOfWar(enable) -- this seems to hide the previously explored areas entirely if toggled offCacheForgottenEntities(enable) -- I'm guessing this sets it to keep any previously-encountered minimap entities on the minimap. I didn't notice an obvious difference when I set it to false, but maybe it matters more for clients.IsVisible()ToggleVisibility() -- these two are used in hiding/showing the map screen
Edited by rezecib
Link to comment
Share on other sites

int GetTextureHandle()int GetZoom()void Zoom(int)int ResetOffset()void AddRenderLayer(uint)void EnablePlayerMinimapUpdate(bool)void DrawForgottenFogOfWar(bool)void CacheForgottenEntities(bool)void Offset(Vector2<float>)void AddAtlas(string xml_filename?)void SetEffects(string clear_filename?)bool IsVisible()void ToggleVisibility()void ShowArea(Vector3<float>, float)void EnableFogOfWar(bool)int? ContinuouslyClearRevealedAreas(bool?)void RebuildLayer(char, int, int)int? ClearRevealedAreas(bool?)

After some digging.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...