[SDK MODCOMP] Vicinity Bonus

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni
Vicinity Bonus SDK Mod Component
For BTS 3.13, made with Bhruic's unofficial patch 1.11

This was requested by Kalimakhus, but I know that other people have wanted something like this, and it serves multiple uses.

What it does: This mod allows you to set a vicinity bonus requirement for the construction of buildings and units in your cities. A vicinity bonus is a resource within your city's workable radius that is connected to your city and improved with its necessary improvement. This allows for greater city diversification, and emphasizes the necessity of city placement: Two well placed cities can easily share a resource if strategically positioned. In the last screenshot below, for example, Lisbon and Oporto will both share the copper resource, since it is in the vicinity of both cities, but Guimaraes does not have copper in its vicinity, and thus will not be able to construct units and buildings that require such a vicinity bonus.

For all intents and purposes resource sharing will work the same: the city will still have the resource as in vanilla CIV, but it will not be able to train units or construct buildings requiring vicinity bonuses unless those resources are in that city's vicinity.



Four new (optional) XML tags have been added to the BuildingInfos and UnitInfos XML files. They are <VicinityBonus> and <PrereqVicinityBonuses> for buildings, with <VicinityBonusType> and <PrereqVicinityBonuses> for units. The latter of both sets are used as OR prereqs, meaning only one of the resources listed will be needed to satisfy the construction requirement.

The Barracks has been set to require Copper in the city's vicinity:
Spoiler :
<VicinityBonus>BONUS_COPPER</VicinityBonus>

The Granary has been set to require either Wheat, Rice, or Corn in its city's vicinity:
Spoiler :
<PrereqVicinityBonuses>
<VicinityBonus>BONUS_WHEAT</VicinityBonus>
<VicinityBonus>BONUS_RICE</VicinityBonus>
<VicinityBonus>BONUS_CORN</VicinityBonus>
</PrereqVicinityBonuses>

The Warrior has been set to require Fish in the city's vicinity:
Spoiler :
<VicinityBonusType>BONUS_FISH</VicinityBonusType>

The Settler has been set to require either Cow, Sheep, or Pig in its city's vicinity:
Spoiler :
<PrereqVicinityBonuses>
<VicinityBonusType>BONUS_COW</VicinityBonusType>
<VicinityBonusType>BONUS_SHEEP</VicinityBonusType>
<VicinityBonusType>BONUS_PIG</VicinityBonusType>
</PrereqVicinityBonuses>

I've also added a new function, bool CvPlot::isHasValidBonus(), which checks if a particular plot has a valid bonus. This means that the plot must be within the player's city radius, it must be part of a bonus network, it must have the proper improvement necessary to "work" the resource (make it valid), and the player must have the proper tech which reveals the resource. The limit to the number of prereqs corresponds to the limit of OR prereqs as alterable in the GlobalInfos XML file.

To see what I changed in the source code, just search for "Shqype," as I have commented all my additions with either "Shqype Vicinity Bonus Start" and "Shqype Vicinity Bonus End" for multi-line additions, or "Shqype Vicinity Bonus Add/Change" for one-line additions/changes. The new schemas are also included.

Please let me know what you guys think of it and if there are any bugs you may encounter. There may be unforeseen scenarios that I haven't accounted for, so let me know if something doesn't work as expected. Enjoy!
 

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni

Duque d'Caxias

Great General
Joined
Nov 17, 2006
Messages
102
Location
Brazil
Interting! Can we set different behavier for different resources, I mean, some as "vicinity bonus" and other as regular bonus?
 

Kalimakhus

Emperor
Joined
May 8, 2007
Messages
1,249
Excellent Shqype!! This along with city pop req. comp just open a host of limitless possibilities to work with cities and resources. One drawback of adding more resources in mods was that it unbalances the game by providing too much happiness or healthiness. With this comp some resources can be limited so they would give happiness only through a building that can be built in a nearby city. Some cities can grow more that others which makes perfect sense and then some mega cities can have buildings that smaller ones can't.

Raw materials and manufactured goods chains can also be implemented through this comp. A city with cotton, silk, or sheep can build a textile factory that creates cloth resource. Other cities will get happiness from access to cloth but only the city with the factory will get gold bonus.

As I said possibilities are limitless and hopefully we can see some of them implemented soon in several mods. Small (in size) comps always make huge difference. :goodjob:
 

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni
Interting! Can we set different behavier for different resources, I mean, some as "vicinity bonus" and other as regular bonus?

Yes, as keldath pointed out.

This mod doesn't change the existing system, it just adds to it. If you check in game you will see that a city may have access to copper, but it still will not be able to construct a Barracks because it doesn't have the copper bonus in its vicinity.

Thus you can make some buildings require bonuses such as in vanilla (shared resources), some buildings require a certain resource in the workable "fat cross," and some buildings require a mixture of both. :)

You're right, Kalimakhus. This allows for a lot of possibilities, as long as you have the imagination for it! :)
 

lamppost4

Holder of the Light
Joined
Jan 13, 2007
Messages
286
Location
Over Yonder
When you say that it is made w/ bhruic's patch, does that means that I have to have bhruic's patch installed to use it?
 
Joined
Jul 28, 2006
Messages
4,016
This is a very clever invention. :) Would be interesting to combine this with Quantitative Resources (if I ever get it done) to create local limitations as well as stockpile caps.
 

zappara

Mod Designer
Joined
Dec 19, 2003
Messages
2,781
Location
Finland
Ooh, this looks really interesting! I've always been bit annoyed how your empire gets access to resources even if the resource is on the other side of world.. like fish / meat won't rot on transportation on ancient times.. vicinity bonus system would solve this problem :)
 

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni
Thanks for the support guys.

lampost4: NikNas93 answered your question. This includes Bhruic's changes.

jefmart1: No coding necessary. I have included the .dll so all you need to do is add it to the Assets folder for your mod.

Gaius, it does have quite a few uses and can be combined with other mods for better effects (as Kalimakhus pointed out).

Zappara, this modcomp does provide a solution for that problem. But, keep in mind that I didn't alter the existing system, I just added new functionality: technically, your city will still have access to Fish, but it will not be able to construct buildings or units unless it has Fish within its vicinity.
 

Shiggs713

Immortal
Joined
Mar 11, 2007
Messages
2,361
Location
Indianapolis
this looks very promising. I was curious if you could link it to a tech or even a route to remove it though. For example say you research railroad, then build a railroad, and any city connected by railroad to the city with the said resource(s), now will count as having it inside the fat cross. It wouldn't have to be exactly like that, but so that once you get more modern, some cities can grow large(r), even without food resources or lush plains... Las Vegas is a good example.

Shiggs
 

Chuggi

Espada
Joined
Jan 2, 2007
Messages
2,369
Location
Australia
An idea for this mod is that some wonders could require resources in their vicinity to be built. Like for Stonehenge and the Pyramids, you wouldn't want to be mining stone from the other end of your empire and transporting it all the way to one city so it can be built there. ;) It would make getting certain wonders harder.
 

MagisterCultuum

Great Sage
Joined
Feb 14, 2007
Messages
16,459
Location
Kael's head
This could be nice. What I think might be even better though would be if you could require certain improvements, features, and terrains be within the city's vicinity.
 

Shqype

Shqyptar
Joined
Nov 15, 2005
Messages
2,468
Location
New York + Shqypni
An idea for this mod is that some wonders could require resources in their vicinity to be built. Like for Stonehenge and the Pyramids, you wouldn't want to be mining stone from the other end of your empire and transporting it all the way to one city so it can be built there. ;) It would make getting certain wonders harder.

If I understand you correctly, that's already possible. :) Just set the new tag for the wonder to require the bonus, and that's it.

I will be updating this to BTS 3.17 and hopefully add new functionality to it based on some of the suggestions I've read here.
 
Top Bottom