local iWonder = GameInfoTypes.BUILDING_MY_WONDER; --change this one to your wonder
local tValidUnits = {[GameInfoTypes.UNIT_PROPHET]=true, [GameInfoTypes.UNIT_MISSIONARY]=true};
local iPromotion = GameInfoTypes.PROMOTION_IGNORE_TERRAIN_COST --(yes, that is the actual name of the promotion that the scout uses)
local bPlayerHasWonder = false;
function GrantWonderPromotion(iPlayer)
local pPlayer = Players[iPlayer];
for pCity in pPlayer:Cities() do --loop through the player's cities
if pCity:IsHasBuilding(iWonder) then
print("this player (ID="..iPlayer..") has the wonder");
bPlayerHasWonder = true;
end
end
if bPlayerHasWonder then --only start looping through the player's units when we know that he has the wonder!
for pUnit in pPlayer:Units() do --loop through the player's units
if not pUnit:IsHasPromotion(iPromotion) and tValidUnits[pUnit:GetUnitType()] then --if the unit does not have the promotion and is a 'valid unit'
pUnit:SetHasPromotion(iPromotion,true);
print("a unit was given the promotion");
end
end
end
bPlayerHasWonder = false; --reset the variable so we can use it in our check next time as well
end
GameEvents.PlayerDoTurn.Add(GrantWonderPromotion)