Author Topic: robin's dumb questions (was: Max base map height is 2?)  (Read 15074 times)

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
robin's dumb questions (was: Max base map height is 2?)
« on: October 20, 2014, 11:21:33 am »
Interior maps, such as x-com base maps or alien base maps, are either 1 or 2 floors high.
Is 2 the maximum? I'd like do a 3-floors high maps (maybe 4), but I want to know for sure before spending tons of time on them: will they work?

Thanks.
« Last Edit: November 04, 2014, 11:16:55 am by robin »

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Max base map height is 2?
« Reply #1 on: October 20, 2014, 11:28:23 am »
make a copy of hangar,lift,storage,quarters with 4 height (upper 2level=empty)
make a mod with only hangar,lift,storage,quarters as starting facilities
make a new battle base defense and take a look
shouldnt need "tons of time" to make a quick test

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Max base map height is 2?
« Reply #2 on: October 20, 2014, 11:34:57 am »
possible, sure, but you'd have to add an extra layer to all the existing maps to prevent units flying over the walls.
map blocks can be any size UP TO the maximum defined in the ruleset for the terrain type, and any "extra" space will be filled with air, not dirt, because maps are assumed to be "outside"

Offline NoelBuddy

  • Colonel
  • ****
  • Posts: 142
    • View Profile
Re: Max base map height is 2?
« Reply #3 on: October 20, 2014, 07:32:19 pm »
There wouldn't be a simple way to add layers underneath would there?

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Max base map height is 2?
« Reply #4 on: October 20, 2014, 08:10:57 pm »
There wouldn't be a simple way to add layers underneath would there?
open mapfile in a hexeditor and add 0x03 for width*height*amountofnewlayers times + change the 3. byte in the map file
so i think its easy to make a "dirt-layer"

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: Max base map height is 2?
« Reply #5 on: October 20, 2014, 08:56:09 pm »
make a copy of hangar,lift,storage,quarters with 4 height (upper 2level=empty)
make a mod with only hangar,lift,storage,quarters as starting facilities
make a new battle base defense and take a look
shouldnt need "tons of time" to make a quick test
Admittedly I didn't think about that test.
Anyway I can mod on saturday, I try to have (on the forum) my doubts figured out  by then, so comes saturday I can start making things right away. Otherwise the mod will take 15 years to come together.

possible, sure, but you'd have to add an extra layer to all the existing maps to prevent units flying over the walls.
map blocks can be any size UP TO the maximum defined in the ruleset for the terrain type, and any "extra" space will be filled with air, not dirt, because maps are assumed to be "outside"
Thanks

