Help a newbie modder

Everything about mods can be found here.

Moderator: Morax

Help a newbie modder

Postby CrazyDutchReaper » 21 Jul 2015, 19:20

G'day everyone!

I have recently started modding supcom fa and have come accross a bit of a road block and require help.
I am currently trying to implement different armor and damage types into the game to increase the depth of the game. For example: a tank-like unit would be better suited to take out another tank-like unit.
Unfortunately, the armor system doesn't work at the moment.

All that i have made so far is inspired by this tutorial http://supcom.wikia.com/wiki/Mod_Help because i haven't been able to find anything that resembles this type of modification.
armordefinition.lua code (slimmed down):
Code: Select all
armordefinition = {
#UEF Land
{   # Damage Type Name UEF Machinegun
      'D_UEF_Machinegun',
      
      # Armor Definition
      'Normal 1.0',
},
{   # New Armor Type Name UEF MediumTank
      'A_UEF_MediumTank',
      
      # Armor Definition
      'D_UEF_Machinegun 0.01',
},
}

Following the tutorial, this should mean that any unit with D_UEF_Machinegun as a damage type would do 0.01 times the damage against a unit with A_UEF_MediumTank armor type.
I am trying to implement it through merging
mod_units.bp code:
Code: Select all
#uef,
   UnitBlueprint {
   Merge = true,
   BlueprintId='uel0106', # mech marine attack change
   Weapon =
      {
      DamageType = 'D_UEF_Machinegun',
      },
   }
   
#uef,
   UnitBlueprint {
   Merge = true,
   BlueprintId='uel0201', # ma12 striker armor change
   Defense =
      {
      ArmorType = 'A_UEF_MediumTank',
      Health = 900,
                MaxHealth = 900,
      },
   }

Using this to merge it with the existing mech marine and ma12 striker nothing happened, so i added heatlh to it to test whether it actually works at all and the ma12 striker actually had 300 -> 900 hp which means that the merging itself works.
Unfortunately, the armor/damage system still does nothing and although i have a hunch its to do with the armordefinition.lua file, i still have no idea why it doesn't work nor how to fix it.

So i am hoping that the more experienced modders/programmers could help me out on this one. Is it a problem with the code? Or does the nature of the game itself make it impossible to do?

Thanks in advance!
CrazyDutchReaper
 
Posts: 5
Joined: 21 Jul 2015, 18:55
Has liked: 0 time
Been liked: 0 time
FAF User Name: datim

Re: Help a newbie modder

Postby The Mak » 21 Jul 2015, 23:16

Could you zip your entire mod and post it somewhere. You may have an error somewhere else that is causing the mod to not work properly.
User avatar
The Mak
Contributor
 
Posts: 342
Joined: 03 Mar 2012, 21:09
Location: New York, NY, USA
Has liked: 5 times
Been liked: 39 times
FAF User Name: The_Mak

Re: Help a newbie modder

Postby CrazyDutchReaper » 21 Jul 2015, 23:23

Never used this file host before but i hope it works http://www.filedropper.com/microcommander

You'll also see my bad attempt at trying to change the tech level of a unit, after more research i found out that instead of merging i am going to have to use destructive hooking to make it work, so i will change that later. (i am a real newbie at supcom modding :? )
CrazyDutchReaper
 
Posts: 5
Joined: 21 Jul 2015, 18:55
Has liked: 0 time
Been liked: 0 time
FAF User Name: datim

Re: Help a newbie modder

Postby The Mak » 22 Jul 2015, 00:44

Ok found the mistakes.

Place your lua folder into a folder labeled hook.

When doing merge blueprints with weapons, keep in mind that each weapon of a unit is an array, and they are stored in a master array called Weapon. So if a unit has three weapons, there are three sub-arrays (one for each weapon) all under the Weapon master array. So when you modify a weapon, you need to specify which weapon array you want to edit. Now for your unit it is quite simple, 1 weapon, which means 1 sub-array to the Weapon master array. Let us say we have a unit with four weapons, and we want to only change the second weapon to have your DamageType.

It would look like this:
Code: Select all
Weapon = {
      {},
      {
         DamageType = 'D_UEF_Machinegun',
      },
      {},
      {},
},


Notice how we have empty arrays in the merge blueprint. This means I do not want to touch any aspect of those particular weapons.

