Pages: [1]
|
|
|
Author
|
Topic: Poking the Source Part 1: Add a new starsystem (Read 2829 times)
|
rk
Zebranky food
Offline
Gender:
Posts: 12
SC2 = great!
|
I've been sifting through the source code, trying to figure out what would be involved in adding certain game content. For step 1, I wanted to add a new star system. (In step 2 next post, we’ll put a Melnorme trader in it.) Here's how I accomplished it, for those interested.
PREAMBLE
Yes, I know this is off on a tangent from the goal for v1.0 of recreating the original game. But it’s interesting and neat, and I’m also curious if there’s been any consideration of how to handle “content-addons”. But before I start:
Big Question: Does anyone have any documentation available on the mechanics of the game code? (aside from the file descriptions in Devel\Files)
I think everyone agrees we can all benefit from generating more documentation on the SC2 guts, and I don’t want to be repeating other people’s work ;-).
A word of warning here for newbies: The sc2 source code is a tightly-knight package and poking it can be dangerous, especially if you don’t know what you’re doing. What I’m describing in this post is a fair bit of poking, and I don’t claim to “know what I’m doing”.
HERE WE GO
Alright, time to get our hands dirty. STAR_DESC starmap_array[] in plandata.c contains star data, including two useful fields: postfix name and alien presence. The latter is taken from encount.h. The former is the index of a record in LBM\starcon.txt. Each line starting with a "#'"and the following line(s) until the next # make up a record. Here's a simple formula: Line number = record index / 4 – 1.
Question for gurus: There are two starcon.txt files. Which one is actually used (or are both?). From my brief testing, I only noticed changes in the \LBM to have effect. Is this correct, or is there more to it?
So, to begin I inserted a line in the starmap_array[] definition in order to create a new white star at 200:200, near Rigel:
{{2000, 2000}, MAKE_STAR (DWARF_STAR, WHITE_BODY, -1), 0, 0, 132},
Note that the list is (and must be) sorted by y-coordinate. The final number is the index of the name for the star. Since it is a byte, it can’t be > 255, so unfortunately you can’t simply insert a new string at the end of the starcon.txt file. Instead, one puts the new record after the last existing star name in starcon.txt (which is probably better practice anyway). So starting at line 525, my file looks like this:
#(Lentilis) Lentilis
#(RKVille) RKVille
#(UNKNOWN) UNKNOWN
Note RKVille is record index 132. Technically, UNKNOWN counts as a star “name”, but I think it is there for safety in case a star isn’t found. Since we inserted rather than appended a record, you have to add 1 to each of the constants DEVICE_STRING_BASE through OPTION_STRING_BASE in globdata.h.
Also incremented the NUM_SOLAR_SYSTEMS constant in encount.h.
Okay, load up the game and voila, a fine new star system complete with planets and minerals vaguely corresponding to its size and color. Neat!
From what I can tell, the planets, life, minerals, etc. for the system are created using a sequence of random numbers generated from a seed that is the X and Y location of the star. This takes place in LoadSolarSys() (in solarsys.c) and DoPlanetaryAnalysis() (calc.c).
I made this post to 1) document what I’ve unraveled so far, and 2) avoid re-doing work someone else may have done. I appreciate any feedback or comments from the gurus. My real goal is to add a "lone ranger" character who hangs out in a far-off star system, kinda like a Melnorme trader. Any tips from the pros on adding custom dialog, graphics, etc. are appreciated!
Keep an eye out for the next post, when we’ll add a Melnorme to the system.
|
|
« Last Edit: April 26, 2004, 10:47:04 pm by richardk »
|
Logged
|
|
|
|
|
rk
Zebranky food
Offline
Gender:
Posts: 12
SC2 = great!
|
Thanks for the response! Couldn't resolve irc.openprojects.net (problem w/ my DNS server??), but I managed to get into the #sc2 channel on Freenode. Unfortunately, I think everyone was asleep (~3am EST).
Cheers!
|
|
« Last Edit: April 27, 2004, 12:54:47 pm by richardk »
|
Logged
|
|
|
|
|
Pages: [1]
|
|
|
|
|