Doubling specific luxuries: how do I code this?

isnorden

Amnesiac Modder
Joined
Jul 6, 2012
Messages
608
Location
Madison, Wisconsin, USA
After using a mod that doubles the amount of strategic resources on the map, I wondered if there was a way to double the amount of specific luxuries (say, Gold or Silver) for all civs. If that's possible without a DLL hack, could you please tell me how? Thank you again!
 
What do you mean ? That each source of Gold or Silver produces two units of these resources instead of one for the civ working the tile, or that the amount of Gold and Silver tiles on the map is twice as normal ?
 
What do you mean ? That each source of Gold or Silver produces two units of these resources instead of one for the civ working the tile, or that the amount of Gold and Silver tiles on the map is twice as normal ?


Double yield per existing tile is what I'm trying to get. (if a Silver tile placed in spot X normally produced 2 Silver for trade, this mod would make the same spot produce 4). Hope that helps!
 
Double yield per existing tile is what I'm trying to get. (if a Silver tile placed in spot X normally produced 2 Silver for trade, this mod would make the same spot produce 4). Hope that helps!
Luxury Resources always only produce 1 copy right? And if you want to grant an extra copy for each one, Arabia's Unique building, the Bazaar, "provides 1 extra copy of each improved luxury resource near this City."

This does not affect yields on that tile though, so if you want that as well what you could do is utilize the <Building_ResourceYieldChanges>-table (which the Mausoleum of Halicarnasseus uses to provide +2 Gold on Marble and Stone for example. I don't know if every yield has been implemented to work though (probably not), but I think that 'unified yields' might fix that)

EDIT: Or you could simply double all of the normal yield values for a specific resource, but this doesn't allow specification in specific cities or for specific Civilizations.
 
Last edited:
<Player> is used as I understand it in the <Resources> table to define for luxury and strategic resouce the ratio of occurance of the resource to the number of players in the game.

For Iron and Oil:
Code:
<Player>100</Player>
For Horses, Coal, Aluminum, Uranium:
Code:
<Player>75</Player>
Most of the luxuries (and also Stone) seem to use:
Code:
<Player>67</Player>
The bonus resources seem to use column <TilesPer>
 
OK...so if I wanted to double the output (for all civs) on any tile with the Silver resource...which table column(s) would I need to update, and where are they? Please forgive me if I sound impatient; I'm a bit confused.
 
Oh, that's a different issue to what I thought you were trying to do. I thought you were tryng to increase the number of plots placed onto the map with Silver or Gold (as examples).

The amounts of a resource that are placed on a single tile are controlled by AssignStartingPlots.lua and are hard-coded within the AssignStartingPlots.lua file. Luxuries and Bonus resources are all set to place 1 copy per tile of the resource.

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

You could try to run an lua script that only executed when the player presses the 'Start Journey' or 'Contunue Journey' buttons. There is a specific lua hook for that. Then scan all plots that have ResourceX, and on tiles that do have ResourceX, alter the quantity on the tile to the quantity desired. This would apply for all civs because it would be adjusting info on the map itself.
 
I've never written that kind of script before; my only experience with Lua in Civ5 involves tweaking lists in existing code. Do you know of any existing mods which use that hook to alter the map?
 
no, but several custom civs add resources or alter resources when the civ founds its capital or founds a new city. The command to alter a plot's resource and qty of resource is
Code:
Plot:SetResourceType(ResourceID, ResourceAmountToSet)
SO once you have the object for a specific plot, to set that the plot has 2 (two) copies of Silver, you do as
Code:
Plot:SetResourceType(GameInfoTypes["RESOURCE_SILVER"], 2)
 
@isnorden

From what I understand from your posts is you want to get more yield from a specific luxury hex that already exists on the map? To get more yield, have you tried a mod like this?

Code:
<Resource_YieldChanges>
        <Update>
               <Where ResourceType="RESOURCE_SILVER" YieldType="YIELD_GOLD" />
               <Set Yield="4" />
        </Update>
</Resource_YieldChanges>

This will change the amount of gold yielded from 2 to 4 for each Silver hex on the map. Silver hexes only yield Gold, so if you want the Silver hex to also yield production, the row for production would need to be added to the database. You'd need something like this to add production:

Code:
<Resource_YieldChanges>
        <Row>
              <ResourceType>RESOURCE_SILVER</ResourceType>
              <YieldType>YIELD_PRODUCTION</YieldType>
              <Yield>4</Yield>
        </Row>
</Resource_YieldChanges>

There is no yield for TRADE in the Yields table. The only valid yield types are Food, Production, Gold, Science, Culture, and Faith. You can add a yield type, but significant additional changes would be required to get the AI to understand the new yield type and hope to use it properly.


@LeeS,

I've seen/experimented with these changes, and they seem to affect map generation, but in ways I don't understand:

Code:
<Resources>
    <Update>
            <Where Type="RESOURCE_COPPER" />
            <Set RandApp1="10" RandApp2="10" ConstAppearance="10" />
        </Update>
        <Update>
            <Where Type="RESOURCE_COW" />
            <Set RandApp1="1" RandApp2="1" ConstAppearance="1" />
        </Update>
        <Update>
            <Where Type="RESOURCE_DEER" />
            <Set RandApp1="1" RandApp2="1" ConstAppearance="1" />
        </Update>
        <Update>
            <Where Type="RESOURCE_TRUFFLES" />
            <Set RandApp1="10" RandApp2="10" ConstAppearance="10" />
        </Update>
        <Update>
            <Where Type="RESOURCE_WINE" />
            <Set RandApp1="10" RandApp2="10" ConstAppearance="10" />
        </Update>
</Resources>

It seems to adjust a few of the resources (not seeing nearly as many Cow and Deer hexes). It doesn't seem to work as well for luxuries, but I'm sure if I understood the mechanics better, perhaps I could get it to do so.

Is this the best XML way to increase/decrease the number of resource hexes that appear, or is there a better way?

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

Disclaimer - all code snippets submitted by me need to be checked for spelling, syntax, etc. As a dyslexia sufferer, things that look correct to me might actually break something for you... :crazyeye:
 
ISN isn't talking about adjusting yields of resources nor how many plots on the map have a specific luxury, as I understand what she wants. She wants each tile with Silver, for example, to give 2 copies of the Silver luxury instead of the 1 copy each Silver tile usually gives.
 
Assuming the game does not barf on luxury tiles having more than one copy of the luxury resource, this code should allow you to adjust the luxury resource amounts on every tile for specified types of resources.
Code:
local tResourcesToAdjust = {     [GameInfoTypes.RESOURCE_SILVER] = 2,
	[GameInfoTypes.RESOURCE_GOLD] = 2     }

function AdjustLuxuryQty()
	if (Game.GetElapsedGameTurns() == 0) then
		for PlotIndex = 0, (Map.GetNumPlots() - 1), 1 do
			local pPlot = Map.GetPlotByIndex(PlotIndex)
			if (pPlot ~= nil) then
				local iPlotResourceType = pPlot:GetResourceType()
				if tResourcesToAdjust[iPlotResourceType] then
					pPlot:SetResourceType(iPlotResourceType, tResourcesToAdjust[iPlotResourceType])
				end
			end
		end
	end
end
Events.LoadScreenClose.Add(AdjustLuxuryQty)
All you need to do is fill in lua table tResourcesToAdjust with any additional resources you want to adjust.

So if you want to add Whales to the list and to make each Whale tile give three copies of the Whale luxury, you alter the table as so:
Code:
local tResourcesToAdjust = {     [GameInfoTypes.RESOURCE_SILVER] = 2,
	[GameInfoTypes.RESOURCE_GOLD] = 2,
	[GameInfoTypes.RESOURCE_WHALE] = 3     }
The rest of the code does not need to change.

The lua code is run from an lua file setup as an InGameUIAddin

It does not actually matter whether the resources you specify are Luxury, Bonus, or Strategic. The code should work for any of the three. But you should not try to fiddle with the 'fake' archeology site resources in this way becuase I have no idea how the game will react once a player learns the tech that reveals archaeology sites.
 
Last edited:
Thanks for the code, LeeS...let me see if it works in playtesting (I learned that the hard way). If it does, I will upload the mod and give you credit.

Edited to add:

  1. Will this code need to be imported to the virtual file system?
  2. Will I need to package any other scripts (such as a copy of AssignStartingPlots.lua) in the mod?
Please let me know!
 
Last edited:
Top Bottom