Forged Alliance Forever Forged Alliance Forever Forums 2018-07-25T05:32:06+02:00 /feed.php?f=41&t=14688 2018-07-19T01:30:00+02:00 2018-07-19T01:30:00+02:00 /viewtopic.php?t=14688&p=165938#p165938 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]> (Can be used by multiple mods, the hook is non destructive)

AIAddBuilderTable.lua
Code:
local OLDAddGlobalBaseTemplate = AddGlobalBaseTemplate
function AddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
    AddGlobalBuilderGroup(aiBrain, locationType, 'NuclearRepulsorShields')
    OLDAddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
end

In this case the builder "NuclearRepulsorShields" will be added to the base template.
Also if the game starts a new location manager, this hook will also add the builder to any expansion base template.

Statistics: Posted by Uveso — 19 Jul 2018, 01:30


]]>
2018-07-16T19:14:09+02:00 2018-07-16T19:14:09+02:00 /viewtopic.php?t=14688&p=165904#p165904 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]>
The next version will inject the "BuilderGroupName" directly into the AIBase-Templates.

So you can add comlete new builders to "All" base templates without changing any of them.

[Edit]
This will be done by hooking the function AddGlobalBaseTemplate inside AIAddBuilderTable.lua
(coming soon :D)

Statistics: Posted by Uveso — 16 Jul 2018, 19:14


]]>
2018-07-15T18:09:13+02:00 2018-07-15T18:09:13+02:00 /viewtopic.php?t=14688&p=165880#p165880 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]>
Uveso wrote:
Here is an example how to make AI BuilderGroups and StructureUpgradeTemplates for the Black Ops Hydrocarbon Power Plants:

https://github.com/aeoncleanse/Mods/pull/255/files


I realize... did this at one time for 4DC.
My prior comment was more of a why this is not done.

Note: Aeoncleanse made a few units for use with 4DC about the same time the he created the script for that mod.

Statistics: Posted by Resin_Smoker — 15 Jul 2018, 18:09


]]>
2018-07-09T18:15:20+02:00 2018-07-09T18:15:20+02:00 /viewtopic.php?t=14688&p=165757#p165757 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]>
https://github.com/aeoncleanse/Mods/pull/255/files

Statistics: Posted by Uveso — 09 Jul 2018, 18:15


]]>
2018-07-08T23:14:21+02:00 2018-07-08T23:14:21+02:00 /viewtopic.php?t=14688&p=165731#p165731 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]> Statistics: Posted by Resin_Smoker — 08 Jul 2018, 23:14


]]>
2018-04-17T01:47:17+02:00 2018-04-17T01:47:17+02:00 /viewtopic.php?t=14688&p=162665#p162665 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]>
Secondly, with Sorian, you'll need to have a custom builder that will;

a) Detect that there are un-upgraded units in the pool. (Done with an appropriate builder condition)
b) Issue the necessary upgrade command to them.

As I recall, Sorian manages extractor upgrades thru this kind of mechanism. You can use that as an example of how it's done.

Statistics: Posted by Sprouto — 17 Apr 2018, 01:47


]]>
2018-04-16T16:22:26+02:00 2018-04-16T16:22:26+02:00 /viewtopic.php?t=14688&p=162647#p162647 <![CDATA[Re: How to: Creating custom unit scripts for Sorian AI]]> Statistics: Posted by HUSSAR — 16 Apr 2018, 16:22


]]>
2018-07-25T05:32:06+02:00 2017-06-02T11:28:00+02:00 /viewtopic.php?t=14688&p=150095#p150095 <![CDATA[How to: Creating custom unit scripts for Sorian AI]]>
Creating scripts for the Sorian AI is very simple.
You only need to create a textfile filled with an Array. Thats all. :)


First we need to create a new folder and .lua file inside your mod:

Create a new directory inside you modfolder named "lua".
Inside the Lua folder create a new directory named "customunits".

Now create an empty textfile inside "customunits" and name it "test.lua".

The new file (test.lua) should now be in this location:
Code:
C:\Users\YOURNAME\Documents\My Games\Gas Powered Games\Supreme Commander Forged Alliance\Mods\YOURMOD\lua\CustomUnits\test.lua

Now we need to fill this test.lua file with an Array that is holding the unit ID with Buildplatoon.

Let's say we have a new Tech 1 GroundDefense with the Unit ID "ueb0815" and we want a 30% build chance.

Then the Array will look like this:
Code:
UnitList = {

   T1GroundDefense = {
      UEF = {'ueb0815', 30},
   },

}
UnitList is the mainarray for all units. (Ingame and customunits)
T1GroundDefense means, if the AI will build a Tech 1 Grounddefense it will use all units saved inside the subarray "T1GroundDefense ". (Ingame and customunits)
UEF = {'ueb0815', 30}, This unit can only be build from UEF, has the unitID "ueb0815", and 30% of all T1GroundDefense builded by AI will be unit "ueb0815".
If you set 30 to 100, then the AI will only build unit "ueb0815" as T1GroundDefense.


You can fill up the test.lua file with several builodplatoons and units. First a list, what you should not do:

This won't work: ( 2 or more units in a buildplatoon for the same faction)
Code:
UnitList = {
    T1GroundDefense = {
        Cybran = {'brmt1expdt2', 50}, -- Name: Pen mk2 (Experimental Point Defense)
        Cybran = {'brpt1pd', 50}, -- Name: Hethula-Uttaus (Heavy Point Defense)
        Cybran = {'brnt2pd2', 50}, -- Name: Ace mk.2 (Heavy Point Defense)
    },
}


