LeeS
Imperator
I think you have an extra ')' in there. See where I highlighted and double-check that you do not have too many ')' on that line.Oh man it worked! Thank you so much!
Now there's only one more thing I need help with. I've got a bit of code which checks how many AI's the player is at war with, but I'm struggling to combine it with the IncreasedWarScience solution so that it gives the policy for every warcount.
Could you perhaps take a look at it and tell me how I could do it?
Warcount:
Code:function JFD_GetNumWars(playerID) local player = Players[playerID] local numWars = 0 for otherPlayerID = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do local otherPlayer = Players[otherPlayerID] if (otherPlayer:IsAlive() and otherPlayerID ~= playerID) then if Teams[player:GetTeam()]:IsHasMet(otherPlayer:GetTeam()) then if Teams[otherPlayer:GetTeam()]:IsAtWar(player:GetTeam())[COLOR="Red"])[/COLOR] then numWars = numWars + 1 end end end end return numWars end
IncreasedWarScience:
Code:function SafavidWarTimeEffects(playerID) local player = Players[playerID] print("SafavidWarTimeEffects is running for playerID of " .. playerID) if player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_AW_SAMANID"] and player:IsEverAlive() then print("player is CIVILIZATION_AW_SAMANID") if Teams[player:GetTeam()]:GetAtWarCount(true) > 0 then print("player is at war with at least one major civilization") [COLOR="Blue"]local iNumWars = JFD_GetNumWars(playerID)[/COLOR] if not player:HasPolicy(GameInfoTypes["POLICY_SAFAVID_DUMMY"]) then print("player does NOT have POLICY_SAFAVID_DUMMY") print("the policy will be added for the player") player:SetNumFreePolicies(1) player:SetNumFreePolicies(0) player:SetHasPolicy(GameInfoTypes["POLICY_SAFAVID_DUMMY"], true) end else print("player is NOT at war with any major civilization") if player:HasPolicy(GameInfoTypes["POLICY_SAFAVID_DUMMY"]) then print("player had the POLICY_SAFAVID_DUMMY but it will now be removed") player:SetHasPolicy(GameInfoTypes["POLICY_SAFAVID_DUMMY"], false) end end else print("player is NOT CIVILIZATION_AW_SAMANID") end end GameEvents.PlayerDoTurn.Add(SafavidWarTimeEffects) print("IncreasedWarProduction.lua loaded all the way to the end")
The trouble you will have is that regardless of 'getting' the number of civs a player is at war with, you can only give the same policy to the player once. You cannot 'stack-up' copies of the same policy. Hence that other thing that I linked to earlier.