As I said, I doubt this is possible with LUA. You need to do this with a modified DLL (either through a game event called from the DLL, and then coded through LUA, or actually coding it that way in the DLL)
I should look and see what sort of calculations are done with the AI in regards to Austria's Diplomatic Marriage.
CvDiplomacyAI
Code:
// **************************
// Would we like to buyout a minor this turn? (Austria UA)
// **************************
bool bWantsToBuyout = false;
if(GetPlayer()->GetPlayerTraits()->IsAbleToAnnexCityStates())
{
if(bFoundCity || bExpandLikeCrazy || bExpandToOtherContinents ||
GetStateAllWars() == STATE_ALL_WARS_LOSING ||
IsGoingForWorldConquest() ||
m_pPlayer->calculateGoldRate() > 100)
{
bWantsToBuyout = true;
}
else
{
int iThreshold = iExpansionFlavor * 5; //antonjs: todo: xml
int iRandRoll = GC.getGame().getJonRandNum(100, "Diplomacy AI: good turn to buyout a minor?");
if(iRandRoll < iThreshold)
bWantsToBuyout = true;
}
}
My logic interpretation of this code:
If the AI wants to found a city, expand rapidly, expand to other continents, is losing all wars (???), is making more than 100 Gold per turn (???), or is going for Military Victory then it can be said that the AI also wants to buy minor civs out. If this is not the case, then we water down the expansion flavor by half on a scale of 100, and load the dice according to this watered down expansion flavor. If the dice give us a good number, then it can also be said that the AI would like to buy a city-state out. Note in the latter scenario, odds can never exceed 1:1 (1/2, 50%)
I should see if some of these AI intentions are exposed to Lua, as I believe some AI intentions actually are, but very few. If this is not the case, I'll have to try to write my own Lua functions to calculate these AI intentions.
EDIT: They're not, as expected.
With the civ that will have the ability to do this, we can assert that it will be going for military victory.
EDIT: I can't seem to find the nuts and bolts of what makes an AI select a specific strategy. Any insight?
bFoundCity will be true under these conditions:
- There must be good settle spots
- The player must not be human
- This must not be an OCC game
- The player must have a "loose" settler -- that is, an idle settler. I will go into detail about good settle spots when I figure it out. Given the context of this, good settle spots ought not matter. Advise if mistaken.
bExpandLikeCrazy will be true under these conditions:
- The game is not OCC
- The player is not human.
- The player is not going for a cultural victory, unless there is not culture policy cost mod per city.
- The player's Expansion flavor dictates that expansion is more important than their current strategy -- we might be able to feign a check by checking for war, checking for apollo program, influence on other civs, whether the world congress is the UN yet and if there's a leader vote going on; that sort of thing.
bExpandToOtherContinents will be true under these conditions:
- The game is not OCC and the player is not human.
- This cannot be active during an island start strategy -- island start is guaranteed to be finished after turn 75.
- This cannot be run during early expansion.
- The player must not be in a war which they are not doing okay with.
- The player must not be going for a culture win -- in the context of this ability, it's highly unlikely that this will be the case -- unless we have, at most, our max culture cities*.
- The player should not be without a capital city, except if he has nowhere to settle.
bGoingForWorldConquest should be fairly self explanatory: We should check to see if the player has another capital under his control and his military strength compared to others.
Another parameter of this is "Are they losing all wars?" In this sense, this doesn't mean they're losing every war, but that, all of their wars considered, they should be on the defensive. Starting to lose any war can trigger this, as can your capital taking damage. A player can be said to be losing all wars if any of these are true:
- The player's capital has anything less than full health
- The player isn't doing well in a specific war. This is a very complex process to find out, but might be able to get a rough calculation of this.
*Players seem to agree 4 is best. This number, however, scales with map size as so: The quotient of the product of the maximum number of cultural cities and the greater of 4160 and the current map's number of plots, and 4160. With our players agreeing 4 is best for a culture victory, our formula would look something like this, where X is the greater of the two numbers 4160 and the current map's number of plots: (4 * X) / 4160. 4160 isn't actually a magic number, it's the number of tiles in a standard map.