Author Topic: Terrain Help  (Read 176 times)

0 Members and 1 Guest are viewing this topic.

Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Terrain Help
« on: October 26, 2017, 11:50:23 AM »
Hello, new modder here. Can someone explain how to add textures to a terrain type? Or send me an example?

I'm trying to add textures to a desert terrain I created.

I tried copying "Terrain.rsc", changing the contents to point to my new image files, and naming it DesertTerrain.rsc. Then changed this line in my "Game/Terrain/Desert.rsc":

Code: [Select]
WeakMaterialInstance _terrainMaterial = "Terrain/DesertTerrain.rsc";
But I get this error when I try to start a new game:

Code: [Select]
Assert: _resource != NULL || _path.GetLength() == 0 Error, shouldn't be dereferencing a weak pointer that is NULL!

C:\Projects\Buildy\code\Runtime\Object/ExternalPtr.h(194)

Callstack:
Application-x64-profile.exe(0x0000000043fa1c35)
Application-x64-profile.exe(0x0000000043f980cb)
Application-x64-profile.exe(0x0000000043f74209)
Runtime-x64-profile.dll(0x0000000086215181)
Runtime-x64-profile.dll(0x00000000861de48c)
MSVCR110.dll(0x0000000090f13fef)
MSVCR110.dll(0x0000000090f14196)
KERNEL32.DLL(0x00000000a10313d2)
ntdll.dll(0x00000000a17554f4)

I can't figure out what I'm doing wrong. Please help.

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #1 on: October 26, 2017, 12:29:27 PM »
first you need to call this inside your MyModRescource.rsc file:
Code: [Select]
"Game/Terrain/TerrainList.rsc",

then inside a copy of the TerrainList.rsc you explain the new terrain type you want to add like:
Code: [Select]
ExternalList resource
{
External _resources
[
"Game/Terrain/Valleys.rsc",
"Game/Terrain/Mountains.rsc",
"Game/Terrain/MyOwnDesert.rsc",
]
}

then you go back to your MyModRecesource.rsc file and you add:
Code: [Select]
"Game/Terrain/MyOwnDesert.rsc",
"Terrain/MyOwnDesertTerrain.rsc",