I'd like to make an interior/underground terrain to be used for terror missions. Currently if I set the UBASE terrain in place of the URBAN terrain, the terror mission crashes.
Regular UFO missions do work, but: no corridors are placed, the game crashed when I try to destroy dirt blocks, ufo and craft maps have “untextured” (black) floor (this is because there's no BLANKS associated to the UBASE terrain, I guess).

Some other questions:
-- how are corridor dug/built? Are they “hardcoded”? I'd have eventually to personalize their appearance;
-- do “dirt floor tile” and “dirt big block” need to be the first 2 tiles of the MCD/terrain/map set (is the order of the tiles important)?
-- is dirt floor “hardcoded” to appear underneath any destroyed floor “0” terrain?
-- are 30x30, 20x30/30x20 maps sizes alright?

Thanks again

Offline XOps

  • Colonel
  • ****
  • Posts: 193
  • Guy who drowns first
    • View Profile
Re: Max base map height is 2?
« Reply #6 on: October 21, 2014, 05:24:52 pm »
-- how are corridor dug/built? Are they “hardcoded”? I'd have eventually to personalize their appearance;

Both the Alien Base Assault (UBASE) and XCom base defense (XBASE) are indeed hardcoded as is the second part of the Cydonia Mission. I looked up the coding for this. Most of it I couldn't make much sense of, but there are parts I did recognize. The coding takes out the dirt filler blocks and then lays down the floor and wall tiles to connect all of the blocks (see attached picture below for confirmation). It leaves parts that border the edge alone naturally. I even saw it make specific mcd # references (specifically walls and floor). However I think this means that automatically connecting blocks is limited only to those missions as the corridor connecting functions only kick in when it sees the strings for base defense or alien base assault missions.

-- do “dirt floor tile” and “dirt big block” need to be the first 2 tiles of the MCD/terrain/map set (is the order of the tiles important)?

Again I am unsure. I haven't tried a complete alien base replacement. The coding didn't make specific mcd/pck file name references that I could see, but as I said above, it does make specific number references within a mcd file. However I do know that the order of the tiles is indeed important. Whether or not you can make a new file and keep the wall and floor tiles in the same position, or have to directly replace U_WALL02 I don't know.

Sorry :-[ Wish I could be of more help.

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: Max base map height is 2?
« Reply #7 on: October 21, 2014, 09:57:00 pm »
Both the Alien Base Assault (UBASE) and XCom base defense (XBASE) are indeed hardcoded as is the second part of the Cydonia Mission. I looked up the coding for this. Most of it I couldn't make much sense of, but there are parts I did recognize. The coding takes out the dirt filler blocks and then lays down the floor and wall tiles to connect all of the blocks (see attached picture below for confirmation). It leaves parts that border the edge alone naturally. I even saw it make specific mcd # references (specifically walls and floor). However I think this means that automatically connecting blocks is limited only to those missions as the corridor connecting functions only kick in when it sees the strings for base defense or alien base assault missions.

Again I am unsure. I haven't tried a complete alien base replacement. The coding didn't make specific mcd/pck file name references that I could see, but as I said above, it does make specific number references within a mcd file. However I do know that the order of the tiles is indeed important. Whether or not you can make a new file and keep the wall and floor tiles in the same position, or have to directly replace U_WALL02 I don't know.

Sorry :-[ Wish I could be of more help.
Yeah I strongly suspected that corridors were hardcoded for UBASE and XBASE only.
I'm going to build the maps with corridors "built-in". On the edges of the whole battlescape map, these corridors will end into nothingness; it' not ideal but battlescape area normally ends into nothingness, so it should be "fine enough".
The problem now is the big block, which are placed only on two (of four) sides, and I have to make them look like walls..
I also don't know about routes for upper floors (which are interconnected too): where will an "exit"-type route on an upper floor connect, with the other on the same level or with the ones on the ground level?

Could there be a way to force certain maps to be specifically placed, when building the full battelscape map, like forcing where the craft is spawned, and forcing a specific map of the set next to it?


(Built-in corridors like this:)

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Max base map height is 2?
« Reply #8 on: October 21, 2014, 11:27:41 pm »
wait until after the map generation overhaul, you're wasting your time otherwise.

Online Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11783
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Max base map height is 2?
« Reply #9 on: October 22, 2014, 04:18:23 pm »
wait until after the map generation overhaul, you're wasting your time otherwise.

Okay, you've made me excited. :)

So many possibilities!

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: Max base map height is 2?
« Reply #10 on: October 25, 2014, 06:40:38 pm »
here some results of playing around with the current possibilities
we can have a "storage" and an "upgraded storage" .. the upgraded storage has 4 instead of 2 layers in basedefense in the example i have radar and storage as dual layer map
i made a script that takes the original xcom base maps and makes 2 types of maps
2 layer and 4 layer +hangar is on the lowest level + lift goes from surfacelevel down to the lowest with elevators
it also puts elevators in all underground layers (yeah i know its ugly)
also the script creates no usefull ROUTES/...RMP values for the layers besides the original two (lowest) layer

i only cared about the map creation here not basebitsprites or usefull values (it crashes if you open base in geoscape)

it more or less just a prove of concept but with some (a lot of) finetuning this could make multilayer base possible + look nice
(you could have a facility with workshop on top and storage below but to have all options the amount of combinations grows too fast )

Spoilerthe script:
Code: [Select]
#WARNING: the script expects a copy of vanilla XBASE_20 map called ORIG_XBASE_20
#it will overwrite the XBASE_20 file so keeps the copy
p=r"THIS\IS\YOUR\PATH\data"
groundlayer=5
lnr=9
elevator=bytes([170,0,0,0])
dirt=bytes([0,0,0,3])
air=bytes([0,0,0,0])
breaksurface={"XBASE_00":dirt,"XBASE_16":air,"XBASE_17":air,"XBASE_18":air,"XBASE_19":air}
import itertools

ground={}
for x in range(0,16):
    ground["XBASE_%02d"%x]="CULTA%02d"%(x%19)
ground["XBASE_00"]="CULTA16"
ground["ORIG_XBASE_20"]="CULTA14"
groundinc=179

mlist=[]   
mlist.append(["XBASE_00","XBASEML4D_00","copy",[[x,y] for x,y in itertools.product(range(2,7),range(2,7))]])
mlist.append(["XBASE_16","XBASEML4D_16",air,[[0,0]]])
mlist.append(["XBASE_17","XBASEML4D_17",air,[[8,0]]])
mlist.append(["XBASE_18","XBASEML4D_18",air,[[0,8]]])
mlist.append(["XBASE_19","XBASEML4D_19",air,[[8,8]]])
mlist.append(["ORIG_XBASE_20","XBASE_20",dirt,[]])
for x in range(1,16):
    mlist.append(["XBASE_%02d"%x,"XBASEML4S_%02d"%x,bytes([0,0,0,3]),[[x,y] for x,y in itertools.product(range(3,6),range(3,6))]])
for x in range(1,16):
    mlist.append(["XBASE_%02d"%x,"XBASEML4D_%02d"%x,"copy",[[x,y] for x,y in itertools.product(range(3,6),range(3,6))]])
for bname,tname,fill,elelist in mlist:
   
    with open(p+"\\MAPS\\"+bname+".MAP","rb") as ifh, open(p+"\\MAPS\\"+bname+".RMP","rb") as irfh:
        idata=ifh.read()
        irdata=irfh.read()
        l=int(idata[0])
        w=int(idata[1])
        with open(p+"\\MAPS\\"+tname+".MAP","wb") as ofh, open(p+"\\ROUTES\\"+tname+".RMP","wb") as orfh:
            print (bname,tname)           
            ofh.write(idata[0:2])
            ofh.write(bytes([lnr]))
            #surfacelayer
            if lnr>groundlayer:
                if bname in ground:
                    with open(p+"\\MAPS\\"+ground[bname]+".MAP","rb") as igfh:
                        igdata=igfh.read()
                        gl=int(igdata[0])
                        gw=int(igdata[1])
                        gh=int(igdata[2])
                        for z,y,x in itertools.product(range(lnr-groundlayer-gh),range(w),range(l)):
                            ofh.write(air)
                        for z,y,x in itertools.product(range(gh),range(gw),range(gl)):
                            do=bytes([int(x)+(groundinc if int(x)>0 else 0) for x in igdata[3+4*(x+y*w+z*w*l):3+4*(x+y*w+z*w*l+1)]])
                            if bname in breaksurface and z==gh-1 and [x,y] in elelist:
                                do=elevator
                            ofh.write(do)
                else:
                    for z,y,x in itertools.product(range(lnr-groundlayer),range(w),range(l)):
                        ofh.write(air)
            #make groundlayer
            if lnr>=groundlayer:
                for z,y,x in itertools.product(range(1),range(w),range(l)):
                    do=dirt
                    if bname in breaksurface:
                        do=breaksurface[bname]
                        if [x,y] in elelist:
                            do=elevator                         
                    ofh.write(do)
            #fill second layer
            for z,y,x in itertools.product(range(2),range(w),range(l)):
                if fill=="copy":
                    do=idata[3+4*(x+y*w+z*w*l):3+4*(x+y*w+z*w*l+1)]
                else:
                    do=fill
                if [x,y] in elelist and "D_" in tname:
                    do=elevator
                ofh.write(do)
            #fill lowest 2 layer
            for z,y,x in itertools.product(range(2),range(w),range(l)):
                do=idata[3+4*(x+y*w+z*w*l):3+4*(x+y*w+z*w*l+1)]
                if [x,y] in elelist:
                    do=elevator               
                ofh.write(do)
            #make rmpcopy
            for x in range(len(irdata)https://24):
                orfh.write(irdata[x*24+0:x*24+2])
                orfh.write(bytes([irdata[x*24+2]+lnr-2]))
                orfh.write(irdata[x*24+3:x*24+24])
           

to fix the the disconnect in the upper/other layers one would need to get rid of the walls like shown in the fix image and make "dirt2" tiles that have wals includes but the top of the wall is still dirt colored so a map that end in "dirt2" tiles sees a wall just the upper pixel of that wall are dirt so you dont see a chess board style in the dirt areas
« Last Edit: October 25, 2014, 06:44:41 pm by Falko »

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: Max base map height is 2?
« Reply #11 on: November 04, 2014, 11:16:02 am »
I noticed this in the ruleset reference, under Alien Deployments:

Quote
Notes:

    terrains can also be used with UFOs, with the game using instead the listed terrain rather than the location of the UFO on Geoscape.

Does this mean we can now override the terrain defined by the geoscape texture with the terrain listed?
If yes, must it be another "geoscape" terrain, or any custom terrain is suitable?

--

Is there a limit to the number of textures types the geoscape can have?
« Last Edit: November 04, 2014, 12:03:38 pm by robin »

Offline Hobbes

  • Commander
  • *****
  • Posts: 2102
  • Infiltration subroutine in progress
    • View Profile
Re: Max base map height is 2?
« Reply #12 on: November 04, 2014, 06:09:16 pm »
I noticed this in the ruleset reference, under Alien Deployments:

Does this mean we can now override the terrain defined by the geoscape texture with the terrain listed?
If yes, must it be another "geoscape" terrain, or any custom terrain is suitable?

Haven't used it but yeah, you can override the texture with a listed terrain. For the ufo simply add:
    terrains:
      - MALIBU
      - LASVEGAS, etc.

If the terrain isn't already predefined, then you can add it to the terrains section of the ruleset.

Offline robin

  • Commander
  • *****
  • Posts: 1226
  • ULTIMATE ROOKIE
    • View Profile
Re: Max base map height is 2?
« Reply #13 on: November 04, 2014, 07:01:14 pm »
Haven't used it but yeah, you can override the texture with a listed terrain. For the ufo simply add:
    terrains:
      - MALIBU
      - LASVEGAS, etc.

If the terrain isn't already predefined, then you can add it to the terrains section of the ruleset.
With this feature we can make special missions quite better. No more "standalone" fixed maps (that takes forever to make).
You just need to use a map from the maps set as the ufo, and you'll get your desired map, randomized normally, with no ufo in sight. With this for example I can have a perfectly conventional urban map for my MiB Terror mission, instead of the fixed village (that gets repetitive so fast).

Online Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11783
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: robin's dumb questions (was: Max base map height is 2?)
« Reply #14 on: April 04, 2015, 11:34:30 am »
Wow, Falko... I missed it before, but this is extremely promising. I want bases with both above- and below-ground levels, and external buildings...