If you want your DamageType to apply to all weapons of a unit, it would look like this.
Code: Select all
Weapon = {
      {
         DamageType = 'D_UEF_Machinegun',
      },
      {
         DamageType = 'D_UEF_Machinegun',
      },
      {
         DamageType = 'D_UEF_Machinegun',
      },
      {
         DamageType = 'D_UEF_Machinegun',
      },
},



I highly recommend you download the mod 'BlackOps Unleashed Balance Changes' and look through the files that start with mod_units. This is where I have learned most of my material when it comes to blueprint merging.

Here is your mod with the necessary changes.
User avatar
The Mak
Contributor
 
Posts: 342
Joined: 03 Mar 2012, 21:09
Location: New York, NY, USA
Has liked: 5 times
Been liked: 39 times
FAF User Name: The_Mak

Re: Help a newbie modder

Postby CrazyDutchReaper » 22 Jul 2015, 13:39

First of all, thank you very very much, its annoying how something so small can stop your entire mod from working :/

But i have another question, a few attempts earlier i had done it like this, but i also had a lua file into the main folder, that didn't work however. So if you have a lua folder in your hook folder, you cannot have another lua folder in the main folder?

Also, with the mod_units_UEF.bp , i tried to change the tech level of a unit, however i noticed that i need to use destructive hooking to fix this. Does this mean that i need to have the modunits folder in the hook folder as well? Or, in this case, can i have 2 modunits folders with one of them in the hook (and different name ofcourse) and one of them in the main folder?

Thanks again and i will definietly look into 'BlackOps Unleashed Balance Changes'.
CrazyDutchReaper
 
Posts: 5
Joined: 21 Jul 2015, 18:55
Has liked: 0 time
Been liked: 0 time
FAF User Name: datim

Re: Help a newbie modder

Postby The Mak » 22 Jul 2015, 20:35

Your welcome, syntax is a bitch, no matter the programming language. Since we do not have and IDE the equivalent of Visual Studio, there is not much that can help us with these small mistakes.

Let us take your questions one at a time.

Q1
datim wrote:But i have another question, a few attempts earlier i had done it like this, but i also had a lua file into the main folder, that didn't work however. So if you have a lua folder in your hook folder, you cannot have another lua folder in the main folder?


For changes to existing game files (such as armordefinition.lua), you should place them in a hook folder and then in the same directory structure you see in the game files.

If you create your own files that fall under a lua folder, then you create a lua folder under your mod directory. Again, and I cannot stress this enough, see examples done in other mods.


Q2
datim wrote:Also, with the mod_units_UEF.bp , i tried to change the tech level of a unit, however i noticed that i need to use destructive hooking to fix this. Does this mean that i need to have the modunits folder in the hook folder as well? Or, in this case, can i have 2 modunits folders with one of them in the hook (and different name ofcourse) and one of them in the main folder?


This is correct. In a blueprint file, such as in Categories, there are all these text entries inside the array. Example:
Code: Select all
    Categories = {
        'PRODUCTSC1',
        'SELECTABLE',
        'BUILTBYTIER1FACTORY',
        'BUILTBYTIER2FACTORY',
        'BUILTBYTIER3FACTORY',
        'CYBRAN',
        'MOBILE',
        'NAVAL',
        'TECH1',
        'DIRECTFIRE',
        'ANTIAIR',
        'ANTIMISSILE',
        'SUBMERSIBLE',
        'VISIBLETORECON',
        'RECLAIMABLE',
        'T1SUBMARINE',
        'OVERLAYSONAR',
        'OVERLAYANTINAVY',
        'OVERLAYDIRECTFIRE',
    },


So how do we go about removing 'TECH1' and then adding 'TECH2'? The adding in of 'TECH2' can be simply done with Merge blueprint. The removing of 'TECH1', well...

Option 1, Destructive hooking or "How not to play nice with other mods and have your changes be very hard to find"

Inside your hook folder, create a units folder.
Inside the units folder, you create a folder labeled with the unit id.
Inside the new folder labeled with the unit id, you copy over the original 'unit id'_unit.bp
Open up that 'unit id'_unit.bp file and make any changes you want.

