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

[SDK MODCOMP] Vicinity Bonus

Discussion in 'Civ4 - Mod Components' started by Shqype, Apr 7, 2008.

  1. Shqype

    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!
     
  2. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
  3. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,274
    Location:
    israel
    excellent!!!
     
  4. Duque d'Caxias

    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?
     
  5. keldath

    keldath LivE LonG AnD PrOsPeR

    Joined:
    Dec 20, 2005
    Messages:
    6,274
    Location:
    israel
    duque d'caxias,

    well theres no need for this to define cetain bonus,

    cause you define which bonus will be needed to be in the vicinity,

    so what you ask is basicly what the mod offers...to set a certain bonus to be needed fro a speciphic building/unit.
     
  6. Kalimakhus

    Kalimakhus Chieftain

    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:
     
  7. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    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! :)
     
  8. lamppost4

    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?
     
  9. NikNaks

    NikNaks Chieftain

    Joined:
    Jul 25, 2006
    Messages:
    2,972
    Location:
    England
    No, it means that this mod includes Bhruic's changes.
     
  10. jefmart1

    jefmart1 Chieftain

    Joined:
    Aug 16, 2005
    Messages:
    463
    Pardon my SDK ignorance. How do I add this to Vanilla BTS or another mod?
     
  11. Gaius Octavius

    Gaius Octavius Chieftain

    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.
     
  12. zappara

    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 :)
     
  13. Shqype

    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.
     
  14. jkp1187

    jkp1187 Unindicted Co-Conspirator

    Joined:
    Aug 29, 2004
    Messages:
    2,494
    Location:
    Pittsburgh, Pennsylvania
    Very nice -- brings me back to one of the good innovations from Civ 3.

    Hopefully I can figure out a way to use this in the future!
     
  15. Shiggs713

    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
     
  16. Chuggi

    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.
     
  17. MagisterCultuum

    MagisterCultuum Great Sage

    Joined:
    Feb 14, 2007
    Messages:
    15,913
    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.
     
  18. Chuggi

    Chuggi Espada

    Joined:
    Jan 2, 2007
    Messages:
    2,369
    Location:
    Australia
    That's another cool idea. Like the Stonehenge should require a hill in the radius before it can be built.
     
  19. Shqype

    Shqype Shqyptar

    Joined:
    Nov 15, 2005
    Messages:
    2,468
    Location:
    New York + Shqypni
    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.
     
  20. zulu9812

    zulu9812 The Newbie Nightmare

    Joined:
    Jan 29, 2002
    Messages:
    6,389
    Location:
    Athens of the North
    Does anyone know if this was ever updated for BTS 3.17, either by Shqype or in some other project?
     

Share This Page