Page 1 of 1

Worldmaps and how they work

Posted: Sun Jan 24, 2016 5:52 pm
by XLambda
I've been trying to understand the ToME world map and how it works for a while. It's still very confusing, and the fact that the Age of Ascendancy map is darn huge makes it even worse. Here are a few questions, if anyone could help answering them I would be really grateful. :)

1) How exactly do the 'playerpop' and 'zone-pop' spot definitions work? I remember seeing the former called during world creation, setting the wilderness coordinates of the player. However, that apparently only works by setting a default wilderness in the birth descriptor.

2) Is there any way to change or disable the calendar on the world map? Maybe even from inside a running game rather than at world-gen? I looked through the code and don't really understand how that whole system works.

3) Is there a simple way to set wilderness coordinates for the player? Especially considering there might be multiple worldmaps, and the ToME code doesn't really seem to be built for that.

Re: Worldmaps and how they work

Posted: Mon Jan 25, 2016 12:02 am
by HousePet
1) Those are just coordinates that can be called from their label. So the code that makes them do stuff is elsewhere and probably not automated.

2) No idea.

3) That should be easy to do, but I have no idea where that is stored.

Re: Worldmaps and how they work

Posted: Mon Jan 25, 2016 8:02 am
by rexorcorum
I think asking around in the Modules Subforum is your best shot or/and poking at the various modules themselves - Classic ToME, VoTE (is there a world map there at all? don't know) and the others - there were a few made 2 years ago for the Module contest.

Re: Worldmaps and how they work

Posted: Mon Jan 25, 2016 9:34 am
by XLambda
HousePet wrote:1) Those are just coordinates that can be called from their label. So the code that makes them do stuff is elsewhere and probably not automated.
Ah, I see. Yeah, that makes a lot of sense.
HousePet wrote:3) That should be easy to do, but I have no idea where that is stored.
Hm, I think I found it. I'll have to experiment with that a bit, and find a clever way to handle the whole thing.
rexorcorum wrote:I think asking around in the Modules Subforum is your best shot or/and poking at the various modules themselves - Classic ToME, VoTE (is there a world map there at all? don't know) and the others - there were a few made 2 years ago for the Module contest.
That's actually an excellent idea, I'll do that. For some reason I had completely forgotten about the Module contest.

Re: Worldmaps and how they work

Posted: Wed Jan 27, 2016 6:18 pm
by Zireael
If I were you, I'd look at how Zizzo did it in his ToME 2 port. I'm using his code for the worldmap and it seems much more robust than ToME 4's (less prone to stranding you :D)

Re: Worldmaps and how they work

Posted: Thu Jan 28, 2016 4:18 am
by Zizzo
Zireael wrote:If I were you, I'd look at how Zizzo did it in his ToME 2 port. I'm using his code for the worldmap and it seems much more robust than ToME 4's (less prone to stranding you :D)
*blush* [bows] :oops: :wink:

Actually, though, the answers to your questions depend a lot on whether you're asking from the perspective of a module writer or an addon writer:
XLambda wrote:2) Is there any way to change or disable the calendar on the world map? Maybe even from inside a running game rather than at world-gen? I looked through the code and don't really understand how that whole system works.
This, for instance; if you're writing a module, I don't think you actually even have to have a calendar at all, and it only logs the date when you tell it to. The T4 module creates its calendar in either mod.class.Game:runReal() or mod.class.Game:newGame(), apparently based on whether you're starting a new character or loading a savefile, and it logs the current calendar date in mod.class.Game:onTurn(). [And I just noticed that the T2 module is missing corresponding code... :oops: ] Ooh, I see a Clever Hackā„¢ if you're working at the T4 addon level: the relevant code in T4's Game:onTurn() is:

Code: Select all

        if self.zone then
                if self.zone.on_turn then self.zone:on_turn() end
        end

        -- [...]

        if not self.day_of_year or self.day_of_year ~= self.calendar:getDayOfYear(self.turn) then
                self.log(self.calendar:getTimeDate(self.turn))
                self.day_of_year = self.calendar:getDayOfYear(self.turn)
        end
So if you have a zone in which you don't want calendar messages, you could give it an on_turn() method that sets game.day_of_year to game.calendar:getDayOfYear(game.turn), which would trick Game:onTurn() into thinking it's already logged the calendar message.
XLambda wrote:3) Is there a simple way to set wilderness coordinates for the player? Especially considering there might be multiple worldmaps, and the ToME code doesn't really seem to be built for that.
There again, if you're writing a module, it's your responsibility to keep track of the player's wilderness coordinates, and you get to decide where they live and how they're accessed. Both the T4 and T2 modules keep them in game.player.wild_x and game.player.wild_y; if you have multiple worldmaps, you could keep corresponding coordinates for each one in game.player.

From a module writer's perspective, the engine doesn't actually make a distinction between a worldmap and any other kind of zone AFAICT; it's the module code's job to handle them differently as needed. Your Game:changeLevel(), for instance, would be responsible for switching between worldmap coordinates and ordinary coordinates when entering or leaving a worldmap.