Modding 107

From Data Realms Wiki

(Difference between revisions)
Jump to: navigation, search
(wsRgdzxVTUNjlnQ)
(Couldn't undo changes, copied the latest sense-making version.)
 
Line 1: Line 1:
-
ktNicm , [url=http://yujlgjlnbpkd.com/]yujlgjlnbpkd[/url], [link=http://aufpdlilkhyt.com/]aufpdlilkhyt[/link], http://sycrgswwgtdq.com/
+
{{TableModArticles}}
 +
 
 +
This "course" exists to introduce you to creating custom objects.  The scope of this article will include creating a weapon, designing its magazine, and making the rounds and tracers contained within the mag.  It is hoped that you have either read or have an understanding of [[Modding 101]], which consists of basic object oriented topics such as vocabulary and structuring.
 +
 
 +
{| align="right"
 +
| __TOC__
 +
|}
 +
 
 +
==Creating Objects from Classes==
 +
Weapons and devices are the easiest objects to create in Cortex Command.  These weapons are devices are called [[HDFirearm]]s, named as such for the class that creates them ('''H'''eld '''D'''evice, '''Firearm''').
 +
 
 +
For this part of the tutorial, please review the page on [[HDFirearm]]s.  This page provides a completed template of an HDFirearm object used in the campaign content.  Create a new folder called ''Mod.rte'', then copy and paste the source code into a new file, and title it ''SMG.ini'' Save the new .ini file in your created .rte module.
 +
 
 +
You now have a fully functional weapon in your mod.  Unfortunately, the interpreter has no idea how to load this file.  To do so, you must create an Index.ini file.  This file will contain the information the interpreter requires to load your source.  Within the Mod.rte folder, create an ''index.ini'' file and save it.  Once you have saved it, copy and paste the following code:
 +
<pre>
 +
DataModule
 +
ModuleName = My new mod
 +
IncludeFile = Mod.rte/SMG.ini
 +
</pre>
 +
 
 +
Ensure the spelling, capitalization, and tabbing are all correct.  If you did not name your module ''Mod.rte'' and the weapon ''SMG.ini'', take the time to change the names now.  Once you have saved these files, attempt to load the game with your new mod.  If you experience a crash, begin with the three most common debugging issues:
 +
# '''Could not find XXXX''': Ensure proper capitalization and spelling was used.
 +
# '''Unknown property''': Ensure you have used proper tabbing
 +
# '''Could not find DataModule''': Ensure the index.ini file is filled properly.
 +
 
 +
For now, you should be familiar with how Cortex Command's interpreter loads files, how those files should be formatted, and how they should be organized.  Next, we will cover changing object properties, such as mass, rate of fire, image files, or projectiles.
 +
 
 +
==Defining HDFirearm Components==
 +
This section will cover how to create the [[round|ammunition]] and [[magazine]]s for HDFirearms.  A critical part of the weapon you are creating is the bullets they fire and the objects that contain ammunition.  The rounds will dictate what type of damage, how much damage, and other physical properties of the weapon's performance.  The magazine will dictate the quantity of rounds to be used, the RoundToTracerRatio (RTTRatio), and the image file for your sprite.
 +
 
 +
===[[Round]]s and [[Tracer]]s===
 +
First, you need to reopen the SMG.ini file you created--if it is not still open.  Secondly, visit the articles on rounds and tracers.  There is a functional copy of the source code available for both.  Copy those files, and paste them '''above''' the code you saved previously.  This is critical because the rounds used by your SMG must be instantiated (or created) before the device can use them.
 +
 
 +
You must copy and paste both of these files because weapons have two types of ammunition: rounds, and tracers. If you have any knowledge of firearms, these are self-explanatory.  For the uninitiated, the round is the actual damaging ammunition.  Alternatively, a tracer is a round who's only function is to illuminate the path bullets take so as to aid manual aimin.
 +
 
 +
Now that you are creating custom objects from existing classes, you need to be sure to create unique [[PresetName]]s for your objects.  If your mod's PresetNames coincide with another modules, there will be compatibility issues.  ''Be as specific as possible when naming your objects.''  '''Gun Round''' is generally not acceptable.  '''BFG-2009 Tracer Round''' is much better.  That having been said, give the rounds and tracers you added to the SMG.ini file unique PresetNames.
 +
 
 +
Revisit the articles on rounds and tracers if you want more in-depth information on specific properties and attributes.
 +
 
 +
===[[Magazine]]s===
 +
As stated earlier, a magazine is what contains our ammunition and tracers.  Visit the article on magazines to access the source file for a device magazine.  Copy and paste that source information '''below'' the rounds, but '''above''' the weapons.  Just like the weapon, the rounds must be instantiated before the magazine can contain them.  On the flip side, the magazine must be created before the weapon can use it.  Hopefully this is starting to make sense.
 +
 
 +
Now, navigate through the magazine source code and locate references to rounds and tracers.  Ensure that the object references point to the rounds and tracers you have created.  Then, give your magazine a unique PresetName as well.  Once you have set these properties, you will need to go down to your existing fire arm and set the Magazine property to the PresetName of the magazine you created.
 +
 
 +
Once all of the PresetNames have been created, and their references set properly, feel free to play around with the properties of each of them.  Play with the RateOfFire variables, or find out how the RoundCount property works.  Most of these properties are self-explanatory, but more in-depth explanations of some of the less-than-obvious attributes.
 +
 
 +
Save your world, and try to load up the mod in the game.  If you have errors, make sure you have done the following:
 +
# Followed proper capitalization rules
 +
# Followed proper tabbing rules
 +
# Used unique PresetNames
 +
# Linked PresetNames to references
 +
: The device should reference the right magazine
 +
: The magazine should reference the right round and tracer.
 +
 
 +
==Round Particles==
 +
Previously, we defined the rounds, tracers, and magazines a weapon uses when firing.  For the purposes of the previous section, we used a default [[MOPixel]] for the fired projectile.  Thankfully, the game allows us to use either MOPixels, [[MOSParticle]]s, and [[MOSRotating]]s.  These are all objects that can be gibbed or fired from a weapon.  By default, weapons fire Pixels, which are essentially single bullets.  But for the creative minds, you can use Particles and Rotatings to try something different.
 +
Alrighty, time for installment #3 of this small series. Today we'll be looking at defining ''the stuff that shoots out of guns'' (and all other things too). MOPixels, MOSParticles, and MOSRotatings (Attachments and AEmitters we will get to in a later tutorial).
 +
 
 +
Quickly reviewing the article on [[MOPixel]]s shows that these are very simple items.  Most of the properties are fairly self-explanatory and their attributes can be derived easily.
 +
 
 +
For the sake of simplicity, we will examine some of the more complex properties:
 +
* '''Lifetime''': Fair simple.  This is the time measured in miliseconds the object fired will last.  When this timer expires, the object is <s>destroyed</s> deleted.  It will not gib, will not explode.  It just ceases to exist.
 +
* '''Sharpness''': This is the ability of an object to damage materials.  Generally speaking, the higher the sharpness, the ease with which a fired object can penetrate. <s> Although, a round with a Sharpness of 0 will not penetrate anything (regardless of mass or velocity).  On the flip-side, a round with a high sharpness can penetrate a lot regardless of mass or velocity. </s> A MOPixel with Sharpness = 0 and Mass = 5000 can still generate enough force to pierce materials, depending on StructuralIntegrity (check materials for extra information). Visit this site for a semi-accurate but very useful guide on sharpness: http://forums.datarealms.com/viewtopic.php?f=1&t=14662
 +
 
 +
Remember that a round can be made up of either a MOPixel, MOSRotating, or a MOSParticle.  View the related articles to view more information on the pros and cons of each object, and potential uses for each.  The important key is that a Round can be made up of any of these particles, as long as they are properly declared before the round.
 +
 
 +
==Recap==
 +
Remember that the interpreter cannot use objects that have not yet been defined.  If you create a weapon calling a certain magazine, that magazine must be defined before the weapon.  If you create a magazine, it must have its rounds and tracers created first.
 +
 
 +
The convention for calling weapon components is as follows:
 +
* Pixel, Particle, or Rotating objects
 +
* Rounds and Tracers
 +
* Magazine
 +
* Weapon
 +
 
 +
They should be created in this order, or should be called in the Index.ini in that order.
 +
 
 +
[[Category:Modding]]
 +
[[Category:Tutorials]]

Latest revision as of 21:21, 16 July 2011

Modding 101 The Basics
Start here.


Actors Actors
Anything that can be controlled.


Effects Effects
Explosions, glows, and emission.


Modding 107 Mod Creation
Learn how the pros create objects.


Devices Devices
Weapons and tools.


Scenes Scenes
How to create scenes.


Module Structure Module Structure
Setting up a module index.


Lua Lua
Scripting.


:Category:Modding Modding
All the modding pages.


This "course" exists to introduce you to creating custom objects. The scope of this article will include creating a weapon, designing its magazine, and making the rounds and tracers contained within the mag. It is hoped that you have either read or have an understanding of Modding 101, which consists of basic object oriented topics such as vocabulary and structuring.

Contents

Creating Objects from Classes

Weapons and devices are the easiest objects to create in Cortex Command. These weapons are devices are called HDFirearms, named as such for the class that creates them (Held Device, Firearm).

For this part of the tutorial, please review the page on HDFirearms. This page provides a completed template of an HDFirearm object used in the campaign content. Create a new folder called Mod.rte, then copy and paste the source code into a new file, and title it SMG.ini Save the new .ini file in your created .rte module.

You now have a fully functional weapon in your mod. Unfortunately, the interpreter has no idea how to load this file. To do so, you must create an Index.ini file. This file will contain the information the interpreter requires to load your source. Within the Mod.rte folder, create an index.ini file and save it. Once you have saved it, copy and paste the following code:

DataModule
	ModuleName = My new mod
	IncludeFile = Mod.rte/SMG.ini

Ensure the spelling, capitalization, and tabbing are all correct. If you did not name your module Mod.rte and the weapon SMG.ini, take the time to change the names now. Once you have saved these files, attempt to load the game with your new mod. If you experience a crash, begin with the three most common debugging issues:

  1. Could not find XXXX: Ensure proper capitalization and spelling was used.
  2. Unknown property: Ensure you have used proper tabbing
  3. Could not find DataModule: Ensure the index.ini file is filled properly.

For now, you should be familiar with how Cortex Command's interpreter loads files, how those files should be formatted, and how they should be organized. Next, we will cover changing object properties, such as mass, rate of fire, image files, or projectiles.

Defining HDFirearm Components

This section will cover how to create the ammunition and magazines for HDFirearms. A critical part of the weapon you are creating is the bullets they fire and the objects that contain ammunition. The rounds will dictate what type of damage, how much damage, and other physical properties of the weapon's performance. The magazine will dictate the quantity of rounds to be used, the RoundToTracerRatio (RTTRatio), and the image file for your sprite.

Rounds and Tracers

First, you need to reopen the SMG.ini file you created--if it is not still open. Secondly, visit the articles on rounds and tracers. There is a functional copy of the source code available for both. Copy those files, and paste them above the code you saved previously. This is critical because the rounds used by your SMG must be instantiated (or created) before the device can use them.

You must copy and paste both of these files because weapons have two types of ammunition: rounds, and tracers. If you have any knowledge of firearms, these are self-explanatory. For the uninitiated, the round is the actual damaging ammunition. Alternatively, a tracer is a round who's only function is to illuminate the path bullets take so as to aid manual aimin.

Now that you are creating custom objects from existing classes, you need to be sure to create unique PresetNames for your objects. If your mod's PresetNames coincide with another modules, there will be compatibility issues. Be as specific as possible when naming your objects. Gun Round is generally not acceptable. BFG-2009 Tracer Round is much better. That having been said, give the rounds and tracers you added to the SMG.ini file unique PresetNames.

Revisit the articles on rounds and tracers if you want more in-depth information on specific properties and attributes.

Magazines

As stated earlier, a magazine is what contains our ammunition and tracers. Visit the article on magazines to access the source file for a device magazine. Copy and paste that source information below the rounds, but above' the weapons. Just like the weapon, the rounds must be instantiated before the magazine can contain them. On the flip side, the magazine must be created before the weapon can use it. Hopefully this is starting to make sense.

Now, navigate through the magazine source code and locate references to rounds and tracers. Ensure that the object references point to the rounds and tracers you have created. Then, give your magazine a unique PresetName as well. Once you have set these properties, you will need to go down to your existing fire arm and set the Magazine property to the PresetName of the magazine you created.

Once all of the PresetNames have been created, and their references set properly, feel free to play around with the properties of each of them. Play with the RateOfFire variables, or find out how the RoundCount property works. Most of these properties are self-explanatory, but more in-depth explanations of some of the less-than-obvious attributes.

Save your world, and try to load up the mod in the game. If you have errors, make sure you have done the following:

  1. Followed proper capitalization rules
  2. Followed proper tabbing rules
  3. Used unique PresetNames
  4. Linked PresetNames to references
The device should reference the right magazine
The magazine should reference the right round and tracer.

Round Particles

Previously, we defined the rounds, tracers, and magazines a weapon uses when firing. For the purposes of the previous section, we used a default MOPixel for the fired projectile. Thankfully, the game allows us to use either MOPixels, MOSParticles, and MOSRotatings. These are all objects that can be gibbed or fired from a weapon. By default, weapons fire Pixels, which are essentially single bullets. But for the creative minds, you can use Particles and Rotatings to try something different. Alrighty, time for installment #3 of this small series. Today we'll be looking at defining the stuff that shoots out of guns (and all other things too). MOPixels, MOSParticles, and MOSRotatings (Attachments and AEmitters we will get to in a later tutorial).

Quickly reviewing the article on MOPixels shows that these are very simple items. Most of the properties are fairly self-explanatory and their attributes can be derived easily.

For the sake of simplicity, we will examine some of the more complex properties:

  • Lifetime: Fair simple. This is the time measured in miliseconds the object fired will last. When this timer expires, the object is destroyed deleted. It will not gib, will not explode. It just ceases to exist.
  • Sharpness: This is the ability of an object to damage materials. Generally speaking, the higher the sharpness, the ease with which a fired object can penetrate. Although, a round with a Sharpness of 0 will not penetrate anything (regardless of mass or velocity). On the flip-side, a round with a high sharpness can penetrate a lot regardless of mass or velocity. A MOPixel with Sharpness = 0 and Mass = 5000 can still generate enough force to pierce materials, depending on StructuralIntegrity (check materials for extra information). Visit this site for a semi-accurate but very useful guide on sharpness: http://forums.datarealms.com/viewtopic.php?f=1&t=14662

Remember that a round can be made up of either a MOPixel, MOSRotating, or a MOSParticle. View the related articles to view more information on the pros and cons of each object, and potential uses for each. The important key is that a Round can be made up of any of these particles, as long as they are properly declared before the round.

Recap

Remember that the interpreter cannot use objects that have not yet been defined. If you create a weapon calling a certain magazine, that magazine must be defined before the weapon. If you create a magazine, it must have its rounds and tracers created first.

The convention for calling weapon components is as follows:

  • Pixel, Particle, or Rotating objects
  • Rounds and Tracers
  • Magazine
  • Weapon

They should be created in this order, or should be called in the Index.ini in that order.

Personal tools