now you do your Game/Terrain/MyOwnDesert.rsc like:
Code: [Select]
TerrainGenerator resource
{
StringTable _stringTable = "UI/MyOwnModStringTable.rsc"; // the name of your stringtable
String _text = "DesertMap"; // the name you gave to your new desert map
bool _exposed = true;

// materials
WeakMaterialInstance _terrainMaterial = "Terrain/MyOwnDesertTerrain.rsc";
WeakMaterialInstance _riverMaterial = "Terrain/River.rsc";
WeakMaterialInstance _lakeMaterial = "Terrain/Lake.rsc";

// size of the map
Feature _features
[
// ------ small ---------
{
int _mapSize = 256;
... (and put all your own numbers for small/med/large with the numbers of river/lake/mountains/etc...)
....

and then you go to make your Terrain/MyOwnDesertTerrain.rsc and define your 4 textures the game needs:
Code: [Select]
MaterialInstance resource
{
Material _material = "Material\Terrain\TerrainMaterial.rsc";
Texture _textures
[
{
String _name = "grass";
ImageBuffer _texture = "Terrain\MyOwnDesertTerrainGrassTexture.rsc";
}
{
String _name = "dirt";
ImageBuffer _texture = "Terrain\MyOwnDesertTerrainDirtTexture.rsc";
}
{
String _name = "rock";
ImageBuffer _texture = "Terrain\MyOwnDesertTerrainRockTexture.rsc";
}
{
String _name = "snow";
ImageBuffer _texture = "Terrain\TerrainSnowTexture.rsc";
}
]
}

then you define each type of textures and linking them each to a 1024x1024 .png ( like this example of the MyOwnDesertTerrainGrass one )
Code: [Select]
ImageBuffer resource : "Texture/TerrainTexture.rsc"
{
String _imageName = "Terrain\MyOwnDesertTerrainGrass.png";
}
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #2 on: October 26, 2017, 12:31:00 PM »
of course dont forget to fill the entries in your stringtable and decide the words you will be using at the screen to read your new option you just added.

Code: [Select]
// ------------ My New Terrain ---------------------------
{ String _name = "DesertMap"; String _text = "Desert"; }
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Re: Terrain Help
« Reply #3 on: October 26, 2017, 02:56:12 PM »
I started over and tried my best to copy everything you said, but I still get the same error when I start a new game with my desert terrain.

JTerrainsResource.rsc:

Code: [Select]
ExternalList resource
{
External _resources

[
"Game/Terrain/TerrainList.rsc",
"Game/Terrain/JValleys.rsc",
"Game/Terrain/JMountains.rsc",
"Game/Terrain/JPlains.rsc",
"Game/Terrain/JMarsh.rsc",
"Game/Terrain/JDesert.rsc",
"Game/Terrain/JJungle.rsc",
"Terrain/JDesertTerrain.rsc"
]
}

Game/Terrain/JDesert.rsc

Code: [Select]
TerrainGenerator resource
{
StringTable _stringTable = "Dialog/JStringTable.rsc:terrainType";
String _text = "JDesert";
bool _exposed = true;

// materials
WeakMaterialInstance _terrainMaterial = "Terrain/JDesertTerrain.rsc";
WeakMaterialInstance _riverMaterial = "Terrain/River.rsc";
WeakMaterialInstance _lakeMaterial = "Terrain/Lake.rsc";

// size of the map
Feature _features
[


// ------ tiny ---------
{
int _mapSize = 192;

// number of flat areas
int _flatAreaCount = 100;

// size of flat areas
int _minFlatAreaSize = 20;
int _maxFlatAreaSize = 30;

// number of areas to avoid
int _avoidAreaCount = 4;

// size of avoidance areas
int _minAvoidSize = 20;
int _maxAvoidSize = 30;

// how many close nodes to connect to
int _flatAreaConnections = 3;

// rivers
int _streamCount = 0;

// erosion
int _erosion = 4000000;

// number of lakes
int _minLakeCount = 0;
int _maxLakeCount = 0;

// lake size
int _minLakeSize = 20;
int _maxLakeSize = 30;

// number of parts per lake
int _lakePartCount = 40;

// part sizes
int _minLakePartSize = 6;
int _maxLakePartSize = 12;
}

// ------ small ---------
{
int _mapSize = 256;

// number of flat areas
int _flatAreaCount = 100;

// size of flat areas
int _minFlatAreaSize = 20;
int _maxFlatAreaSize = 30;

// number of areas to avoid
int _avoidAreaCount = 4;

// size of avoidance areas
int _minAvoidSize = 20;
int _maxAvoidSize = 30;

// how many close nodes to connect to
int _flatAreaConnections = 3;

// rivers
int _streamCount = 0;

// erosion
int _erosion = 4000000;

// number of lakes
int _minLakeCount = 0;
int _maxLakeCount = 0;

// lake size
int _minLakeSize = 20;
int _maxLakeSize = 30;

// number of parts per lake
int _lakePartCount = 40;

// part sizes
int _minLakePartSize = 6;
int _maxLakePartSize = 12;
}

// ------ medium ---------
{
int _mapSize = 384;

// number of flat areas
int _flatAreaCount = 250;

// size of flat areas
int _minFlatAreaSize = 20;
int _maxFlatAreaSize = 30;

// number of areas to avoid
int _avoidAreaCount = 8;

// size of avoidance areas
int _minAvoidSize = 20;
int _maxAvoidSize = 30;

// how many close nodes to connect to
int _flatAreaConnections = 4;

// rivers
int _streamCount = 0;

// erosion
int _erosion = 8000000;

// number of lakes
int _minLakeCount = 0;
int _maxLakeCount = 0;

// lake size
int _minLakeSize = 30;
int _maxLakeSize = 50;

// number of parts per lake
int _lakePartCount = 50;

// part sizes
int _minLakePartSize = 6;
int _maxLakePartSize = 12;
}

// ------ large ---------
{
int _mapSize = 512;

// number of flat areas
int _flatAreaCount = 400;

// size of flat areas
int _minFlatAreaSize = 20;
int _maxFlatAreaSize = 30;

// number of areas to avoid
int _avoidAreaCount = 16;

// size of avoidance areas
int _minAvoidSize = 20;
int _maxAvoidSize = 30;

// how many close nodes to connect to
int _flatAreaConnections = 4;

// rivers
int _streamCount = 0;

// erosion
int _erosion = 16000000;

// number of lakes
int _minLakeCount = 0;
int _maxLakeCount = 0;

// lake size
int _minLakeSize = 30;
int _maxLakeSize = 60;

// number of parts per lake
int _lakePartCount = 70;

// part sizes
int _minLakePartSize = 6;
int _maxLakePartSize = 12;
}
]
}

Terrain/JDesertTerrain.rsc
Code: [Select]
MaterialInstance resource
{
Material _material = "Material\Terrain\TerrainMaterial.rsc";
Texture _textures
[
{
String _name = "grass";
ImageBuffer _texture = "Terrain\JDesertGrassTexture.rsc";
}
{
String _name = "dirt";
ImageBuffer _texture = "Terrain\JDesertDirtTexture.rsc";
}
{
String _name = "rock";
ImageBuffer _texture = "Terrain\JDesertRockTexture.rsc";
}
{
String _name = "snow";
ImageBuffer _texture = "Terrain\JDesertSnowTexture.rsc";
}
]
}

All textures are 1024px pngs. I still don't know what I'm missing. If you need to see more of my code, just let me know.

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #4 on: October 26, 2017, 03:21:14 PM »
you started 6 new game/terrain in your resource file .... but i only see "Terrain/JDesertTerrain.rsc" in your resource file
you need 1 for each. you started jvalleys... jmountains...jplains...jmarsh...jdesert which is ok... jjungle... you are probably crashing another place even if you get the same error message.

« Last Edit: October 26, 2017, 03:44:36 PM by RedKetchup »
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #5 on: October 26, 2017, 03:36:27 PM »
so your resource file should be:
Code: [Select]
ExternalList resource
{
External _resources

[
"Game/Terrain/TerrainList.rsc",
"Game/Terrain/JValleys.rsc",
"Game/Terrain/JMountains.rsc",
"Game/Terrain/JPlains.rsc",
"Game/Terrain/JMarsh.rsc",
"Game/Terrain/JDesert.rsc",
"Game/Terrain/JJungle.rsc",
"Terrain/JValleysTerrain.rsc"
"Terrain/JMountainsTerrain.rsc"
"Terrain/JPlainsTerrain.rsc"
"Terrain/JMarshTerrain.rsc"
"Terrain/JDesertTerrain.rsc"
"Terrain/JJungleTerrain.rsc"
]
}

your terrainList should be like:
Code: [Select]
ExternalList resource
{
External _resources
[
"Game/Terrain/Valleys.rsc",
"Game/Terrain/Mountains.rsc",
"Game/Terrain/JValleys.rsc",
"Game/Terrain/JMountains.rsc",
"Game/Terrain/JPlains.rsc",
"Game/Terrain/JMarsh.rsc",
"Game/Terrain/JDesert.rsc",
"Game/Terrain/JJungle.rsc",
]
}

you should have a Game/Terrain/JValleys.rsc, Game/Terrain/JMountains.rsc, Game/Terrain/JPlains.rsc, Game/Terrain/JMarsh.rsc, Game/Terrain/JJungle.rsc files similar to your Game/Terrain/JDesert.rsc you described but with their own names and their own numbers.


your Game/Terrain/JValleys.rsc should also point to the Game/Terrain/JValleysTerrain.rsc
your Game/Terrain/JMountains.rsc should also point to the Game/Terrain/JMountainsTerrain.rsc
your Game/Terrain/JPlains.rsc should also point to the Game/Terrain/JPlainsTerrain.rsc
your Game/Terrain/JMarsh.rsc should also point to the Game/Terrain/JMarshTerrain.rsc
your Game/Terrain/JDesert.rsc should also point to the Game/Terrain/JDesertTerrain.rsc
your Game/Terrain/JJungle.rsc should also point to the Game/Terrain/JJungleTerrain.rsc


then you should have a Terrain/JValleysTerrain.rsc, Terrain/JMountainsTerrain.rsc, Terrain/JPlainsTerrain.rsc, Terrain/JMarshTerrain.rsc, Terrain/JJungleTerrain.rsc files similar to your  Terrain/JDesertTerrain.rsc you also described. i saw you changed the snow one in the JDesertTerrain.rsc ... (you can keep the original snow texture unless you really want to make a new snow one). they each should point to differents grass/dirt/rock textures as you need for different kind of map.


and your Dialog/JStringTable.rsc:terrainType should set the screentext for each 6 different ones.
« Last Edit: October 26, 2017, 03:50:17 PM by RedKetchup »
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Re: Terrain Help
« Reply #6 on: October 26, 2017, 05:17:53 PM »
I only want custom textures for the desert one right now.

All the other terrains and my new map size show up and work fine. It's only the desert one that gives an error and only when this line is changed:

Code: [Select]
WeakMaterialInstance _terrainMaterial = "Terrain/Terrain.rsc";
I went ahead and tried creating a separate mod that added the desert terrain only and it still popped that same error.

I tried just making a copy of Terrain.rsc without actually changing anything about it except renaming it to JDesertTerrain.rsc and got the same error again.

I see someone else had this issue with no solution:
http://shiningrocksoftware.com/forum/discussion/4169/terrain-rsc-is-hardcoded-can039t-make-new-terrain-types

But I know there has to be some work around because Colonial Charter has unique textures for certain terrain types.

Any chance you have a working source for a basic terrain texture mod I could play with?

Thanks again.


Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Re: Terrain Help
« Reply #7 on: October 26, 2017, 05:47:36 PM »
Here's my test with just adding a desert terrain type only. Maybe it'll be easier to spot and tell me where I'm going wrong.

Edit: Just noticed I forgot to remove the tiny map size from the test terrain files. Just know that the main mod does add it to stringtable properly. Fixing that didn't make the error go away though.  :(
« Last Edit: October 26, 2017, 06:17:30 PM by gl4d0s »

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #8 on: October 26, 2017, 06:53:58 PM »
sorry i ve got an hockey game tonight.... my Boston Bruins won tonight over SanJose Sharks woooohooo ^^

something is missing from your zip file :
a folder called Texture and within a file named TerrainTexture.rsc


go in your modkit resource folder, spot the folder named Texture and inside copy the file named TerrainTexture.rsc. go in your mod folder. create a folder named Texture and paste it there.
try to recompile.

EDIT:
oh also in your terrain/jdesertTerrain.rsc file.... there is a typo in your last .zip
at the end of your snow line there is a double " and a double ;
« Last Edit: October 26, 2017, 07:12:05 PM by RedKetchup »
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #9 on: October 26, 2017, 07:07:14 PM »
i just deleted everything and redid again.

unzipped your mod folder, added a folder texture + the TerrainTexture.rsc. i corrected the typo at snow ... compiled... great, start a game : screenshot
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Re: Terrain Help
« Reply #10 on: October 26, 2017, 08:29:15 PM »
Thank you! For some reason I'm still seeing that error on my end.

It's silly but can you reupload that zip with the changes you made. lol

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #11 on: October 26, 2017, 08:37:36 PM »
sure and use my .bat
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.

Offline gl4d0s

  • Newb
  • *
  • Posts: 6
Re: Terrain Help
« Reply #12 on: October 26, 2017, 09:04:16 PM »
Yep, that did it. Thanks again!

Offline RedKetchup

  • Champion
  • Banished Expert
  • *****
  • Posts: 7384
Re: Terrain Help
« Reply #13 on: October 26, 2017, 09:19:52 PM »
happy to hear it works for you :)
any other questions.... dont hesitate :)
> > > Support Mods Creation developments with Paypal Donations < < <
Click here to PayPal Donate.