View unanswered posts | View active topics It is currently Fri Apr 26, 2024 11:39 pm



Reply to topic  [ 6 posts ] 
 Dissecting the Cortex Command INI; WIP (Work in Progress) 
Author Message
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Dissecting the Cortex Command INI; WIP (Work in Progress)
This guide is to understand Cortex Command's INI file syntax, or as code as you refer to it in this forum.

Table of Contents
1 Introduction
2 Basics
2.1 Modding
2.2 Creating Entities
2.3 Tips
3 Tricks
3.1 HowTo: Dual Wielding
3.2 HowTo: Preequip Actors
4 Variable Table

1. Introduction
You have played Cortex Command for a long time and then found out you can mod it. So you make cool weapon concepts and have cool ideas, but then you discover "OH SHI- I can not code!" and you think of giving up because you do not understand Cortex Command's way of coding. You try to fiddle around in Cortex Command's Base.rte before giving up and then try to understand how everything is related. Okay, so you made a cool test weapon and tests it. Oh snap it doesn't work, you maybe got a Syntax error or the game hung up. So you give up and just download mods to play from this forum.

BUT! It is not too late to save you from being passive! This Tutorial\Article will teach you the basics in coding and give you helpful tips in your coding adventures. So continue reading if you are interesting in modding for Cortex Command. :D

2.0 Basics
This section will teach you the most basic components of coding for Cortex Command and gives hints on how improving code readability.

Now so may you think "Now what?" and want to make your Ãœber mod of Burning Kitten Demons, but WAIT! You do need to know the basics first if you are going to make your super mod. You maybe have modified one of the ini files in the Base.rte and made a weapon super good or a Actor with redicilous ammounts of health. But STOP there! You made a common newbie mistake there, never EVER modify ANY file in the Base.rte if you don't know what you are doing! And this will take us to the next topic.

2.1 Modding
Okey, you are not allowed to modify the Base.rte folder and you think it's silly. But it is for a reason you should not modify the Base.rte folder. (Really, you shouldn't) It can cause incompatibilites with other mods that you or others might download and\or mess up the game so it must be reinstalled is one or more reasons to NOT modify Base.rte.

Then how can you make your own mod then may you think, and how is the correct way to mod?

Cortex Command recognise EVERY folder wich ends with .rte as something it should load at start of the game. It loads the Base.rte FIRST and then the other .rte folders in Alphabethic order wich may look like this;
1. Base.rte
2. 0_Something.rte
3. A.rte
4. Shoop Da Whoop.rte

But how does Cortex Command know WICH files to load in the .rte? The answer is that it allways look after a file named index.ini in the .rte and parses it. A index.ini file may look like this:
Code:
DataModule
   IncludeFile = Base.rte/Materials.ini
   IncludeFile = Base.rte/Sounds.ini
   IncludeFile = Base.rte/Effects.ini
   IncludeFile = Base.rte/Ammo.ini
   IncludeFile = Base.rte/Devices.ini
   IncludeFile = Base.rte/Actors.ini
   IncludeFile = Base.rte/Scenes.ini


