Editing text files and creating mods in GoT/Spartan

PC/MAC : Turn based Empire building in the ancient Greek World.

Moderator: Slitherine Core

Redpossum
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Thu Jun 23, 2005 12:09 am
Location: Buenos Aires, Argentina
Contact:

Editing text files and creating mods in GoT/Spartan

Post by Redpossum »

It's not so bad once you get used to it. I've done quite a bit of making my own scenarios for GoT/Spartan, and it's a bit tricky at first, but you learn.

N.B. This post partially duplicates the information inthe "Mod Kit" thread.

Part One

First, let's just talk about making your own scenarios, without modifying the game engine at all.

You cannot create new maps. You must use the existing ones. Adding or deleting cities causes problems.

However, you can do a great deal by just editing text files, and the text files are sort of self-explanatory.

Nota Bene: The sample directory structure below is for the Matrix version of the game. Your directory structure may be different, but only the part to the left of "Gates of Troy". Everything to the right of that is the same, regardless of version.

The important part is to create a \mod directory, mine is at -
C:\Matrix Games\Gates Of Troy\MOD

Then under the mod directory, you create a directory named whatever you want your mod's name to be. For example -
C:\Matrix Games\Gates Of Troy\MOD\Rhodes

I now have a mod named "Rhodes". Then under that, you need to mirror the stock directory structure. This sounds far more complex than it is. Since my "Rhodes" scenario is played on the "Grand Campaign 1500BC" map, I wind up with -
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data\maps\GCBasic

Then you just need to copy stuff from the stock version at -
C:\Matrix Games\Gates Of Troy\data\maps\GCBasic
into my new directory at -
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data\maps\GCBasic

Now, all you really need to copy is the *.txt files and events.bat

Slitherine did a very good job of writing this part of the engine, and any files needed for this GCBASIC scenario which are not found in the modded GCBASIC directory, it will get from the stock GCBASIC directory. Therefore, your modded GCBASIC directory only really needs to contain the files you are planning to change.

The one exception is the "events" files. If you are going to change any of them, you need to copy all of them and events.bat

This part is a wee bit tricky. You never edit events.txt directly. You edit the individual event*.txt files, like EventHistoric.txt, EventRandom.txt

Then you run events.bat to compile (concatenate?) a new events.txt file, which is what the game engine actually reads.

I have more to share, but I'll start a new post.
Last edited by Redpossum on Sat Sep 22, 2007 11:31 pm, edited 1 time in total.
Redpossum
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Thu Jun 23, 2005 12:09 am
Location: Buenos Aires, Argentina
Contact:

Post by Redpossum »

Part Two

Tweaks.txt

Let me digress a bit and talk about tweaks.txt

This file is usually found in-
C:\Matrix Games\Gates Of Troy\data

But if you copy it to your mod's data directory, for example -
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data

You can edit it, and the game engine will read your modded copy when running your mod. Note that this is not the same location discussed for the other files in the post above!

Now tweaks.txt contains all sorts of interesting stuff. Be careful in there, as you can hose the game completely.

Note that one of the things in tweaks.txt is "StartingArmyExp", which is set to 100 by default. This parameter determines the experience level of all units at the beginning of the scenario. 100 experience is level 3. This is why all units start the game at level 3. This has nothing at all to do with the experience level of units you recruit during the course of the game. That parameter is, as far as I can tell, hard-coded to level 1.

I will append here the notes at the beginning of my "standard" possum version of tweaks.txt

Most of these changes are just to reduce the handicap suffered by the AI at lower difficulty levels.

I have also increased the morale boost from the Rally command from 200 to 250. As you can see, I did this work 27 months ago, and frankly I can't recall why that seemed like a good idea at the time :)

// BEGIN Changes made 6-21-05

// Difficult Settings - %age of building & squad costs AI pays on this difficulty level
// AILEVEL0 changed to 150
// AILEVEL1 changed to 120

// How long to prevent AI building units
// AIDelay0 changed to 1
// AIDelay1 changed to 1

// END Changes made 6-21-05

// BEGIN Changes made 6-24-05

// pop gain per free worker
// POPULATIONGROWTHRATE 5

// Difficult Settings - %age of building & squad costs AI pays on this difficulty level
// AILEVEL2 110

// Difficulty effecting research - value is the % of the 'normal' research amount that AI sides need to achieve.
// AIRESEARCH2 110

// how much morale is boosted by the rally command
// RALLYAMOUNT 250

// END Changes made 6-24-05
Redpossum
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Thu Jun 23, 2005 12:09 am
Location: Buenos Aires, Argentina
Contact:

Post by Redpossum »

Part Three

First, a bit of disambiguation (thank you, Wikipedia, for that lovely word!)

I have used the words "mod" and scenario" interchangeably up to this point. This is because in order to make a new scenario for Spartan/Got, one must create a mod (or else overwrite the original scenario files, which seems to me like a spectacularly bad idea). So technically, what we are doing is creating a mod, and then creating a new scenario within that mod.

Also, it should be noted that Slitherine does not endorse direct editing of text files. Slitherine suggests you use the mod kit, which contains excel versions of the text files, editing those excel versions and then doing a txt export. See the mod kit thread linked above for more information. Personally, I have done a good deal of direct editing of the text files in Spartan/GoT, with generally excellent results. However, when doing so, I am very careful to preserve the original spacing and format. The tutorial which follows will work with either method of editing.

Right, on with the meat of the matter.

In these next few chapters, we'll be looking at the three files at the heart of your new scenario -

armies.txt
cities.txt
sides.txt

In our first installment, we looked at directory structure. Let's go ahead and use that directory structure to create a simple mod/scenario.

In the directory-
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data\maps\GCBasic

you should now have 15 files which you have copied from-
C:\Matrix Games\Gates Of Troy\data\maps\GCBasic

These 15 files are-
armies.txt
cities.txt
sides.txt
events.bat
and 11 files named "event(something).txt"

Optionally, you may also wish to copy tweaks.txt from-
C:\Matrix Games\Gates Of Troy\data
to
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data


And now, let's begin.

Open up sides.txt with your favorite text editor. I personally use good old notepad, and these notes assume you are also using notepad. Turn *off* wordwrap under the "Format" menu at top of screen. Only the last few resource listings will be offscreen to the right, and that's why Steve Jobs created scrollbars.

At the top of the file, you'll see a bunch of stuff about setting variables. Leave that alone!

Below that, you'll see the actual sides listings start with "AUTARIATIA".

