Local Resources Increase Production Speed of Wonders/Buildings Mod

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
WIP at the moment. PLUS I posted this by accident on one of Bane_'s threads *sigh* :sad:. Anyway:

I've been doing some work on a mod that speeds production of certain wonders and buildings based on the presence of Local City Resources. If this sounds familiar, it was a 'thing' in CIV4. I have a starting list of wonders, and some tentative thoughts on what "regular" buildings ought to have increased production-speed based on the presence of local city resources.

So far I've been thinking along these lines, for resources that affect wonder production speeds:
Spoiler :

Note that "Iron" is being used as a stand-in for "Structural Steel" in some cases because we don't have such a resource as "Structural Steel".
  • Marble: (wonders not currently affected by Marble)
    1. Grand Temple
    2. Heroic Epic
    3. National Treasury
    4. Oxford University
    5. Hermitage
    6. Alhambra
    7. Leaning Tower
    8. Uffizi
    9. Angkor Wat
    10. Notre Dame
    11. Sistene Chapel
    12. Taj Mahal
    13. Brandenburg Gate
    14. Louvre
  • Stone:
    1. Great Lighthouse
    2. StoneHenge
    3. Pyramids
    4. Great Wall
    5. Red Fort
    6. Circus Maximus
    7. Borobudur
    8. Chichen Itza
    9. Machu Pichu
    10. Kremlin
    11. Himeji Castle
    12. Cristo Redentor
    13. Pentagon
  • Copper:
    1. Forbidden Palace
    2. Statue of Liberty
    3. Colossus
  • Iron:
    1. Broadway
    2. Big Ben
    3. Pentagon
    4. Sydney Opera House
    5. Eiffel Tower


Resources that would increase production of regular buildings:
Spoiler :

Note that I haven't thought this through completely. Nor am I really going for "every building is speed-enhanced by a resource", though I am not opposed to such a system if there are enough reasonable suggestions. Nor am I opposed to buildings that ought to construct faster being production-bumped by the presence of nearby terrains or features.
  • Marble:
    1. University-Class Buildings (University & Wat*)
    2. Courthouse
    3. Temple-Class Buildings (Temple, Burial Tomb, Mud Pyramid Mosque*)
  • Stone:
    1. Monument-Class Buildings (Monument and Stele)
    2. Library-Class Buildings (Library, Paper Maker and Royal Library)
    3. Castle-Class Buildings (Castle and Mughal-Fort)
    4. Lighthouse
    5. Harbor
    6. Colosseum
    7. Stadium (?)
    8. Public Schools
    9. Aqueduct
    10. Arsenal
    11. Military Base
  • Copper:
    1. nuttin' so far
  • Iron:
    1. Observatory
    2. Stadium (?)
    3. Factory
* If we had a resource such as "clay" I would be tempted to split these out to use that resource instead.
If we had a "timber" or "wood" resource I'd make Watermill-Class and Windmill-Class Buildings go faster with such a resource.



What I am looking for some feedback on:
  1. Not sure if I want to make the resource specifications and production bumps through a new game table or if I want to do it all directly in lua. Nor have I decided whether I want to directly manipulate a city's production, or whether I want to use a dummy buildings approach, where the dummy buildings either have a <BuildingProductionModifier> or a <WonderProductionModifier>. I've already figured how to "capture" the name such as BUILDING_LIGHTHOUSE of what is being produced in a city, and the code to see whether a city has a local resource. Though I've probably over-coded it by also writing checks to be sure that not only is the resource local to the city, but it is an improved resource that is also being worked by the city in question.
  2. The listing of which buildings/wonders are to be production-speed-enhanced by which local resources.
  3. I haven't decided yet on a good balanced % modifier yet. And I may adopt a "stacking resources" effect where having both Stone and Marble local to a city (as example) would give the production speed increase for both. So if Marble and Stone were each adding 10% production individually, if a city had access to both, the modifier would be 20% total.
  4. If I delete the current Marble in-game effect from RESOURCE_MARBLE and replace it with my own method, is the game still going to look for that and freak out because there's some hard-coded lines in the C++ / DLL to make the game want to see that Marble-resource-effect on construction of early-era wonders coming direclty from RESOURCE_MARBLE.
 
