Civ IV traits in Civ V

My game crashes whenever the game configures the game data after I hit the next button in the mod menu. How do I fix this? I have never had any problems with this mod until now.
 
2 questions:
1) Is it balanced yet? I love the idea of making each civ even more unique but I don't want it to be OP
2) Is it compatible with CBP, ExCE, Piety and Prestige, CulDiv, E+D?

Thanks.
 
It's balanced and fully compatible with all of those mods.
 
Asking here to track down a potential problem I have with my Squamish mod (and a couple other civs' Traits): has anybody here encountered a conflict between Civ 4 Traits and another mod that would prevent civs not internally supported by this mod from having traits?

Everything seems to work fine when it's just this mod and a modded civ, but something in my mod collection seems to be conflicting without leaving a trace in the logs. I initially noticed this problem with my Squamish, but found out that Firebug's Almohad (which does have internal support for Traits) is having the same problem.
 
Here:

Spoiler :
Iroquois City Names
Dynamic Culture Overview
InfoAddict
CCSMM
Randomize City Names
Cultural Diversity
Cultural Diversity Soundtrack
No Spy Freeloaders
Civ IV Leader Traits in Civ V
City-State Diplomacy
Separate Great People Counters
Historical Religions Complete
CCSMM/MMR
Gibraltar, Reef, and Krakatoa Fixes
AI Fair Play BNW
Workable Mountains
Disable policy requirements for wonders
Artificial Unintelligence Lite
More Luxuries
More Pantheons
Wonder Randomizer
Scout Doesn’t Upgrade to Archer
Warrior Doesn’t Upgrade to Spearman
Afsharids
Alans
Algeria
Afghanistan
Akkad
Almohad
 
Question can I add a 3rd trait (working on ygaemp map pack trying to balance things for European powers...) like add for all European powers creative to give them extra culture... or inventive etc... basically give them the buff they need with few cities...

For example I wanted it to be like it was kind of IRL
 
Got it closer changed all native traits to defensive Diplo changed the modifier 1 to 3 for creative and spiritual and gaver creative to all euro

but question is any way to add a third trait? For example multiple traits for England France Germany rome.
 
Not without editing both the SQL table schema to allow another trait and the Lua script to pull the traits from the database and actually bestow them on the player in-game, no.
 
Hello, I've been trying to make this and my mod compatible to no avail. I have made a custom civilization and nomatter which way I try to add the entries to the database it doesn't seem to work. The latest way I've tried is downloading Stephen's compatibility mod and adding my own leader to his list, and when i do that my game doesn't crash like it normally does but it doesn't seem to apply the mod to my Leader. I've attached my mod and the modified version of Stephen's compatibility, maybe someone can help.
 

Attachments

  • Kaixa Mod (v 1).zip
    1.1 MB · Views: 186
  • Stephan's Civ4 Traits Compatibility Pack (v 10).zip
    17.3 KB · Views: 176
Find the mod's folder, and find a file called SetLeaderTraitPolicy.lua. It can be opened with a text editor like notepad.

For each civilization, you should see a block of code that looks something like this (In this case, it's the code for America):
Code:
function SetLeaderTraitAmerica (playerID)
    local player = Players[playerID]
    if player:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AMERICA then
        if not player:HasPolicy(GameInfoTypes["POLICY_EXPANSIVE_X"]) then
            player:SetNumFreePolicies(1)
            player:SetNumFreePolicies(0)
            player:SetHasPolicy(GameInfoTypes["POLICY_EXPANSIVE_X"], true)   
                    if player:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AMERICA then
                        if not player:HasPolicy(GameInfoTypes["POLICY_CHARISMATIC_X"]) then
                            player:SetNumFreePolicies(1)
                            player:SetNumFreePolicies(0)
                            player:SetHasPolicy(GameInfoTypes["POLICY_CHARISMATIC_X"], true)   

                end
            end
        end
    end
end
GameEvents.PlayerDoTurn.Add(SetLeaderTraitAmerica);

It is, ultimately, these lines:
Code:
...
            player:SetHasPolicy(GameInfoTypes["POLICY_EXPANSIVE_X"], true)   
...
                            player:SetHasPolicy(GameInfoTypes["POLICY_CHARISMATIC_X"], true)   

...
...that define America's traits.
Where you see POLICY_SOMETHING_X, you'll need to replace that with the exact name of the replacement trait you want, which can be found in the Traits.xml file. e.g. Charismatic would correspond to POLICY_CHARISMATIC_X.

You must type the trait name in with exactness, in all caps and not forgetting the _X at the end, or it will not work.
Repeat for all other civilizations that you want to change the traits of. Save, and done.
Just wanted to thank you for this response, I was wanting to alter the traits for some civ's so this is great!
 
in case someone is intereseted in code that distributes the traits randomly to the leaders at game start:

Spoiler :

Code:
local num_traits = 2 -- the amount of traits every leader should get
local traits = {"POLICY_AGGRESSIVE_X", "POLICY_CHARISMATIC_X", "POLICY_CREATIVE_X", "POLICY_DIPLOMATIC_X",
                "POLICY_EXPANSIVE_X", "POLICY_FINANCIAL_X", "POLICY_IMPERIALISTIC_X", "POLICY_INDUSTRIOUS_X",
                "POLICY_INVENTIVE_X", "POLICY_MERCANTILE_X", "POLICY_PHILOSOPHICAL_X", "POLICY_PROTECTIVE_X",
                "POLICY_SEAFARING_X", "POLICY_SPIRITUAL_X"}
local trait_icons = {["POLICY_AGGRESSIVE_X"]="[ICON_WAR]", ["POLICY_CHARISMATIC_X"]="[ICON_HAPPINESS_1]", ["POLICY_CREATIVE_X"]="[ICON_CULTURE]", ["POLICY_DIPLOMATIC_X"]="[ICON_INFLUENCE]",
                    ["POLICY_EXPANSIVE_X"]="[ICON_FOOD]", ["POLICY_FINANCIAL_X"]="[ICON_TRADE]", ["POLICY_IMPERIALISTIC_X"]="[ICON_CITY_STATE]", ["POLICY_INDUSTRIOUS_X"]="[ICON_PRODUCTION]",
                    ["POLICY_INVENTIVE_X"]="[ICON_RESEARCH]", ["POLICY_MERCANTILE_X"]="[ICON_GOLD]", ["POLICY_PHILOSOPHICAL_X"]="[ICON_GREAT_PEOPLE]", ["POLICY_PROTECTIVE_X"]="[ICON_STRENGTH]",
                    ["POLICY_SEAFARING_X"]="[ICON_GREAT_EXPLORER]", ["POLICY_SPIRITUAL_X"]="[ICON_PEACE]"}

function Distribute_Random_Traits()
    print("Distribute_Random_Traits")
    local done = false
    for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS - 1 do
        local pPlayer = Players[iPlayer]
        if pPlayer.GrantPolicy==nil then
            print("ERROR CivIV Traits Mod: You are missing a mod dll with the dummy policy fix from whoward?! No GrantPolicy function")
        else
            if pPlayer~=nil and pPlayer:IsEverAlive() then
                local traitsassigned = 0
                local failsafe = 0
                while traitsassigned<num_traits and failsafe<num_traits*25 do -- 50 tries should be enough
                    failsafe = failsafe + 1
                    local randchoice = Game.Rand(#traits,"RandomCivIV_Trait") + 1
                    local pTrait = GameInfo.Policies[traits[randchoice]]
                    local assigned = false
                    if pTrait~=nil then
                        assigned = pPlayer:GrantPolicy(pTrait.ID, true)
                        if assigned then
                            traitsassigned = traitsassigned + 1
                            done = true -- traits were assigned to at least one player, so we consider this a success I guess
                        end
                    end
                    print("giving " .. pPlayer:GetName() .. " " .. traits[randchoice] .. ", success:"..tostring(assigned))
                end
            end
        end
    end
    return done
end

-- reflect the assigned traits in leader names
function UpdateLeaderNames() -- of course this will display wrong icons, if we have the same leader more than once! but I guess tere is no solution for it, so simply dont play with the same leader twice
    print("UpdateLeaderNames")
    local localelanguage = "Language_" ..Locale.GetCurrentLanguage().Type;
    local You = Locale.ConvertTextKey("TXT_KEY_YOU")
    local tquery = {}
    local iActivePlayer = Game.GetActivePlayer()
    for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS - 1 do
        local pPlayer = Players[iPlayer]
        if pPlayer~=nil and pPlayer:IsEverAlive() then
            local icons = ""
            for traitpolicy, icon in pairs(trait_icons) do
                local pPoliciy = GameInfo.Policies[traitpolicy]
                if pPoliciy~=nil and pPlayer:HasPolicy(pPoliciy.ID) then
                    icons = icons .. icon
                end
            end
            if icons~="" then
                local leaderinfo = GameInfo.Leaders[pPlayer:GetLeaderType()]
                local leadertype = leaderinfo.Type
                local leadername = Locale.ConvertTextKey(leaderinfo.Description)
                table.insert(tquery,"UPDATE "..localelanguage.." SET Text = '".. leadername..icons .."' WHERE Tag = 'TXT_KEY_"..leadertype.."'")
                if iPlayer==iActivePlayer then -- not sure if the "you" txt key also should be updated...
                    table.insert(tquery,"UPDATE "..localelanguage.." SET Text = '".. You..icons .."' WHERE Tag = 'TXT_KEY_YOU'")
                end
            end
        end
    end
    for i, iQuery in pairs(tquery) do
        print ("Changing Leadernames: " .. i .. "/" .. #tquery );
        for result in DB.Query(iQuery) do
        end
    end
    Locale.SetCurrentLanguage( Locale.GetCurrentLanguage().Type )
end

local g_SaveData = Modding.OpenSaveData();
function OnSequenceGameInitComplete()
   print("OnSequenceGameInitComplete")
    Events.SequenceGameInitComplete.Remove(OnSequenceGameInitComplete); -- only call this once
    local bInit = g_SaveData.GetValue("CivIVRandomTraits_Distributed");
   if not bInit then
       g_SaveData.SetValue("CivIVRandomTraits_Distributed", Distribute_Random_Traits());
   end
    UpdateLeaderNames() -- update the leader names. this has to be done after every game load, so we dont check bInit for it.
end

Events.SequenceGameInitComplete.Add( OnSequenceGameInitComplete );


It uses the "GrantPolicy" Method from whowards dll, this needs CustomModOptions "BUGFIX_DUMMY_POLICIES" enabled, which is not currently in community patch dll.
But you can also replace GrantPolicy by the old way assigning dummy policies, like it is done in Leader_Traits.lua.
Of course you should disable the sql code that hardcodes traits first.

The code will distribute num_traits (2) traits to each major player and then changes their leadername string accordingly. This works for most leadername strings, but not for all, eg in the diplomatic overview they are missing, but that is not such a big deal I think.
 
Top Bottom