1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Jarcast's The Etruscans for VP

Discussion in 'Mods Repository' started by jarcast2, Apr 8, 2020.

  1. jarcast2

    jarcast2 Warlord

    Joined:
    Jan 10, 2018
    Messages:
    106
    Location:
    Gallia Belgica

    Hi everyone. I am opening this thread to discuss the VP compatibility of my new mod, and specifically for 3 reasons.

    1) as I did not play VP for long I may have fallen behind in terms of updates and feeatures so I need feedbacks on how to balance the mod: is it weak? is it strong? how can it be adjusted?

    2) need input for 3rd and 4th components.
    For now I thought about adding a trireme replacement
    Spoiler 3rd component :
    Pisaeus war galley
    (Pisaeus was a legendary Etruscan said to have invented the rostrum, a ram lately adopted by the Romans. Pisaeus also gave its name to the city of Pisa)

    Has +1 movement and can enter rival territory
    Can Plunder Fishing boats and Sea Trade routes even in Peace time gaining Gold and 15XP.
    For the 4th component I was thinking about something synergizing with "artist points" part of the UA, so maybe a Necropolis that has the possibility to spawn a Great Work of Art or Artifact when a great person is expended (= an elite person dies).

    3) need some lua help because the Bucchero luxury resource does not look the be improved correctly even though IsMonopoly is set to 1. When a town is created I place the resource under the town, then remove the improvement and regive it in order to improve the resource (which is set to be improved by customs houses/towns and trading posts/villages). The resource is said to be correctly improved as it appears in the tile output but it does not appear anywhere among the available resources in the resource tab and when I look into the monopoly tab it says 0% (0 out of 9 improved) when at that moment only one resource exists on the map. If I complete the East India Company then I receive another copy of it and the line in the tab change to 50% (1 out of 2 in the world).
    I get no error whatsoever in the lua.log as the code seems to work correctly so what did I do wrong?

    Spoiler Bucchero Lua code :
    Code:
    function GetImprovementIDFromResourceID( resourceID)
       tResImprovements  = {}
       for row in DB.Query("SELECT a.ID ResID, b.ResourceType ResType, c.ID ImprovID FROM Resources a, Improvement_ResourceTypes b, Improvements c WHERE a.Type = b.ResourceType and b.ImprovementType = c.Type and a.ID = '" .. resourceID .. "'") do
           table.insert(tResImprovements, row.ImprovID);
       end
       return tResImprovements[1]
    end
    -------------------------------------------------------------------------------------------------------------------------
    function Jar_PlaceResourceOnPlot(playerID, resourceID, pPlot, improvementID)
       if pPlot:GetResourceType() == -1 then
           pPlot:SetResourceType(resourceID, 1)
           if pPlot:IsCity() then
               pPlot:SetImprovementType(improvementID)
               -- removes plantation after connecting the resource to trade list
               pPlot:SetImprovementType(-1)
           else
               pPlot:SetImprovementType(-1)
               pPlot:SetImprovementType(improvementID)
           end
       else
           local plotresID = pPlot:GetResourceType()
           local plotresNum= pPlot:GetReconCount()
           --local pCity = Neirai_GetNearestCity(Players[playerID], pPlot)
           if pPlot:IsCity() then
               local pCity = pPlot:GetPlotCity()
           else
               local pCity = pPlot:GetWorkingCity()
           end
           for i = 0, pCity:GetNumCityPlots() - 1, 1 do
               local pAdjacentPlot = pCity:GetCityIndexPlot(i)
               if pAdjacentPlot and pAdjacentPlot:GetOwner() == playerID and pAdjacentPlot:GetResourceType() == -1 and (pAdjacentPlot:GetImprovementType() == -1) then
                   pAdjacentPlot:SetResourceType(plotresID, plotresNum)
                   pAdjacentPlot:SetImprovementType( GetImprovementIDFromResourceID( plotresID) )
                   -- Notification
                   local sTitle = "A resource was moved."
                   local sText = "A resource was moved to the highlighted plot to make space for another resource to take its place."
                   Players[playerID]:AddNotification(NotificationTypes.NOTIFICATION_CITY_TILE, sText, sTitle, pAdjacentPlot:GetX(), pAdjacentPlot:GetY())
                   break
               end         
           end
           pPlot:SetImprovementType(-1)
           pPlot:SetResourceType(resourceID, 1)
           pPlot:SetImprovementType(improvementID)
           if pPlot:IsCity() then pPlot:SetImprovementType(-1) end
       end
    end
    -------------------------------------------------------------------------------------------------------------------------
    -- Use global variables to avoid having the event be called twice for the same plot (Thanks DMS)
    JarEtruscanBucchero_BuildFinished_PlayerID = 0
    JarEtruscanBucchero_BuildFinished_X = 0
    JarEtruscanBucchero_BuildFinished_Y = 0
    JarEtruscanBucchero_BuildFinished_Improvement = 0
    
    function Jar_BuccheroUnderCustomsHouse(playerID, plotX, plotY, improvementID)
       if(JarEtruscanBucchero_BuildFinished_PlayerID == playerID and JarEtruscanBucchero_BuildFinished_X == plotX and JarEtruscanBucchero_BuildFinished_Y == plotY and JarEtruscanBucchero_BuildFinished_Improvement == improvementID) then
           return;
       end
       -- Store inputs for duplication check
       JarEtruscanBucchero_BuildFinished_PlayerID = playerID; 
       JarEtruscanBucchero_BuildFinished_X = plotX;                 
       JarEtruscanBucchero_BuildFinished_Y = plotY;                 
       JarEtruscanBucchero_BuildFinished_Improvement = improvementID;
    
       local pPlot = Map.GetPlot(plotX, plotY)
       local pPlayer = Players[playerID]
       --local pPlayer = Players[pPlot:GetOwner()]
       if pPlayer:GetCivilizationType() == iCiv and pPlayer:IsAlive() then
           if improvementID == CustomsHouseID then
               Jar_PlaceResourceOnPlot(playerID, BuccheroResID, pPlot, improvementID)
           end
       end
    end
    
    GameEvents.BuildFinished.Add(Jar_BuccheroUnderCustomsHouse)
     
    Last edited: Apr 20, 2020
    pineappledan likes this.
  2. Asterix Rage

    Asterix Rage Warlord

    Joined:
    Jun 6, 2010
    Messages:
    1,169
    Jarcast's The Etruscans is in my current marrathon Game as an opponent.
    Landlocked at the bottom of the map, between The Huns and Indonesians, he's not going well. I plan to free some of its cities to observe its evolution and exchange few Bucherro with him.
     
  3. jarcast2

    jarcast2 Warlord

    Joined:
    Jan 10, 2018
    Messages:
    106
    Location:
    Gallia Belgica
    Managed to solve the Bucchero resource bug.
    Basically the resource is placed on the plot and improved by the merchant improvement.
    However, it appears on the monopoly screen as "Control: 0 out of 1 in the world".
    Then I just coded a dummy building giving the resource and added it to the city working the plot: "Control: 1 out of 1 in the world" and now correctly gives the monopoly (+10% gold in cities btw)
    Perfect.

    Update is now online.
     

Share This Page