Mod making

Everything about mods can be found here.

Moderator: Morax

Re: Mod making

Postby Uveso » 18 Oct 2016, 00:00

Code: Select all
LOG('processing >>>'..id..'<<< +LAND -STRUCTURE -EXPERIMENTAL : Changing MaxHealth from ('..(bp.Defense.MaxHealth)..') to "'..(bp.Defense.MaxHealth * 2.0)..'"')


This is a simple "print" into the debug log. It just show information about the unit and what you are changing on it.

I guess you have the debugwindow always open when you are programming/checking someting in Supreme commander ?

If not:
Start the game in windowed mode.
Select skirmish or LAN and launch into a game session.
If you can see your commander press [F9] to activate the debug window.
The debugwindow will be maybe under or behind your main-game-window.

There you can see any errors and many information about the game.


You can also force the debugwindow to show up while gamestart:

Please Make a desktop-shortcut from the file:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe
(Rightclick the file and select "Send to" -> Desktop Shortcut")

Open the shortcut and change the Command line (target):
from:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe
to:
C:\ProgramData\FAForever\bin\ForgedAlliance.exe /init init_faf.lua /EnableDiskWatch /log C:\game.log /showlog

commandline explanation:
"/init init_faf.lua" this will start the normal FAF version of the game. Change this to "/init init_fafbeta.lua" and you will start the beta version of FAF
"/EnableDiskWatch" with this you can change unit or game files and the game will immediately load and execute the new changes. You dont need to restart the game.
"/log C:\game.log" will force to write the game.log at c:\ root dir.
"/showlog" displays the Debug Window (Shows the same what you can find inside the game.log)


For your problem with death nuke weapons this will help:
It's looping over all weapons, and looking for "weapon.WeaponCategory == 'Death'"
If it has found a deatweapon it will check for nuke-ring-damage or set the normal damage to zero.
Code: Select all
        -- remove deat weapon damage on eco buildings
        if Categories.ECONOMIC and not Categories.EXPERIMENTAL then
            -- check first if we have a weapon array inside the unit blueprint
            if bp.Weapon then
                -- Loop over all Weaponss
                for _,weapon in bp.Weapon do
                    -- check if we have a Death Weapon
                    if weapon.WeaponCategory and weapon.WeaponCategory == 'Death' then
                        -- If we have a nuke Weapon then disable damage from inner and outer nuke blast ring
                        if weapon.NukeInnerRingDamage and weapon.NukeOuterRingDamage then
                            LOG('processing >>>'..id..'<<< +ECONOMIC -EXPERIMENTAL : Changing Weapon.Damage from Nuke-Deathweapon from ('..weapon.NukeInnerRingDamage..'/'..weapon.NukeOuterRingDamage  ..') to "0"')
                            -- set the damage to 0
                            weapon.NukeInnerRingDamage = 0
                            weapon.NukeOuterRingDamage = 0
                        -- in case its not a nuke weapon set the normal damage to Zero
                        elseif weapon.Damage then
                            LOG('processing >>>'..id..'<<< +ECONOMIC -EXPERIMENTAL : Changing Weapon.Damage from normal-Deathweapon from ('..(weapon.Damage)..') to "0"')
                            -- set the damage to 0
                            weapon.Damage = 0
                        end
                    end
                end
            end
        end



If you want to reduce the BuildTime from an upgradeable unit you can do this:
Code: Select all
        -- Find a upgradeable structure and reduce the buildtime to 10%
        if Categories.STRUCTURE then
            -- is tis unit upgradeable ?
            if bp.General.UpgradesTo then
                -- check if we have a BuildTime and change it.
                if bp.Economy.BuildTime then
                    LOG('processing >>>'..id..'<<< +STRUCTURE : Is upgradeable, Changing BuildTime from ('..(bp.Economy.BuildTime)..') to "'..(bp.Economy.BuildTime * 0.1)..'"')
                    -- set the BuildTime to 10%
                    bp.Economy.BuildTime = bp.Economy.BuildTime * 0.1
                end
            end
        end


Well now to the last thing :)
Code: Select all
          --Hide full life bars
          if Categories.SELECTABLE then
             if bp.LifeBarSize and bp.Defense.MaxHealth and bp.Defense.Health then
                if bp.Defense.MaxHealth = bp.Defense.MaxHealth then
                   bp.LifeBarSize = 0
                end
             end
          end


