Formulapower
Warlord
- Joined
- Nov 5, 2007
- Messages
- 148
I am trying to give a single civ a specific tech on a specific turn. I have tried everything I can think of but still get nothing to work. Can any one advise/help?
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CIVNAMEGOESHERE) then
if (Game.GetGameTurn() == x) then
Teams[pPlayer:GetTeam()]:SetHasTech(GameInfoTypes.TECH_TECHNAMEGOESHERE, true)
end
end
end)
although then it would fire every turn thereafter.
function CustomFunction(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CIVNAMEGOESHERE) then
if (Game.GetGameTurn() == x) then
Teams[pPlayer:GetTeam()]:SetHasTech(GameInfoTypes.TECH_TECHNAMEGOESHERE, true)
end
end
GameEvents.PlayerDoTurn.Remove(CustomFunction)
end
[COLOR="blue"][B]bTechGiven = false[/B][/COLOR]
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CIVNAMEGOESHERE) then
if (Game.GetGameTurn() == x) [COLOR="blue"][B]and not bTechGiven[/B][/COLOR] then
Teams[pPlayer:GetTeam()]:SetHasTech(GameInfoTypes.TECH_TECHNAMEGOESHERE, true)
[COLOR="Blue"][B]bTechGiven = true[/B][/COLOR]
end
end
end)
The problem is that not only would it not be savegame friendly, it would also only fire for the first player that matches that particular Civ, meaning any other players also playing that Civ (AI or otherwise) would not get the tech for free, since the function has been removed by the time PlayerDoTurn runs their functions.