Regen in game different from blueprint

Talk about general things concerning Forged Alliance Forever.

Moderators: FtXCommando, Ze Dogfather

Regen in game different from blueprint

Postby Evildrew » 31 Jan 2019, 17:36

Buff regen doesnt seem to be working as in the blueprints, all exps get +25/level on my test regardless of what is in the blueprint. Tested it with GC & Fatboy, same problem.

Buffs = {
Regen = {

Anyone know why that is or if it can be fixed?
Evildrew
Avatar-of-War
 
Posts: 248
Joined: 18 Sep 2015, 11:41
Has liked: 1 time
Been liked: 36 times
FAF User Name: Evildrew

Re: Regen in game different from blueprint

Postby Uveso » 31 Jan 2019, 19:00

Hello Evildrew,

i am not sure in this case!

But the veteran system was changed and those tables are a left over from the old system.

Actual the veteran level and regen is calculated hardcoded inside unit.lua script:
https://github.com/FAForever/fa/blob/develop/lua/sim/Unit.lua#L1445
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: Regen in game different from blueprint

Postby Evildrew » 31 Jan 2019, 19:28

Hm, thats not cool, so i need to put this line below in my unit.lua file to negate this?
local regenBuffs = {
}

I remember long ago someone was saying on a youtube video that Cybran ACU was balanced ok because it had more regen... I guess not.
Evildrew
Avatar-of-War
 
Posts: 248
Joined: 18 Sep 2015, 11:41
Has liked: 1 time
Been liked: 36 times
FAF User Name: Evildrew

Re: Regen in game different from blueprint

Postby Uveso » 31 Jan 2019, 19:47

You can't just append this to the end of the unit.lua file because the function is "inside" the unit class definition.

You need a hook for the unitclass.

Create a file in your mod/hook folder:
Code: Select all
\Mods\YOURMODNAME\hook\lua\sim\Unit.lua


Then copy & paste this into the Unit.lua file:

Code: Select all
-- Save/store the original Unit class
local OldUnit = Unit
-- create a new unitclass with the same name (overwrite the original) and use as base the OldUnit class
Unit = Class(OldUnit) {

    -- This overwrites the original CreateVeterancyBuffs function
    CreateVeterancyBuffs = function(self, level)
        local healthBuffName = 'VeterancyMaxHealth' .. level -- Currently there is no difference between units, therefore no need for unique buffs
        local regenBuffName = self:GetUnitId() .. 'VeterancyRegen' .. level -- Generate a buff based on the unitId - eg. uel0001VeterancyRegen3

        if not Buffs[regenBuffName] then
            -- Maps self.techCategory to a number so we can do math on it for naval units
            local techLevels = {
                TECH1 = 1,
                TECH2 = 2,
                TECH3 = 3,
                COMMAND = 3,
                SUBCOMMANDER = 4,
                EXPERIMENTAL = 5,
            }
           
            local techLevel = techLevels[self.techCategory] or 1
           
            -- Treat naval units as one level higher
            if techLevel < 4 and EntityCategoryContains(categories.NAVAL, self) then
                techLevel = techLevel + 1
            end
           
            -- Regen values by tech level and veterancy level
            local regenBuffs = {
                {1,  2,  3,  4,  5}, -- T1
                {3,  6,  9,  12, 15}, -- T2
                {6,  12, 18, 24, 30}, -- T3 / ACU
                {9,  18, 27, 36, 45}, -- SACU
                {25, 50, 75, 100,125}, -- Experimental
            }
       
            BuffBlueprint {
                Name = regenBuffName,
                DisplayName = regenBuffName,
                BuffType = 'VeterancyRegen',
                Stacks = 'REPLACE',
                Duration = -1,
                Affects = {
                    Regen = {
                        Add = regenBuffs[techLevel][level],
                    },
                },
            }
        end
       
        return {regenBuffName, healthBuffName}
    end,

}


Now you can play around with it.
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


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest