News:

Welcome to World of Banished!

Main Menu

Request for help understanding .rsc files

Started by salamander, October 04, 2014, 06:28:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

salamander

Seeing all of the cool things folks are coming up with, I would like to try something simple myself, but I'm having some trouble wrapping my head around how the modding works.  I have a couple of questions I'm hoping some of you accomplished modders out there can help with.

First, after poking around in the .rsc files, it seems to me like these files don't contain code (other than assignments), but are access points to data that the game uses internally.  Is this a reasonable view of what .rsc files are?  If so, are the variables defined in blocks within a .rsc file the only things that can be changed, or can variables be added in modded versions?  For example, buildings have a PathBits variable in their creation block, but some structures don't.  Can a PathBits variable be added to the creation block of those that don't, and have the game pay attention?

Second, if I make small changes to the .rsc files in the Mod Kit directories, and start the debug version of the game from the command line, should those changes automatically be reflected in the game, or do I have to include command line parameters to make them available?

Probably not the best description of what I don't understand because I really don't understand what it is I don't understand.  ???

Thanks

slink

I run the debug version of the game from the directory rather than from a command line, but that should also work.  It will automatically compile changed rsc files in the resource directory before using them.  In fact, you can edit them while the debug version of the game is running and it will often compile them and the change will be reflected immediately.  This is a good way to crash the game if you haven't already done so.  *said wryly*  But it can save some time if you are tweaking a layout or something similar.

You are correct that the rsc files are basically assignment of values to variables, in C-code format, combined with names of routines which are probably inside the executable, such as CreatePlacedDescription.  The line between variables and code gets blurred with object-oriented programming (OOP) because the structure of something can contain both in various elements of the structure.  It can be very powerful if you can re-use the container over and over again, with some elements being used and some not depending upon the purpose of the specific instance of that container.  I suspect Luke has a master game structure container which he adapts to many purposes.  Not all of the elements would work together well, I suspect, but they are probably all available if we knew the names and structures of all of them.  I am speaking on the bleeding edge of my expertise, because I only managed to write one OOP program in my life.  Most of my programming tasks since I retired have been of the quick-and-dirty utility types, and before then there was no OOP.

I've probably confused you more than I've helped you, so why don't you tell me into which file you are thinking of inserting a PathBits variable and I'll hazard a guess, or test it yourself if you prefer.

salamander

@slink -- Thanks.  Actually, you've helped more than you might think.  I've been writing programs (on an amateur basis) in C, C++, and more recently Java since the late 80's, so everything you said makes sense to me.  The de-coupling of the data from the classes in the game code makes me appreciate more than ever the effort Luke put in to make the mod kit available.

What I'm looking at trying to do was inspired by the Better Farms mod by @rageingnonsense -- specifically the part where farms/orchards can be placed further up hill slopes than usual.  I don't recall there being a description of what was changed to make the mod, but looking at CropField.rsc, there's a block called 'createdrag':


CreateDragDescription createdrag
{
bool _ignoreZones = false;

PathBits _placeBits = Normal | Obstacle;

int _maxWidth = 15;
int _maxHeight = 15;
int _minWidth = 4;
int _minHeight = 4;

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}


My guess is that the _placeBits variable is the key to where the crop fields can be built.  Looking at other structures, there are a number of other bitflags, such as 'walkable', that can be used.  My original thought was to include the 'walkable' flag for roads to allow them to be built over a low hill where citizens can walk, but roads could not originally be built.  The DirtRoad.rsc has a block called 'createroad', but it doesn't include a variable of type PathBits.  I tried adding a 'PathBits _placeBits' variable to the 'createroad' block, but it didn't work -- maybe because the game code that uses 'createroad' doesn't use a PathBits (after all, it wasn't included in the 'createroads' of the .rsc file), or because I didn't do things correctly to get the change into the game (that was the reason for my second question).

slink

