[Help wanted]Please, help with little customization!

I have another set of questions:
1. How can I show policy "Strategy" and "Civilopedia" entries for Authocracy, Order and Freedom policies? Like for Tradition, Honor, etc? (Full game version with all extensions)
2. Is there a way to set faith purchase for space ship components with level 3 policy?
3. How can I apply to some building such bonus: +1 to minimum SS influence level?
 
1) Not sure what you mean, but these entries appear under the 'Policies' tab in the civilopedia.
2) The 'Allows purchasing of Great Engineers upon entering the industrial era' from the Tradition finisher looks like it might almost do what you want, though I couldn't find how Firaxis coded this... (maybe it's hardcoded?). Next way I could think of is to add a 'fake spaceship part' that costs faith but cannot be produced (similar to how missionaries work), and use Lua and GameEvents.PlayerCanTrain(...). I'm not sure how this GameEvent interacts with (faith) purchasing though, so that's something you'd have to test. Then, once the fake spaceship spawns, replace it by the normal spaceship unit.
3) I don't get what you mean by +1 minimum SS influence level? Is it City State influence? If yes, that'd require use of dummy policies (the Patronage branch provides policies that raise this minimum level for example)

For the question in your first post, find out which .dds files these icons are taken from. Then, in your own mod, add a .dds file with the same name as the name of the icons you want to replace and set VFS=true for that file. Your new .dds file will replace the old one now.
 
1) Not sure what you mean, but these entries appear under the 'Policies' tab in the civilopedia.
2) The 'Allows purchasing of Great Engineers upon entering the industrial era' from the Tradition finisher looks like it might almost do what you want, though I couldn't find how Firaxis coded this... (maybe it's hardcoded?). Next way I could think of is to add a 'fake spaceship part' that costs faith but cannot be produced (similar to how missionaries work), and use Lua and GameEvents.PlayerCanTrain(...). I'm not sure how this GameEvent interacts with (faith) purchasing though, so that's something you'd have to test. Then, once the fake spaceship spawns, replace it by the normal spaceship unit.
3) I don't get what you mean by +1 minimum SS influence level? Is it City State influence? If yes, that'd require use of dummy policies (the Patronage branch provides policies that raise this minimum level for example)

For the question in your first post, find out which .dds files these icons are taken from. Then, in your own mod, add a .dds file with the same name as the name of the icons you want to replace and set VFS=true for that file. Your new .dds file will replace the old one now.

Thanks for answer!

1. Solved this by myself.
2. It's too complex for me right now) May be sometime later on
3. Yes, City-States. It was my typo. I don't understand how to merge building construction and dummy policy(( May be you could provide me some example? The goal is: every time certain building appears in city, minimum influence level to all CS raised by 1 point. +4 for four buildings in four cities and so on
4. I found two files: ChooseIdeologyPopup.lua and ChooseIdeologyPopup.xml
In XML file there are those lines:
Spoiler ChooseIdeologyPopup.xml :

<Stack Offset="10,75" StackGrowth="Right" Padding="5">
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="64,0" ID="CultureVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="0,64" ID="DiplomaticVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="64,64" ID="DominationVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="0,0" ID="ScienceVictory" />
</Stack>

And in LUA file:
Spoiler ChooseIdeologyPopup.lua :

local ideologies = {
{
PolicyBranchType = "POLICY_BRANCH_AUTOCRACY",
VictoryTypes = {"DiplomaticVictory", "DominationVictory", "ScienceVictory"},
Image = "SocialPoliciesAutocracy.dds",
ImageOffsetX = 0,
ImageOffsetY = 20,
},
{
PolicyBranchType = "POLICY_BRANCH_FREEDOM",
VictoryTypes = {"CultureVictory", "DiplomaticVictory", "ScienceVictory"},
Image = "SocialPoliciesFreedom.dds",
ImageOffsetX = 0,
ImageOffsetY = 0,
},
{
PolicyBranchType = "POLICY_BRANCH_ORDER",
VictoryTypes = {"CultureVictory", "DominationVictory", "ScienceVictory"},
Image = "SocialPoliciesOrder.dds",
ImageOffsetX = 0,
ImageOffsetY = 0,
}
}

What I want is to add two new types of victores from Extra Victory Conditions mod (economic and religious) and show them on "choose-ideology-popup" screen. I have two dds-images of these types and replace ChooseIdeologyPopup.xml with my version with this adding:
Spoiler ChooseIdeologyPopup.xml :

<Stack Offset="10,75" StackGrowth="Right" Padding="5">
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="64,0" ID="CultureVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="0,64" ID="DiplomaticVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="64,64" ID="DominationVictory"/>
<Image Size="64,64" Texture="VictoryConditions_64_Shared.dds" TextureOffset="0,0" ID="ScienceVictory" />
<Image Size="64,64" Texture="Victory_Religious.dds" TextureOffset="0,0" ID="ReligionVictory" />
<Image Size="64,64" Texture="Victory_Economic.dds" TextureOffset="0,0" ID="EconomicVictory" />
</Stack>


I also add new victories to ChooseIdeologyPopup.lua. And it works, but.... two new images adds to all thre line as one image, even if I don't want it:

What am I doing wrong?
 
2. It's too complex for me right now) May be sometime later on
See the Lua Reference Vault for an example (it's all the way down)

3. Yes, City-States. It was my typo. I don't understand how to merge building construction and dummy policy(( May be you could provide me some example? The goal is: every time certain building appears in city, minimum influence level to all CS raised by 1 point. +4 for four buildings in four cities and so on
It's a Lua-intensive method (and only works as the buildings have a global effect as policies are global too!), but it works.
The basic idea is that you grant free policies using a trick that does not increase policy costs. As there's no way to remove that policy without decreasing policy costs, what you could do is swap it out for another dummy policy (as removing and then adding another policy does not change the policy costs). In order to limit the number of policies you'll need, people add the policies in binary format (assuming that the policy effect stacks!). I.e. dummy1 adds 1 influence, dummy2 adds 2 influence, dummy 3 adds 4 influence, dummy 4 adds 8 influence, etc.
You can find a more extended explanation in the Lua Reference Vault
Here's part of the code for a Monaco civ that I wrote a while ago. It makes Great People maintenance free (based upon a binary-policy effect). With minor changes, it'll do exactly what you need. (It's a more extended example of what is basically done in the reference vault)
Spoiler :

Code:
-- RKT_Mon_UA
-- Author: Troller001
-- DateCreated: 12/21/2016 9:30:44 PM
--------------------------------------------------------------
print("RKT_Mon_UA.lua was loaded!");
--Allows the UA of Monaco to function
--Know bug: The culture gained from the UA does not show up in the toppanel.
--Bonus UA Tourism is applied up to a maximum of 255 Tourism (which corresponds to 2550 GPT)
--Up to a maximum of 63 Great People can be Maintenance Free

local iMon = GameInfoTypes.CIVILIZATION_RKT_MONACO;
--snip
local tFreeGP = {GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_1,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_2,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_4,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_8,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_16,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_32}
local tFreeGPDummy = {GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_1,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_2,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_4,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_8,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_16,GameInfoTypes.POLICY_RKT_NO_MAINTENANCE_DUMMY_32}

function CalculateMonUA(iPlayer)
    local pPlayer = Players[iPlayer];
    if pPlayer:GetCivilizationType() == iMon then
        print("-------------UA: Playground of the Rich and Famous-------------------")
       --snip
        UpdateFreeGPPolicies(iPlayer);
      --snip
        print("-------------UA check done ------------------------------------------");
    end
end

--snip

function UpdateFreeGPPolicies(iPlayer)
    local iNumGreatPeople = CountGreatPersonType(iPlayer,-1)
    SetFreeGPPolicies(iPlayer,iNumGreatPeople);
end

function SetFreeGPPolicies(iPlayer,iNumGreatPeople)
    print("--------------Setting appropriate dummy policies for GP--------------")
    local pPlayer = Players[iPlayer]
    local tNumGreatPeople = toBits(iNumGreatPeople);
    for i=1,6,1 do
        print("Policy "..i.." set to: "..tNumGreatPeople[i])
        print("Dummy Policy "..i.." set to: "..math.abs(tNumGreatPeople[i]-1))

        if tNumGreatPeople[i]==0 then
            pPlayer:SetHasPolicy(tFreeGP[i], false)
            pPlayer:SetHasPolicy(tFreeGPDummy[i], true)
            --in order for the 'policy swap trick' to work, a policy needs to be set to 'false'
            --FIRST; it won't work the other way around (this prevents policy costs from increasing
            --when swapping (or setting and unsetting) dummy policies)
        else
            pPlayer:SetHasPolicy(tFreeGPDummy[i], false)
            pPlayer:SetHasPolicy(tFreeGP[i], true)
        end
    end

    print("--------------Policy Update Done-------------------------------------");
end

function CheckMonacoGPChange(iPlayer,iUnit,_,_,_,bDelay)
    --only execute once (bDelay prevents this code from firing twice)
    if not bDelay then
        local pPlayer = Players[iPlayer];
        if pPlayer:GetCivilizationType() == iMon then
            local pUnit = pPlayer:GetUnitByID(iUnit);
            if pUnit:IsGreatPerson() then
                print("A Monacon Great Person was expended or killed!");
                local iNumGreatPeople = CountGreatPersonType(iPlayer,-1)
                print((iNumGreatPeople-1).." Great People are sent to 'SetFreeGPPolicies'. ("..iNumGreatPeople.." were actually counted)");
                SetFreeGPPolicies(iPlayer,iNumGreatPeople-1);
                -- '-1' since CountGreatPersonType also counts the Great Person that just died!
            end
        end
    end
end

function CheckMonacoGPSpawn(iPlayer, iUnit)
    local pPlayer = Players[iPlayer];
    if pPlayer:GetCivilizationType() == iMon then
        local pUnit = pPlayer:GetUnitByID(iUnit);
        if pUnit:IsGreatPerson() then
            print("A Monacon Great Person Spawned! (or embarked, or upgraded, or sth else, but that doesn't matter anyways for this function!");
            local iNumGreatPeople = CountGreatPersonType(iPlayer,-1)
            SetFreeGPPolicies(iPlayer,iNumGreatPeople);
        end
    end
end

--for the GameEvents check the bottom of this file
-------------------

--counts all Great People with a specific type; Use -1 to count all Great People regardless of type
function CountGreatPersonType(iPlayer,iGPType)
    local pPlayer = Players[iPlayer];
    local iNumGreatPeople = 0;
 
    for pUnit in pPlayer:Units() do
        if iGPType == -1 then
            if pUnit:IsGreatPerson() then
                iNumGreatPeople = iNumGreatPeople + 1;
            end
        else
            if pUnit:GetUnitType() == iGPType then
                iNumGreatPeople = iNumGreatPeople + 1;
            end
        end
    end
    print(pPlayer:GetName().."("..iPlayer..") currently has "..iNumGreatPeople.." Great People alive in the empire");
    return iNumGreatPeople;
end


--grants the initial dummy policies (used for maintenance free great people) to
--every player, so that they still start with the same scores
function GrantInitialDummies()
    print("------------Distributing Dummy Policies-------------")
    for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
        local pPlayer = Players[iPlayer]
        --if the player exists, i.e. if the player is currently active/in the game
        if pPlayer ~= nil then
            if pPlayer:IsEverAlive() then
                --execute once for each of the 'bit'-policies
                for i=1,6,1 do
                    --the 'free policy trick' so that policy cost does not increase when granting dummy policies
                    pPlayer:SetNumFreePolicies(1)
                    pPlayer:SetNumFreePolicies(0)
                    pPlayer:SetHasPolicy(tFreeGPDummy[i], true)
                end
                print("Dummy (non-buffing) Policies given to "..pPlayer:GetName())
            end
        end
    end
    print("----------------------------------------")
end

function toBits(num)--UltimatePotato's toBits
    -- returns a table of bits, least significant first.
    t={} -- will contain the bits
    while num>0 do
        local rest=math.fmod(num,2)
        t[#t+1]=rest
        num=(num-rest)/2
    end
 
    for i=1,8,1 do
        if(t[i]==nil)then
            t[i]=0
        end
    end

    return t
end

--whoward's IsCivInPlay
function IsCivInPlay(iCivType)
  for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
    local iSlotStatus = PreGame.GetSlotStatus(iSlot)
    if (iSlotStatus == SlotStatus.SS_TAKEN or iSlotStatus == SlotStatus.SS_COMPUTER) then
      if (PreGame.GetCivilization(iSlot) == iCivType) then
        return true
      end
    end
  end
 
  return false
end

----------------------

if IsCivInPlay(iMon) then
    print("Monaco is in play!");
    GrantInitialDummies();
    GameEvents.PlayerDoTurn.Add(CalculateMonUA);
    GameEvents.UnitPrekill.Add(CheckMonacoGPChange)
    Events.SerialEventUnitCreated.Add(CheckMonacoGPSpawn)
end


---------------------------------------------------------------------

This is from the same Lua file as you referenced (but a few more lines downwards in the code):
Code:
            itemInstance.CultureVictory:SetHide(true);
            itemInstance.DiplomaticVictory:SetHide(true);
            itemInstance.DominationVictory:SetHide(true);
            itemInstance.ScienceVictory:SetHide(true);
    
            for _, victoryControl in ipairs(ideology.VictoryTypes) do
                print(victoryControl);
                itemInstance[victoryControl]:SetHide(false);
            end
What this does is that it first hides every image (as they're shown by default). After that it makes an ideology's VictoryTypes visible. I.e. those defined in the list of the Lua file you provided.
You can fix your problem by replacing the Lua file as well. More specifically change up these sections:
Code:
--[..]SNIPPED[..]

local ideologies = {
        {
            PolicyBranchType = "POLICY_BRANCH_AUTOCRACY",
            VictoryTypes = {"CultureVictory", "DiplomaticVictory", "DominationVictory", "ReligionVictory"}, --EDIT: Relgion victory recommendation added.
            Image = "SocialPoliciesAutocracy.dds",
            ImageOffsetX = 0,
            ImageOffsetY = 20,
        },
        {
            PolicyBranchType = "POLICY_BRANCH_FREEDOM",
            VictoryTypes = {"CultureVictory", "DiplomaticVictory", "ScienceVictory", "EconomicVictory"}, --EDIT: Economic Victory recommendation added
            Image = "SocialPoliciesFreedom.dds",
            ImageOffsetX = 0,
            ImageOffsetY = 0,
        },
        {
            PolicyBranchType = "POLICY_BRANCH_ORDER",
            VictoryTypes = {"CultureVictory", "DominationVictory", "ScienceVictory"},
            Image = "SocialPoliciesOrder.dds",
            ImageOffsetX = 0,
            ImageOffsetY = 0,
        }        
    }

--[..]SNIPPED[..]

          itemInstance.CultureVictory:SetHide(true);
            itemInstance.DiplomaticVictory:SetHide(true);
            itemInstance.DominationVictory:SetHide(true);
            itemInstance.ScienceVictory:SetHide(true);
           itemInstance.ReligionVictory:SetHide(true); --EDIT: hide the religion icon by default
           itemInstance.EconomicVictory:SetHide(true); --EDIT: hide the economic icon by default
    
            for _, victoryControl in ipairs(ideology.VictoryTypes) do
                print(victoryControl);
                itemInstance[victoryControl]:SetHide(false);
            end

--[..]SNIPPED[..]

(And of course also override the .xml file which were already doing)

5. Where could I find VictoryConditions_64_Shared.dds ? Seems like it is in some archive, but where?
It's packed in one of the .fpk files. Here's how to actually get the .fpk files and how to unpack them:
https://forums.civfanatics.com/threads/unpacking-the-fpk.386385/
https://forums.civfanatics.com/threads/dds-unpacker-for-interface-textures.389316/
 
Last edited:
5. It works!!! Thank you!!! I were one step close to solve it, but you are awesome!

3. Well, will see it later)) Thanks!

So, Troller0001, if you are so skilled in modding, could you please help me to fix two little (realy!) mods? I can't find its author for about a month (he seem to be off more than a year ago). His name is RuNeLess and his mods are very good, but have some bugs. And I don't skilled enough to fix them)
 
