Getting AI to build improvements outside of their lands

crawf0rd

The One and Only
Joined
Jan 30, 2012
Messages
483
In my current project, I have it so tile improvements are buildable outside of your territory, and building the improvement grants you the tile. Problem being, I can't seem to comment my way to getting the AI to try building outside of their territory. Any C++ gurus have any suggestions?
 
Have you tried changing CvBuilderTaskingAI::EvaluateBuilder?

This line:
m_aiPlots = m_pPlayer->GetPlots()
should be what you need. m_aiPlots are the plots the AI will check and here we set it to the plots the player own. You'll need to figure out a way to include plots the player doesn't own but might want to improve, maybe by using and extending m_aiNonTerritoryPlots? (also checked in that function, but only for roads).

I'm not sure if changing that function will be enough but it would be a start.
 
Have you tried changing CvBuilderTaskingAI::EvaluateBuilder?

This line:
m_aiPlots = m_pPlayer->GetPlots()
should be what you need. m_aiPlots are the plots the AI will check and here we set it to the plots the player own. You'll need to figure out a way to include plots the player doesn't own but might want to improve, maybe by using and extending m_aiNonTerritoryPlots? (also checked in that function, but only for roads).

I'm not sure if changing that function will be enough but it would be a start.

Ok I'll give that a try thanks!
 
The Portuguese improvement is built outside their lands by default... maybe check out its xml.

I've looked there; the code there is just for improving coastal city state tiles unfortunately. Thanks for your reply though!
 
Back
Top Bottom