One crucial thing to know about all these files is that any line beginning with a double forward-slash (//) is not read by the game engine. Such lines are said to be "commented out", because they are often used for comments, notes, and explanations.

The first thing we want to do is find Sparta. Press Ctrl-F, type "laked" in the window and press enter. From now, I'm just going to say "search for xxxxx". You are, after all, big boys & girls now ;)

Under the listing for Sparta (which is, you'll see, actually listed as Lakedaimon), you'll see the 7th line is "SetSideAsDefault". Comment that out by adding two slashes and a space to the beginning of the line, so it looks like this-
// SetSideAsDefault

Now search on Rhodes, find that same 7th line, and UN-comment it, by removing the two slashes and the space from the beginning of the line.

We are doing this because Sparta was the default side in the stock version of this scenario, and we want Rhodes to be the default side.

Since we have the sides listing for Rhodes up, let's look more closely.

The 2nd line is important, where it says "SetSide 90". Make a note of this, as we'll need it later.
The 3rd line is "SetSideType". The Rhodeans are Dorians, which the game lists as simply "Greek". See the top of file for other types.
The 4th line is "SetSideHouseType", and I confess I have no clue what that does.
The 5th line is a repeat of line 2, AFAIK.
The 6th line is "SetSideRGB". This is a simple RGB triplet to set your side's color. Works great! See products at www.visibone.com if you need color help.
The 7th line we already edited.
The 8th line, "SetSideAsPassive", seems to make a given side just sit and vegetate.
The 9th line "SetSideResources" is your "base" starting resources, but Difficulty setting can/will modify this.
The 10th line "SetSideBonus" determines your "Nation Bonus", those resources you receive each turn, above and beyond the production of your cities.

Unfortunately, the sides.txt file just gives us a line of numbers for the resources, which can be a pain. So at this point, let's also open up cities.txt, (remember to turn off wordwrap), which also uses the same sequence of numbers to represent the same resources, and which has a helpful comment line above, listing their names!

As you can see, there are 9 resources. BM is known as bricks in Spartan/GoT. The term BM is a holdover from CoW, when it was called "building materials".

So, let's carefully edit sides.txt, (cities.txt is only open for information, at this point), to give ourselves a better base for building an empire. Let's start with the first three resources, Gold, Food, Iron. Remember now, "SetSideResources" is the starting amount, as modified by Difficulty setting, "SetSideBonus" is the per-turn Nation Bonus.

Gold, leave starting at 14, and change bonus to 9
Food, change starting to 432, and change bonus to 40
Iron, leave starting at 32, and change bonus to 5

The next three resources are Bricks (BM), Horses, Marble

Bricks, change starting to 438, and change bonus to 40
Horses and Marble, leave all unchanged

The last three resources are Copper, Wood, Silver. This is where you get to use the scrollbar ;)

Copper, leave starting at 77, change bonus to 5
Wood, leave both unchanged
Silver, leave starting at 822, change bonus to 350

And that's it. We are finished with sides.txt, so save and exit.

Next up, we edit cities.txt
Last edited by Redpossum on Thu Sep 27, 2007 11:53 pm, edited 2 times in total.
Redpossum
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1813
Joined: Thu Jun 23, 2005 12:09 am
Location: Buenos Aires, Argentina
Contact:

Post by Redpossum »

Part Four

***edit*** I was having a blonde moment here folks. I wrote "Win-F" and I meant "Win-M"

First, I'd like to talk about a simple windows convention that may be helpful with all these files open at once, Win-M.

The Win-M command is issued by holding down the "Windows" key, (that funny one at the bottom left of your keyboard between Ctrl and Alt), and pressing the "M" key. The Win-M command will minimise all open windows. This can be handy when you have 5 windows open, and suddenly need to see your desktop. Shift-Win-M will restore all windows minimised with the Win-M command, and restore them to their previous size, location, and order. Shift-Win-M will not restore windows minimised manually.

OK, on to editing cities.txt

When we left off, we were working in the-
C:\Matrix Games\Gates Of Troy\MOD\Rhodes\data\maps\GCBasic

directory, and had just finished editing sides.txt

Let's now take a closer look at cities.txt, remembering to be sure word wrap is off. Search for "Rhodos". No, that's not a typo. These files use strict translations of the ancient greek, not the more popular anglicised versions of names. Remember Sparta being listed as "Lakedaemon" ??

As you can see, most of the entry is commented out. I love how Slitherine *always* leaves room for future expansion. Iain's long experience in the industry has taught him some serious foresight. You can almost see him as a spotty 14-year old coder manque, running out of room for something he really wanted to add, because he hadn't allocated enough space in the initial design, and vowing, "I will never Never NEVER paint myself into a corner like this again!!".

Ahem, you're babbling again, Possum. Right.

The Rhodos entry looks like this-

Code: Select all

	CityID	253								
	EditorString	Rhodos								
	Side	90								
	StringID	253								
	Position 	248 225								
	Population	4								
	AddBuilding LargeEncampment									
	AddBuilding WheatFarm1									
	AddBuilding Capital									
	// AddBuilding 4									
	// AddBuilding 5									
	// AddBuilding 6									
	// AddBuilding 7									
	// AddBuilding 8									
	// AddBuilding 9									
	// AddBuilding 10									
	// AddBuilding 11									
	// AddBuilding 12									
	// AddBuilding 13									
	// AddBuilding 14									
	// 	gold	food	iron	bm	horses	marble 	copper	wood	silver
	SetResLevel	0	8	0	8	0	0	6	6	0
	BuildFlags 0									
...and then several more lines of commented-out blank entries that need not concern us.

City ID is engine-internal data, editor string is the name of the city (duh!), and "Side" is 90. Now, remember when we started editing sides.txt, and I told you to make a note of our side number? It was 90, and here's the first relevance of that number. The city of Rhodos is controlled by side 90, and that's us!

String ID is related to the name in localisation.txt, which we are *not* going to discuss right now, since it's a whole 'nother can of worms.

Position is actually relevant, that's the X,Y coords of our city. Useful for placing reinforcements, which we'll talk about later.

Population is the starting units of population. Four seems awfully meagre for empire-building, so let's change that to 6.

Now we come to the entries for buildings. First off, we must specify the city's initial size, or rather level of development. Every city defaults to Small Encampment, and if you wish it to start beyond that point, you must specify it here.

There are 8 possible levels of development, Small & Large Encampment, Small & Large Village, Small & Large Town, Small & Large City.

Each level must be added incrementally, so if we want to start with a Large Village, we need 3 lines to accomplish that-

Code: Select all

	AddBuilding LargeEncampment
	AddBuilding SmallVillage
	AddBuilding LargeVillage
Our entry for Rhodos already has the first line, so just add the other two, after Large Encampment, and before Wheatfarm1.

We want to keep the size of the entry the same, so you should also delete the commented-out lines about AddBuilding 4 and AddBuilding 5.

Wheatfarm1 again seems meager, so change that to Wheatfarm3.

When you're done that part of the entry should look like this...

Code: Select all


	CityID	253								
	EditorString	Rhodos								
	Side	90								
	StringID	253								
	Position 	248 225								
	Population	6								
	AddBuilding LargeEncampment									
	AddBuilding SmallVillage
	AddBuilding LargeVillage
	AddBuilding WheatFarm3									
	AddBuilding Capital									
	// AddBuilding 6									
	
OK, we are almost done, all we have left to do is look at the city's resources.

(in progress...)
HBalck
1st Lieutenant - Grenadier
1st Lieutenant - Grenadier
Posts: 786
Joined: Thu May 21, 2009 9:28 pm
Location: Augsburg / Bavaria / Germany...but I am from Eastern Germany !

Post by HBalck »

Hallo possum
It is possible to change the unitanimation and the map (bigger map - global europe).
For my new animations please go the the Legion forum !
Image

H.Balck
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil »

Very cool - is this inside Legion?
HBalck
1st Lieutenant - Grenadier
1st Lieutenant - Grenadier
Posts: 786
Joined: Thu May 21, 2009 9:28 pm
Location: Augsburg / Bavaria / Germany...but I am from Eastern Germany !

Post by HBalck »

Yes - you can see 30% menpower of one of the 4 inside legions.
Can you answer my question !

H.Balck
HBalck
1st Lieutenant - Grenadier
1st Lieutenant - Grenadier
Posts: 786
Joined: Thu May 21, 2009 9:28 pm
Location: Augsburg / Bavaria / Germany...but I am from Eastern Germany !

Post by HBalck »

Over one week without answer....

Halloooooooooooo
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil »

I've been out of the office for a week so trying to catch up - hope to get back to you soon. You are the person who e-mailed me?
HBalck
1st Lieutenant - Grenadier
1st Lieutenant - Grenadier
Posts: 786
Joined: Thu May 21, 2009 9:28 pm
Location: Augsburg / Bavaria / Germany...but I am from Eastern Germany !

Post by HBalck »

yes
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil »

I have replied to your mails :)
aizuddin
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Tue Mar 01, 2011 4:39 am