So, Troller0001, if you are so skilled in modding, could you please help me to fix two little (realy!) mods? I can't find its author for about a month (he seem to be off more than a year ago). His name is RuNeLess and his mods are very good, but have some bugs. And I don't skilled enough to fix them)
If you post the issues here I'll see what I can do. (Also depends on how 'clean' Runeless's code is, as I won't dig through giant piles of spaghetti; I have my own mods for that! :p)
 
Well...
1. http://steamcommunity.com/sharedfiles/filedetails/?id=564077824
Great mod, than adds fourth ideology. Works almost well, except the last policy Pentecost, that seems to be corrupted, because nothing happens, when I adopt it
2. http://steamcommunity.com/sharedfiles/filedetails/?id=622392837
This mods add new elements to Civilopedia, nut has severral issues:
a) for Atomic Bomb, Nuclear Missile, and all Spaceship Parts in Pedia pages are empty
b) pages for militaristic city-states are empty
c) also on CS-pages table "happiness per luxury" always display 0
These issues very disappoint me( I want to improve them and include in my future EE-pack, but can not do it without fixes)
 
I checked out the code for 1) and this is what I found:
Spoiler :

Code:
function Tokata_FundamentalismAdoptPolicy(playerID, policyID)
    local pPlayer = Players[playerID]
    --snip (other policy)
 
    -- Pentecost
    if (policyID == GameInfo.Policies["POLICY_PENTECOST"].ID) then
        print("CheckpointA")
        for plotLoop = 0, Map.GetNumPlots() - 1, 1 do
            local pPlot = Map.GetPlotByIndex(plotLoop)
            local pOwner = Players[pPlot:GetOwner()]
            if (pOwner == pPlayer) then
                print("CheckpointB")
                if (pPlot:GetImprovementType() == GameInfoTypes["IMPROVEMENT_HOLY_SITE"]) then
                    local bUnit = false
                    if (pPlayer:IsHuman()) then
                        local pUnit = pPlot:GetUnit(0)
                        if (pUnit ~= nil) then
                            if (pUnit:IsCombatUnit()) then
                                bUnit = true
                                pUnit:Kill()
                            end
                        end
                    else
                        bUnit = true
                    end
                    if (bUnit == true) then
                        -- Get random great person
                        local nRandom = math.random(0, 4)
                        local iGreatPerson = GameInfoTypes["UNIT_GREAT_GENERAL"]
                        local iUnitAI = UNITAI_GENERAL
                        if (nRandom == 0) then
                            iGreatPerson = GameInfoTypes["UNIT_ARTIST"]
                            iUnitAI = UNITAI_ARTIST
                        elseif (nRandom == 1) then
                            iGreatPerson = GameInfoTypes["UNIT_WRITER"]
                            iUnitAI = UNITAI_WRITER
                        elseif (nRandom == 2) then
                            iGreatPerson = GameInfoTypes["UNIT_MUSICIAN"]
                            iUnitAI = UNITAI_MUSICIAN
                        end
                        local NewUnit = pPlayer:InitUnit(iGreatPerson, pPlot:GetX(), pPlot:GetY(), iUnitAI, DirectionTypes.DIRECTION_WEST)
                        -- NewUnit:JumpToNearestValidPlot()
                        -- Send Notification
                        Tokata_FundamentalismGreatPersonNotification(pPlayer, iGreatPerson, pPlot)
                    end
                end
            end
        end
    end
 
    --snipped comment
end
GameEvents.PlayerAdoptPolicy.Add(Tokata_FundamentalismAdoptPolicy)

--snipped code
function Tokata_FundamentalismGreatPersonNotification(pPlayer, iGreatPerson, pPlot)
    local nameGreatPerson = GameInfo.Units[iGreatPerson].Description
    local pCity = pPlot:GetPlotCity()
    if (pCity ~= nil) then
        local nameCity = pCity:GetName()
        local strGreatPerson = Locale.ConvertTextKey("TXT_KEY_TOKATA_FUNDAMENTALISM_GREAT_PERSON_A_TEXT", nameGreatPerson, nameCity)
    else
        local strGreatPerson = Locale.ConvertTextKey("TXT_KEY_TOKATA_FUNDAMENTALISM_GREAT_PERSON_B_TEXT", nameGreatPerson)
    end
    local strGreatPersonHeading = Locale.ConvertTextKey("TXT_KEY_TOKATA_FUNDAMENTALISM_GREAT_PERSON_HEADING")
    pPlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERICkk, strGreatPerson, strGreatPersonHeading, pPlot:GetX(), pPlot:GetY())
end


I'm not sure what exactly causes the thing to not work (as I've not tested it myself), but there are definitely some issues.
  • The use of math.random instead of Game.Rand(..). math.random causes desyncs in Multiplayer and should generally be replaced by Game.Rand().
  • Nothing happens if math.random(..) >2! As you can see, nothing is defined for when this happens! When math.random(..)>2, a Great General is spawned (and as such has a higher chance of spawning compared to the other units
  • math.random() is never seeded using math.randomseed(..), meaning that you will get the same 'random' order every time you play. (Game.Rand() is seeded automatically by the game)
  • The lines similar to "iUnitAI = UNITAI_ARTIST" have the issue that UNITAI_ARTIST is never defined. It should've been GameInfoTypes.UNITAI_ARTIST. (It is interpreted as 'nil' now).
  • The last two parameters of :InitUnit(..) are optional, so they could've been omitted (as the new unit gets the default unitAI anyways)
  • 'pOwner == pPlayer'. It's generally better to avoid comparing pointers!
  • I have no idea what the author wants with the IsHuman() check as the same should happen for the AI and the human player
  • The author loops over every plot on the map, while it would be more efficient to loop over all of the player's units. (Avoid looping over the entire map if possible)
  • local pUnit = pPlot:GetUnit(0) only checks the first unit on a plot (which works if there can only be at most 1 civilian unit on a tile in all instances)
  • possibly even more stuff I missed
I'm almost entirely sure this line causes an error:
pPlayer:AddNotification(NotificationTypes.NOTIFICATION_GENERICkk, strGreatPerson, strGreatPersonHeading, pPlot:GetX(), pPlot:GetY()) as NOTIFICATION_GENERICkk does not exist! (simply remove the kk)

Note that this is all feedback/friendly criticism, and no hate against the author of the mod! :)

EDIT: Here is a version of the functions that I suppose should work. I have not tested it however, but that can easily be done quickly using IGE. (The error in the Notification-function should still be removed, though that's not reflected in the code below)
Spoiler :

Code:
------------------------------------------------------------------------------------------------------
-- When player adopt a policy
------------------------------------------------------------------------------------------------------
--local variables added by Troller0001
local iPentecost = GameInfoTypes.POLICY_PENTECOST;
local iReligiousArt = GameInfoTypes.POLICY_RELIGIOUS_ART;
local tGreatPeople = {GameInfoTypes.UNIT_GREAT_GENERAL, GameInfoTypes.UNIT_ARTIST,GameInfoTypes.UNIT_WRITER,GameInfoTypes.UNIT_MUSICIAN}
local iHolySite = GameInfoTypes.IMPROVEMENT_HOLY_SITE;

--Function was Fixed and Edited by Troller0001 (with regards to the Pentecost Policy)
function Tokata_FundamentalismAdoptPolicy(iPlayer, iPolicy)
    local pPlayer = Players[iPlayer];
    if (iPolicy == iReligiousArt) then
        -- Religious Art
        Tokata_FundamentalismReligiousArt(iPlayer); --I did not check this function for bugs/issues
    elseif (iPolicy == iPentecost) then
        --pentecost
        print("Pentecost adopted")
        --loop through all of the player's units
        for pUnit in pPlayer:Units() do
            local pPlot = pUnit:GetPlot();
            if pPlot:GetOwner() == iPlayer and pPlot:GetImprovementType() == iHolySite then
                --plot is owned by the player who just adopted the policy AND the plot contained a Holy Site
                print("Unit was in player terrritory on a Holy Site")
                if pUnit:IsCombatUnit() then
                    print("Unit was not a civilian unit; killing it off and replacing it...");
                    pUnit:Kill();
                    --select a random unit from the table (units can simply be added and removed to it without editing this statement)
                    local iRandomUnit = tGreatPeople[Game.Rand(#tGreatPeople,"")+1];
                    --Game.Rand(value,msg) chooses an integer number between 0 and value-1. 
                    local pNewUnit = pPlayer:InitUnit(iRandomUnit, pPlot:GetX(), pPlot:GetY());
                    print("Unit was spawned!");
                    Tokata_FundamentalismGreatPersonNotification(pPlayer, iRandomUnit, pPlot);
                end
            end
        end
    end
end
GameEvents.PlayerAdoptPolicy.Add(Tokata_FundamentalismAdoptPolicy)
 
Last edited:
PlayerAdoptPolicy doesn't fire for opening a Policy Branch nor as I recall for the Policy Branch "finisher" being given. Which may be the issue with the code not seeming to work for the POLICY_PENTECOST, if it is either an opener or a finisher.
 
PlayerAdoptPolicy doesn't fire for opening a Policy Branch nor as I recall for the Policy Branch "finisher" being given. Which may be the issue with the code not seeming to work for the POLICY_PENTECOST, if it is either an opener or a finisher.
It's a level 3 Tenet of an ideology that was added, so neither an opener nor a finisher ;)
 
Top Bottom