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

Some Observations About Events and Techs

Discussion in 'Civ4 - Creation & Customization' started by Merkava120, Feb 14, 2020.

  1. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    380
    Gender:
    Male
    Location:
    Socially distant
    I've been fiddling around trying to create a dynamic tech tree using random events (so have techs be randomly discovered by your people instead of you actively researching them), and I found out some interesting things.

    1. Events that have to do with techs do not occur unless you can actually research things (i.e. you have to have a city).
    2. Events that give you progress toward a tech will only give you that progress if the tech is available to research right now. So
      1. you can't get disabled techs through events
      2. you can't get techs that are enabled but have disabled techs as a prereq
      3. you can't get techs further up the tree than where you're at / can't skip prereqs
    This makes doing a dynamic tech tree using pure XML...much harder. The only way I can think of to go from scratch to dynamic tech tree would be to have an event give you a city and then have all the techs in the tree cost 1,000,000,000 to research so you have to rely on the events to give you progress. But that sort of takes the fun out of it.

    Of course, you could just use a python callback with an event, to give you a tech, I think. That's probably the easiest.

    Anyone else have random thoughts about making dynamic tech trees? There were also some good ideas on this thread.
     
  2. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,058
    Gender:
    Male
    Location:
    Leblanc
    Using Python to give the tech instead is what I would do. Not even the vanilla Firaxis events are all XML only, and it's pretty lightweight.

    Why is having a city a concern? Doesn't everyone have a city except the first few turns at most?
     
  3. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Perhaps he has a "Nomadic Start" in mind - I certainly would :)
     
  4. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,058
    Gender:
    Male
    Location:
    Leblanc
    That's interesting.
     
  5. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,519
    Gender:
    Male
    Location:
    Canberra, Australia
    The ends if you (player) don't have a city or unit that can build a city. Nation dies if it has neither also. Also only cities generate :science: so you can't research without a city.

    There was a mod by Jonny Smith (I think) that had nomadic units but they still had to set up camp to get :science:. The camp was the city. It was just temporary.
     
  6. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    380
    Gender:
    Male
    Location:
    Socially distant
    Yeah that's the idea. I've made it so that units at the beginning are losing health every turn which recharges when they kill animals. Planned on having them randomly discover things like archery, planting, etc. that eventually combine to give them a settler and start a civilization.

    Another idea I had: it would be cool to make a python callback function that I could use for every event, that gives a tech depending on the name of the event (for example EVENT_TECH_ARCHERY would give the archery tech). I don't know how to reference EventInfo XML tags from python though, is that possible?
     
  7. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    380
    Gender:
    Male
    Location:
    Socially distant
    I got it to work!!:hammer::run::rockon:

    This snippet takes the name of the event, strips off the first six characters (e v e n t _ ) and gives you the tech that matches the rest.

    So then all you have to do is:
    1. Put "giveEventTech" in <PythonCallback> in the XML for the event.
    2. Make sure the name of the event is EVENT_TECH_blahblahblah.
    And it will give you the tech when you choose that event after it triggers.

    Code:
    ## Give a technology from the event name ##
    
    def giveEventTech(argsList):
       iEvent = argsList[0]
       kTriggeredData = argsList[1]
       eventInfo = gc.getEventInfo(iEvent)
       eventString = eventInfo.getType()
       techString = eventString[6:]
       iTech = gc.getInfoTypeForString(techString)
       player = gc.getPlayer(kTriggeredData.ePlayer)
       iPlayerTeam = player.getTeam()
       pTeam = gc.getTeam(iPlayerTeam)
       iLeader = pTeam.getLeaderID()##this might seem circular but I need the integer reference for the player
       pTeam.changeResearchProgress(iTech, pTeam.getResearchCost(iTech), iLeader)
    
    If you look at the code carefully there's a whole lot of
    Code:
    this
    that = this
    that thing = that
    useful thing = that thing
    
    but I couldn't find a way around it :lol:


    Edit: Also just confirmed that it works even if the tech in question is disabled. So, bombs away!!
     
    Dancing Hoskuld and Zeta Nexus like this.
  8. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    I am really curious about your work. I'd like to try it :)
    I also wonder how much the AI can handle it?
     
  9. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    380
    Gender:
    Male
    Location:
    Socially distant
    I could put it up on the database if you want. It's still in super early stages though, haha, only have one tech in the "tree", planning a few hundred :crazyeye:

    As for AI, I think it'll react to a dynamic tech tree pretty well. It won't be able to predict what techs happen when like a human would, but I think that makes it more natural.

    So far I've only played a few turns and at least one AI dies every time :lol: so I think the animals might need balancing a bit.
     
  10. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Are you modding vanilla BtS or some other mod? I ask it because some mods (AND2, C2C) have more capabilities regarding hunting.
    In mine for example (which is an AND2 modmod) killing animals will generate yield and :gp: (Great Hunter) in nearest city and has a chance of subduing the animal (can be butchered in a city for more yield or build special buildings).
    I also came up with a simple Improvement+Event based Gathering mechanic but it could use some improvement. However, I hate working with events :sad:

    I am somewhat satisfied with the Hunting&Gathering I have... Somewhat... What I don't like is that both require a city.
    Your approach is very interesting but has some downsides:
    • Very tedious: Has to define each tech separately
    • Not universal: You can't get a tech that is not defined
    • Not AI friendly: I think the AI will fall behind with this very much (AI Autoplay test are needed)
    • One at a time: each event can be triggered only once per turn, even if you meet the requirements several times
    ...but it doesn't need cities which is great.

    A little brainstorming about what (I think) would work:

    Divide all (ancient era) techs into 4 categories: :food:,:hammers:,:commerce: and :strength:(military).
    When a unit is standing on a tile it generates :science: to the corresponding techs that have met all requirements. Example: A Warrior on a tile with: :food::food::hammers::commerce::commerce: would generate 2:science: for Agriculture :)food:tech), 1:science: for Stone-tools :)hammers:tech), 1:science: for Ritualism :)commerce:tech) and 1:science: for Storytelling :)commerce:tech). Then it kills a Lion (3:strength:) that generates 3:science: for Hunting :)strength:tech).

    Pros:
    • Don't need to teach the AI anything
    Cons:
    • Who can code this? :mischief: :lol:
    • How would you get :science: for Fishing?
    • What would make you move the units from tile to an other once you find a very rich one?
    More thoughts:
    • For balance reasons a Settler should be created at about the same time for all players. Or... if a unit does not move that civ also gets 1:science: for Sedentary Lifestyle tech and once the tech is discovered he receives a free Settler. This way if any or all AIs would be passive they would still get a Settler earlier than the Human player and could start normal development; in the the meanwhile the Human player can enjoy a different play style with similar results.
    • Civs should not explore "half of the world" during their nomadic wandering, so tiles in fog of war should turn back to black until some middle-ancient tech.

    Okay, I think I went a little deep here :D
     
  11. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,519
    Gender:
    Male
    Location:
    Canberra, Australia
    I agree this looks very interesting. I am currently working on a project that aims to explore the nomad-sedentary boundary.
    I like the clean feel to your mod's (AND2) hunting mechanic but while I am still building the C2C mechanic I like the depth and breath of it. There is a bit of tedium in the middle that needs addressing.

    This is really painful as you can't auto explore. Your explorers end up covering the same plots over and over. Pie_at has it in his mod. It just means I don't bother exploring. In Pie_at's mod it does appear that goody huts will respawn in hidden territory under some circumstances which does reward exploration but not enough to overcome the irritation;).
     
  12. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    THX :hatsoff:
    Errr... what do you mean? I am not native in English so sometimes I miss the point.
    I understand your point and agree. But until you have no cities I think it would be a valid feature. Once you have a city (or very soon after it) FoW should work normally.
    I think it would add to the nomadic immersion.

    @Merkava120
    Once you have some techs done (a dozen or so) please upload your work. I'd like to try it. Thx!
     
  13. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,519
    Gender:
    Male
    Location:
    Canberra, Australia
    I second this.
    In C2C hunting is more exciting when you are capturing or killing wild animals you have not seen before. This happens two or more times in C2C. It happens at the start and every time you find a new landmass with new biomes. From Sedentary Lifestyle to Navigation is a long time to be only seeing the same animals. In C2C animals spawn throughout the game. The mechanism is separate to the barbarian spawning mechanism.

    The problem with loosing memory of explored lands is that what you suggest is the exact opposite of "reality". Even migrating animals "remember" the terrain they traverse in their migrations. The latest indication that this is the case is that if an animal is reintroduced to a range where the previous group died out. Then the new group will not go as far in their migration as the original herds. Evidence is not in but the new herds do seem to increase their range each year and will get back to the original herd's paths. It would be more "realistic" to have the FoW only reset when the nomadic people settle into cities. It would be even better if the terrain moved a bit in that fog as well. A mountain range moving one plot, the river or coast not quite where the player remembers it and so on. Way too complex.;)
     
  14. Merkava120

    Merkava120 Oberleutnant

    Joined:
    Feb 2, 2013
    Messages:
    380
    Gender:
    Male
    Location:
    Socially distant
    That's a good thing :thumbsup: My turn lol.

    Just vanilla. I've added a lot of python (mostly by platyping) to it though. I envision a mod that combines the best ideas of earlier civ mods (revolutions and inquisitions, etc.) but also gets more realism in ways that haven't been fully done yet (true nomadism, dynamic tech tree). The main goal with all of that is to make a game that is forcefully different every time you play.

    Also this. Nomadism ftw!

    My solution for hunting was just to damage units outside a players' borders every turn, then give them health back when they kill animals (or plant units with tiny strength and movement 0). This also makes things like supply wagons possible, and also affects exploration...

    The exploration problem is really hard...

    because yes, it's unrealistic that a newly-formed city-state has accurate and detailed maps of the entire continent.

    ...and it's also annoying to explore everything three times.

    One way to solve it, that I accidentally found, is to spawn dangerous animals everywhere and give the nomads a measly camp unit to protect, which spawns their warriors. Turns out that when your entire civilization can get destroyed by one wolf-pack you tend to park in one area and hope it ends soon (which is actually fairly realistic to how 'nomads' in prehistoric times moved around - they typically stayed in a pretty close area, and migrations took tens of thousands of years across many generations).

    But even then, you do move around, and then when you settle you still have either 1. a perfect map or 2. an annoying need to re-explore everything again (which is doubly annoying now, because there are dangerous animals everywhere and your unit loses health every turn).

    So, I have no idea. :dunno: Probably just an inherent problem with how the game works - one player controlling a whole civilization.

    The more I think about your idea the more I like it. In fact, a combination of the two might be ideal.

    The main reason to use events over techs would be the ability to have very specific conditions lead to very specific techs - for example, discovering bronzeworking requires that you have tin smelting and copper smelting going on in the same city. You could do the same kind of thing with the auto-generated way, but for specifics it would get very tedious (you'd have to hard-code the specifics for each tech).

    However, it's fairly easy to split the techs into categories by Advisor/Great Person (I think I've seen mods do that). Then you can have all sorts of triggers lead to beakers in the different categories - units resting in certain tiles, units getting killed, buildings being built, population growing, contacting other civs, trading with other civs, on and on.

    You'd have to make sure to restrict eras, so that ancient civs don't accidentally discover Cannons, but that's pretty easy too.

    I am now envisioning a combination of three tech tree ways:
    1. Techs that can only be triggered by specific conditions through events, such as bronzeworking, settling your first city, etc. (Similar to historic events spurring certain technologies.)
    2. Techs that are learned over time through python like you said, that build further advances in different areas. (Similar to people getting better at whatever they do a lot of.)
    3. Techs that you can actually research through the tech tree, once you have the ability to direct scientists. (Similar to actual grant-funded scientific research.) Could combine this with events/platyping's tech events mod to give random techs of certain types after completing certain research.

    Actually, if there's a truly dynamic and realistic tech tree, balance will be very difficult throughout the whole game. My vision of the mod ignores balance. You might be plugging along as a little ancient empire and then get totally destroyed by invading soldiers using new bronze weapons/better tactics, for example.

    I don't know how yet, but I plan to include an ability to switch to other civs/new civs that spawn, kind of like RFC. That way you could switch if your civ goes down the pipe.

    After I get a mod fully working with a dynamic tech tree I'll be genuinely curious how people's games go. They shouldn't go the same way twice!

    Ok will do! Obviously I have big plans for this mod, but I think I'll upload one as soon as I get it reasonably working up to founding cities. I'll probably post a thread for it too.
     
    Zeta Nexus likes this.
  15. LPlate2

    LPlate2 Warlord

    Joined:
    Dec 27, 2018
    Messages:
    112
    Spoiler :


    This is one of the handiest bits of python I've seen in a while.
    How would you go about converting 'TECH_blahblah' into 'EVENT_TECH_blahblah'?
     
  16. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Sure thing. A player doesn't have to forget the area but giving him a map is a different thing :p
    Requiring a very early tech (e.g Story telling, Oral traditions, etc.) is realistic. Remember that each tile represents very big area of the real world. Depending on map size a tile may represent 100 square km. In real world that size of area may hold several hill and valleys and rivers, etc.
    I agree that it is annoying on a longer period but if it is limited for the early game it could be a challenge instead: "Should I beeline for this tech for X building/unit/civic or that one to keep my tiles revealed?"
    Perhaps it should be tweaked this way: Any FoW tile that is adjacent to a black tile has a 20% chance of turning black. This way it wouldn't be all black outside your sight right the next turn, just the edges get "forgotten".

    Way too complex. Way too weird. :undecide:
    But I do see your point.
    The best would be to play the early game in a separate map that is an enlarged version of your starting location. Take a 7 tiles radius around your start location (15x15tiles) and enlarge them into a separate map with a scaling of 1:4 (60x60tiles).
    Make some variety: If a tile has Forest not all 16 tiles should have Forest; but also some of the neighbouring tiles outside the 4x4 are could get Forest. Same goes for Hills, Peaks, Jungles, Fresh Water Lakes, etc. An Oases would be translated into a 1-6 tiles Fresh Water Lake and Rivers into 1 tile wide fresh water Coast lines. Even some extra rivers could be added, representing Streams that would not appear on the big map.
    And when this part of the game ends (e.g. the human player settles a city) the whole area is converted back: If too many Forest tiles are chopped, that tile is cleared on the big map too. If a barbarian city is funded and is bellow 5 pop, than it is converted into a Tribal Village; if it is above 5, than it is converted into a size 1 barbarian city.

    And... "Wake up, Nexus! Wake up! You are dreaming again!" :aargh:

    Probably it is also way too complicated and of course I cannot imagine it working in multiplayer either.
     
  17. LPlate2

    LPlate2 Warlord

    Joined:
    Dec 27, 2018
    Messages:
    112
    I had looked at reinstating the fog of war on any tile that was not currently visible (until Cartography was researched) back in 2012. The AI does not handle it well, kept exploring same few tiles. So, I just hid the tiles for the human player and blocked map trading in my trial mod.
    If doing something like this (reinstating fog of war) you'd just want to apply it each turn for the human player and only apply it for the AI on the turn that they get the Cartography (or equivalent tech). That way the player gets the challenge, AI can function and map trading is fair with the right tech.
     
  18. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,519
    Gender:
    Male
    Location:
    Canberra, Australia
    I have seen a game that did just that. Not Civ though. Not only that but maps you bought of other nations were not quite right if you did not already have some landmarks in common. This meant you could travel to a far off city only to discover that your map was off by 5 plots. It corrected itself once you had explored some common areas. Maps from one nation on other nations were even more off if neither of you had some common reference points.

    However the point is that I don't find hiding the plots in fog of war to be useful even for the player. All it does is stop you using auto explore. I can remember the terrain that has been explored.
    Yes having the map expand to fit the needs would be nice but how to do it? I did think of saving the game running a program and then running some code on it to make a new save and then starting the game from there similar to a scenario. Another option is to have more types of screens. Sort of like the tactical fight screen people have talked about in the past. One of the problems with that is the borders. What happens across them?
     
  19. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Here's an other idea how to prevent a nomadic start from exploring the whole world:

    Your early units start with "Cannot reveal new tiles" feature, except for one: Tribe.
    Tribe would have a line of sight higher than usual and 1:move:. So you can move around your Tribe (default AI could be explore) and your other units could move only within its close proximity. Tribe could receive Xp based on what the other units are doing around it (like killing animals). It would have its on promotion tree, for example:
    • Wandering I-II-III: +1 range of sight
    • Birth of a Forager: when chosen receive a Forager unit, then the promotion is removed
    • Large Tribe: when settling a city, start at 2nd population level
    • Ancient Lore: when settling a city, start at 2nd culture level
    When finally receiving a certain tech it could fund a city and "normal game" starts.
     
  20. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,818
    Gender:
    Male
    Location:
    In a constant brainstorm...
    I wonder if a cross-mod data-transfer would possible (and desirable)?

    Phase 1: Start a game in a mod dedicate to the prehistoric era with a nomadic start:
    There would be no AIs involved, only opponents would be the barbarians and animals so any crazy-human-understand-only design would be possible. Maybe it could even be based on Colonization and make advantage of its resource collecting system as gathering.
    Phase 2: When you win Phase 1, transfer the data to an other compatible mod - be it C2C, AND2 or CoM. I understand that to make this work all included mods need to be designed along the same guidelines and a lot of things would need to be standardized - mainly names of units, buildings, terrains, resources, etc. The utility would need to be able to skip things that are present only in one of the mods. Once the utility has created the new scenario the game would go on as a regular game until...
    Phase 3: Launch the Spaceship! Once the first spaceship is launched the utility would create another scenario with a space mod (PlanetFall, MarsNow!, etc). Again, the utility should be able to transfer some data between the mods, such as: techs and when an other Earth-civ lunches an other spaceship. If PlanetFall is the space-mod, than the first civ launching the spaceship would be actually launching the Unity, on which the mutiny happens and breaks into factions. So it wouldn't be a single civ in the game without any competition until other earthers launch an other ship.

    Ahhh... Dreaming :love:
     
    Dancing Hoskuld likes this.

Share This Page