Craig_Sutter
Deity
I have two civilizations in my scenario that are derived from the no-annex particulars for Venice. They do not have "Merchant of Venice" type units. Instead, I generate ordinary Merchant units using lua in those situations where the civilizations might otherwise generate a Merchant of Venice.
Only thing is, these units do not do anything. They simply move around without either doing a trade mission nor creating an custom house. I think the same problem arises with any Merchant generated by great person points as well.
Is the AI for Venice type civs merchants hard-coded in some way? Is it the civ itself that not correctly using the merchants?
Anyway, here is the lua code I use (I don't think there should be any problem with it...)
Anyone know what could be affecting the merchants?
Only thing is, these units do not do anything. They simply move around without either doing a trade mission nor creating an custom house. I think the same problem arises with any Merchant generated by great person points as well.
Is the AI for Venice type civs merchants hard-coded in some way? Is it the civ itself that not correctly using the merchants?
Anyway, here is the lua code I use (I don't think there should be any problem with it...)
Code:
--this is to add merchants at adoption of a certain policy
function OnPolicyAdopted(playerID, policyID)
if policyID == (GameInfo.Policies["POLICY_COLLECTIVE_RULE"].ID) then
local pPlayer = Players[playerID];
if pPlayer:IsEverAlive() then
if GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pPlayer:GetCivilizationType() or
GameInfo.Civilizations.CIVILIZATION_FRANCE.ID == pPlayer:GetCivilizationType() then
local pCity = pPlayer:GetCapitalCity()
local pPlot = pCity:GetCityIndexPlot();
local Spawnunit;
local iSpawnX = pPlot:GetX();
local iSpawnY = pPlot:GetY();
Spawnunit = pPlayer:InitUnit(GameInfoTypes["UNIT_MERCHANT"], iSpawnX, iSpawnY, UNITAI_MERCHANT );
print (pCity:GetName() ,"...is spawning a Merchant from policy... ");
end
end
end
end
GameEvents.PlayerAdoptPolicy.Add(OnPolicyAdopted);
--this is to add merchants at acquisition of a certain technology
function OnTechResearched(team, tech, change)
local pPlayer
local pPlayerTeamID
--local pPlayerTeam
if (tech == (GameInfoTypes["TECH_OPTICS"])) then
for playerID=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pPlayer = Players[playerID];
if pPlayer:IsEverAlive() then
if (GameInfo.Civilizations.CIVILIZATION_PERSIA.ID == pPlayer:GetCivilizationType()) or
(GameInfo.Civilizations.CIVILIZATION_FRANCE.ID == pPlayer:GetCivilizationType()) then
local pPlayerTeamID = pPlayer:GetTeam()
if pPlayerTeamID == team then
local pCity = pPlayer:GetCapitalCity()
local pPlot = pCity:GetCityIndexPlot();
local Spawnunit;
local iSpawnX = pPlot:GetX();
local iSpawnY = pPlot:GetY();
Spawnunit = pPlayer:InitUnit(GameInfoTypes["UNIT_MERCHANT"], iSpawnX, iSpawnY, UNITAI_MERCHANT, DIRECTION_NORTHWEST );
print (pCity:GetName() ,"...is spawning a Merchant from technology... ");
end
end
end
end
end
end
GameEvents.TeamTechResearched.Add(OnTechResearched);
Anyone know what could be affecting the merchants?