First of all, the script is only executed once at gamestart.
It will not check the whole game long for the if statement.
So you can't change it inside the blueprint.lua.

Second, your if statement is missing a equal sign. you need 2 equals "=="
Code: Select all
    if bp.Defense.MaxHealth == bp.Defense.MaxHealth then


And of course "MaxHealth" is always equal to "MaxHealth". One of it should be "Health" ^^


I don't know what else could be a nice change. And i fear the balance terrorist. They are seeing everything :D

There are some people on steam asking for a cheat for Supreme Commander.
Maybe those players have some ideas what they want to change in the game as cheat or trainer.
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: Mod making

Postby StylisticSagi » 18 Oct 2016, 16:40

Okay i always started supcom from steam, since i already had some other mods installed apart from those on faf the commander did not even spawn haha. So i look into in working with faf if i can make steam get it to run instead of fa from steam itself.
And yeah i have read about the mods that there where some serious restrictions when it comes to modding. However since i change everyhting for all factions balance between them should at least be the same. But if it get's finisched i will load it and if they don't like it then they can go to hell cuz i am mainly creating this to play with friends so faf will have the coice if we play on faf or on our own server.

Apart from that i assume there would be no way then to hide the life bar of units that aren't damaged?
I like all the tactical info but i give more credit to visual effect (that is the reason why i made the line of sight radius larger for land units, but i tweaked it to 1.5 and also give it to naval units)

The upgradable mod you wrote won't work (i tried something simular).
The problem is that the final form is not an upgradable unit so the final upgrade will stil go very slow.
But i am experimenting with a way around it. Already tried by selecting every building with a build rate but not a factory to give it much more build rate but then the first upgrade goes way to fast and the final one goes way to slow.
StylisticSagi
Crusader
 
Posts: 41
Joined: 22 Aug 2016, 17:53
Has liked: 1 time
Been liked: 1 time
FAF User Name: StylisticSagi

Re: Mod making

Postby Uveso » 18 Oct 2016, 18:25

My comment about balance terrorist was a insider joke :)

You can mod what you want. Only exeption is a cheat mod.
Cheat don't means that you can't make mods with indestructible buildings.
Cheating is, if a mod can disable fog of war, or dispaly things even if fog of war is active.
Then many people will dislike your mod.

Your mod is actual changing the gameplay for all playes. Thats perfectly ok.
(i would not help for a cheat mod ^^)


Well there is a way to hide the life bars if a unit has full health, but not inside blueprint.lua.
You need to hook the corresponding function and change the code for the lifebar display.


For the upgradeproblem you can use "UpgradesFrom" instead of "UpgradesTo". Then the final upgrade will be also fast. ;)
if you want also the buildtime reduced for the base building, use both. "UpgradesFrom" AND "UpgradesTo".

if you want differnt upgradetimes for the differnet tech buildings, you could ask something like:
Code: Select all
If Categories.TECH1 then
    bp.Economy.BuildTime = bp.Economy.BuildTime * 0.2
elseIf Categories.TECH2 then
    bp.Economy.BuildTime = bp.Economy.BuildTime * 0.4
end
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: Mod making

Postby StylisticSagi » 18 Oct 2016, 18:31

With every post i read of you i learn alot more :D
Just finisched creating another pair of broken scripts but i am gonna try to fix them myself first. If you fix all my stuff then i don't learn to do it properly. But i do have a question what does this line and particular the _ do/mean?
for _,weapon
StylisticSagi
Crusader
 
Posts: 41
Joined: 22 Aug 2016, 17:53
Has liked: 1 time
Been liked: 1 time
FAF User Name: StylisticSagi

Re: Mod making

Postby speed2 » 18 Oct 2016, 18:39

it's same as
Code: Select all
for k, weapon do

but if you use it like this
Code: Select all
for _, weapon do

it means that you won't use the k (key) in the loop

easier to read
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Mod making

Postby StylisticSagi » 18 Oct 2016, 18:42

And why is that line needed then?
Busy eperimenting with altering weapons now and nothign works so the key probably lies in this line.

p.s. how do i give a unit another category?
since you start with defining all the categories i can't get a building or unit being build by another faction.
StylisticSagi
Crusader
 
Posts: 41
Joined: 22 Aug 2016, 17:53
Has liked: 1 time
Been liked: 1 time
FAF User Name: StylisticSagi

Re: Mod making