Post by aizuddin »

hey possum, why i cannot save the edited side.txt file? when i want to save it says access denied...
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil »

Is the file write protected? Do you have permissions to save to the foler you are editing?
aizuddin
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 6
Joined: Tue Mar 01, 2011 4:39 am

Post by aizuddin »

some cause, when i try to copy the file..... to the mod folder, it ask the permission from admin... and i move it as admin, is the "access denied" appear because i create another account in my computer?
pipfromslitherine
Site Admin
Site Admin
Posts: 9702
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

You could have problems if you are trying to write files in windows7 to the Program Files folders - Spartan was written long before these kind of restrictions. You might be best doing all your modding on an admin account

Cheers

Pip
dithyrambos
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 103
Joined: Sat May 13, 2006 5:01 am
Location: Thermopylae, 480 B.C.

Post by dithyrambos »

possum wrote:// Difficult Settings - %age of building & squad costs AI pays on this difficulty level
// AILEVEL0 changed to 150
// AILEVEL1 changed to 120
Is this what affects how active/inactive the AI factions are at different difficulty levels? I have noticed that smaller, 1 city factions tend to be rather inactive at lower levels, which has diminished the fun of the Colonialism scenario for me, as the only way I can seem to get the AI to do anything is to play on hard difficulty or higher, but being quite out of practice, the AI steamrolls me on hard (heck, it is steamrolling me on normal in some other scenarios). If I tweak these, perhaps to the levels you have here, would the smaller AI factions be more active and not be such pushovers? Also, what else can I affect for the AI? Is there a way to tweak aggression (at all or by difficulty level) or tweak the AI's preferences for Heavy Inf, Light Inf, Skirmishers, Cavalry, et al?
"Now Dithyrambos, the Thespian captain... by trade an architect and by no means a professional soldier, had already distinguished himself with such magnificent courage throughout the day..." From Steven Pressfield's Gates of Fire
duppydem
Private First Class - Opel Blitz
Private First Class - Opel Blitz
Posts: 2
Joined: Sat May 11, 2013 6:28 pm

Re: Editing text files and creating mods in GoT/Spartan

Post by duppydem »

For some reason I tried to edit the squad size & the game keeps on crashing
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Re: Editing text files and creating mods in GoT/Spartan

Post by IainMcNeil »

Unless the formations file has enough slots for the extra men it will crash. Changing squad size is quite involved.
Mazeppa
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 30
Joined: Sun Aug 12, 2012 10:27 am

Re: Editing text files and creating mods in GoT/Spartan

Post by Mazeppa »

aizuddin wrote:some cause, when i try to copy the file..... to the mod folder, it ask the permission from admin... and i move it as admin, is the "access denied" appear because i create another account in my computer?
You'll have to right click the file, copy and paste it on another place. That's pretty much what you have to do on Windows 7 if you want to edit it and that's exactly what I did. I made a folder containing two folders, one which is original and one which is modded (just for organizing purposes). I pasted the original, then used it to edit the txt file, then saved it on modded with some an additional note to make sure I know what the heck I modded there. :)

Then I copied it, pasted it on the game's data folders and overwrote the original file in that folder by re-naming it exactly the same name as what it was before it was modded. Hope you understood. :)
luk3Z
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 8
Joined: Wed Feb 13, 2013 5:10 pm
Location: Poland

Re: Editing text files and creating mods in GoT/Spartan

Post by luk3Z »

Hi there.
Any chances for more parts or any modding manuals ?
Post Reply

Return to “Spartan & Gates of Troy”