Those working on this mod do so in their own free time and for no pay.
Show your support for them by enabling ads on this site!

Author Topic: Big Campaigns and Minor Faction AI - I think i figured it out  (Read 2180 times)

0 Members and 2 Guests are viewing this topic.

August 01, 2011, 10:36:42 AM

Offline markb50k

  • Stormtrooper
  • **
  • Posts: 7
  • Approval: +2/-1
    • View Profile
I have been messing with Minor Faction AI, among other things, in my personalized version of this mod, and I believe I finally got it working..

Things you must realize:
- Minor Factions DO NOT gain credits like playable factions.  Either its in the Base Code or its some flag I havent set (or anyone has) in the Factions.XML.  But not to worry, I found a very easy way of doing it in the GameScoring.LUA script.  I wrote a function that spawns a thread at game start, that every weeks does a check of minor faction planets and rewards the minor faction AI with money commensurate to its planetary holdings and based on the presence of Tax or Mining Facilities.  Its not perfect but it pretty freaking close.
- The above is not and SHOULD NOT be needed for Empire/Rebel/Underworld factions.  They gain credits fine the normal way.

Perceptual Equations:
- Woah, wasted alot of time on these and was ready to give up but read up on a German mod and figured out (through translation) how to do it.
- All XML in the XML/AI folders can be edited in the Imperial_Civil_War directory structure, EXCEPT for the PERCEPTUALEQUATIONS directory.  You can make edits to those files, yes, BUT it wont take affect in game.  The ONLY way to get perceptual equations edits to work is to have the files in the base  FOC/Data/XML/AI/PERCEPTUALEQUATIONS directory.  And you need to be very careful of your edits. 
- Why are these equation edits necessary?  Well because there are a bunch of places where it hardcodes the equations to only work if the calling faction is one of the majors.  I edited mine to take into account minor factions as well.  For instance, one function tries to determine if a target planet is connected to "me", whoever the calling faction is.  Well in it the only faction values that will allow the function to return a 1 (TRUE) are "REBEL", "EMPIRE", or "UNDERWORLD"

# of planets/ # of Trade Routes:
- came across a big error that was not allowing me to add in more planets to the GC.  What i found out is, and this is across the entire XML directory, but you cannot have a field with more than around 3500 characters in it.  Given the Thrawn's Revenge names of their routes, it could only hold around 160 trade routes in it before it would not load.  Well, just rename the routes to abbreviations like instead of "All_Coruscant_Byss" change to "CorBys" and you can fit tons more.  As a result, more trade-routes = MORE PLANETS.

The Result:
- My GC has 150 planets, and SEVENTEEN independent factions all acting with full AI, and the game is as stable as ever.  I even run it off of a work laptop, so lag is not an issue.

Anyway, credits go to Corey and the team for the awesome mod, and I hope this info is useful to other modders and to the team.  Figured all the banging my head against the wall should do someone some good.  Hopefully y'all can use this info.

Thanks

August 01, 2011, 12:11:14 PMReply #1

Offline Corey

  • Mod Leader
  • Administrator
  • Emperor
  • *****
  • Posts: 7,520
  • Approval: +410/-80
  • Dream Crusher
    • View Profile
Re: Big Campaigns and Minor Faction AI - I think i figured it out
« Reply #1 on: August 01, 2011, 12:11:14 PM »


Things you must realize:
- Minor Factions DO NOT gain credits like playable factions.  Either its in the Base Code or its some flag I havent set (or anyone has) in the Factions.XML.  But not to worry, I found a very easy way of doing it in the GameScoring.LUA script.  I wrote a function that spawns a thread at game start, that every weeks does a check of minor faction planets and rewards the minor faction AI with money commensurate to its planetary holdings and based on the presence of Tax or Mining Facilities.  Its not perfect but it pretty freaking close.
- The above is not and SHOULD NOT be needed for Empire/Rebel/Underworld factions.  They gain credits fine the normal way.

We are aware of the basic problem here, but we worked around it a different way. Yours sounds better but I'm not sure that it fixes the problem the minor factions having AI actually causes.


Perceptual Equations:
- Woah, wasted alot of time on these and was ready to give up but read up on a German mod and figured out (through translation) how to do it.
- All XML in the XML/AI folders can be edited in the Imperial_Civil_War directory structure, EXCEPT for the PERCEPTUALEQUATIONS directory.  You can make edits to those files, yes, BUT it wont take affect in game.  The ONLY way to get perceptual equations edits to work is to have the files in the base  FOC/Data/XML/AI/PERCEPTUALEQUATIONS directory.  And you need to be very careful of your edits. 
- Why are these equation edits necessary?  Well because there are a bunch of places where it hardcodes the equations to only work if the calling faction is one of the majors.  I edited mine to take into account minor factions as well.  For instance, one function tries to determine if a target planet is connected to "me", whoever the calling faction is.  Well in it the only faction values that will allow the function to return a 1 (TRUE) are "REBEL", "EMPIRE", or "UNDERWORLD"

We already knew about this, but consider it the biggest dick move of all dick moves to edit the base game files as far as just basic modding goes, which is why we've never actually touched them.

# of planets/ # of Trade Routes:
- came across a big error that was not allowing me to add in more planets to the GC.  What i found out is, and this is across the entire XML directory, but you cannot have a field with more than around 3500 characters in it.  Given the Thrawn's Revenge names of their routes, it could only hold around 160 trade routes in it before it would not load.  Well, just rename the routes to abbreviations like instead of "All_Coruscant_Byss" change to "CorBys" and you can fit tons more.  As a result, more trade-routes = MORE PLANETS.

We were also aware of this, but didn't address it because it doesn't actually effect the mod in any way. We haven't hit the limit, so it really doesn't matter. We have more or less all of the planets we intend to add, except for maybe 10.

The Result:
- My GC has 150 planets, and SEVENTEEN independent factions all acting with full AI, and the game is as stable as ever.  I even run it off of a work laptop, so lag is not an issue.

It's all interesting but I don't think it addresses the actual problem that minor factions cause, with the backlog around week 25-60. If you want to send me the files, I can edit them into the mod for the next beta we do (full credit of course) and we can see if this somehow does fix that. And if you want a job, you can have one of those too, except I don't pay.
I also have a YouTube channel where I talk about mod development and gaming, do tutorials, and Let's Plays. If you like the content, consider supporting it on Patreon


August 01, 2011, 01:01:10 PMReply #2

Offline markb50k

  • Stormtrooper
  • **
  • Posts: 7
  • Approval: +2/-1
    • View Profile
Re: Big Campaigns and Minor Faction AI - I think i figured it out
« Reply #2 on: August 01, 2011, 01:01:10 PM »
Well, I figured that most of the stuff I had figured out you guys were aware of, but I know that in my case I had the hardest time finding good stuff on the web about this, so I figured I'd provide some good material for guys like me searching in the future.

As for the credit issue with Minor Factions, I'm definitely interested in how you guys handled that.  I see you give them a ton of starting credits, and i tried that too, but nothing beats having them under the same restrictions as you.

As for the backlog, i've gone pretty far into GCs, but I will continue to test to see long term issues with all those AIs, and if it continues to look stable I'll send the code over.  My mod is such a zombification of yours however it hardly resembles yours anymore, so any code i give you will have to to be highly edited to even be used in your beta.  I posted this moreso for informational purposes.

As far as a job, i have one already, and this is a labor of love, as it is with all of us, but again much respect to you guys who have put in the effort you have to create something for people just because you love SW.

 

Those working on this mod do so in their own free time and for no pay.
Show your support for them by enabling ads on this site!