How to check AI buildings

XelmatZe

Chieftain
Joined
Nov 5, 2010
Messages
23
Hi,

I created two new buildings and I wanted to check if the AI builds them ingame or not. Is it possible to do so? Somewhere in FireTuner? Didn´t find anything so far...

If it matters: the first building increases production from forest tiles and the second building is an oil powerplant using one oil and increases production by 20%

Thanks for your help!
 
You can loop over an AI player's cities and check for the presence of a building with City:GetNumBuilding().
Here's an example using the granary:
Code:
for i,p in ipairs(Players) do 
	if (p~=nil and not p:IsHuman()) then 
		for c in p:Cities() do
			if (c:GetNumBuilding(GameInfoTypes.BUILDING_GRANARY) > 0) then
				print(string.format("%s has a granary.",c:GetName()))
			else
				print(string.format("%s does not have a granary.",c:GetName()))
			end
		end
	end
end
 
Top Bottom