1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice

Opportunities

Discussion in 'Communitas Expansion Pack' started by Thalassicus, Jan 31, 2012.

  1. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    1. Overview
    2. Goals
    3. Plans
    4. Details


    1. Overview

    Opportunities appear at turning points in human history to improve society. The paths we take depend on moral choices between different philosophies. The Communitas Expansion Pack adds this brand new feature to Civilization 5. This system was created by Hipfot, Skodkim, Spatzimaus, and VeyDer, with additional contributions from me, Thalassicus.

    Each has:
    • Historical significance.
    • A way to enhance or reform society.
    • Distinct moral choices.
    Opportunities present moral decisions, such as:
    • Invest in compassion, artistry, and conservation.
    • Invest in ruthlessness, militarism, and development.
    • Let locals decide instead of taking a national stance.

    If you have ideas for new opportunities to add, open CivVModding and click the "Triggers" tab. The file opens in excel or LibreOffice (the free office).
    \Documents\My Games\Sid Meier's Civilization 5\MODS\G&K Enhanced Mod\CivVModding.xls

    When creating new opportunities your A/B categories don't have to be like the ones above, so long as the choice is clearly distinct. The categories here are based on the paragon/renegade morality systems from Bioware games. Ideally neither choice is strictly "good" or "evil." There should always be one "locals handle it" option, in case the central government cannot invest in the opportunity.

    Important note: if you want to create new opportunities, permanent effects are much easier to code (~5 minutes work) than temporary effects (several hours of work). Almost anything is possible except setting the mood of two major civs between one another:

    Get major civ diplomatic relations
    Set major civ diplomatic relations
    Get minor civ diplomatic relations
    Set minor civ diplomatic relations



    2. Goals

    Good luck in life such as meeting someone interesting, getting an unexpected raise at work, and winning the lottery is fun and exciting! Bad luck like unexpected breakups or getting fired is frustrating and depressing.

    We play games to have fun! Opportunities are therefore designed to feel like good luck. The benefits are clearly visible, while the downsides are hidden in the background with economic and accounting concepts. For example, consider an opportunity where we invest 150g in +3 science per turn.

    Benefits
    • +3:c5science: per turn.
    Downsides
    None of the downsides are shown on the opportunity popup window, to make them feel fun and powerful. We only see an up-front cost for a per-turn bonus.

    Even if the trigger of an opportunity has a negative aspect, like protests, the outcomes can be positive: reducing crime or improving education. It's an opportunity to improve society. The central government can invest in this opportunity to get better results, or let the local authorities handle it with fewer resources, lower costs, and lower rewards.



    3. Plans

    We completed the major phases of development, and reached on the fun part of creating new and interesting opportunities:
    1. Import the existing events mod created by Hipfot, Skodkim, Spatzimaus, and VeyDer.
    2. Update the choices with basic early drafts of opportunities chosen for their historical significance.
    3. Update the opportunity selection system with:
      • Prevented repeat occurrences of the same opportunity on the same tile.
      • Changed from independent to dependent probabilities, so as time passes without seeing an opportunity, odds rise of it finally appearing.
    4. Add more complex opportunities which respond to different aspects of the game, such as units, citystates, combat outcomes, diplomacy, etc.



    4. Details


    Say we're in the Medieval era on standard game speed. We get 1 opportunity every 20 turns, at a random time during those 20 turns. It works like this:

    1. Each turn has a rising chance of an opportunity.
    2. If the chance happens:
      • Run an opportunity.
      • Block future opportunities.
      • Continue incrementing the chance.
    3. When the stored chance reaches 100%:
      • Reset chance to 0%.
      • Unblock opportunities.

    For example, if we're at turn 100 in the Medieval era, things might go like this:
    turn: chance
    100: 0%
    101: 5%
    102: 10%
    103: 15%
    104: 20%
    105: 25%
    - 25% chance randomly happens this turn.
    - Do an opportunity.
    - Block future opportunities.
    106: 30%: blocked
    ...
    123: 90%: blocked
    124: 95%: blocked
    125: 100%:
    - Reset to 0%.
    - Unblock opportunities.
    126: 0%
    127: 5%
    128: 10%: chance opportunity occurs
    129: 15%: blocked
    130: 20%: blocked
    131: 25%: blocked
    ... repeating ...
    The increase in +% chance per turn depend on era and game speed. For normal speed these are the current timers:

    This means in the Medieval era we always have 1 opportunity every 20 turns. It randomly occurs earlier or later in that 20-turn timeframe, but the average is constant. After 60 turns in the medieval era we'd have precisely 3 opportunities.
     

    Attached Files:

  2. TRex56

    TRex56 Chieftain

    Joined:
    Jul 21, 2011
    Messages:
    18
    This looks to be a great addition, but v. 1.27 doesn't appear to have been uploaded.
     
  3. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    I missed a few things from the bug report forum; once I have those problems solved v127 will be uploaded. :)
     
  4. TRex56

    TRex56 Chieftain

    Joined:
    Jul 21, 2011
    Messages:
    18
    Thanks for all your hard work in making Civ5 a much more enjoyable experience!
     
  5. Jaybe

    Jaybe civus fanaticus Supporter

    Joined:
    Sep 24, 2001
    Messages:
    2,583
    Gender:
    Male
    Location:
    Las Vegas, Nevada
    Oh, JOY -- EVENTS!! :bounce:
    Thank you.

    Browsing through the text however, I found:
    line 140, closing "}" without an opening one
    line 451, RareHerbs/tornado seemingly a mismatch.
    lines 23, 758, 806:
    should per my sense of grammar be "I have neither time nor money for this nonsense!"
    (... or "no" or "not the"); refer to Napoleon's reply to ... Fulton, was it? ... at the discovery of Steam Power in Civ4.
    ;) Yes, I know this is so very important.
     
  6. Txurce

    Txurce Deity

    Joined:
    Jan 4, 2002
    Messages:
    8,280
    Location:
    Venice, California
    This looks interesting, but I have a consistency question. Over the last year you've consistently taken the position of wanting to eliminate randomness - hence your leveling of Spain, as well as some of the Wonders, not to mention strategic resources. I liked the idea of that randomness, since Civ is never going to be remotely "even."

    Out of curiosity, how does adding this fit your approach to all of the above, etc?
     
  7. natedaren

    natedaren Chieftain

    Joined:
    Aug 22, 2010
    Messages:
    8
    Location:
    Houston
    I noticed that some of the events that are displayed are referring to me as "you", even though they occured for a different (and unmet) civilization. I can't remember the exact text but it was something like "Nomads have joined you as workers and have appeared outside Mecca". I was playing as Babylon and had yet to meet anyone as it was only about turn 5. There were a couple other occurences of this as well.

    The issue with this is not only gramattical but also it reveals which leaders are in the game. I don't really have a problem with that but I just thought you'd like to know. Also, I am at about turn 50 of a new game with Ver 28 but have not had any events affect me. Are they completely random?

    Thanks for all your great work Thal! You have made CiV an excellent game to play.
     
  8. Spatzimaus

    Spatzimaus Mad Scientist

    Joined:
    Sep 21, 2005
    Messages:
    3,063
    Location:
    Los Angeles, CA
    I'm not Thal so I can't answer definitively, but as I wrote part of the code in question, I can take a stab at it.

    veyDer's original User Events system was purely random; every event had exactly X chance of happening on a given turn. There was nothing stopping the same event from triggering two turns in a row (or even just twice in the same game), and nothing that'd make it impossible to go an entire game without triggering one. More importantly, veyDer's original mod had no ability to affect a specific AI player; all events were either global (affecting all players equally) or specific to you, the active player. Obviously, this led to serious balance issues.

    In the course of trying to adapt veyDer's Event system to my own Mythology mod (see .sig), I fixed all of the above, and passed my fixes along to Hipfot and Skodkim for their own use back in December. In case you weren't aware, there's already a thread for this package over in the Mod Components forum where they updated their component to use these fixes.

    The changes I'd made that weren't possible in the original mod included:
    > The ability for an AI to receive a player-specific Event as easily as you could, AND pick between any options with some basic Flavor weighting. You could even add an external weighting function to make the AI change the type of outcome it preferred on the fly, in addition to the Flavors involved. (My mod has an alignment system, and each outcome has both its direct effects AND an alignment shift, so I needed a dynamic two-stage weighting.)
    > The ability to split conditions into both Event-specific and Option-specific conditions. (In veyDer's original system, all conditions were tied to an option; if you wanted an event that could only trigger once you reached, say, the Medieval... well, it'd waste a HUGE amount of overhead checking to see if all options' conditions were valid for every possible combination of unit, city, and plot.)
    > The ability to add a global timer that would prevent any events from happening within X turns of each other. In my mod, I have it to where you can never experience two events within 5 turns of each other, ever.
    > The ability to add a event-specific timer that could be used to either prevent a specific event from ever repeating within X turns (I use 20 and 40 for most events), and setting that value to -1 meant that a certain event could NEVER repeat for a given player (used for certain really rare but powerful events).
    > The ability to adjust the probabilities for an event on the fly. My mythology mod uses an alignment system, and depending on your alignment, some events will be more common and some will be less. You can easily use this mechanism to make events more likely to occur for someone who hasn't had one recently, to avoid the obvious randomness issues.

    Now, I don't know what Thal actually received, or whether he intends to make use of any of the above features. But they're all possible, and have all been used within my own mod for a few months now to manage a pool of ~30 events.
     
  9. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    Randomness is good if it adds variety between games without determining the outcome. Getting 500:c5gold: on turn 10 from starting next to a natural wonder as Spain is basically an I-Win button. :lol: In contrast, things like events or ancient ruins should have much less of an impact.
     
  10. Txurce

    Txurce Deity

    Joined:
    Jan 4, 2002
    Messages:
    8,280
    Location:
    Venice, California
    Thanks, Thal. If it's roughly on the scale of ruins, or conversely running into a bad barb situation, then it should enhance the variables that I particularly enjoy. I haven't had a chance to play with Events yet because I'm giving someone a tutorial using v126, and it takes a lot longer than my solo blitzes.
     
  11. The_J

    The_J Say No 2 Net Validations Administrator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    36,340
    Location:
    DE/NL/FR
  12. apocalypse105

    apocalypse105 Deity

    Joined:
    May 17, 2011
    Messages:
    2,705
    Hell no random events break the game appart

    I can't tell you how many times I stopt playing a game because I found eldorado
     
  13. Dunkah

    Dunkah Emperor

    Joined:
    Feb 7, 2007
    Messages:
    1,189
    Location:
    Just north of Boston
    Hooray! I have been using Hipfot, Skodkim, Spatzimaus, and VeyDers user events and absolutely love the variety it adds to the game.

    Perhaps if you could make them "Turn-Off-able" for the haters... but please keep!
     
  14. Txurce

    Txurce Deity

    Joined:
    Jan 4, 2002
    Messages:
    8,280
    Location:
    Venice, California
    Keeping in mind that I have yet to play with Events, I have wondered whether this is like a mini-mod, a VEM component that could have an easy on-off switch, or enough like Ruins that it should be embraced as is.
     
  15. Spatzimaus

    Spatzimaus Mad Scientist

    Joined:
    Sep 21, 2005
    Messages:
    3,063
    Location:
    Los Angeles, CA
    It would be trivial to add an on-off switch to the existing code, as it's completely self-contained Lua logic. I didn't add that sort of toggle in my own mod because I NEED the events (they're the primary driver of alignment changes in my religious system), and in my mod the effects are always positive (and therefore are part of the mod's balance equations) but it's pretty obvious where to place the toggle check if you wanted one in a mod where some effects were positive and some were negative.
     
  16. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    I like events but really dislike some of the aesthetic aspect. Adding resource to an improved plot shows it as unimproved. Also I would love some manner of visual on the event popup. Hmm.
     
  17. wobuffet

    wobuffet Barbarian

    Joined:
    Jun 27, 2011
    Messages:
    1,248
    Any way we could get a line at the top of some *.lua file, something like
    Code:
    local probMulitiplier = 1.00
    so that users can easily decide "I don't want events, I'll set this to 0" or "I really like events, I'll make this 1.5" or "Events are cool, but come a bit too often... I'll make this 0.5"?


    Also, I don't know how easy this would be to code (or if it's already there!), but is there any mechanism for balancing different player's luck re: the random events? What I mean is, Civ X should get better events than "usual" if and only if everybody else does too (more or less, of course).

    Alternatively, Civs behind in score could get a couple more good events, although score's obviously a rather imperfect measure of probability of winning.
     
  18. mitsho

    mitsho Deity

    Joined:
    Nov 3, 2003
    Messages:
    8,178
    Location:
    Europe, more or less
    The Mario Kart Syndrome? I do like it, not sure wether it's a good idea for civ. After all, you should be punished for doing badly. Also, I see complaints about the enemy capital getting a free city wall just as I am about to take it. Not fun... ;) Even if it would be realistic to some degree and make the late game more fun...
     
  19. Spatzimaus

    Spatzimaus Mad Scientist

    Joined:
    Sep 21, 2005
    Messages:
    3,063
    Location:
    Los Angeles, CA
    Again, I don't know what code Thal is actually using, but yes, it'd be trivial to do this. In fact, it was already done. You see, in the blocks of code I gave to skodkim/hipfot, I'd included a call to an outside function, a weighting algorithm to modify the base probability for that player for each event. The probability would be based on their alignment; Lawful players would be more likely to get Lawful events and less likely to get Chaotic ones, and vice-versa.

    Since they didn't need that in their event mod, the call to the weighting function was simply removed to where the base probabilities weren't multiplied by anything. You could simply put a multiplier in there in lieu of my extra bit of code...

    ...or you could KEEP the call to the weighting function and have it base the value on that player's current rank instead of alignment. Or do both.

    (I also had a bit of code that'd weight the options for each individual events, to where an AI of a certain alignment would be more likely to pick outcomes aligned with certain alignments. This was also removed, and hard-set to 1.0 in their mod.)

    Honestly, I probably should have just posted my updated UserEvents as its own mod component, but it was just easier to go through Skodkim and HipFot's thread instead of making another one. They didn't need some of the functionality I'd added, so what they ended up with was a somewhat simplified version of my logic. But if you DO want that full functionality, you could just start from my own mod's logic and use their actual events. (My code is fully backward-compatible, with the sole exception of the weighting function mentioned above.)
     
  20. Txurce

    Txurce Deity

    Joined:
    Jan 4, 2002
    Messages:
    8,280
    Location:
    Venice, California
    If VEM is going to have Events, then I think spatzimaus' weighting so that certain civs are more likely to have (or act on) certain Events is a terrific idea, and would love for it to be included in VEM.

    I agree with mitsho that weighing Events as a handicap to help trailing civs is not a good idea. It not only penalizes success, but has nothing to do with historical reality (where good and bad Events can happen to any civ).
     

Share This Page