So I have a script mostly working for this, with one small error that I can't seem to figure out. I have attached a screenshot so you can see what the virtue trees look like after my editing. Might has been split into 3 separate trees, one for each affinity. Once you finish one of the trees it unlocks 2 of the more advanced trees (Prosperity, Knowledge, and Industry), but until you finish one of the Might trees you cannot adopt any of the other trees.
The first tree of Might is for Supremacy, second Purity, and third Harmony.
Finishing Supremacy unlocks Knowledge and Industry.
Purity unlocks Prosperity and Industry.
Harmony unlocks Prosperity and Knowledge.
So everything about this is working, but with a small error in that Purity is unlocking Knowledge when it is not supposed to, and I cannot figure out why. Everything else I have described is working, except that. Can anyone see what I'm missing?
Code:
function CanAdoptVirtue(playerID, policyID)
local policyInfo1 = GameInfo.Policies["POLICY_INDUSTRY_1"]
local virtue1ID = policyInfo1.ID
local policyInfo2 = GameInfo.Policies["POLICY_KNOWLEDGE_1"]
local virtue2ID = policyInfo2.ID
local policyInfo3 = GameInfo.Policies["POLICY_PROSPERITY_1"]
local virtue3ID = policyInfo3.ID
local perk1 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_5"].ID;
local perk2 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_6"].ID;
local perk3 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_7"].ID;
local perk4 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_12"].ID;
local perk5 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_13"].ID;
local perk6 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_14"].ID;
local perk7 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_19"].ID;
local perk8 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_20"].ID;
local perk9 = GameInfo.PlayerPerks["PLAYERPERK_MIGHT_21"].ID;
local Player = Players[playerID];
if policyID == virtue1ID and (Player:HasPerk(perk1) and Player:HasPerk(perk2) and Player:HasPerk(perk3)) or (Player:HasPerk(perk4) and Player:HasPerk(perk5) and Player:HasPerk(perk6)) then
return true
elseif policyID == virtue1ID then
return false
elseif policyID ~= virtue1ID and policyID ~= virtue2ID and policyID ~= virtue3ID then
return true
end
if policyID == virtue2ID and (Player:HasPerk(perk1) and Player:HasPerk(perk2) and Player:HasPerk(perk3)) or (Player:HasPerk(perk7) and Player:HasPerk(perk8) and Player:HasPerk(perk9)) then
return true
elseif policyID == virtue2ID then
return false
elseif policyID ~= virtue1ID and policyID ~= virtue2ID and policyID ~= virtue3ID then
return true
end
if policyID == virtue3ID and (Player:HasPerk(perk4) and Player:HasPerk(perk5) and Player:HasPerk(perk6)) or (Player:HasPerk(perk7) and Player:HasPerk(perk8) and Player:HasPerk(perk9)) then
return true
elseif policyID == virtue3ID then
return false
elseif policyID ~= virtue1ID and policyID ~= virtue2ID and policyID ~= virtue3ID then
return true
end
end
GameEvents.PlayerCanAdoptPolicy.Add(CanAdoptVirtue);
For reference, virtue1ID is Industry, 2 is Knowledge, and 3 is Prosperity. Perk 1-3 is Industry, 4-6 is Purity, and 7-9 is Harmony.
(Note: I have set the FreePolicy on the Policy branches to nothing, so the first policy in each tree is fired in lua as a normal policy and not by policy branch. As far as I have tested this is working).