Jump to content

[Newbie] Assistance required-map


Recommended Posts

Hi, I'm trying to make a mod for automatic map sharing. I was wondering if anyone could point me to which files deal with updating the map with the current position of your character. If I broke any rules just holler and I'll change whatever I need too. Thanks :D

~Lulach

Link to comment
Share on other sites

I've working on it too this weekend, but I've found a few problems. My work in progress:

GLOBAL.CHEATS_ENABLED = trueGLOBAL.require( 'debugkeys' )---------------------------------------------------------------------local minimap = nillocal players = { }local REVEAL_SIZE = 30local UPDATE_TIME = 0.5---------------------------------------------------------------------function UpdateSharedMap()  if minimap ~= nil then    local deletedPlayers = {}        for i=1, #players do      local oPlayer = players[i]      if oPlayer ~= nil and oPlayer ~= GLOBAL.ThePlayer and not oPlayer:HasTag("playerghost") then        local x,y,z = oPlayer.Transform:GetWorldPosition()        if x ~= nil and y ~= nil and z ~= nil then          minimap.MiniMap:ShowArea(x, y, z, REVEAL_SIZE)        else          table.insert(deletedPlayers, i)        end      end    end        for i=#deletedPlayers, 1, -1 do      table.remove(players, deletedPlayers[i])    end  endend---------------------------------------------------------------------local function RegisterPlayer(oPlayer)  if #players == 0 then    oPlayer:DoPeriodicTask(UPDATE_TIME, UpdateSharedMap)  end  table.insert(players, oPlayer)end---------------------------------------------------------------------local function RegisterMiniMap(oMiniMap)  minimap = oMiniMapend---------------------------------------------------------------------AddPrefabPostInit("minimap", RegisterMiniMap)for i=1, #GLOBAL.DST_CHARACTERLIST do  AddPrefabPostInit(GLOBAL.DST_CHARACTERLIST[i],  RegisterPlayer)end

I have to big problems, or a big problem and a wish:

- The problem is that it's updated properly, but it's not saved if the player disconnects.

- My wish is that I'd like to retrieve the state of the map when a player logs in, so I can synchronize the maps with new players. This is useful if two players haven't been playing at the same time, or if a player has been playing with the mod disabled and then he starts using it. I'm not sure if it can be done.

 

Note: as I said, it's a WIP so there are some bad practices, like the way I cache the players (in particular how I get the local player looks pretty unsafe and unaccurate, but I did it for fast testing) and the minimap (furthermore, I think that the minimap can be accessed using TheWorld.minimap.MiniMap).

 

I hope that it helps you, and somebody smarter than me can help us both :-)

Link to comment
Share on other sites

Yeah me and a friend tested this out earlier and it works like you said, after reading the code I wonder if maybe the problem is that the minimap that is created from the shared data is not saved to the ~official~ minimap. I haven't programmed at all in Lua and I am having some trouble digging around the code. If we could find the process that updates the official minimap it should just be a small tweak in your code to keep it saved. As for the other problem of new people joining the game or rejoining after taking a break that almost seems like it would be easier to make a prefab *map* that you could use or trade on the new person to update there map(it didn't seem to me like there was any easy way to send saved information from one person to another). If you want to maybe skype or something I would definitely be open to maybe skyping and using eachother for fresh ideas. Admittedly you are probably much more knowledgable than me.

Link to comment
Share on other sites

The problem about sharing the map when connecting is that I don't know how to ask the map if a specific tile is discovered or not. If I could get that info, it would be easy to OR the local player's map with remote player's maps. (Maybe this could be solved with something similar to the auxiliar file that I describe below)

 

About ShowArea, it's a method implemented in C++ probably. My guess is that they have the logic funcionality of the map (the matrix of booleans that mark a tile as visible or not, the serialization and deseralization methods, the update process that unlocks your path when you move, etc.) in a CLogicMap class, and the visual representation of it in CVisualMap class. ShowArea may be modifying CVisualMap, but as I said, the logic part is the one that rules the save-to-disk feature. It's only my guess, and maybe I'm wrong. A possible solution with this approach could be to write an additional file with the "extra" unlocked tiles (those that have been discovered by other players), and make an OR with it when the local map is loaded from disk at the beginning. But again, I don't know if the API supports writing to disk. I'll research it when I had time (this weekend with some luck).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...