My hunch tells me this is going to be really hard. However just a short remark to your last question #4: Rather than deleting the original Marbe resource, I think the best solution would be to just tweak spawn chance to zero on all terrains. That way you would avoid nasty issues with hardcoded stuff not finding what they needed in database. Just my 5 cents.
 
I guess I was unclear. I don't intend to remove Marble as a resource from the game. I was thinking of removing the tags:
Code:
<WonderProductionMod>15</WonderProductionMod>
<WonderProductionModObsoleteEra>ERA_MEDIEVAL</WonderProductionModObsoleteEra>
from Marble.
 
Oh ok, or maybe I didn't read properly. I don't know for sure, but pretty sure that wouldn't cause any harm if you set modifier to 0.
 
I think the whole concept, where local resources facilitate the construction of certain buildings (like in civ IV) is fantastic and I'd love to play such a mode. That someone is modding along this lines is great news. I would only suggest to make more resources capable of providing these bonuses. It is easy to assume that stone should speed up basically everything up to modern era or so; however, I don't think it would be very well balanced this way.
How about making silk, fur and cotton help with factory construction? this will be a textile factory in this case. Citrus can provide a bonus to hospitals maybe (scurvy?), gold and silver to workshops, and maybe gems too, and libraries could get boost from animals (if you don't know paper yet, you might want to write on the dried skin or so).

So maybe the "every building is speed-enhanced by a resource" is indeed far from perfect, but other way around, "nearly every resource should be useful for a building" is a good way of implementing it.
Thanks and good luck with modding!
 
Hey LeeS, been thinking of doing something similar for my own personal mod (it's on the back-burner, however XD).

Using (local or global) resources to enhance the production of normal buildings is not a bad idea, but you may wish to consider re-balancing costs (and possibly effects) of those building classes, as some civs will have access to certain resources, some may not, and some will never be present on the map (un-modded, you could always make every single resource appear on the map regardless of size).

If you're modifying Marble's effect into a much larger scope, you'll probably want to dig up the code-block that controls marble placement in AssignStartingPlots.lua (have fun with that, I know I did(n't) :lol:), and increase its generation rate so that more than 1-2 civs can actually make use of it (i.e within either their first or second city's reach). Well to be fair, you're going to want to do this regardless of whether its Marble or not, given the ramifications of rolling a start (or map!) with or without some of these resources.

For its actual implementation, I'm sure it could be done with LUA, but if you want a scalable template, consider creating a new table, or extending an existing table.

Spoiler :
Code:
For example: a table called "Resource_BuildingClassProductionModifier" 

[U]"Resource" | "BuildingClass" | "ProductionModifier"[/U] 
RESOURCE_MARBLE | BUILDINGCLASS_UNIVERSITY | 25

and then using CvCity::GetLocalResourceWonderProductionMod (assuming you coded the read-from-xml-functionality for your new table) as a template (or modifying the function itself depending on how you want to go about coding it), you can write the modification/addition with the check on BuildingTypes eBuilding (the function loops through all the resources for you anyways).

If you are unfamiliar with how to do, Whoward69 has written several wonderful and informative Wall of Texts Adding new tables to the database and Adding new primary tables to the database. There are several others on this topic, which you may find on the front page of a quick Google Search.
 
I'm not concerned with my ability to do the XML / SQL / LUA* side of it. I was more hoping for some feedback as to what the community mod-authors think would be a better method to use: direct lua adjustment of a city's production progress or a building added via lua with the building/wonder modifier as a column within that "dummy" building.

Thinking of trying to slog my way through AssignStartingPlots.lua might nearly be a deal breaker :) There's a reason why for some forum members the use of "AssignStartingPlots.lua" in a post is secret code for curse words.

Anything DLL is just way over my pay grade at the moment. Plus I don't like to use DLL if I can at all avoid it to accomplish something because of the Highlander-Rule.


* well, assuming the LUA in question is not trying to edit AssignStartingPlots.lua or the City View one, or any of the other UI files *brrrrr-shudder*
 
You can use LUA to assign more resources to the map; Consult the LUA files (if have the patience to do so) of the ''Really Advanced Setup''.
 
Top Bottom