Units fire red lines (instahit)

Moderators: Uveso, burnie222

Re: Units fire red lines (instahit)

Postby Uveso » 10 Dec 2017, 17:33

Hello CSI,

How to: Creating custom unit scripts for Sorian AI:
http://forums.faforever.com/viewtopic.php?f=41&t=14688

It's also working with the normal AI in FAF :)
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: Units fire red lines (instahit)

Postby CSI » 10 Dec 2017, 18:32

Oh very nice, so if I understood correctly, the file name can be anything, only the platoon names are considered by th game ?

And I guess we cannot extend the platoon list unless we make a new version of Sorian ?
CSI
Avatar-of-War
 
Posts: 101
Joined: 09 Apr 2017, 18:59
Has liked: 18 times
Been liked: 5 times
FAF User Name: CSI

Re: Units fire red lines (instahit)

Postby Uveso » 12 Dec 2017, 13:13

Yeah you can use as filename what you want, but as you said, the platoonnames are fixed.

And sure we can add platoons or something else. This has nothing to do with the sorian mod.

I am actual working on my own AI, so i can add/test what you want ;)
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: Units fire red lines (instahit)

Postby CSI » 12 Dec 2017, 15:14

Cool ! But right now I can't fit every unit in the default platoons, for example UEF t1 arti. I have the t1 gatling PD in T1GroundDefense already so how do I do ? :/
CSI
Avatar-of-War
 
Posts: 101
Joined: 09 Apr 2017, 18:59
Has liked: 18 times
Been liked: 5 times
FAF User Name: CSI

Re: Units fire red lines (instahit)

Postby Uveso » 13 Dec 2017, 03:35

Well i am not sure, but the T1 Land arty has already its own platoon (T1LandArtillery) ?!?

See file LandPlatoonTemplates.lua:

Code: Select all
PlatoonTemplate {
    Name = 'T1LandArtillery',
    FactionSquads = {
        UEF = {
            { 'uel0103', 1, 1, 'Attack', 'none' }
        },
        Aeon = {
            { 'ual0103', 1, 1, 'Attack', 'none' }
        },
        Cybran = {
            { 'url0103', 1, 1, 'Attack', 'none' }
        },
        Seraphim = {
            { 'xsl0103', 1, 1, 'Attack', 'none' }
        },
    }
}


This is called from AILandAttackBuilders.lua:

BuilderGroupName = 'T1LandFactoryBuilders',
Code: Select all
BuilderGroup {
    BuilderGroupName = 'T1LandFactoryBuilders',
    BuildersType = 'FactoryBuilder',
    # T1 Artillery, built in a ratio to tanks before tech 3
    Builder {
        BuilderName = 'T1 Mortar',
        PlatoonTemplate = 'T1LandArtillery',
        Priority = 830,
        BuilderConditions = {
            #{ UCBC, 'LocationFactoriesBuildingLess', { 'LocationType', 1, 'INDIRECTFIRE LAND MOBILE' } },
            { UCBC, 'HaveUnitRatio', { 0.25, categories.LAND * categories.INDIRECTFIRE * categories.MOBILE, '<=', categories.LAND * categories.DIRECTFIRE * categories.MOBILE}},
            { UCBC, 'FactoryLessAtLocation', { 'LocationType', 1, 'FACTORY LAND TECH3' }},
            { IBC, 'BrainNotLowPowerMode', {} },
            { EBC, 'GreaterThanEconEfficiencyOverTime', { 0.6, 1.05 }},
        },
        BuilderType = 'Land',
    },
}


------------------------------------------------------------------------------------------------------------------------------------------------------------

T1LandFactoryBuilders is also building other units, so if you want to make a Platoonbuilder with only arty you can add its own Builder.

To do so, create a new file "T1ArtyBuilders.lua" inside the directory "\lua\AI\AIBuilders".
Paste this into the new file:
Code: Select all
local IBC = '/lua/editor/InstantBuildConditions.lua'

BuilderGroup {
    BuilderGroupName = 'T1ArtyFactoryBuilders',
    BuildersType = 'FactoryBuilder',
    Builder {
        BuilderName = 'T1 Mortar',
        PlatoonTemplate = 'T1LandArtillery',
        Priority = 1200, -- changed for testing, original value was 830
        BuilderConditions = {
            { IBC, 'BrainNotLowPowerMode', {} },
            { IBC, 'BrainNotLowMassMode', {} },
        },
        BuilderType = 'Land',
    },
}



Now you need to add this BilderGroup to any AI that should use it.
Go to the directory "\lua\AI\AIBaseTemplates" and edit every lua file (TechMain.lua, RushMainBalanced.lua etc.)
Add the BuilderTeplate for "T1ArtyFactoryBuilders":

Code: Select all
BaseBuilderTemplate {
    [...]
    Builders = {
        [...]
        'T1ArtyFactoryBuilders',
        [...]
    },


Now the AI will spam T1 arties like hell :)
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: Units fire red lines (instahit)

Postby CSI » 13 Dec 2017, 11:39

Oh but I'm not talking about mobile artis, but the building added by Total Mayhem, so it's built by engis and not in the factory
CSI
Avatar-of-War
 
Posts: 101
Joined: 09 Apr 2017, 18:59
Has liked: 18 times
Been liked: 5 times
FAF User Name: CSI

Re: Units fire red lines (instahit)

Postby Uveso » 13 Dec 2017, 19:09

Ah i see.

Well thats easy :D

If you need to add more customunits to the same buildplatoon like "T1GroundDefense", then you need more then 1 lua file.

Create a lua file named "XYZ_file1.lua" inside the "\lua\CustomUnits" folder and paste this into the file:
Code: Select all
UnitList = {
   T1GroundDefense = {
      UEF = {'brnt1expd', 40}, -- Name: Mayor MK1 - (Experimental Gatling Defense System)
   },
}


Now create a second file named "XYZ_file2.lua" and paste the other unit in:
Code: Select all
UnitList = {
   T1GroundDefense = {
      UEF = {'brnt1exart', 40}, -- Lumberjack (Experimental Artillery Installation)
   },
}


Both units have a buildchance of 40(%).
If the AI decides to build a T1GroundDefense now, it will be to 40% the Lumberjack, to 40% the Mayor and 20% the original T1GroundDefense from the maingame.
If the AI decides to build a T1GroundDefense now, it will be to 20% the Lumberjack, to 20% the Mayor and 60% the original T1GroundDefense from the maingame.
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: Units fire red lines (instahit)

Postby Sprouto » 13 Dec 2017, 22:11

Just to be correct, the way the AI selects a custom unit is not quite as direct as that.

When there are custom units, the code generates a number between 0 and 100 and if that value is equal to or less than the value on the custom unit, then the AI will select a custom unit.

So if there is only one custom unit, it's true - the 40 will mean 40%.

However, if there is more than one custom unit at 40, then either one may get selected.

If you set your custom unit value to 100, it will always replace the stock unit.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Units fire red lines (instahit)

Postby Uveso » 14 Dec 2017, 19:35

Thanks Sprouto!

I updated the post above to 20/20/60 buildchance.
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: Units fire red lines (instahit)

Postby CSI » 14 Dec 2017, 19:48

What if I set 60 and 20 ? :mrgreen:

Hey Uveso can you tell me more about the AI you're working on ? :v
CSI
Avatar-of-War
 
Posts: 101
Joined: 09 Apr 2017, 18:59
Has liked: 18 times
Been liked: 5 times
FAF User Name: CSI

PreviousNext

Return to Total Mayhem

Who is online

Users browsing this forum: No registered users and 1 guest