Postby Vanguard » 19 Oct 2016, 09:07

StylisticSagi wrote:p.s. how do i give a unit another category?
since you start with defining all the categories i can't get a building or unit being build by another faction.

Not sure if I give the right answer here, or what you want to achieve - however: The simple answer is to edit the blueprint and under Categories, you add the desired categories. So if you´d want an unit build by engineers, you could add "needsmobileengineers" or what´s it called to the categories.

Edit: If you want units to be built cross faction, but cannot add multiple factions to the categories, simply copy that unit and give it different faction categories each copy.
Vanguard
Avatar-of-War
 
Posts: 88
Joined: 05 Apr 2016, 13:45
Has liked: 15 times
Been liked: 11 times
FAF User Name: Vanguard

Re: Mod making

Postby Uveso » 19 Oct 2016, 10:06

@StylisticSagi:

every command has a syntax. And because we can't change the syntax itself (you will get an error if you try to do so), we are using the line (Underscore) as placehoder for unneded values.

In this case the Underscore only stores the index of the weapon array.
So there is only a number inside "_" like 1 or 2. Nothing we really need.

If you try to set a new category (from blueprint.lua) you need to delete the old category.

For example, if you have an UEF unit, and want to build it from cybran, you need to add "CYBRAN" to the category array AND you need to delete "UEF" from that array.
You also should change General.FactionName from 'UEF' to 'Cybran'.

Because it's tricky to remove something from an array, i made a function for it:

Code: Select all
function RemoveItemFromArray(REMOVEME,ARRAY)
    zold = 1
    while ARRAY[zold] do
        if ARRAY[zold] == REMOVEME then
            table.remove(ARRAY, zold)
        else
            zold = zold + 1
        end
    end
    return ARRAY
end

to remove "UEF" from the Category array call this:

Code: Select all
bp.Categories = RemoveItemFromArray('UEF',bp.Categories)
User avatar
Uveso
Supreme Commander
 
Posts: 1788
Joined: 11 Dec 2015, 20:56
Location: Germany
Has liked: 70 times
Been liked: 291 times
FAF User Name: Uveso

Re: Mod making

Postby StylisticSagi » 19 Oct 2016, 15:38

@Vanguard
well copy the unit and changes things in it is exactly what i have been doing for 3 years and i now want to do it properly :P

@uveso
Yeah i am trying to make the hydrocarbon plant more usefull also late game. but to remind people i want to place in the experimental section (i don't mind that t1 can build them).
this was the code i was trying but the categorie changing obviously didn't work so i am now gonna try your way.

Code: Select all
      --Hydro plant supper boost
      if Categories.HYDROCARBON then
         if bp.Economy.ProductionPerSecondEnergy then
            bp.Economy.ProductionPerSecondEnergy = 20000
            bp.Economy.ProductionPerSecondMass = 100
            bp.Categories.EXPERIMENTAL = true
            bp.Categories.TECH1 = false
         end
      end



p.s. i can't get to make changes in the projectiles directory does this have a specific way of programming since it is in another folder?
My logic tells me not since they are blueprints just the same but my scripts won't work...

example:
Code: Select all
         --Anti nukes price
         if Categories.Projectile and ANTIMISSILE then
            if bp.Economy.BuildTime and bp.Economy.BuildCostEnergy and bp.Economy.BuildCostMass then
               bp.Economy.BuildCostEnergy = 50000
               bp.Economy.BuildCostMass = 10000
               bp.Economy.BuildTime = 50
            end
         end
         --Nukes Price
         if Categories.Projectile and STRATEGIC then
            if bp.Economy.BuildTime and bp.Economy.BuildCostEnergy and bp.Economy.BuildCostMass then
               bp.Economy.BuildCostEnergy = 1350000
               bp.Economy.BuildCostMass = 2500
               bp.Economy.BuildTime = 50
            end
         end
StylisticSagi
Crusader
 
Posts: 41
Joined: 22 Aug 2016, 17:53
Has liked: 1 time
Been liked: 1 time
FAF User Name: StylisticSagi

Re: Mod making

Postby StylisticSagi » 21 Oct 2016, 18:17

Hmm to bad i can't get a reply from this one it was the last ting i needed to do...
StylisticSagi
Crusader
 
Posts: 41
Joined: 22 Aug 2016, 17:53
Has liked: 1 time
Been liked: 1 time
FAF User Name: StylisticSagi

PreviousNext

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest