isau
Deity
- Joined
- Jan 15, 2007
- Messages
- 3,071
Hey guys, weird problem showing up in my mod related to the code below. Wondering if anyone can suggest a workaround.
The code below properly gives the Code of Laws civic to Gilgamesh on turn 1. It's borrowed more or less directly from code from scenario files that award free techs on turn 1.
It works fine for human players and also appears to award the tech to the AI. But then the AI never advances past Code of Laws. It just sits there the whole game without researching anything else.
The unlock government bit at the bottom isn't actually needed--I just added it in there in case that was getting the AI stuck. But it doesn't fix the issue. Nor does the SetCivicCompletedThisTurn setting. Is there something obvious I'm missing?
TBH I'd really rather do this with Modifiers anyway, so if there's an Effect for just outright awarding a specific civic someone knows of, I'd be delighted if you could point me to it. I try to avoid Lua wherever possible.
The code below properly gives the Code of Laws civic to Gilgamesh on turn 1. It's borrowed more or less directly from code from scenario files that award free techs on turn 1.
Code:
-- on turn 1 give gilgamesh code of laws civic for free
if (currentTurn == 1) then
if (sLeaderName == "LEADER_GILGAMESH") then
local pCulture:table = pPlayer:GetCulture();
pCulture:SetCivic(GameInfo.Civics["CIVIC_CODE_OF_LAWS"].Index, true);
pCulture:SetCivicCompletedThisTurn(true);
pCulture:UnlockGovernment(GameInfo.Governments["GOVERNMENT_CHIEFDOM"].Index);
pCulture:SetCurrentGovernment(GameInfo.Governments["GOVERNMENT_CHIEFDOM"].Index);
end
end
It works fine for human players and also appears to award the tech to the AI. But then the AI never advances past Code of Laws. It just sits there the whole game without researching anything else.
The unlock government bit at the bottom isn't actually needed--I just added it in there in case that was getting the AI stuck. But it doesn't fix the issue. Nor does the SetCivicCompletedThisTurn setting. Is there something obvious I'm missing?
TBH I'd really rather do this with Modifiers anyway, so if there's an Effect for just outright awarding a specific civic someone knows of, I'd be delighted if you could point me to it. I try to avoid Lua wherever possible.
