News:

Welcome to World of Banished!

Main Menu

How To ...

Started by slink, September 13, 2014, 10:23:04 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

slink

Add A Mediterranean Climate

Go to Resource\Game\Climate.

Make a copy of Mild.rsc.
Rename the copy to Mediterranean.rsc.
Edit Mediterranean.rsc with an editor that has Administrator's privileges.

Harsh and Mild climate files contain only changes relative to the Fair climate file, so we have to add some additional changes if we want to change the climate very much.  Edit Mediterranean.rsc so that it is as follows.  What you will have done is edited the string name, and also changed the average temperature from temperate to sub-tropical by adding changes from Fair to the base temperature and the range of temperatures.

ClimateGenerator resource : "Fair.rsc"
{
String _text = "Mediterranean";

// base range for temperature over the year
float _baseTemperature = 60.0;
float _temperatureRange = 20.0;

// normal temperature swing
float _temperatureTolerance = 2.0;

// normal distribution range of base temperature change (biyearly?)
float _temperatureVariance = 20.0;

// normal distribution range of weather chance
float _weatherVariance = 0.1;
}


Save the file. 

Now open ClimateList.rsc in the same editor.  Add a line to tell the game to include the new climate file.  It will look as follows, when you are done.

ExternalList resource
{
External _resources
[
"Game/Climate/Mediterranean.rsc",
"Game/Climate/Mild.rsc",
"Game/Climate/Fair.rsc",
"Game/Climate/Harsh.rsc",
]
}


Save the file.

Now you need to add a display string to another file.  This file is in the Resource\Dialog directory, and it is named StringTable.rsc.  Open that file in your editor.  Search for the string table for climate, and add a line so that section appears as follows.

StringTable climate
{
Entry _strings
[
{ String _name = "Mediterranean";         String _text = "Mediterranean"; }
{ String _name = "Mild"; String _text = "Mild"; }
{ String _name = "Fair"; String _text = "Fair"; }
{ String _name = "Harsh"; String _text = "Harsh"; }
]
}


Save your change and run the debug program.  If you make a new world you should see Mediterranean as a choice.  Creating a world with that climate will give you a world that never sees snow.  The temperature ranges from 40(F) in winter to 80(F) in summer, with slight variations.

This does not add the new climate to your ordinary game.  That is a different lesson.

slink

Make A Perfectly Flat Map With Only The River

Go to Resource\Game\Terrain.

Make a copy of Valley.rsc.
Rename the copy to GreatPlains.rsc.
Edit GreatPlains.rsc with an editor that has Administrator's privileges.

Edit GreatPlains.rsc so that it is as follows.  What you will have done is edit the string name, and also changed every numerical value under each size map to zero, except for the first four values.  The first and second values remain the same, while the third and fourth values are set to the same number as the first.

TerrainGenerator resource
{
StringTable _stringTable = "Dialog/StringTable.rsc:terrainType";
String _text = "GreatPlains";
bool _exposed = true;

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

// size of the map
Feature _features
[
// ------ small ---------
{
int _mapSize = 256;

// number of flat areas
int _flatAreaCount = 30;

// size of flat areas
int _minFlatAreaSize = 256;
int _maxFlatAreaSize = 256;

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

// size of avoidance areas
int _minAvoidSize = 0;
int _maxAvoidSize = 0;

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

// rivers
int _streamCount = 0;

// erosion
int _erosion = 0;

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

// lake size
int _minLakeSize = 0;
int _maxLakeSize = 0;

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

// part sizes
int _minLakePartSize = 0;
int _maxLakePartSize = 0;
}

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

// number of flat areas
int _flatAreaCount = 75;

// size of flat areas
int _minFlatAreaSize = 384;
int _maxFlatAreaSize = 384;

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

// size of avoidance areas
int _minAvoidSize = 0;
int _maxAvoidSize = 0;

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

// rivers
int _streamCount = 0;

// erosion
int _erosion = 0;

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

// lake size
int _minLakeSize = 0;
int _maxLakeSize = 0;

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

// part sizes
int _minLakePartSize = 0;
int _maxLakePartSize = 0;
}

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

// number of flat areas
int _flatAreaCount = 120;

// size of flat areas
int _minFlatAreaSize = 512;
int _maxFlatAreaSize = 512;

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

// size of avoidance areas
int _minAvoidSize = 0;
int _maxAvoidSize = 0;

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

// rivers
int _streamCount = 0;

// erosion
int _erosion = 0;

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

// lake size
int _minLakeSize = 0;
int _maxLakeSize = 0;

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

// part sizes
int _minLakePartSize = 0;
int _maxLakePartSize = 0;
}
]
}


Save the file. 

Now open TerrainList.rsc in the same editor.  Add a line to tell the game to include the new terrain file.  It will look as follows, when you are done.

ExternalList resource
{
External _resources
[
"Game/Terrain/Valleys.rsc",
"Game/Terrain/Mountains.rsc",
"Game/Terrain/GreatPlains.rsc"
]
}


Save the file.

Now you need to add a display string to another file.  This file is in the Resource\Dialog directory, and it is named StringTable.rsc.  Open that file in your editor.  Search for the string table for terrain, and add a line so that section appears as follows.

StringTable terrainType
{
Entry _strings
[
{ String _name = "Valleys"; String _text = "Valleys"; }
{ String _name = "Mountains"; String _text = "Mountains"; }
{ String _name = "GreatPlains"; String _text = "Great Plains"; }
]
}


Save your change and run the debug program.  If you make a new world you should see Great Plains as a choice.  Creating a world with that terrain will give you a world that has only flat land and the large river.  There will be no streams, lakes, hills, mountains, or bumps in the road.  Of course, you can't mine for iron or coal on this map, but you can maintain farms and forests to your heart's content.

As before, this does not add the new terrain to your ordinary game.

slink

#2
Include the above two in a mod package and use them in your regular game.

This is a somewhat trickier process.  You need to create a directory under BanishedKit\Examples, and name it Override.  Under Override, create directories named Game and Dialog.  Under Game, create directories named Climate and Terrain.

Now, under Dialog, copy your edited version of StringTable.rsc.

Under Game\Climate, copy your edited versions of Mediterranean.rsc and ClimateList.rsc.  You will also need a copy of the original Fair.rsc, because your new climate references that file.

Under Game\Terrain, copy your edited versions of GreatPlains.rsc and TerrainList.rsc.

Into the root of Override, create a Package.rsc file.  It should contain the following lines.  Be sure the word "override" in the very first line is lowercase.  The packaging step won't work if you use an uppercase "o".  Put this down to case-sensitivity in the C programming language and don't worry about it.

PackageFile override
{
String _name = "My Overrides";
String _author = "ME!";
String _description = "This mod adds a Mediterranean climate and a Great Plains terrain type.";
int _userVersion = 1;

// all files in resource directory
String _includeList
[
"*"
]

// exclude package files, mod files, file used for building packages
String _excludeList
[
"Package_*.crs"
"*.pkg"
"*.pkm"
]
}

ExternalList list
{
External _resources
[
"Game/Climate/Mediterranean.rsc"
"Game/Climate/ClimateList.rsc"

"Game/Terrain/GreatPlains.rsc"
"Game/Terrain/TerrainList.rsc"

"Dialog/StringTable.rsc:climate"
"Dialog/StringTable.rsc:terrainType"
]
}


Next create a batch file named buildoverride.bat, in the root of BanishedKit.  It should contain the following lines.

bin\Tools-x64.exe /build Package.rsc:list /pathres ../example/Override /pathdat ../example/Override/bin

bin\Tools-x64.exe /mod Package.rsc:override /pathres ../example/override /pathdat ../example/override/bin


Create a DOS window in administrator mode.  Change directory to the BanishedKit directory.  Run buildoverride.bat.  If everything goes well, you should find a file named override.pkm in the BanishedKit\bin\WinData directory.

Copy this file into the WinData directory of your regular game.  Now if you run the regular game, you can load your saves made from the toolkit version using the new climate and terrain.  You can also create new games with these things. 

If you look under Map, however, the entries for terrain and climate are blank.  Obviously I missed two new string entries somewhere.  The changes still work, but the mod isn't ready to distribute.  I am attaching it to this post anyway, so you can see that it works, along with the source code and the batch file.

I was able to rename override.pkm to My Overrides.pkm with no problem.  Some people appear not to be able to do this without breaking the mod.  I am using Win 7.

Paeng

Wonderful tutorial, thank you... seeing the whole process laid out step-by-step (and without omitting steps C, H, X and Y) really helps a lot to wrap one's head around this...  :)
[i]Heads are round so thoughts can take a turn[/i]
[color=teal][size=8pt]Editor's Choice [b]here[/b][/size][/color]

slink

#4
As an addendum, I searched and searched for another place in which to add strings.  I finally decided that I had changed everything required.  I loaded the saved game and checked for the text under Map.  It was missing.  I went to Mod, and the mod was unchecked.  I checked it, told it okay for saving and reloading, and then checked Map again.  The text now appeared.  It may have happened when I renamed the mod, or perhaps it was because the map was created in the toolkit without an actual mod being present.  Either way, the mod was after all ready for distribution, except for renaming properly.  My Overrides is hardly a unique name.   :D

As a note, I use one batch file to compile and package all of my mods.  Therefore I name them all "override" initially, and then rename the directory and mod afterward to an appropriate name.  I do this because batch files are automatically edited by Notepad by right-clicking and choosing Edit instead of Run.  Notepad when run in that fashion is not in Administrator's mode, and won't save anyplace except to Documents.  Rather than continually creating, editing, and copying from Documents to BanishedKit, I just made the one batch file and rename everything else.  I use another editor, in Administrator mode, for editing rsc files by simply clicking on them, so that is no problem.  Theoretically I could always log on as the Administrator, instead of as a user with Administrator rights, but I was taught that is a security risk so I don't do it.

Pangaea

#5
Tried to follow your recipe, letter by letter, but I'm not getting the .pkm file :( Instead, I get a load of *.crs files

I only made a very small change in the orchard trees files, just to test out this modding business. Can somebody look over and see if you see any glaring mistakes? I didn't get an error when running the batch file. Before running it, I copied over the files I had changed to the overrides folder like you suggested. They're now in BanishedKit\example\Override\Template

Package.rsc
PackageFile override
{
String _name = "Pangaea's Mod";
String _author = "Pangaea";
String _description = "This mod does all kinds of naughty stuff.";
String _icon = "icon.png";
int _userVersion = 1;

// all files in resource directory
String _includeList
[
"*"
]

// exclude package files, mod files, file used for building packages
String _excludeList
[
"Package_*.crs"
"*.pkg"
"*.pkm"
]
}

ExternalList list
{
External _resources
[
"Template/NaturalResourceAppleTree.rsc"
"Template/NaturalResourceCherryTree.rsc"
"Template/NaturalResourceChestnutTree.rsc"
"Template/NaturalResourcePeachTree.rsc"
"Template/NaturalResourcePearTree.rsc"
"Template/NaturalResourcePecanTree.rsc"
"Template/NaturalResourcePlumTree.rsc"
"Template/NaturalResourceWalnutTree.rsc"
]
}




Batch-file, copied the text from your file above
bin\Tools-x64.exe /build Package.rsc:list /pathres ../example/Override /pathdat ../example/Override/bin

bin\Tools-x64.exe /mod Package.rsc:override /pathres ../example/override /pathdat ../example/override/bin

Why is one override in uppercase and another in lowercase btw?


Edit: It appears the file was created after all, it was just located in the root/bin/WinData instead. Unfortunately the site just went down (I'm getting an SQL message now), but this tutorial was very useful: http://banishedmods.com/showthread.php?tid=90

RedKetchup

> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

Pangaea

Yes, I managed to run it in the end, and have now managed to make a mod that removes the annoying wind when you are zoomed out :)

Can somebody else check it out, just to make sure it actually works on your end too?

RedKetchup

yup works awesomly fine :)

Thanks you :)
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

Pangaea

Quote from: RedKetchup on September 20, 2014, 11:17:56 PM
yup works awesomly fine :)

Thanks you :)

Excellent :)

Finally managed to retrace my steps, I think, and redo it with just a slightly different name. The guide I read on that other site (still down atm) had a run.bat file that opened the game and when I create a new game, some files are added to the bin folder. Then there is a pack.bat file. Is there a way to do all these steps without having to fire up the game and create a game?

This is what the bat files look like right now

Run.bat
..\..\bin\Application-x64-profile.exe /pathres ../mymods/NoWindTo /pathdat ../mymods/NoWindTo/bin

Pack.bat
..\..\bin\Tools-x64.exe /mod Package.rsc:NoWindTo /pathres ../mymods/nowindto /pathdat ../mymods/nowindto/bin

Earlier I tried what was mentioned in this thread, but I couldn't get that to work, so I'm a bit confused here...

RedKetchup

i dunno every little change i compile, move my .pkm to the game windata and lauch the game and start a new game each time i do a little change ^^
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

Pangaea

That's what I'm wondering about really, because now I have to start up the game just to create some files that are needed before I can even compile the .pkm. How do you compile it more quickly?

Have uploaded the NoWind file to BanishedInfo, so I hope it works for others too :) As I wrote there, I still hear some slight wind noise at times, but it's very faint.

RedKetchup

#12
i dont understand how you start the game to make thing before you compile it :P

it s sound like doing something at Rome while you are on the road and just left London :P
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

RedKetchup

#13
me :

1. i do my changes
2. delete bin and build folders
3. launch my .bat in DOS window
4. look how it compiles
5. go in the 2 little Windows folder at top of my screen (kit bin windata and the game windata)
6. click and drag the .pkm from bin/windata to my game windata
7. launch the game with steam launcher
8. start a new game
9. check in game what i did
10. close the game

11+ rince and repeat. with more changes
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

slink

When I was creating these tutorial posts I did have to occasionally delete the bin directory that was created by the batch files.  I forgot to mention that.  It appears that if the bin directory already exists, that old files within are not removed and they get included in the final package.

Quote from: Pangaea on September 20, 2014, 08:18:05 PM
Tried to follow your recipe, letter by letter, but I'm not getting the .pkm file :( Instead, I get a load of *.crs files
...
Batch-file, copied the text from your file above
bin\Tools-x64.exe /build Package.rsc:list /pathres ../example/Override /pathdat ../example/Override/bin

bin\Tools-x64.exe /mod Package.rsc:override /pathres ../example/override /pathdat ../example/override/bin

Why is one override in uppercase and another in lowercase btw?


Edit: It appears the file was created after all, it was just located in the root/bin/WinData instead.

Yes, that is what I said, only I called "root" by the name "BanishedKit" because that is where I have the toolkit installed.

"Override" is capitalized in one place and not in the other because I typed it that way one time and the other way the next time.  One gets out of practice if one hasn't touched a C compiler in ten years.

I am glad that you found a tutorial that works for you.  Everyone's mind works differently.  I had to buy several books before I found one that explained OOP to me in a way I could utilize.