Home » MODDING HQ 1.13 » v1.13 Coding Talk » Strategic Map load in source code
Strategic Map load in source code[message #339037] Tue, 20 January 2015 16:37 Go to next message
Drecouse

 
Messages:8
Registered:November 2011
Hey guys!

I'm searching the current 1.13 source code to find the part which loads the strategic map (and the corresponding tactical maps) into the game when it starts. Could somebody, who knows the source, tell me in which file and where it is? Thanks in advance.
Re: Strategic Map load in source code[message #339043 is a reply to message #339037] Tue, 20 January 2015 22:08 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
BOOLEAN SetCurrentWorldSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ ) loads a sector, that should get you starting. Note that only sector can ever be loaded at a time, other sectors are meanwhile stored in the map and map modification files.



"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339046 is a reply to message #339043] Wed, 21 January 2015 00:05 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
Thank you for the answer. Btw when the game starts which function loads the strategic map (which contains the picture of the map, and the indexes of the sectors)? And maybe it's a bit too much to write it down here, but could you explain me how the VFS works, and if it's possible to use it dynamically during the game (like changing already loaded files during the game without restarting)?
Re: Strategic Map load in source code[message #339047 is a reply to message #339046] Wed, 21 January 2015 00:27 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
Hmm. So you are merely interested in the picture. That is different...

The strategic map picture seems to be in INTERFACE\\b_map_1024x768.pcx (or so, there are several ones for different resolutions). I don't know how to open or edit them at the moment, but as it has been done (like in AIMNAS), this can be done.

In case you are referring to loading a different version of a sector ingame... that should be possible, though far from trivial. I don't think that is possible without at least heavy debugger use. One can replace the temporary map files in the savegame folder, but unless you really, REALLY know how maps work, that is a surefire way to crash the game and/or corrupt savegames.



"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339048 is a reply to message #339047] Wed, 21 January 2015 00:53 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
I think the best will be if i write down what i want to do exactly happy.

I had an idea of combining different strategic maps (the one which contain 16*16 sector). Like the B2B map with base Ja2 map. Then in the game the players could switch strategic maps when the they are on the edges. To do this i would have liked to recall the function which loads the strategic map. Keep track of the current coordinates in a 2D map and according to this load the corresponding picture with changing the Virtual folder for the sectors. I know it's a bit insane and probably nobody will use this, but i'm just learning c++ and thought it would be a good exercise.
Re: Strategic Map load in source code[message #339049 is a reply to message #339048] Wed, 21 January 2015 01:17 Go to previous messageGo to next message
DepressivesBrot

 
Messages:3809
Registered:July 2009
Yikes.



Chat with us!
#bearpit on IRC
Discord
Get your latest 1.13 Builds
(Pls don't use my forum PMs for general game queries)


Re: Strategic Map load in source code[message #339050 is a reply to message #339048] Wed, 21 January 2015 01:23 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
Yoiks. Not trying to rain on your parade, but that would be very, VERY hard. For starters, all sector IDs are stored in an UINT8 - which doesn't take numbers higher than 255, thus does not allow maps bigger than 16x16. If you want to rewrite that, expect at least a week running over the entire code and replacing UINT8 with UINT16 (this will break the game in numerous places). As all enemy groups, mercs, towns, inventories etc. have sector coordinates, you have to remap those too.

An alternative would be to have a second 16x16 map as you intend - but then you still have to tell the code everywhere a sector is mentioned whether map A or B is used, basically in the entire code. Note that sector manipulation code is relatively pristine, you'll find undocumented, dubious code there that hasn't been touched for over a decade ;)

Loading an alternate version of a sector you already visited (to, say, simulate ongoing destruction/construction of buildings) would be somewhat easier (and often asked for in the last years).

I can't tell you not to do this (it is good that more people volunteer for coding on our beloved game), but unless you have a truly epic frustration tolerance I wouldn't recommend this.

Hmm.

If you are looking for relatively easy code in 1.13, I'd go to the Laptop websites or the trait system - there's simply enough of both to get good examples. Be warned, however, that 1.13 isn't exactly good C++, it's more C with a bit of C++ mixed in.



"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339059 is a reply to message #339050] Wed, 21 January 2015 09:57 Go to previous messageGo to next message
CVB

 
Messages:130
Registered:September 2014
Location: Berlin
Flugente wrote on Wed, 21 January 2015 00:23
For starters, all sector IDs are stored in an UINT8 - which doesn't take numbers higher than 255, thus does not allow maps bigger than 16x16.


Does this mean that we may have 256 maps max (including basement/mine maps), or are those handled outside this 256 sector id limit?
In other words, may we use hitherto unused ocean sectors and the south-east country map corner for additional maps or do they have to be left empty to accomodate the mines and cellars in the UINT8?



Peace is a purely theoretical state of affairs whose existence we deduce because there have been intervals between wars.
J. Pournelle
Re: Strategic Map load in source code[message #339064 is a reply to message #339059] Wed, 21 January 2015 14:26 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
Okay, i think for some days i will be really determined to start and complete this project, after that probably i will abandon this, but until that I will have finally something interesting to do big grin. Here i shall write down how i planned to do this. If anything would be incorrect or there would be an easier solution please correct me:

1. I would like to create some buttons on the strategic map interface to navigate between the maps and with this change the map picture. (I think that's the easiest part.)

2. I have to learn how the saving functions work and then add a new variable for every possible object (merc, npc, item, etc.) which will determine which map it belongs to. (I hope these are in classes or structs.) Then i have to modify the loading functions to understand the changes.

3. Every place where an object is created must be modified to add the new variable which will determine what map it belongs to.

Then of course there is no solution yet for the quests, and enemy movement (how the enemy would move and attack if we leave the current map, it shouldn't be discarded but i don't see other solution except somehow handling all the maps parallel). And all these changes should be made with ini variables for the different maps to be able to easily create a new one, and should be handled in different folders.

[Updated on: Wed, 21 January 2015 16:44]

Re: Strategic Map load in source code[message #339065 is a reply to message #339059] Wed, 21 January 2015 14:28 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
@CVB: We can have max 256 maps per level. There are 4 levels (normal level and 3 underground levels), so 1024 max maps. However, a lot of vital strategic functions does not work underground - pathing, facilities, helicopter, reinforcements, and so on. It is similar to the tactical roof level insofar as that a lot of functionality has been cut, simply because the original devs didn't want with that additional complication.

Given that, it would be surprisingly easy to add even more underground levels - but as these are so limited in their functionality, I neither see the need nor gain.

All the sectors on the map we cannot access are empty. By creating a new map with the editor and correctly adding it to the xmls, yes, we can add new sectors. If I recall, AIMNAS uses a few sectors that have no equivalent in stock 1.13, and other mods do that too. What limits us from using all 256 sectors is the simple fact that creating new maps is hard work (note how good smeagol is in creating new maps, and it'll still be years before he's finished mapping Aruclo). Codewise, all necessary work has long been done.

[Updated on: Wed, 21 January 2015 14:29]




"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339068 is a reply to message #339065] Wed, 21 January 2015 16:42 Go to previous messageGo to next message
CVB

 
Messages:130
Registered:September 2014
Location: Berlin
Flugente wrote on Wed, 21 January 2015 13:28
@CVB: We can have max 256 maps per level. There are 4 levels (normal level and 3 underground levels), so 1024 max maps.


Thanks for the info. Just wanted to make sure that I don't have to throw out existing mines and basements when adding new ground level maps. I would like to have a couple of maps with deep water (harbours, island SAM sites come to mind) where your SCUBA gear gets to play a more important role.

You are correct, at least AIMNAS and Arulco Revisited have added new maps. It has worked for me as well (with some very rudimentary maps just to test the concept). I just ran into a crash and feared that I had run into a map ID limit. I suspect now that adding a basement to A9 (landing sector) might be... unadvised. There seems to be a problem with the first hardcoded palace cutscene when leaving A9 via a basement teleport.

You are of course right concerning the limited functionality of basement maps, but for example the Meduna sewer maps of JA2WF had a certain nice old-fashioned dungeon crawl feeling, and raiding Alma Barracks from the underground bunker was great fun (at least for me cheeky )
I would like to use such cellars mainly for immersion and storytelling purposes.

[Updated on: Wed, 21 January 2015 16:51]




Peace is a purely theoretical state of affairs whose existence we deduce because there have been intervals between wars.
J. Pournelle
Re: Strategic Map load in source code[message #339069 is a reply to message #339065] Wed, 21 January 2015 17:14 Go to previous messageGo to next message
CVB

 
Messages:130
Registered:September 2014
Location: Berlin
Quote:
However, a lot of vital strategic functions does not work underground - pathing, facilities, helicopter, reinforcements, and so on.


Just one other question: (at least for now cheeky. BTW: Thanks a lot for your willingness to answer questions)
Given that facilities were a 1.13 addition, is there some fundamental reason why facilities can't work underground, or was it just not implemented? I could think of some basements were facilities would make a lot of sense (Interrogation in Tixa, Factory in Orta...)



Peace is a purely theoretical state of affairs whose existence we deduce because there have been intervals between wars.
J. Pournelle
Re: Strategic Map load in source code[message #339075 is a reply to message #339069] Wed, 21 January 2015 21:27 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
Not implemented is the main reason it seems.



"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339094 is a reply to message #339075] Thu, 22 January 2015 16:31 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
Okay first part what i have planned (
Toggle Spoiler
) is here: "https"://www.sendspace.com/file/gru7lk

It's really basic just simply a new button which adds another 3 to the game. With these you can type in numbers like 00, 01, 02, 10 ... 22. This will determine what picture the game will load. And of course some ini variables in the JA2_Options.ini under Strategic Interface Settings. Here anybody can add new Maps easily up to 9. (The forum didn't allowe me to post a link so just remove the "-s.) (Based on 7720)

[Updated on: Thu, 22 January 2015 16:33]

Re: Strategic Map load in source code[message #339095 is a reply to message #339094] Thu, 22 January 2015 22:11 Go to previous messageGo to next message
Flugente

 
Messages:3425
Registered:April 2009
Location: Germany
The buttons work somewhat odd for me - have to toggle a combination of sorts, but I get the idea.



"Is there any way to get the blood to flow up the walls?"
"I don't see why not."

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.


Re: Strategic Map load in source code[message #339101 is a reply to message #339037] Fri, 23 January 2015 13:35 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
I'm glad to hear that. happy Btw do you know any other way of getting the input? I was thinking about something like a text box but I don't know how to implement it.

In the past few days I thought about how these maps should work. For example use them as the normal maps, handle them as a different world (being able to change the other without loading)... What do you think, how it should work (not just the ones which I have described) and what should I try to implement? And of course thank you for your answers, they are helping me a lot. happy
Re: Strategic Map load in source code[message #339171 is a reply to message #339037] Thu, 29 January 2015 16:18 Go to previous messageGo to next message
Drecouse

 
Messages:8
Registered:November 2011
After long thinking i realized that what i wanted to do is impossible because even if i manage to save the new maps and keep track of all the items, enemy etc., the campaign wouldn't change so in reality just an alternate arulco would be loaded.
You mentioned alternate maps from individual sectors, but it's been done already, no? I have seen in the code a lot of mention about alternate maps, and on some maps in the game folder there is a '_a' text. These do the same (loading an alternative version of the map) or they have some other meaning?
Re: Strategic Map load in source code[message #339176 is a reply to message #339171] Fri, 30 January 2015 00:23 Go to previous message
DepressivesBrot

 
Messages:3809
Registered:July 2009
Yeah, they are alternates that get used under certain circumstances. Best example are the maps with and without the weapon caches.



Chat with us!
#bearpit on IRC
Discord
Get your latest 1.13 Builds
(Pls don't use my forum PMs for general game queries)


Previous Topic: JA2 Roguelike mod
Next Topic: New Stealth Mechanics
Goto Forum:
  


Current Time: Sun Dec 16 14:56:03 EET 2018

Total time taken to generate the page: 0.01276 seconds