LeeS
Imperator
I've been trying to write something to check for whether there are barbarian or enemy units in plots around a city. But every plot:somemethod() that I've tried gives me either "nil" or "table 654907" or "false" even when I know for a certainty there's a barbarian unit standing on one of the plots adjacent to my capital city. I put a barbarian brute next to my capital in a test-game so I could test for detecting his presence.
I'm using this method to look through plots around a city:
is the method using pCity:GetNumCityPlots() and for i = 0, iNumPlots - 1 do, etc., just not going to be of any use?
I tried pPlot:GetUnit() with or without stuff inside the "()" and all I ever get from that is "nil" or a table reference #. The wiki isn't particularly helpful on what any of the Plot:SomeKindOfUnitSomethings() will actually give you in terms or whether it's a unit ID# or a UnitType or what exactly it gives.
This is being run as part of a PlayerDoTurn function.
PS: looking for a notification isn't going to work because AI's don't get notifications. Why would they? The game already let's AI's know everything about where everything and everyone on the map is anyway.
I'm using this method to look through plots around a city:
Code:
function CheckForBarbariansNearCity(pPlayer, pCity)
local iNumPlots = pCity:GetNumCityPlots()
for i = 0, iNumPlots - 1 do
local pPlot = pCity:GetCityIndexPlot(i)
local iPlotIndex = pPlot:GetPlotIndex() --not sure if I actually need this for anything
local plotvisible = pPlot:IsVisible(pPlayer:GetTeam(), false)
--I extracted out everything else in this function from here because it's confusing and isn't working anyway
I tried pPlot:GetUnit() with or without stuff inside the "()" and all I ever get from that is "nil" or a table reference #. The wiki isn't particularly helpful on what any of the Plot:SomeKindOfUnitSomethings() will actually give you in terms or whether it's a unit ID# or a UnitType or what exactly it gives.
This is being run as part of a PlayerDoTurn function.
PS: looking for a notification isn't going to work because AI's don't get notifications. Why would they? The game already let's AI's know everything about where everything and everyone on the map is anyway.