This won't work: (more then one unique buildplatoon (like 2 x T1GroundDefense) in the same file)
Code:
UnitList = {
    T1GroundDefense = {
        Cybran = {'brmt1expdt2', 50}, -- Name: Pen mk2 (Experimental Point Defense)
        Seraphim = {'brpt1pd', 50}, -- Name: Hethula-Uttaus (Heavy Point Defense)
    },
    T1GroundDefense = {
        UEF = {'brnt2pd2', 50}, -- Name: Ace mk.2 (Heavy Point Defense)
        Cybran = {'brmt2pd', 50}, -- Name: Sabertooth (Heavy Point Defense)
    },
}


But if you use different platoons, you can fill up the file as much as you want:
Code:
UnitList = {
    T1GroundDefense = {
        Cybran = {'brmt1expdt2', 50}, -- Name: Pen mk2 (Experimental Point Defense)
        Aeon = {'brot1hpd', 50}, -- Name: Zpyker (Heavy Point Defense)
        Seraphim = {'brpt1pd', 50}, -- Name: Hethula-Uttaus (Heavy Point Defense)
    },
    T1LandDFTank = {
        UEF = {'brnt1htt3', 50}, -- Name: Predator mk.3 (Heavy Tank)
        Cybran = {'brmt1at', 50}, -- Name: Roach (Assault Tank)
        Aeon = {'brot1mt', 50}, -- Name: Lintea (Medium Tank)
        Seraphim = {'brpt1asta', 50}, -- Name: Hethistle-ve (Assault Tank)
    },
    T2ShieldDefense = {
        Cybran = {'qrb4208', 30}, -- ED6: Gilmore (Village Shield Generator)
    },
    T3ShieldDefense = {
        UEF = {'qeb4408', 55}, -- UHSD Puls: Cochran (Village Shield Generator)
        Aeon = {'qab4408', 55}, -- Cashton (Village Shield Generator)
        Seraphim = {'qsb4408', 55}, -- Atha Ythisioz (Village Shield Generator)
    },
}


And you can put up to 5 units in each platoon. For every faction one Unit:
Code:
UnitList = {
    T4LandExperimental2 = {
        UEF = {'qeb4410', 50}, -- EXHSD Puls: Bucksport (Metropolis Shield Generator)
        Cybran = {'qrb4410', 50}, -- ED8: Bovill (Metropolis Shield Generator)
        Aeon = {'qab4410', 50}, -- Jenks (Metropolis Shield Generator)
        Seraphim = {'qsb4410', 50}, -- Athayii Ythisioz (Metropolis Shield Generator)
        Nomads = {'qnb4410', 50}, -- Wagos (Metropolis Shield Generator)
    },
}


And these are all buildplatoons that will work with sorian and normal AI:
Code:
MassStorage
EnergyStorage
Wall

T1LandFactory
T1SeaFactory
T1AirFactory
T1AirFighter
T1AirBomber
T1Gunship
T1AirTransport
T1EnergyProduction
T1MassCreation
T1Resource
T1Radar
T1HydroCarbon
T1AADefense
T1GroundDefense
T1NavalDefense
T1Sonar
T1SeaSub
T1SeaFrigate

T2LandFactory
T2SeaFactory
T2AirFactory
T2FighterBomber
T2AirGunship
T2AirTorpedoBomber
T2AirTransport
T2StrategicMissile
T2ShieldDefense
T2RadarJammer
T2EngineerSupport
T2MissileDefense
T2GroundDefense
T2AADefense
T2Artillery
T2ShieldDefense
T2Radar
T2RadarJammer
T2Resource
T2EnergyProduction
T2AirStagingPlatform
T2NavalDefense
T2Sonar
T2SeaDestroyer
T2SeaCruiser
T2SubKiller
T2ShieldBoat
T2CounterIntelBoat

T3LandFactory
T3AirFactory
T3AirFighter
T3AirBomber
T3AirGunship
T3TorpedoBomber
T3AirTransport
T3QuantumGate
T3SeaFactory
T3SeaBattleship
T3SeaNukeSub
T3SeaCarrier
T3MissileBoat
T3SubKiller
T3Battlecruiser
T3MassCreation
T3Artillery
T3RapidArtillery
T3EnergyProduction
T3AADefense
T3GroundDefense
T3StrategicMissile
T3StrategicMissileDefense
T3MassExtraction
T3ShieldDefense
T3Radar
T3NavalDefense
T3Sonar
T3Optics

T4LandExperimental1
T4LandExperimental2
T4LandExperimental3 (only cybran)
T4AirExperimental1
T4SeaExperimental1
T4EconExperimental (only aeon)
T4SatelliteExperimental (only UEF)
T4Artillery


To create those Buildplatoon arrays you can use my private unit debugger mod.
If you load the game with the debuggermod and your unitmod; simply press [SHIFT]+[a] ingame.
You will see a list of all units (in copy+paste ready array style) inside the debugwindow [F9] or the game.log.

It will look like this:
Code:
INFO: Uveso Debugger: [UnitDebug.lua 714] - Unit UEB0001 veryfied, has Icon but no AI Support. Name:(Hammer) (Tech 1 Power Defence)
INFO: T1GroundDefense = {
INFO:         UEF = {'UEB0001', 50}, -- Name: Hammer(Tech 1 Power Defence)
INFO: },
Remove the "INFO: ", then you can copy this to your "customunits\test.lua"

You can use as filename what you want. The game will load all .lua files from the "customunits" folder.

Download debuggermod:
http://faforever.uveso.de/forum/UvesoDebuggerV49.zip

Greetings, Uveso.

Statistics: Posted by Uveso — 02 Jun 2017, 11:28


]]>