Spatzimaus
Mad Scientist
All right, I'm kind of stuck on one little detail in my own mod. Here's the problem.
I've created a new Specialist type, the Priest, used in my religious buildings. A Priest gives you 1 Food, 1 Culture, 1 Happiness, and (3, 6, or 9) Favor, where Favor is my custom yield that unlocks new gods and such. That's a lot of stuff, so they should be very desirable, especially once you unlock the National Wonders that add +1 Production or +1 Gold to them as well.
The problem is that the AI doesn't think so; it doesn't know about the Happiness or Favor part, and since they don't produce Great Person Points, it thinks Priests are less useful than normal specialists. The SpecialistFlavors table doesn't seem to be used at all; while it's in the vanilla game's XML, there's no actual table declared for any vanilla specialist types, and even setting a specialist's flavor to 999 doesn't make the AI more inclined to use them. So it looks like the AI only uses the yields given (and won't include any consideration for the Happiness or Favor I add) when deciding if/when to slot one. The only time the city manager AI will slot one is if a city is set to Great Person Focus (which, again, is stupid as they don't produce GP points).
Now, I NEED the AI to use a certain number of them, both in the city manager AI for the human player and the AI players' controller as well. So I found an override method based on how CityView handles specialist slots:
And I just execute that command block within a loop that uses an equation to decide how many Priests to use based on a bunch of explicit factors. This works... for the human player. It slots a worker in the building, regardless of whether you've set the AI to manual or automatic specialist handling, and they stay there through the end of the turn, so it does exactly what I need. Similarly, TASK_REMOVE_SPECIALIST removes the specialist from a building, which I need to be able to do at the end of my mod's content to prevent things from breaking. This mechanism does what I want, for the human player's city AI, but it does NOT work, at all, for the AI-controlled players.
So is there any way to apply this, or any other method, to an AI player?
The problem seems to be that those UI commands, which require a city to be selected, can't be used for cities other than those of the active player. It just doesn't DO anything when I try it; a check immediately after the command says that there are still no Priests slotted in that city.
What's funny is that in my Alpha Centauri-based mod, the Empath specialist (+2 Food, +1 Happiness, +5 Great Empath points) is definitely used by the AI. So if I can't do this sort of hard override, I COULD just create a new great person type (say, the Great Prophet) for the Priests, and jack up their Great Person Points to a level where the AI still wants them. But I really doubt the AI will use the right number of them in this situation.
I've created a new Specialist type, the Priest, used in my religious buildings. A Priest gives you 1 Food, 1 Culture, 1 Happiness, and (3, 6, or 9) Favor, where Favor is my custom yield that unlocks new gods and such. That's a lot of stuff, so they should be very desirable, especially once you unlock the National Wonders that add +1 Production or +1 Gold to them as well.
The problem is that the AI doesn't think so; it doesn't know about the Happiness or Favor part, and since they don't produce Great Person Points, it thinks Priests are less useful than normal specialists. The SpecialistFlavors table doesn't seem to be used at all; while it's in the vanilla game's XML, there's no actual table declared for any vanilla specialist types, and even setting a specialist's flavor to 999 doesn't make the AI more inclined to use them. So it looks like the AI only uses the yields given (and won't include any consideration for the Happiness or Favor I add) when deciding if/when to slot one. The only time the city manager AI will slot one is if a city is set to Great Person Focus (which, again, is stupid as they don't produce GP points).
Now, I NEED the AI to use a certain number of them, both in the city manager AI for the human player and the AI players' controller as well. So I found an override method based on how CityView handles specialist slots:
Code:
UI.ClearSelectedCities();
UI.AddSelectedCity(pCity, pID);
Game.SelectedCitiesGameNetMessage(GameMessageTypes.GAMEMESSAGE_DO_TASK, TaskTypes.TASK_ADD_SPECIALIST, iSpecialist, iBuilding);
UI.ClearSelectedCities();
So is there any way to apply this, or any other method, to an AI player?
The problem seems to be that those UI commands, which require a city to be selected, can't be used for cities other than those of the active player. It just doesn't DO anything when I try it; a check immediately after the command says that there are still no Priests slotted in that city.
What's funny is that in my Alpha Centauri-based mod, the Empath specialist (+2 Food, +1 Happiness, +5 Great Empath points) is definitely used by the AI. So if I can't do this sort of hard override, I COULD just create a new great person type (say, the Great Prophet) for the Priests, and jack up their Great Person Points to a level where the AI still wants them. But I really doubt the AI will use the right number of them in this situation.