If you have any other mods running and they change the same unit, then it will come down to the UID of the mod as to which will actually run. Sad time for me who usually plays with 70 or so mods at once. :cry:


Option 2, ModBlueprints or Non-Destructive Hooking or "How not to play nice with other mods and have your changes be very easy to find"

Inside your hook folder, create a lua folder.
Inside the lua folder, create a system folder.
Inside the system folder, create a file called Blueprints.lua

Now comes the part where you need to look at examples, *cough* BlackOps Unleashed Balance Changes *cough*

You begin in the Blueprints.lua file with this:

Code: Select all
do
   local oldModBlueprints = ModBlueprints

   function ModBlueprints(all_bps)
      oldModBlueprints(all_bps)


From here you can specify a single unit:
Code: Select all
      if all_bps.Unit.xsl0309 then


Multiple units, the smart way (hint, try to avoid repeating if all_bps.Unit.blaa blaa)
Code: Select all
      local units_SCU = {
         'ual0301',
         'uel0301',
         'url0301',
         'xsl0301',
      }
      for scuid, buildcat in units_SCU do
         if all_bps.Unit[scuid] then


Multiple units, the smart way, with faction differences
Code: Select all
      local units_SCU = {
         ual0301 = 'BUILTBYTIER4COMMANDER AEON',
         uel0301 = 'BUILTBYTIER4COMMANDER UEF',
         url0301 = 'BUILTBYTIER4COMMANDER CYBRAN',
         xsl0301 = 'BUILTBYTIER4COMMANDER SERAPHIM',
      }
      for scuid, buildcat in units_SCU do
         if all_bps.Unit[scuid] then


or units that have things in common:

Code: Select all
for unitid, unitbp in all_bps.Unit do
         for k, cat in unitbp.Categories do
            if cat == 'HOVER' then



Now for your case, Categories is a table of values. So we have to first remove an entry:
Single unit
Code: Select all
table.removeByValue(all_bps.Unit.uel0106.Categories, 'TECH1')

Multiple units, smart way
Code: Select all
table.removeByValue(all_bps.Unit[unitid].Categories, 'TECH1')

Units that have things in common
Code: Select all
table.removeByValue(all_bps.unitbp.Categories, 'TECH1')


Now we add an entry:
Single unit
Code: Select all
table.insert(all_bps.Unit.uel0106.Categories, 'TECH2')

Multiple units, smart way
Code: Select all
table.insert(all_bps.Unit[unitid].Categories, 'TECH2')

Units that have things in common
Code: Select all
table.insert(all_bps.unitbp.Categories, 'TECH2')



Make sure to add all the end's you need to close each function, including the first do function at the top of Blueprints.lua


datim wrote:Thanks again and i will definietly look into 'BlackOps Unleashed Balance Changes'.


For scripting help, which is another order above with modding SupCom, I recommend going through the mod '4DC FAF Release (v0.5)', the units folder (new custom units, not under the hook folder) and look at each units' _Script.lua file
User avatar
The Mak
Contributor
 
Posts: 342
Joined: 03 Mar 2012, 21:09
Location: New York, NY, USA
Has liked: 5 times
Been liked: 39 times
FAF User Name: The_Mak

Re: Help a newbie modder

Postby quark036 » 22 Jul 2015, 21:30

Probably also want to remove builtbyt1factory
quark036
Avatar-of-War
 
Posts: 165
Joined: 11 Mar 2015, 03:17
Has liked: 10 times
Been liked: 26 times
FAF User Name: Quark036

Re: Help a newbie modder

Postby CrazyDutchReaper » 24 Jul 2015, 10:50

Ok, so i tried your Blueprints.lua approach as it seems to be a lot better than the destructive hooking, but something didn't work out... It somehow removed all units from the game... and so when you start a game, nothing happens, because even the acu doesn't spawn :s

Code: Select all
do
   local oldModBlueprints = ModBlueprints

   function ModBlueprints(all_bps)
      oldModBlueprints(all_bps)
end

# UEF

#hovertank
table.remove(all_bps.Unit.uel0203.Categories, 'TECH2'),
table.insert(all_bps.Unit.uel0203.Categories, 'TECH1'),
table.insert(all_bps.Unit.uel0203.Categories, 'BUILTBYTIER1FACTORY'),

#medium tank
table.remove(all_bps.Unit.uel0201.Categories, 'TECH1'),
table.remove(all_bps.Unit.uel0203.Categories, 'BUILTBYTIER1FACTORY'),
table.insert(all_bps.Unit.uel0201.Categories, 'TECH2'),

#heavy tank
table.remove(all_bps.Unit.uel0203.Categories, 'TECH2'),
table.remove(all_bps.Unit.uel0203.Categories, 'BUILTBYTIER2FACTORY'),
table.insert(all_bps.Unit.uel0203.Categories, 'TECH3'),


i tried the table.removeByValue , but it doesn't seem to do anything either and apparantly its not an excisting command?
I don't want to look like i am having you do all the work for me or anything, but i simply have no idea why this is happening. . .
CrazyDutchReaper
 
Posts: 5
Joined: 21 Jul 2015, 18:55
Has liked: 0 time
Been liked: 0 time
FAF User Name: datim

Re: Help a newbie modder

Postby The Mak » 24 Jul 2015, 16:29

I am sorry, but I do not think you are understanding how a function is suppose to be structured. Again, please look through BlackOps Unleashed Balance Changes and structure your Blueprints.lua the same way it is structured there.

The code in Blackops Unleashed Balance Changes works, so you have a working reference and example. You need to have your code structured the same way as theirs and add you changes where it is appropriate.

Also, when you try to run your mod and the game gets all messed up; that is a good thing. That means somewhere very early in your code is a mistake or you have made a simple mistake (like missing a comma, bracket, or an end), which makes finding it very easy.


Edit*
The function table.removeByValue() could have possibly been renamed with all the changes that were done in the recent patch. To be safe, run your mod through the standalone FA (just start FA without going through the FAF online client). I am still trying to get an answer as what needs to be done with mods to get them compatible with this new patch.
User avatar
The Mak
Contributor
 
Posts: 342
Joined: 03 Mar 2012, 21:09
Location: New York, NY, USA
Has liked: 5 times
Been liked: 39 times
FAF User Name: The_Mak

Re: Help a newbie modder

Postby CrazyDutchReaper » 24 Jul 2015, 21:40

You are right, i do not know how it is supposed to be structured and when i first tested it and found out it didn't work, i checked other mods (had to check a few before i came accross a mod with Blueprints.lua). And the only thing i was missing was the "end", and so i added it, but it still does not work so i am a bit at a loss.

EDIT: So i went on to experiment and tried everything i could think of and looked at a lot of mods, but it still doesn't work.
Code: Select all
do
local oldModBlueprints = ModBlueprints

function ModBlueprints(all_bps)
oldModBlueprints(all_bps)

#UEF

#hovertank
if all_bps.Unit.uel0203 then
   table.removeByValue(all_bps.Unit.uel0203.Categories, 'TECH2'),
   table.insert(all_bps.Unit.uel0203.Categories, 'TECH1'),
   table.insert(all_bps.Unit.uel0203.Categories, 'BUILTBYTIER1FACTORY'),
end

#medium tank
if all_bps.Unit.uel0201 then
   table.removeByValue(all_bps.Unit.uel0201.Categories, 'TECH1'),
   table.removeByValue(all_bps.Unit.uel0201.Categories, 'BUILTBYTIER1FACTORY'),
   table.insert(all_bps.Unit.uel0201.Categories, 'TECH2'),
end

#heavy tank
if all_bps.Unit.uel0202 then
   table.removeByValue(all_bps.Unit.uel0202.Categories, 'TECH2'),
   table.removeByValue(all_bps.Unit.uel0202.Categories, 'BUILTBYTIER2FACTORY'),
   table.insert(all_bps.Unit.uel0202.Categories, 'TECH3'),
end

if all_bps.Unit.uel0103 then
   table.insert(all_bps.Unit.uel0103.Categories, 'VEHICLE',),
end
   
end


I am really hoping someone can explain what i am doing wrong, because as far as i can see now, i am gonna have to do a lot of stupid things to get this working.
Last edited by CrazyDutchReaper on 26 Jul 2015, 12:04, edited 1 time in total.
CrazyDutchReaper
 
Posts: 5
Joined: 21 Jul 2015, 18:55
Has liked: 0 time
Been liked: 0 time
FAF User Name: datim

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest