bouncymischa
Synthetic Genie
Okay, for a civ I'm working on I've put together this Lua code:
However, when I start a game with 3 spies, the first one spawns the building fine... but then the others don't. According to my text strings, it should be spawning the proper number of buildings, but they don't seem to be spawning correctly. Each building generates 2 happiness, but while I get 2 happiness from the first, I only get 1 from the second, and 0 from the third.
I set the buildingclass <NoLimit>true</NoLimit>, so I don't think it's that.
Is there something in the DLL that affects the spawning of buildings?
EDIT: Apparently, this may be related to the Happiness effect. I tried having each building generate 1 Gold, and got the appropriate numbers for the number of buildings. So apparently Civ doesn't like getting happiness from multiple copies of the same building?
Code:
-- Earn Happiness from spies.
local bHAPPY = GameInfoTypes.BUILDING_TH_TANUKI_PRANKS
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer];
if (pPlayer:IsAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_TH_TANUKI) then
local pCity = pPlayer:GetCapitalCity();
local iNumSpies = pPlayer:GetNumSpies();
local iNumUnassignedSpies = pPlayer:GetNumUnassignedSpies();
local iActiveSpies = iNumSpies - iNumUnassignedSpies;
print("Num Spies: " .. iNumSpies)
print("Num Spies Unassigned: " .. iNumUnassignedSpies)
print("Num Spies Active: " .. iActiveSpies)
if (pCity:GetNumBuilding(bHAPPY) > 0) then
pCity:SetNumRealBuilding(bHAPPY, 0);
end
if (iActiveSpies > 0) then
print("Spawning buildings: " .. iActiveSpies)
pCity:SetNumRealBuilding(bHAPPY, iActiveSpies);
end
end
end
end)
However, when I start a game with 3 spies, the first one spawns the building fine... but then the others don't. According to my text strings, it should be spawning the proper number of buildings, but they don't seem to be spawning correctly. Each building generates 2 happiness, but while I get 2 happiness from the first, I only get 1 from the second, and 0 from the third.
I set the buildingclass <NoLimit>true</NoLimit>, so I don't think it's that.
Is there something in the DLL that affects the spawning of buildings?
EDIT: Apparently, this may be related to the Happiness effect. I tried having each building generate 1 Gold, and got the appropriate numbers for the number of buildings. So apparently Civ doesn't like getting happiness from multiple copies of the same building?