AW Arcaeca
Deus Vult
Basically for a UU I just need help with this part: How do you find all adjacent units, and how do you select a specific unit out of them?
The idea here is I'm looking for a way to make a UU receive a bonus if adjacent to cavalry (or anything else that is UNITCOMBAT_MOUNTED), sort of like the discipline promotion. But I can't find any lua functions for getting adjacent units except Unit.IsFriendlyAdjacentUnit, but that doesn't seem like exactly what I need...
Anyway, trying to use that function, I wrote up this code, but something tells me it won't work
:
I don't think it'll work because
1) assigning 2 variables to pPlayer:GetUnits() - does that even work?
2)Probably not the right function anyway, and
3) It doesn't even look like it's structured right.
But, you know, what do you more experienced coders think?
The idea here is I'm looking for a way to make a UU receive a bonus if adjacent to cavalry (or anything else that is UNITCOMBAT_MOUNTED), sort of like the discipline promotion. But I can't find any lua functions for getting adjacent units except Unit.IsFriendlyAdjacentUnit, but that doesn't seem like exactly what I need...
Anyway, trying to use that function, I wrote up this code, but something tells me it won't work

Code:
function ThisCivUUBonusAdjacentCavalry(playerID)
local pPlayer = Players[playerID]
for pUnit in pPlayer:GetUnits() do
local mUnit = pPlayer:GetUnits()
if pUnit:IsFriendlyAdjacentUnit([mUnit:GetUnitCombatType() == GameInfoTypes.UNITCOMBAT_MOUNTED]) then
pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_THIS_PROMOTION, true)
else
pUnit:SetHasPromotion(GameInfoTypes.PROMOTION_THIS_PROMOTION, false)
end
end
end
GameEvents.PlayerDoTurn.Add(ThisCivUUBonusAdjacentCavalry)
1) assigning 2 variables to pPlayer:GetUnits() - does that even work?
2)Probably not the right function anyway, and
3) It doesn't even look like it's structured right.
But, you know, what do you more experienced coders think?