Getting AI to build Mod Units

Everything about mods can be found here.

Moderator: Morax

Getting AI to build Mod Units

Postby Lex Ryder » 19 Mar 2017, 00:05

I've put together an Experimental Point Defense Laser (set on T1 for cheap while testing) for the UEF (photo below) and I can't get the AI to build it for themselves at all. Here's what I have so far. The particular mod unit I'm focused on is 'uebmod2'.

--.../mods/insane/hook/lua--

ModPointDefense.lua

Code: Select all
UnitList = {
   T1GroundDefense = {
      Cybran = {'urbmod1', 25}, -- Pointdefense from Logan
      UEF = {'uebmod2', 50,} -- Pointdefense from Logan
      UEF = {'uebmod1', 50}, -- Pointdefense from Logan
},
}
Attachments
Experimental Laser.jpg
Experimental Laser.jpg (171.65 KiB) Viewed 3876 times
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: Getting AI to build Mod Units

Postby speed2 » 19 Mar 2017, 00:19

Code: Select all
UnitList = {
   T1GroundDefense = {
      Cybran = {'urbmod1', 25}, -- Pointdefense from Logan
      UEF = {'uebmod2', 50,} -- Pointdefense from Logan
      UEF = {'uebmod1', 50}, -- Pointdefense from Logan
},

I never tried this myself so can't tell you for sure how to make it work but few things I know:

There's syntax error on this line
Code: Select all
UEF = {'uebmod2', 50,} -- Pointdefense from Logan

the comma needs to be after the } bracket

Another thing is that lua tables are array of key = value,
which means that you have a key UEF and value {'uebmod2', 50}
but the next line overwrites it since you're defining key UEF again
so only this line
Code: Select all
UEF = {'uebmod1', 50},

Will end up in the final table.
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: Getting AI to build Mod Units

Postby Sprouto » 19 Mar 2017, 00:44

Are you able to build the item manually ? If so, then you're almost there. Speed has shown you what you need to make it happen.

If testing is all your interested in, bump the 50 value up to 100, that will insure that he builds your new unit when he's ready build T1 Ground Defense.

If you want to add more than one unit to the T1 Ground Defense for the UEF, you'll need a second ModPointDefense.lua file, for example, ModPointDefense2.lua.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Getting AI to build Mod Units

Postby Lex Ryder » 19 Mar 2017, 01:01

Something like this?

Code: Select all
UnitList = {
   T1GroundDefense = {
      UEF =   {'uebmod2', 100},
},
}
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: Getting AI to build Mod Units

Postby Sprouto » 19 Mar 2017, 03:37

That should do it - the 100 insures that it will be a 100% replacement of anything else.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Getting AI to build Mod Units

Postby Lex Ryder » 19 Mar 2017, 05:14

Okay, so this is what's all here and it's still building the normal UEF T1 Defense. Logically, it should be working, right?

...mods/insane/hook/lua/

ModPointDefense.lua

Code: Select all
UnitList = {
   T1GroundDefense = {
      UEF =   {'uebmod2', 100},
},
}
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: Getting AI to build Mod Units

Postby Lex Ryder » 01 May 2017, 21:27

Alright, I've been out of the SC Loop for a while. I'm about to get back into my modding, but still don't know exactly what's wrong with this particular problem. Anyone?
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: Getting AI to build Mod Units

Postby Uveso » 01 May 2017, 21:56

Hello Lex Ryder,

without testing i can't say more. The syntax of the UnitList array is fine.

Maybe the case-sensitive unitID is the problem ?

[edit]
PS: "hook" dir is wrong;
Code: Select all
\Mods\yourmodname\lua\CustomUnits\yourunits.lua
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: Getting AI to build Mod Units

Postby Lex Ryder » 03 May 2017, 05:33

I'm unsure if this is the proper way to share this, but here is a ZIP of what I have thus far. I can't seem to crack the AI build code. I'm using UEBMOD2 unit as the test subject.
https://drive.google.com/file/d/0B1S09OdRoX4UZ0ZhT21Kc3dqbWs/view?usp=sharing
Lex Ryder
Crusader
 
Posts: 35
Joined: 18 Feb 2016, 11:22
Has liked: 1 time
Been liked: 3 times
FAF User Name: Lex Ryder

Re: Getting AI to build Mod Units

Postby Uveso » 03 May 2017, 20:57

Hello Lex Ryder,

i tested the mod wit 6 UEF Sorian AIx with 1.4 cheat+build.

All AI are building unit UEBMOD2 after 12-15 minutes.

It's working fine.

Image
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

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest