Supreme Commander Wiki
Register
Advertisement

Creating units is generally a long process, so you should have at least an hour blocked off if you want to complete it in one sitting. This tutorial will cover creating a new unit called the MA20 Blaster, a T2 Heavy Assault Tank. Shall we begin?

Required Tools[]

There are only a couple of tools required to make new units (models and such nonwithstanding):

  • A utility to open SCD files (SCD files are zip files with a different extension, so any utility to handle zip files will work)
    • 7zip [1]
    • Winrar (a trial is available)
  • Notepad (or text editor of your choice) (to open the .lua and .bp fles)

Preparation[]

One of the best (and most straightforward) ways to successfully create and add new units to Supreme Commander is by creating a modification (mod). Mods allow the developer to create new unit files and include them into the game easily rather than modifing existing core game files. Mods provide the gamer with greater flexibility as they can be enabled/disabled before any match. Furthermore, mods allow many different players to quickly include and share changes to the game (such as new units) very quickly.

To begin, lets start by creating a modification folder on your local machine. For example, create a directory on your desktop and call it something like "SupCom Mods". All the files and directories we will need to work with to create a new unit will be placed inside this parent directory (for the remainder of the tutorial I will refer to the "SupCom Mods" directory as the parent directory or /).

What we are essentially going to do as this tutorial progresses is create a copy of an existing unit, modify it, and then create a new mod which this unit is a part of. The mod directory we will create will contain a smiliar directory structure (within gamedata) as the full supreme commander game, but will only include our unit. This allows the player to include this additional unit to the game without effecting core game files which we don't ever want to do.

Next, navigate to your /Supreme Commander Install Directory/gamedata directory

Once in the gamedata directory, open the following files using Winrar:

  • units.scd
  • lua.scd
  • textures.scd
  • mods.scd

Extract the above files into the parent directory. Once complete you should have a directory structure like the following:

  • /SupCom Mods/units
  • /SupCom Mods/lua
  • /SupCom Mods/textures
  • /SupCom Mods/mods

These directories contain the files we need to create a new unit.

Next, navigate to /mods and create a new directory within it. Seeing as we plan to make a new tank we could call it MA20Blaster. For the remainder of this tutorial I will refer to the directory just created (MA20Blaster) as the (modding directory or \).

Next, navigate to /units and find the UEL0201 folder. Copy it then paste it into the modding directory under \mods\mod_directory_name\units (note: you will need to create the \units directory).

Please note: after this article was updated it was discovered that the reference to unit UEL0201 (Striker) is actually incorrect and should be UEL0202 (Paladin). However until such time that this article is updated either use UEL0201 as your base unit as the tutorials are based on this. However all the principles within should apply should you feel adventurous to try using UEL0202.[2]

Next, open the /mods/ResourceRich directory and copy the mod_info.lua file to \mods\mod_directory_name\. This file (with modification) will inform the game about our mod.

Next, open /textures/ui/common/icons/units and copy the file (potentiall more than one) starting with UEL0201 to \mods\mod_directory_name\textures\ui\common\icons\units (Note: as with the previous step you will need to create directories below mod_directory_name yourself). These files are the build and select icons and we need them if we want to make our unit look like it came with the game.

Next, open '/lua/ui/help/unitdescription.lua to \mods\mod_directory_name\lua\ui\help' (Note: as with the previous step you will need to create directories below mod_directory_name yourself). This file contains the descriptions you see when you hover over build icons. By now you should have in your modding directory three folders: \mods, \lua, and \textures. Continuing on...

File Modification[]

Open up \mods\your_mod_dir\mod_info.lua with notepad. You should see several lines, and we will only need to edit a few. Let's start with the first line: "name = ". Fairly self explanatory, the line that indicates the mod name to the game; change the words in quotes to "MA20 Blaster". Now you have a mod named MA20 blaster! Good work! But there is still a lot of work to do so let's continue.

The next line you need to change is the "description = " line. put in here a brief description of the MA20(hint: include that it is a UEF unit, T2 unit, a Heavy assault tank, and the name).

The only other line you need to change is the uid line. This identifies the mod as a unique mod to the game. You are only required to change one character but correctly change a few of them to ensure no registry conflicts using following these rules:

Numbers where there are numbers, capital letters where there are capital letters, and don't change the dashes.
It is extremly important that you follow these rules, if not followed correctly you will corrupt the uid and the mod will not work.

Once complete, save and close the mod_info.lua file and open the \mods\mod_dir_name\units directory. Rename the UEL0201 dir to UEL0204. Now go into that dir; see that every file starts with UEL0201? rename them so all of them start with UEL0204. The last two steps make it so the (soon to be modified) unit is not confused with the MA12 Striker.

Next, go to \lua\ui\help and open unitdescription.lua. Navigate to the end (before the }) and add this data:

['uel0204'] = "The Blaster is a state-of-the-art attack vehicle, equipped with the latest armor and the most powerful drive motors. It's also equipped with a fast firing Gauss cannon that does more damage than both the MA12 and the Pillar. Based off of the MA12, this tank has less armor than the Pillar but is much faster.",
-or
you could use this description: ['uel0204'] = "The Martin Armories type-20 Blastfire Heavy Operations Battle tank, or simply just the MA20 Blaster; armed with an experimental rapid fire Coilgun Gun system, this lightly armored fast attack battle tank of a similar design to the Paladin, is a must have, enforcer, that will surely turn the tide of battle.",
(If you don't like these description options, feel free to change text within the quotes, but ensure you include the ',' at the end.)

Save and close the file and steer yourself over to /textures/ui/common/icons/units and locate the UEL0201_icon.dds file and copy it to \textures\ui\common\icons\units and rename the file to start with UEL0204.

Now go to \mods\mod_dir_name\units\UEL0204 and open UEL0204_unit.bp. Wow this file is big isn't it? Scroll down until you can see the "Defense" portion of the file. Edit the numbers after the "Health and "MaxHealth" lines to say 600 on both; now it should look like this:

   Defense = {
       ArmorType = 'Normal',
       Health = 600,
       MaxHealth = 600,
       RegenRate = 0,
   },

Scroll up a bit; you should see a heading called "Categories". we are going to remove and add some of those next. Remove these:

       'TECH1',
       'BUILTBYTIER1FACTORY',

That will make it so that it isn't a tech 1 unit and it can't be built by a T1 factory. Now add this line(keeping the same amount of spaces before it as the other lines near it):

       'TECH2',

This will tell the game that it should put it with the rest of the T2 units. Scroll up a bit. you should see a heading entitled "Buffs". Find the line matching the following line that is closest to the heading:

           Value = 75,

and edit it to say this:

           Value = 150,

Change the numbers to say the same thing on the next 3 ones. The last one is very interesting, it controls a regeneration bonus; change the number after the "Value = " to say 5. Now, at veteran levels 2 and 4, our unit will get an extra 150 health and at veteran level 5, will get some armor regeneration! continuing on, search (Ctrl + F) for "Economy". Edit these lines:

       BuildCostEnergy = 250,
       BuildCostMass = 50,
       BuildTime = 125,

To say this:

       BuildCostEnergy = 1000,
       BuildCostMass = 200,
       BuildTime = 300,

Now, each MA20 costs 1000 energy, 200 mass, and takes 3/4's of the time of a pillar to build. Scroll back up until you see a line called "Description". edit the line to say this:

   Description = 'Heavy Assault Tank',

Now scroll back(sorry) down to the "Intel" heading; edit the line contained to say this:

       VisionRadius = 30,

That will make it have a 30 square vision radius. Now find the UnitName (it is above the line I just had you edit) line and put this in place of it:

       UnitName = 'MA20 Blaster',

Now our new unit has the correct name. Now edit the HelpText line to say this:

       HelpText = 'Heavy Assault Tank',

That fixes the interface help text. Find the MaxAcceleration line and set it's value to 1.5. Now our unit accelerates almost three times as fast as it used to. The next lines you should change are maxBrake and MaxSpeed. Set these to 7.5. Now our unit is much faster, but what about turning? change the MaxSteerForce line to 50 and the Turnrate to 250. Now our unit moves and turns much faster like we said in the description! We are mostly done but we have a couple more things to do; change the StrategicIconName to 'icon_land2_directfire'. This will make it use the strategic icon the Pillar uses. Now we edit the data within the Veteran heading; I used these values:

       Level1 = 10,
       Level2 = 25,
       Level3 = 50,
       Level4 = 100,
       Level5 = 200,

These control after how many kills does the unit get various buffs (upgrades).

Now comes the interesting part: The Weapons. Shall we begin? We will start with the buffs; since this thing needs more of a punch, we will adjust it so it gets +10 damage at each level.

Now set the base damage to 45; doesnt seem as much as a Pillar's DPS, doesn't it (it's 56)? We will fix that in a minute but increase the DamageRadius to 3 and the radius to 25. That makes it do the damage over a large area and it can fire farther now.

Now Set The RateOfFire value up to 2; now our unit's DPS is a whopping 90! Wow!

Now set the TrackingRadius value to 26; that way it will start tracking units before it can fire at them.

Set the TurretYawSpeed to 180. now it can rotate the turret around much faster!

Save and close and open the UEL0204_Script.lua file and change this line:

UEL0201 = Class(TLandUnit) { Weapons = { MainGun = Class(TDFGaussCannonWeapon) {} }, }

TypeClass = UEL0201

to this line:

UEL0204 = Class(TLandUnit) { Weapons = { MainGun = Class(TDFGaussCannonWeapon) {} }, }

TypeClass = UEL0204

Icons in build display To keep from getting the blue placeholder icon for your new unit at the factory, you need to tell the game where to get the icons from. File: \mods\<my mod name>\lua\ui\game\gamecommon.lua

Contents:

do
   local MyUnitIdTable = {
      'UEL0101',     #new unit name
      'UEL0105',     #new unit name
   }
   local oldFileNameFn = GetUnitIconFileNames
   
   local function IsMyUnit(blueprint)
      for i, v in MyUnitIdTable do
         if v == blueprint.Display.IconName then
            return true
         end
      end
      return false
   end
   
   function GetUnitIconFileNames(blueprint)
      LOG(blueprint.Display.IconName)
      if IsMyUnit(blueprint) then
#this assumes you use the same path and naming conventions as the default game
          local iconName = "/mods/<my_mod_name>/textures/ui/common/icons/units/" .. blueprint.Display.IconName .. "_icon.dds"
          local upIconName = "/mods/<my_mod_name>/textures/ui/common/icons/units/" .. blueprint.Display.IconName .. "_build_btn_up.dds"
          local downIconName = "/mods/<my_mod_name>/textures/ui/common/icons/units/" .. blueprint.Display.IconName .. "_build_btn_down.dds"
          local overIconName = "/mods/<my_mod_name>/textures/ui/common/icons/units/" .. blueprint.Display.IconName .. "_build_btn_over.dds"
         
          if DiskGetFileInfo(iconName) == false then
            WARN('Blueprint icon for unit '.. blueprint.Display.IconName ..' could not be found, check your file path and icon names!')
              iconName = '/textures/ui/common/icons/units/default_icon.dds'
          end
         
          if DiskGetFileInfo(upIconName) == false then
              upIconName = iconName
          end

          if DiskGetFileInfo(downIconName) == false then
              downIconName = iconName
          end

          if DiskGetFileInfo(overIconName) == false then
              overIconName = iconName
          end
         
          return iconName, upIconName, downIconName, overIconName
      else
         return oldFileNameFn(blueprint)
      end
   end
end

Save and close. That's all the editing we have to do, so on to the Final Steps...

Final Steps[]

Copy mods.scd into the mod dir; open it and go into the mods folder and delete everything in there. Now copy everything in your mod dir into the scd file(not the .scd file though). Before you compress the files, set the compression method to "Store". That way it will be identical to the other .scd files. Now rename it whatever you like. Copy it into the game's /gamedata dir. Fire up SupCom, enable the mod, and have fun!


Advertisement