#3
I was going to try this change in cropfields.rsc, but my game is completely not working right now for some unknown reason which may be a consequence of having installed 3ds MAX.   >:( 

CreateDragDescription createdrag
{
//   bool _ignoreZones = false;
   bool _ignoreZones = true;

See if that changes anything, if you would be so kind?  While I go troubleshoot my game installations ...

Edit: Nope, that wasn't the change that made Better Fields work better.  BTW, my copies of the dll files apparently weren't right anymore.  Very strange.  It's all working again now, though.

salamander

I was just getting ready to try what you suggested when I saw your edit.  I'm guessing that roads may work a little differently than buildings, maybe because of the pathing that the game has to do as the road's laid out.  I would think that there would be a similar way to determine whether a road can pass over a particular square on the map as there is for buildings, but possibly the pathing requires road building to be more integrated into the main game code.

I'm sure I'm not the first to think of changing where roads can be built, so it may be one of those things that's not moddable.

RedKetchup

i tried to follow the thread , not 100% understood everything, maybe cause i just woke up ..... :P ^^

but something freaks me out :

never never do the change directy in your toolkit ressource files ! always working on new files you are creating in a folder you also creating (in example folder=best)
at some point you will start to crash and wont even new where come from and how to resolve out of reinstalling the toolkit completly.

never make any change in the resource folder , not even one letter or one dot. work on your own files.
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

slink

@salamander, at think you may be correct.  Luke has struggled enough with roads that it's probably mostly hard-coded by now.  Some day I would like more types of appearance, but the behavior probably can't be changed.

@RedKetchup, whoa there!   ;D  Working on new things is different from making overrides.  Maybe it's not true for others, but my text editor makes a backup copy so I can always tell where I've changed something by the presence of xxx.rsc.$$$ in the directory.  It's very laborious to make an entire mod to test one little change in a standard file.  Instead, I comment out the original code and edit a copy of the section.  If it doesn't work, I put that back to the original and delete the backup, or just use the backup if I haven't edited the file more than once.  Once I've gotten what I wanted, then I make a mod directory and package it up for use with the normal game executable.  And yes, on occasion I've lost patience with tracking down all of my changes to revert them and replaced the abused Resources directory with a new copy from the zip file.  Run Buildresources and you are up and running again.  No big deal.   ;)

RedKetchup

but still. you are starting to learn to make mods... i only can suggest you to work properly please. start and get used to work on your own folder please.
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

slink

Quote from: RedKetchup on October 04, 2014, 01:27:01 PM
but still. you are starting to learn to make mods... i only can suggest you to work properly please. start and get used to work on your own folder please.

And this @assobanana76, is an example of why we can't make one big team out of all the modders.   ;)

irrelevant


RedKetchup

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

salamander

@RedKetchup -- Your point's a good one, and if I ever get far enough into modding to try writing one with many changes spread over many files, I would set up a separate mod directory and work on copies of the files.  Both because of the reasons you mentioned, and also because otherwise every mod you write would also include all previous mods.

Like you said, though, I'm just now trying to get started, and the simplest thing for me is to make very small changes that can easily be undone (I use @slink's method of commenting out lines and setting off added lines with comments) directly in the resource directories.  If it makes you feel any better, I do make a backup of the files I'm changing.  ;)

RedKetchup

on my drive i have :

/bkit/ folder. thats the one i use to make mods and i put my mods inside /examples/

i have also 2 more copy :

/banishedkit1/
/banishedkit2/

they are strictly copies. since i often click and drag, it happends often i forget to hold the 'shift' to copy.. so .. i move them unfortunatly sometimes, and i see it later so i have back up copies ^^
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

slink

I have an amusing anecdote about programmers who edit directly the code on a live system without proper forethought.  We were editing the source files for a DIBOL accounting package for a client, and the lead programmer said we didn't have time to set up a new installation for our work.  Since our company used the same package, and it was always both the newest version and completely vanilla, we were to use that one for our work.  We would restore it from backup when the job was done.  Friday afternoon came around and the secretary went to print the paychecks, but the paycheck module no longer worked with the rest of the system.  Fortunately I was a subcontractor working there semi-permanently, so I was paid through the accounts payable module.  I got my check and left the employees standing around the lead programmer with their piercing gazes focused on him.  I also left my employment there a couple of months later.  They were much too shoddy in all of their practices.

However, the modding kit directory is not the live system for me, and if it is buggered beyond repair, I simply copy in fresh files.  My copy of the downloaded zip file is my ultimate backup.  Trust me to know what I am doing with regards to preserving file data, and also to accept the consequences of my mistakes.   ;)

RedKetchup

another anecdote :

when i decided to do the grain silo ... i decided to copy couple of things from my chapel, since was kinda same mats .... and i saw 4 days layer .... my chapel is missing its SpriteSheet.rsc ^^

so if i want to make an update on my chapel ... i need to rebuild a new spritesheet first lol
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .