More Unique Components for Vox Populi

3rd and 4th Unique Components for VP - Official thread 88.10

Is it possible to disable building by sql for one civ? If you disable building classfor Armory will the dummy be accessible?
Yes, Egypt already does this.
Aztec also does this in base VP.
It will not affect our ability to put whatever building we want in a city via lua, since sql will only remove their ability to build them
What thing do you have planned for Timurids lua?
3 things I haven't gotten to work properly with the timurids lua:

1. Timurids build all buildings from captured cities in their capital immediately. This includes unique buildings, except for a few exceptions (won't build unique buildings which give unique promotions)
It's a very big code, since it has to go through each possible UB. Here's a snippet of it, just dealing with Arsenal replacements
Code:
function JewelOfTheEast (iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)
    local nPlayer = Players[iNewOwner];
    local oldOwner = Players[iOldOwner];
    local nCapital = nPlayer:GetCapitalCity()
    local city = Map.GetPlot(iX, iY):GetPlotCity();
    local title = "Jewel of the East";

    if nPlayer:GetCivilizationType() == TimuridsID  then
        if (city:GetNumBuilding(GameInfoTypes.BUILDING_ARSENAL) > 0) then
            if oldOwner:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AUSTRIA then
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_ARSENAL, 0);
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_KREPOST, 0);
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_AUSTRIA_STANDSCHUTZEN, 1);
                local descr = "Foreign architects have constructed a " .. Locale.ConvertTextKey(GameInfo.Buildings[GameInfoTypes.BUILDING_AUSTRIA_STANDSCHUTZEN].Description) .. " in your [ICON_CAPITAL] Capital!";
                nPlayer:AddNotification(NotificationTypes.NOTIFICATION_WONDER_COMPLETED, descr, title, nCapital:GetX(), nCapital:GetY(), GameInfoTypes.BUILDING_AUSTRIA_STANDSCHUTZEN, -1);

            elseif oldOwner:GetCivilizationType() == GameInfoTypes.CIVILIZATION_RUSSIA then
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_ARSENAL, 0);
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_AUSTRIA_STANDSCHUTZEN, 0);
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_KREPOST, 1);
                local descr = "Foreign architects have constructed a " .. Locale.ConvertTextKey(GameInfo.Buildings[GameInfoTypes.BUILDING_KREPOST].Description) .. " in your [ICON_CAPITAL] Capital!";
                nPlayer:AddNotification(NotificationTypes.NOTIFICATION_WONDER_COMPLETED, descr, title, nCapital:GetX(), nCapital:GetY(), GameInfoTypes.BUILDING_KREPOST, -1);

            elseif not nCapital:IsHasBuilding(GameInfoTypes.BUILDING_ARSENAL) then
                nCapital:SetNumRealBuilding(GameInfoTypes.BUILDING_ARSENAL, 1);
                local descr = "Foreign architects have constructed a " .. Locale.ConvertTextKey(GameInfo.Buildings[GameInfoTypes.BUILDING_ARSENAL].Description) .. " in your [ICON_CAPITAL] Capital!";
                nPlayer:AddNotification(NotificationTypes.NOTIFICATION_WONDER_COMPLETED, descr, title, nCapital:GetX(), nCapital:GetY(), GameInfoTypes.BUILDING_ARSENAL, -1);
            end
        end
    end
end
GameEvents.CityCaptureComplete.Add(JewelOfTheEast)
2. I planned to give the Timurid's a unique wonder which gives constant yields based in city based on the number of international trade routes that enter/leave the city:
Code:
function MadrasahTradeYields(PlayerID)
    local pPlayer = Players[PlayerID]
    if (pPlayer:IsAlive() and pPlayer:GetCivilizationType() == TimuridsID) then
        print("Trade out!");
        local Routes = pPlayer:GetTradeRoutes();
        local NumRoutes = pPlayer:GetNumInternationalTradeRoutesUsed()
        if (NumRoutes > 0) then
            for city in pPlayer:Cities() do
                local iCounter = 0;
                local cityID = city:GetID();
                local iMadrasah1 = GameInfoTypes.BUILDING_TIMURID_MADRASAH_1_MOD
                local iMadrasah2 = GameInfoTypes.BUILDING_TIMURID_MADRASAH_2_MOD
                local iMadrasah3 = GameInfoTypes.BUILDING_TIMURID_MADRASAH_3_MOD
                for tradeRouteID, tradeRoute in ipairs(Routes) do
                    local pFromCity = tradeRoute.FromCity
                    local pFromCiv = tradeRoute.FromCivilizationType
                    local pToCity = tradeRoute.ToCity
                    local pToCiv = tradeRoute.ToCivilizationType
                    local dPlayer = Players[DestPlayer]
                 
                    if ((pFromCity:GetNumBuilding(GameInfoTypes.BUILDING_TIMURID_MADRASAH_MOD) > 0) and pFromCiv ~= TimuridsID) or ((pToCity:GetNumBuilding(GameInfoTypes.BUILDING_TIMURID_MADRASAH_MOD) > 0) and pToCiv ~= TimuridsID) then
                        iCounter = iCounter + 1
                    end
                end
                if city:IsHasBuilding(iMadrasah1) then
                    city:SetNumRealBuilding(GameInfoTypes.BUILDING_TIMURID_MADRASAH_1_DUMMY, iCounter)
                end

                if city:IsHasBuilding(iMadrasah2) then
                    city:SetNumRealBuilding(GameInfoTypes.BUILDING_TIMURID_MADRASAH_2_DUMMY, iCounter)
                end

                if city:IsHasBuilding(iMadrasah3) then
                    city:SetNumRealBuilding(GameInfoTypes.BUILDING_TIMURID_MADRASAH_3_DUMMY, iCounter)
                end
            end
        end
    end
end

GameEvents.PlayerDoTurn.Add(MadrasahTradeYields)
3. The Timurids are supposed to get a dummy building which gives yields in the capital every time they raze a city. This lua doesn't seem to fire though
Code:
function CapitalBonusOnRaze(hexPos, iOldOwner, cityID, iNewOwner)
    local nPlayer = Players[iNewOwner];
    local nCapital = nPlayer:GetCapitalCity()

    if nPlayer:GetCivilizationType() == TimuridsID then
        nCapital:SetNumRealBuilding(bTimDummy, (nCapital:GetNumRealBuilding(bTimDummy) + 1))
        if nPlayer:IsHuman() and nPlayer:IsTurnActive() then
            local vCityPosition = PositionCalculator(nCapital:GetX(), nCapital:GetY())
            nPlayer:AddNotification(NotificationTypes.NOTIFICATION_INSTANT_YIELD,
                'Your Palace in [COLOR_POSITIVE_TEXT]'..nCapital:GetName()..'[ENDCOLOR] has gained more yields: +1 [ICON_CULTURE] Culture, +1 [ICON_SCIENCE] Science, +1 [ICON_GOLD] Gold, and  +1 [ICON_PRODUCTION] Production,[NEWLINE][ICON_BULLET], and +1 [ICON_WAR] Military Supply in your [ICON_CAPITAL] Capital',
                'Artisans fled to '..nCapital:GetName(),
                nCapital:GetX(), nCapital:GetY(), nCapital:GetID())
        end
    end
end

Events.SerialEventCityDestroyed.Add(CapitalBonusOnRaze)
4. Lastly, the unique improvment for the Timurids is soppused to REPLACE the village, so I need to disable their ability to create IMPROVEMENT_TRADING_POST. For some reason, the code I have posted disabled IMPROVEMENT_PASTURE.
Code:
function TimuridNoVillage (iPlayer, iUnit, iX, iY, iBuild)
    if iBuild == GameInfoTypes.IMPROVEMENT_TRADING_POST and Players[iPlayer]:GetCivilizationType() == TimuridsID then
        return false
        else return true
    end
end
 
Last edited:
The lua seems rock solid, it's a very straightforward code:
Code:
function TradeRoutesToGPPAndGold(iPlayer)
    local pPlayer = Players[iPlayer]
    numTR = pPlayer:GetNumInternationalTradeRoutesUsed()
       for pCity in pPlayer:Cities() do
           if pCity:IsHasBuilding(GameInfoTypes.BUILDING_KOREA_CHAEBOL) then
                pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_DUMMYGPPANDGOLD, numTR)
           end
        end
    end
GameEvents.PlayerDoTurn.Add(TradeRoutesToGPPAndGold)
the bonus won't be exposed to the UI though
 
@CppMaster You can check with IGE installed. If you suppose that you should have some bonus from Chaebol, then open IGE menu, click on the city and check the number of dummy buildings named: Dummy GPP and Gold or something. If code is not working then there would be no copy.
 
the bonus won't be exposed to the UI though
Oh, good to know. Is it feasible to show it in UI? I use improved city view mod.
But it would change number of turns to GP born, right?
@CppMaster You can check with IGE installed. If you suppose that you should have some bonus from Chaebol, then open IGE menu, click on the city and check the number of dummy buildings named: Dummy GPP and Gold or something. If code is not working then there would be no copy.
Ok, I'll try it.
 
I have only one such building in every city, despite having 8 international trade routes. Do TRs to a CS also count?
chaebol1.png chaebol2.png
 
Should be couned cos international exclude only internal (food and production) ones. I checked lua code. It's working but NOT as intended. Instead of counting international trade routes, it counts number of active Caravans/Cargo Ships you have. So if you have 4/5 on the top bar then the bonus give 4 in each city (you can use it for internal trade routes, no matter). IGE only shows 1 copy of the building. Even if you have 100 it shown still 1. @pineappledan Where did you get those GetInternationalTradeRoutesUsed function from? It needs to be substituted with something else.

Pushed another Github update.
Fixed proxenos. @pineappledan: look at Github/Proxenos issue.
 
Last edited:
You can check with IGE installed. If you suppose that you should have some bonus from Chaebol, then open IGE menu, click on the city and check the number of dummy buildings named: Dummy GPP and Gold or something.
IGE only shows 1 copy of the building. Even if you have 100 it shown still 1.
I'm confused. What number should I check? Other dummy buildings have multiple copies.
 
Should be couned cos international exclude only internal (food and production) ones. I checked lua code. It's working but NOT as intended. Instead of counting international trade routes, it counts number of active Caravans/Cargo Ships you have. So if you have 4/5 on the top bar then the bonus give 4 in each city (you can use it for internal trade routes, no matter). IGE only shows 1 copy of the building. Even if you have 100 it shown still 1. @pineappledan Where did you get those GetInternationalTradeRoutesUsed function from? It needs to be substituted with something else.
Hokath wrote that code.

I'll check the proxenos code
 
I checked it via lua print statement to be sure. You cannot have one copy having 10 TRs. Nevertheless lua function used in code returnes wrong values and need to be fixed.
 
The other option is to have the Chaebol check every TR, in a manner very similar to how my Timurid Registan is supposed to work:
Code:
function ChaebolGPP(PlayerID)
    local pPlayer = Players[PlayerID]
    for tradeRouteID, tradeRoute in ipairs(Routes) do
        local pFromCiv = tradeRoute.FromCivilizationType
        local pToCiv = tradeRoute.ToCivilizationType

        if (pFromCiv ~= pToCiv) and pFromCiv == pPlayer:GetCivilizationType() then
            iCounter = iCounter + 1
        end
    end
    for pCity in pPlayer:Cities() do
        if city:IsHasBuilding(GameInfoTypes.BUILDING_KOREA_CHAEBOL) then
            city:SetNumRealBuilding(GameInfoTypes.BUILDING_DUMMYGPP2, iCounter)
        end
    end
end

GameEvents.PlayerDoTurn.Add(ChaebolGPP)
Something like that?
 
Last edited:
Yup this could work. I can do rework of chaebol using that code and test it.

What aboutrest of civs mentioned few posts earlier?
 
Hehe, unfortunately Routes means Roads and Railroads not Trade Routes. This kind of stuff wont work. I'm trying with additional line of code:
Code:
local tTradeRoutes in pPlayer:GetTradeRoutes()
 
Last edited:
What about rest of civs mentioned few posts earlier?
I have reduced the :c5science: from faith purchases from the Madrasah.

I think it's a great mechanic, but I think Hinin is correct, it can get out of hand pretty easilly.
  • On standard speed at Medieval, a standard missionary or religious building is 200:c5faith:
  • As we had it, that translates to 40:c5science:, or 1:c5science:/5:c5faith:
  • With the Fealty opener and Pacifism, Missionaries can be lowered to 84:c5faith:, so each purchase is 1:c5science:/2:c5faith:. This is much too efficient.
At 15:c5science: per purchase, that's only 1:c5science:/6.7:c5faith:

Hehe, unfortunately Routes means Roads and Railroads not Trade Routes. This kind of stuff wont work.
 
Chaebol working! Small correction to your code and it's ok.

Maybe you should add some modifier from fealty and pacifism instead of decresing value?
 
Something I mentioned earlier that I am not certain was addressed yet - does the Morocco's Riad bonuses scale properly per trade route going out?(Scaling with gamespeed and era is obviously not necessary.) Last time I played about a week ago, it did not feel like it did. Because if not, that's a lot of gold, culture and GMP advertised, missing.

(My other worries, like the +GMP not showing in GP bar, were more minor about it.)
 
This is part of code:
Code:
for i, tradeRoute in pairs(pPlayer:GetTradeRoutes()) do
        local pCity = tradeRoute.FromCity

        if pCity:IsHasBuilding(eBuildingRiad) then

            iGain1 = 2
            iGain2 = 100
It scales but is not visible to not outspam players. We programmed it by lua so it is not visible on the bar too. We would need to add dummies to do that. I'm looking at the code:
  • we would need to clear all cities from dummies each turn,
  • then check trade routes as we do now and add one dummy for each one if it fits conditions.
  • without deleting we cannot control the number of dummies and trade routes in cities, too much values are needed and the number rise with cities. Deleting is easiest way.
  • If we do that then the counter would be adjusted each turn by dummies and gold and culture income will be shown on top bar too. It could be worth a shot.
 
Last edited:
Ok code changed on Github. Now it uses dummy buildings that adds 1GMP, 2 gold and 2 culture each. Code scans through trade routes and puts 1 copy of dummy for each tr if riad is in there too. So if city sends 3 trade routes, then there will be 3 copies. This will make values of each factor appear in top bar and GMbar in city view. There are no more notifications like before. @FoxOfWar Could you check it? I'm about to go to work on a night shift and I will not be able to test it out for few hours.
 
Last edited:
Ok code changed on Github. Now it uses dummy buildings that adds 1GMP, 2 gold and 2 culture each. Code scans through trade routes and puts 1 copy of dummy for each tr if riad is in there too. So if city sends 3 trade routes, then there will be 3 copies. This will make values of each factor appear in top bar and GMbar in city view. There are no more notifications like before. @FoxOfWar Could you check it? I'm about to go to work on a night shift and I will not be able to test it out for few hours.
Yeah, I'll see about testing it when I start my next game.
 
Ok code changed on Github. Now it uses dummy buildings that adds 1GMP, 2 gold and 2 culture each.
Adjusted dummy building so that it adds culture and gold onto the Riad itself, instead of having the yields firectly on the dummy building. This exposes the culture and gold to UI, so players can see the yields on the Riad. No way to add the GMerchant Points, but it will be a little nicer
Maybe you should add some modifier from fealty and pacifism instead of decresing value?
I'd rather not. Finding those kinds of synergiesis what humans are supposed to do in civ. The only reason we did a similar thing for the Intihuatana was because that rationalism policy is useless without observatories.

The building was just far too good at converting faith into science. Hopefully reducing it by 25% should be enough.

As for what to do with the other things people suggested changes for:
Armada - E-Swag said it's too hard for AI to use, but I think we've made the XP from spotting minimal enough, and hard enough to acheive that I don't really feel to bad about it anyways
Qadi Court - Hinin said he doesn't really like it. I agree with him, but I never really liked it in the first place, so obviously the two of us are in a minority here. Unless people have actionable items and a real snese of what they don't like, then there's nothing to change.
 
Last edited:
Back
Top Bottom