As you can see so does it start with Datamodule and maybe wonder why. The Datamodule declares that it is handling data. And IncludeFile tells Cortex Command to include and parse the file in the path after the Equal To (=) sign. (All paths in Corex Command have it's Root in Cortex Command\ and not in C:\ or whatever you have.)

Maybe you notice that there is a TAB on every row, it is because Cortex Command uses Tabs as it's way of telling if all the Data is a group. If this was in Psuedo-C++ so would it look like this:
Code:
DataModule{
 IncludeFile(Base.rte/Materials.ini);
 IncludeFile(Base.rte/Sounds.ini);
 IncludeFile(Base.rte/Effects.ini);
 IncludeFile(Base.rte/Ammo.ini);
 IncludeFile(Base.rte/Devices.ini);
 IncludeFile(Base.rte/Actors.ini);
 IncludeFile(Base.rte/Scenes.ini);
}

The Tabs basically tells Cortex Command that this is a Datastructure. :pipe:
Now over to something completely different.

Comments! Everyone loves comments! Do you not? Anyway, commenting is crucial to making readable code and makes it easier for you to code! A comment is very easy to define and fits everywhere, all you need to do is to add two magic slashes! // That's it! All you need and the rest of the line is a comment wich will NOT be parsed by the Cortex Command parser! Example:
Code:
//This is a comment

But be careful of where you put the comment, if put it after a TAB where the compiler expects for as an example IncludeFile so will you get a parse error.
These are also valid comments:
Code:
///////////////////////////////////
// This is a comment
///////////////////////////////////
DataModule
   IncludeFile = Base.rte/Materials.ini //Include Materials
   IncludeFile = Base.rte/Sounds.ini
   IncludeFile = Base.rte/Effects.ini
   IncludeFile = Base.rte/Ammo.ini
   IncludeFile = Base.rte/Devices.ini
   IncludeFile = Base.rte/Actors.ini //Exclude Scenes
// IncludeFile = Base.rte/Scenes.ini


Variables, variables... It is those wich enables Cortex Command to be so customisable, and let you make crazy weapons. The variables are the Bread and Butter of Cortex Command and it is those wich actually makes the game. Some example variables:
Code:
RateOfFire
FullAuto
SharpLength

Variables are usually defined with the '=' symbol in this manner: Var = x

Datastructures uses a lot of tabs to make up the actual structure for the parser to parse. They are aligned logically like this:
Code:
SomeStructure
   SomeVar
   AdvancedVar
      YetAnotherVar
   AVar

Weapons, Actors, Tools and lots of other stuff are made of Datastructures.

Enough theory, let's create a weapon! :D

Now create a folder in the Cortex Command directory wich we can call MyWeaponMod.rte (Or name it what you want) We will base our weapon on the Ak-47 and we are going to make it shoot faster than the Normal Ak-47.

Let's now create a index.ini file with this structure:
Code:
DataModule
   IncludeFile = MyWeaponMod.rte/MyWeapon.ini

This will tell the Cortex Command that we want it to include MyWeapon.ini in parsing too. Now create a file named MyWeapon.ini and enter this into the file:
Code:
AddDevice = HDFirearm
   CopyOf = AK-47
   InstanceName = Supar AK
   GoldValue = 60
   RateOfFire = 1000

Woah, woah! May you think, what is the CopyOf doing? The answer is pretty simple, it just makes a straightout copy of the original AK-47. But why do we have InstanceName and the other variables then? It is because we are redefining them so we do not have TWO AK-47's and so we can make our own simple modifications without doing too much work. Now save it and test your creation in Cortex Command :).

Most variables are selfdescripting as you can see. The AddDevice tells the Parser that a Device should be added, like a Gun, Shield or a Bomb. The '=' and the value after tells it what type of Device it is, in this case HDFirearm wich is a Held Firearm. The HDFirearm is a Datastructure wich stores all variables for our firearm and thus makes it available for the game to use.

This concludes this Sub-chapter.

2.2 Creating Entities
What's an entity may you ask. The answer is pretty simple; All Actors, Weapons, Tools, Bombs, Rockets, Dropships, etc... are entities wich allows the player to interact with the game. (Moving, Shooting, etc...) In order for the game to know what those Entities are so must it create them. To get Cortex Command to create those entities so does it first create Templates from the .rte and .ini files by parsing them. After the Templates are created so can the game use them as many times as it want. All actors you order as an example is a Exact copy of the original wich is stored in Memory wich is then used to become interactive with the game. Enough theory, let's learn how all this works.

All Entities as you read is stored in a template, to create a template so must you let the game add it. Let's now add an Firearm for example;
Code:
AddDevice = HDFirearm

Now so have we created a empty firearm, it is ready to use in memory but is not usable ingame. The AddDevice tell the parser to add a new usable Device for actors and HDFirearm is a type of a Device to add. Let's make it so we can refer the Firearm by name.
Code:
AddDevice = HDFirearm
   InstanceName = Some Firearm


Our Firearm can we now refer to by name, but there is still a lot of Variables missing. (You can base your guns on existing ones.) The point with this is that we have created a TEMPLATE for the game to use. The same basic rules appends to:
AddDevice = Type
AddEffect = Type
AddAmmo = Type
AddActor = Type
etc...

This is why you can use the CopyOf because you refer to it by an Template's InstanceName.

Still in progress...


Last edited by ChJees on Wed Aug 01, 2007 1:57 am, edited 3 times in total.



Tue Jul 31, 2007 3:04 pm
Profile WWW
User avatar

Joined: Wed Feb 14, 2007 9:34 pm
Posts: 883
Location: America
Reply with quote
Post Re: Dissecting the Cortex Command INI; WIP (Work in Progress)
Good Job, should prove useful


Tue Jul 31, 2007 3:10 pm
Profile
User avatar

Joined: Fri Apr 27, 2007 4:55 pm
Posts: 1178
Location: America!
Reply with quote
Post Re: Dissecting the Cortex Command INI; WIP (Work in Progress)
Good. It's nicely readable. Add to FAQs.


Tue Jul 31, 2007 8:52 pm
Profile
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Re: Dissecting the Cortex Command INI; WIP (Work in Progress)
Is this good enough for a sticky or being linked :)?

(Going to wok more on this later)


Wed Aug 01, 2007 2:41 pm
Profile WWW
Forum Moderator
User avatar

Joined: Fri Feb 02, 2007 3:53 pm
Posts: 1896
Location: in my little gay bunker
Reply with quote
Post Re: Dissecting the Cortex Command INI; WIP (Work in Progress)
how did you get the dual wielding effect in B15?


Wed Aug 01, 2007 4:08 pm
Profile
User avatar

Joined: Thu Jul 19, 2007 11:31 am
Posts: 249
Location: Sweden, Hallstavik
Reply with quote
Post Re: Dissecting the Cortex Command INI; WIP (Work in Progress)
Meh, nevermind. I do not know what Data did to fux up dualwielding.

I will maybe change that topic to something different.


Wed Aug 01, 2007 4:58 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.073s | 15 Queries | GZIP : Off ]