Tiles giving science

MetroGoldyMayer

Chieftain
Joined
Apr 17, 2015
Messages
1
Well hello!

I'm making a mod where the Leader trait is that "beach" tiles (and by that I mean ground tiles within a city that have at least one coast tile as a neighbor) give +1 science.
It would be something like Kamehameha's Mohai but with science and without needing to build an improvement, more like a passive effect of a social policy.

If it is possible, I would like it to be visible from within the city administration, like a great scientist improvement.

I'm getting familiar with the API, so there's a few questions:
- IsCoastalLand() works with what I have defined as "beach" tile?
- What's the best workaround this? Can a invisible social policy or improvement made? Or should I stay with invisible buildings?

Thank you
 
What you described as a "beach" tile is what the game considers a coastal tile so that should work. If I were you, I what make an invisible building and just give it to all of the civs cities. If by "visible within city administration" you mean visible on the map I'm not sure how to do that or if it can be done.
 
I'm pretty sure terrain yields modified by a building will appear on the map -- my Makai civ uses a dummy building to add production to tundra and snow tiles, and as long as they're in my city's borders (even if not worked) the additional yields appear when I mouse over the tile.

I suspect the biggest issue will be if he wants to modify the yields following a formula a dummy building can't provide -- for example, modifying hill or mountain tiles, since they're not true features. In that case, you'll probably have to use Lua to frequently adjust the yields of specific plots -- I think Pouakai's Tibet mod has an example of this, as he uses it to adjust Mountain tiles. Although I suspect there may be issues if multiple mods are trying to manipulate the same tiles, depending on exactly how you do so.
 
Although I suspect there may be issues if multiple mods are trying to manipulate the same tiles, depending on exactly how you do so.
Ho boy could there be issues!

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

The problem with using buildings is that you can either enhance the yield of a water tile using <Building_SeaPlotYieldChanges> table, or the tile of a specific terrain-type via <Building_TerrainYieldChanges> table, but niether allow adjustment of land tiles that are adjacent to coastal water tiles, but only those adjacent land tiles. <Building_SeaPlotYieldChanges> table adjusts the yield of the coastal water tile, not the land tile next to the coastal water tile.
 
Ho boy could there be issues!

From what I recall of the code in the Tibet mod, what stood out was that if the Mountain tile wasn't in Tibet territory, he reset the yields for the tile to 0 -- meaning that if anyone else was using similar code to try and adjust mountains, their own bonuses would be negated. (And then they'd presumably try to readjust them, and back and forth...)

I'm not sure, but I think I've seen other people do it in a more 'delta' fashion, where they just remove the yields they added? I think DarkScythe's Spice and Wolf mod might do this.
 
From what I recall of the code in the Tibet mod, what stood out was that if the Mountain tile wasn't in Tibet territory, he reset the yields for the tile to 0 -- meaning that if anyone else was using similar code to try and adjust mountains, their own bonuses would be negated. (And then they'd presumably try to readjust them, and back and forth...)

I'm not sure, but I think I've seen other people do it in a more 'delta' fashion, where they just remove the yields they added? I think DarkScythe's Spice and Wolf mod might do this.
It's been a while since I tried to understand exaclty what-all Darkscythe is doing in his mod, but I think he may have also coded in some 'safety-valve' stuff by comparing the base game-defined yield to the current yield, and then did some magic or other (maybe, I'm still not 100% sure I understand everything going on in his code) to account for extra 'mystery' yields.

You can do this fairly straightforwardly for buildings that alter terrain or resource yields, by creating a table holding all the building-to-resource and building-to-terrain combinations, then checking for building-x in a city, and if done properly in the construction of the lua table this will account for all other mods making adjustments via buildings.

But as you mentioned there's no easy-peasy way to detect if another mod is making direct tile-yield-changes via lua -- I think that case would look identical (from the point of view of the logic within one's own code) to either the tile did not get modified properly last time around by my own code or my code is extra-adjusting, so it needs to "un-extra-adjust".

So as you mentioned, you get:
  1. mod 1 adds a yield to a tile
  2. mod 2 sees that adjustment and deems it incorrect, and un-adjusts the tile
  3. mod 1 re-makes the same adjustment again
  4. mod 2 sees that re-adjustment and deems it incorrect, and re-un-adjusts the tile
  • If both mods are doing their adjustments under PlayerDoTurn this would probably only have the detrimental effect of essentially not getting the proper function for either Mod 1 or Mod 2.
  • But suppose it was being handled by both mods using one of the real-time lua hooks? I could see some real hilarity-ensues there.
 
From what I recall of the code in the Tibet mod, what stood out was that if the Mountain tile wasn't in Tibet territory, he reset the yields for the tile to 0 -- meaning that if anyone else was using similar code to try and adjust mountains, their own bonuses would be negated.

Actually no, I use a SetPlotYield function that allows me to set the values for that tile, but the function only affects values set by my mod.

The SetPlotYield is essentially that Delta thing you describe:

Code:
function SetPlotYield(pPlot, iYield, iDelta)
	iOldDelta = load(pPlot, iYield)
	if iOldDelta == nil then
		Game.SetPlotExtraYield(pPlot:GetX(), pPlot:GetY(), iYield, iDelta)
	else
		Game.SetPlotExtraYield(pPlot:GetX(), pPlot:GetY(), iYield, iDelta - iOldDelta)
	end
	
	save(pPlot, iYield, iDelta)
end

Game.SetPlotExtraYield() would be more accurately named Game.ChangePlotYield() BTW. It doesn't set, it adds or subtracts.
 
Missed this thread, and mentions of my Civ, but yes, as sukritact mentioned, Game.SetPlotExtraYield() is effectively a "Change" method. This is also the same method I use with Holo to alter plot yields in specific circumstances.

It will simply continuously add or subtract the indicated yields from the plot each time it is fired, so it will work fine with other mods using the same method on the same plot (since they will simply affect the plot with +/- adjustments multiple times.)

For Holo, I track which plots I have altered, and I have defined the bonuses to be assigned, so when I detect that a plot I've previously altered is no longer eligible for the bonus yields, it will run Game.SetPlotExtraYield() again with a negative modifier on the bonus amount it was eligible for previously, in order to "cancel out" the bonus, and effectively "reset" the plot back to whatever state it would be without any of my bonuses (but would leave, say, bonuses from sukritact's mod intact, if it somehow affected the same plot.)
 
Just chiming in because this thread is relevant to a problem I've run into. From what I gather both here, and from my own experimentation, I take it that you can't alter terrain yields in the trait XML file? I have to do that via a dummy building?
 
I'm pretty sure terrain yields modified by a building will appear on the map -- my Makai civ uses a dummy building to add production to tundra and snow tiles, and as long as they're in my city's borders (even if not worked) the additional yields appear when I mouse over the tile.

I suspect the biggest issue will be if he wants to modify the yields following a formula a dummy building can't provide -- for example, modifying hill or mountain tiles, since they're not true features. In that case, you'll probably have to use Lua to frequently adjust the yields of specific plots -- I think Pouakai's Tibet mod has an example of this, as he uses it to adjust Mountain tiles. Although I suspect there may be issues if multiple mods are trying to manipulate the same tiles, depending on exactly how you do so.

Just looking through the mod of yours you mentioned to find a solution for my own problem, but I don't see anything about tundra or snow tiles. The trait text is "Tourism increases combat strength. Combat strength increases by +1 for every 10 Tourism generated per turn, to a maximum of 30." Is there another mod that has that, or am I just not finding what you mentioned?
 
Pretty much the only thing you can alter with the Traits table is whatever is listed in the Schema section at the top of the game's CIV5Traits.xml file. Unfortunately, I don't believe any sort of general terrain yield adjustment table exists there, so that's why we resort to using dummy buildings and such.

Holo uses a dummy building to provide +1 food in Snow and Tundra.
 
Pretty much the only thing you can alter with the Traits table is whatever is listed in the Schema section at the top of the game's CIV5Traits.xml file. Unfortunately, I don't believe any sort of general terrain yield adjustment table exists there, so that's why we resort to using dummy buildings and such.

Yeah, I tried making my own tag of <Trait_TerrainYieldChanges> and it just made the game crash.

Holo uses a dummy building to provide +1 food in Snow and Tundra.

Sweet, I'll look there. Thanks!
 
The XML is unfortunately completely hardcoded, so you're limited to exactly what is listed in each file's Schema, and nothing more than that. Trying to create new tables can work, but you need to actually create the new logic yourself to make the game do something with it, otherwise it'll just sit there not doing anything, or in the worst case, crash your game.

Having said that, though, there does exist various 'unused' XML columns and such that you can try using -- some of them work, and some of them don't, as I've come across both types in my testing. Either way, they are all listed in the Schema.

Also, feel free to let me know in my Civ thread if you have any issues with her, as I know her current Lua is a mess that I'm still trying to rewrite; I don't want to clutter up and hijack other threads to clarify Holo's stuff.
 
Having said that, though, there does exist various 'unused' XML columns and such that you can try using -- some of them work, and some of them don't.

Finding out which ones are fully "hooked-up", which ones are "read-only" (in the sense that there are accessor functions within the .cpp files, but are not actually used anywhere), and which ones are for decorative purposes can be very, very annoying.

This applies for some of the secondary GameData tables too.
 
Back
Top Bottom