How do I check if the player who owns the improvement is the same as the player holding the unit......
in this lua code
----------------------------------------------------------------------------------------------------------------------------------------
function PadreRadar(playerID, unitID)
local player = Players[playerID];
local iPromotionunuID = GameInfoTypes["PROMOTION_WATCH_TOWER"]
if player:IsAlive() then
local unit = player:GetUnitByID(unitID);
if (unit:GetDomainType() == DomainTypes.DOMAIN_LAND) or (unit:GetDomainType() == DomainTypes.DOMAIN_SEA) then
if unit:IsWithinDistanceOfImprovement(GameInfoTypes.IMPROVEMENT_WATCH_TOWER, 3) then
unit:SetHasPromotion(iPromotionunuID, true)
elseif not unit:IsWithinDistanceOfImprovement(GameInfoTypes.IMPROVEMENT_WATCH_TOWER, 3) then
unit:SetHasPromotion(iPromotionunuID, false)
end
end
end
end
GameEvents.UnitSetXY.Add(PadreRadar);
in this lua code
----------------------------------------------------------------------------------------------------------------------------------------
function PadreRadar(playerID, unitID)
local player = Players[playerID];
local iPromotionunuID = GameInfoTypes["PROMOTION_WATCH_TOWER"]
if player:IsAlive() then
local unit = player:GetUnitByID(unitID);
if (unit:GetDomainType() == DomainTypes.DOMAIN_LAND) or (unit:GetDomainType() == DomainTypes.DOMAIN_SEA) then
if unit:IsWithinDistanceOfImprovement(GameInfoTypes.IMPROVEMENT_WATCH_TOWER, 3) then
unit:SetHasPromotion(iPromotionunuID, true)
elseif not unit:IsWithinDistanceOfImprovement(GameInfoTypes.IMPROVEMENT_WATCH_TOWER, 3) then
unit:SetHasPromotion(iPromotionunuID, false)
end
end
end
end
GameEvents.UnitSetXY.Add(PadreRadar);