Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,059
Recently we have been using terms like "tech tree" and "tech progression". The main idea is that not all game content will be available from the start, but rather more and more will be unlocked as the game progresses. Civilization have proven this concept to be valid for gameplay and it makes sense that tanks and planes are included, but not from the start due to starting during the stone age.
The core system
I worked on the tech tree implementation in Medieval Conquest and based on experienced I already wrote some implementation in develop-2.8. It's not a complete copy though because I redesigned away from the time killers regarding code creation and maintenance. Also what I wrote is faster at runtime.
It's designed around the concept of a new xml file called CivEffects. A player can own them and they give bonuses (or penalties). This can be allowing a new unit or profession, but it can be so much else too. Players don't get CivEffects directly. Instead a player gets them by gaining something, which provides a CivEffect, like a trait, civilization, era, founding father etc. That way we can add a feature to one of them and it applies to all. We can then add civics and techs without any code for what they should do when you gain them, just making them give you a CivEffect, meaning they from day one can do everything those other can do.
The CivEffect implementation relies on a cumulative cache system, meaning it's fast and the runtime is constant regardless of if we have 5 or 500 CivEffects in xml. That's better than the BTS implementation of techs. In fact it takes vanilla actions into account like which unit to use for a certain unitclass meaning that alone makes it faster than vanilla.
Tech requirements
We need a way for the player to gain techs. The most common method is to add a tech tree. However "just add a tech tree" doesn't answer how it should work ingame.
If we go for a civ style tech tree, we have the benefits of relying on a concept most players already know. We could make techs have requirements, but rather than techs we could set them to be CivEffects. While techs would be the most common requirement, eras could be interesting to add too. From an engine point of view, it would be a good idea to not restrict meaning by just allowing all CivEffects, somebody can write a trait as requirements in xml without any dll updates.
We should have multiple requirements in some logical and and or setup. Working on lists rather than copying the civ4 system. Also adding the ability to unlock by listing say 5 requirements and say it's unlocked when the player has at least 3. Having a not requirement could also be interesting like an aggressive trait could prevent a certain peaceful tech.
Rather than adding one tech tree, the engine should have a list of tech trees. This way it will support a military tech tree, a trade tech tree, an exploration tech tree and so on. Since they are all CivEffects, they can add requirements of techs on other trees if needed. I'm not saying we should use it, but the engine should support it because ideally it's added now and then it supports all the stuff we need in the future without too much hassle. It's way better now to just think this into the design than to try to add it later because adding a new feature to existing code can be way more time consuming and prone to bugs.
Gaining techs
We need something to unlock the techs on the tech tree. In most cases this is done with research points. The big question is: how should we be able to gain research points?
The research modcomp (used by Medieval Conquest and Colonization 2071) has a research profession, which produces a research yield. Each tech can then set yield requirements like the farming tech will make the researcher create one research for each food spent on research. Not filling out requirements means free like crosses in the sense that they are produced without any input resource.
However the question is if that is the way we want to go. Does that feel like a colonization feeling? Should we be able to gain research points in some other way?
One way that could be interesting would be to have one type of research points for each research screen. We could then have a native techs screen where you gain the research points by trading with the natives or live with them and otherwise interact with them in a friendly manner. Multiple types of research points also means we would support researching one tech on each screen at the same time. I would love to add support for this in the engine.
However it still doesn't answer the main question: how do we gain research points towards stuff like better military units?
What techs can do once gained
Another question is what techs does as in why would a player wants to gain techs. The simple answer is they unlock units, but they can do so much more.
If we take allowUnit as an example, then each CivEffect can have an AllowUnit value for each UnitClass (usually 0). A player then has the allow value, which is all the owned CivEffects added together. If it's larger than 0, then it can be used. This is the BTS approach, except I simplified it for runtime performance and at startup all players gain an autogenerated CivEffect, which adds 1 to everything where no CivEffects has a positive value, meaning if nothing adds the unit, it will be available from the start. Since xml can also contain negative values, it's possible to disable units as well. It's also possible to assign -1 by default meaning you need two +1 CivEffects to unlock, like a specific tech and a specific Civic at the same time. It's a simple concept, but it becomes very flexible with a bit of xml creativity.
This allow system benefits from being implemented already.
The same system applies to buildings, professions, promotions, improvements, civic, yields etc.
As for units, there is also allow immigration meaning a unit has to be allowed as both unit and as immigrant in order to show up on the docks. This allows features such as an FF removing all criminals from the dock (sounds familiar?).
There is also an existing implementation of changes to the count of units on the dock. Right now the dll defaults to 0 while the default CivEffect (in xml) says 4. However we can add a tech, which has +1, in which case the dock will instantly generate a new unit and place it on the dock to give the player one more to choose from. The only upper limit is the screen space in the Europe screen and I have tested this with 15 units. It's capped at 1 unit though, meaning providing negative values will not make the unit count drop below 1.
Free promotions is also implemented in categories: all, specific unit, specific profession, specific UnitCombat. (I think that were the options). The power of adding free promotions should speak for itself.
For other tags we can add to CivEffects, for a start I would say anything, which exist for anything, which provides a CivEffect. This means anything currently possible with traits, civics, FFs and all that.
So what would we realistic use this for. Something like farm lv 1 is available from the start, but it can't upgrade to lv 2 before the plot owner has unlocked the improvement in question.
Pioneers can only build allowed improvements and routes, but it can also need to unlock the build itself, meaning builds without any route or improvement can require research (like drain marsh).
Free building in all colonies (possibly being able to filter based on all/landlocked/port). Making this an otherwise unbuildable building allows adding a building in all colonies, which grants +5% food production or similar. How we can benefit from this depends on what fun features we put into CvBuildingInfo. This can also be something like we currently have from FF as in -X% yield (like tools) needed for building a building.
Other interesting boosts could be a fixed addition of yields/turn, like +2 food.
Looking at what is in M:C, the following could be interesting too:
The Europe travel time could be set for each access region, meaning it would be possible to set for only west or only east. Since CivEffects can also be set for each CvCivilizationInfo, it will make it possible to add players coming from west like China or perhaps Russia. They would then travel home fast towards the west and slow from the east.
We can also split builds and unlock them at different times like we can unlock high end roads for flatlands before a later tech unlocks it for hills and mountains. This would create the interesting scenario where it could be beneficial to use a high quality road to go around the mountains rather than a slow road to cross directly.
Yes I'm aware that some of them might easily become overpowered. That is something to keep in mind.
How do we make this into a working plan?
That's the question. I have written about what techs can do, but it still doesn't answer the two main questions:
The core system
I worked on the tech tree implementation in Medieval Conquest and based on experienced I already wrote some implementation in develop-2.8. It's not a complete copy though because I redesigned away from the time killers regarding code creation and maintenance. Also what I wrote is faster at runtime.
It's designed around the concept of a new xml file called CivEffects. A player can own them and they give bonuses (or penalties). This can be allowing a new unit or profession, but it can be so much else too. Players don't get CivEffects directly. Instead a player gets them by gaining something, which provides a CivEffect, like a trait, civilization, era, founding father etc. That way we can add a feature to one of them and it applies to all. We can then add civics and techs without any code for what they should do when you gain them, just making them give you a CivEffect, meaning they from day one can do everything those other can do.
The CivEffect implementation relies on a cumulative cache system, meaning it's fast and the runtime is constant regardless of if we have 5 or 500 CivEffects in xml. That's better than the BTS implementation of techs. In fact it takes vanilla actions into account like which unit to use for a certain unitclass meaning that alone makes it faster than vanilla.
Tech requirements
We need a way for the player to gain techs. The most common method is to add a tech tree. However "just add a tech tree" doesn't answer how it should work ingame.
If we go for a civ style tech tree, we have the benefits of relying on a concept most players already know. We could make techs have requirements, but rather than techs we could set them to be CivEffects. While techs would be the most common requirement, eras could be interesting to add too. From an engine point of view, it would be a good idea to not restrict meaning by just allowing all CivEffects, somebody can write a trait as requirements in xml without any dll updates.
We should have multiple requirements in some logical and and or setup. Working on lists rather than copying the civ4 system. Also adding the ability to unlock by listing say 5 requirements and say it's unlocked when the player has at least 3. Having a not requirement could also be interesting like an aggressive trait could prevent a certain peaceful tech.
Rather than adding one tech tree, the engine should have a list of tech trees. This way it will support a military tech tree, a trade tech tree, an exploration tech tree and so on. Since they are all CivEffects, they can add requirements of techs on other trees if needed. I'm not saying we should use it, but the engine should support it because ideally it's added now and then it supports all the stuff we need in the future without too much hassle. It's way better now to just think this into the design than to try to add it later because adding a new feature to existing code can be way more time consuming and prone to bugs.
Gaining techs
We need something to unlock the techs on the tech tree. In most cases this is done with research points. The big question is: how should we be able to gain research points?
The research modcomp (used by Medieval Conquest and Colonization 2071) has a research profession, which produces a research yield. Each tech can then set yield requirements like the farming tech will make the researcher create one research for each food spent on research. Not filling out requirements means free like crosses in the sense that they are produced without any input resource.
However the question is if that is the way we want to go. Does that feel like a colonization feeling? Should we be able to gain research points in some other way?
One way that could be interesting would be to have one type of research points for each research screen. We could then have a native techs screen where you gain the research points by trading with the natives or live with them and otherwise interact with them in a friendly manner. Multiple types of research points also means we would support researching one tech on each screen at the same time. I would love to add support for this in the engine.
However it still doesn't answer the main question: how do we gain research points towards stuff like better military units?
What techs can do once gained
Another question is what techs does as in why would a player wants to gain techs. The simple answer is they unlock units, but they can do so much more.
If we take allowUnit as an example, then each CivEffect can have an AllowUnit value for each UnitClass (usually 0). A player then has the allow value, which is all the owned CivEffects added together. If it's larger than 0, then it can be used. This is the BTS approach, except I simplified it for runtime performance and at startup all players gain an autogenerated CivEffect, which adds 1 to everything where no CivEffects has a positive value, meaning if nothing adds the unit, it will be available from the start. Since xml can also contain negative values, it's possible to disable units as well. It's also possible to assign -1 by default meaning you need two +1 CivEffects to unlock, like a specific tech and a specific Civic at the same time. It's a simple concept, but it becomes very flexible with a bit of xml creativity.
This allow system benefits from being implemented already.
The same system applies to buildings, professions, promotions, improvements, civic, yields etc.
As for units, there is also allow immigration meaning a unit has to be allowed as both unit and as immigrant in order to show up on the docks. This allows features such as an FF removing all criminals from the dock (sounds familiar?).
There is also an existing implementation of changes to the count of units on the dock. Right now the dll defaults to 0 while the default CivEffect (in xml) says 4. However we can add a tech, which has +1, in which case the dock will instantly generate a new unit and place it on the dock to give the player one more to choose from. The only upper limit is the screen space in the Europe screen and I have tested this with 15 units. It's capped at 1 unit though, meaning providing negative values will not make the unit count drop below 1.
Free promotions is also implemented in categories: all, specific unit, specific profession, specific UnitCombat. (I think that were the options). The power of adding free promotions should speak for itself.
For other tags we can add to CivEffects, for a start I would say anything, which exist for anything, which provides a CivEffect. This means anything currently possible with traits, civics, FFs and all that.
So what would we realistic use this for. Something like farm lv 1 is available from the start, but it can't upgrade to lv 2 before the plot owner has unlocked the improvement in question.
Pioneers can only build allowed improvements and routes, but it can also need to unlock the build itself, meaning builds without any route or improvement can require research (like drain marsh).
Free building in all colonies (possibly being able to filter based on all/landlocked/port). Making this an otherwise unbuildable building allows adding a building in all colonies, which grants +5% food production or similar. How we can benefit from this depends on what fun features we put into CvBuildingInfo. This can also be something like we currently have from FF as in -X% yield (like tools) needed for building a building.
Other interesting boosts could be a fixed addition of yields/turn, like +2 food.
Looking at what is in M:C, the following could be interesting too:
- free experience for new units (specific units or all?)
- pioneer work speed modifier (general and/or specific builds)
- pioneer can start working after spending all movement points
- improvement upgrade modifier (might take 40 turns instead of 50)
- Changes to yield production at the colony plot (like all colonies produce +1 cotton if center plot produces cotton)
- Europe screens as in say Africa isn't unlocked from turn 1
- Modify tax related stuff like max tax cap
- Modify native land prices
- King's fee for transporting treasure modifier
- Gold from natives modifier
- Immigration cross requirement modifier
- Buy in Europe price modifier
- Unit heal rate modifier (settings for own team, neutral and enemy owned plots)
- Unit stats (like movement points) changes for any unit, which might not have a UnitCombat (may or may not be needed)
- Extra yield from plot if it produces more than a certain amount (like +1 fur for any plot producing at least 6 furs)
- Modifier for research point requirements (per type of research points, like cost -5%)
- FF point cost modifiers, specific type and/or all
- Missionary conversion rate modifier
- Improvement yield production change (providing we can make the code fast enough)
- learn time in native settlement modifier
- Europe travel time changes
The Europe travel time could be set for each access region, meaning it would be possible to set for only west or only east. Since CivEffects can also be set for each CvCivilizationInfo, it will make it possible to add players coming from west like China or perhaps Russia. They would then travel home fast towards the west and slow from the east.
We can also split builds and unlock them at different times like we can unlock high end roads for flatlands before a later tech unlocks it for hills and mountains. This would create the interesting scenario where it could be beneficial to use a high quality road to go around the mountains rather than a slow road to cross directly.
Yes I'm aware that some of them might easily become overpowered. That is something to keep in mind.
How do we make this into a working plan?
That's the question. I have written about what techs can do, but it still doesn't answer the two main questions:
- How do we add techs in a way, which feels balanced?
- How do we let the player get/research new techs?