AW Arcaeca
Deus Vult
Ain't I soooooooooooo good at Latyn? 
As the title suggests, if you can get the basic drift of my false Latin, I just have a couple quick lua inquiries:
1. I'd like to be able to access all of pPlayer's units of a specific unit type, but there doesn't seem to be any function to accomplish this. Can I use a function such as this to find all units of that unit type?
2. And then, can I return the number of units of iUnitType that pPlayer has like this?
3. By using these functions, I intend to check if the player has at least one of this unit type and it has at least 40 XP; however, would the following code check for if just one of that unit has 40 XP or if every one has 40 XP? And if it's the latter, how can I change it to the former?
4. Finally, not related as such, but is there some way to select a random city owned by pPlayer? I guess I'm just having a brain fart or something but I can't quite figure this out. :/
TIA,
AW

As the title suggests, if you can get the basic drift of my false Latin, I just have a couple quick lua inquiries:
1. I'd like to be able to access all of pPlayer's units of a specific unit type, but there doesn't seem to be any function to accomplish this. Can I use a function such as this to find all units of that unit type?
Code:
function AW_UnitIterator(pPlayer, iUnitType)
for pUnit in pPlayer:Units() do
-- Get all units of iUnitType
if (pUnit:GetUnitType() == iUnitType) then
return pUnit
end
end
end
Code:
SpecificUnit = GameInfoTypes.UNIT_VAGUE_SECRECY_IS_VAGUE
numSpecificUnit = 0
function AW_SpecificUnitNum(pPlayer)
pUnit = AW_UnitIterator_Type(pPlayer, SpecificUnit)
for mUnit in pPlayer:Units() do
if mUnit == pUnit then
numSpecificUnit = numSpecificUnit + 1
end
end
return numSpecificUnit
end
Code:
if (AW_UnitIterator(pPlayer, unitType):GetExperience() >= 40) then
4. Finally, not related as such, but is there some way to select a random city owned by pPlayer? I guess I'm just having a brain fart or something but I can't quite figure this out. :/
TIA,
AW