Main.SideBar (edit) |
Main /
UseOfUpgradesIntroductionIn this document we discuss where upgrades might be of use and how such a use could be implemented. We assume that we have an upgrade implementation that provides at least the features described in Upgrades, and therefore at least temporary as well as permanent upgrades and upgrades that apply to all units of a type, all new units of a type or certain units only. DefinitionThe term "Upgrade" refers to the fact that some property (such as maximum health) is modified in some way so that it differs from its original value. For example an upgrade "health += 100" increases the maximum health of a unit by 100. If that unit had 10 health only out of an initial maximum of 100, then it has a new maximum health of 200 and the actual health may depend on the implementation (it might remain at 10, it might be increased by 100 or it might be increases so that the health/maxhealth factor remains constant, i.e. health=20).
The term "technology" has often been used as a synonym for upgrades in Boson, therefore I am going to define it as well here, as we use it differently. A "technology" is an upgrade that can be researched, for example in a TechCenter. Upgrades that can not be researched (such as "experience") are not called "technology". Possible upgrades
These are always permanent. They always apply to all new units of the types they apply to. They can apply (but dont have to) to existing units of the types they apply to.
These are always permanent. They apply to a single unit only. Certain technologies (or other upgrades) might even cause units to have some "initial" experience, i.e. to have an experience upgrade right after they got produced (a training center might cause such an effect)
very similar to experience, but are not permanent. An example would be attacking a civil unit: the "good guys" may get a negative upgrade then, the "bad guys" might have fun at doing so and therefore may get a positive upgrade.
can be any kind of upgrades: temporary, permanent (usually temporary), positive, negative, ...
like Special items this can be any kind of upgrades. But unlike special items, this can happen without the player doing anything.
How do you take care of removing such upgrades? E.g. suppose you have two events: "night" and "day" triggering "Night" and "Day" upgrades. How do you make sure the "Night" upgrade gets removed before the "Day" is applied? - RL
AB: from IRC discussion: From a upgrade-architecture point of view this is easy: removeUpgrade(night); addUpgrade(day);. The concrete implementation might use a "ApplyOnEvent=EventList" entry in an upgrade config and analogously a "RemoveOnEvent=EventList" or a "RemoveBeforeApply=UpgradeList" entry.
always temporary (lasts only as long as that unit or unittype is on the map). Example may be "sightrange *= 2" when player has a radar, or "health *= 10" when a "general" is on the map.
Same as "Presence of a certain unit or unittype on the map", but with a certain range. Both may be implemented the same way, by using "infinite range" for the previous one.
StorageIDsThe last unresolved problem from Upgrades (upgrades architecture) is how to save and load upgrades. In other words: how to assign IDs to the upgrades. We will most likely require IDs set by the user for the upgrades. I cannot see a way around this, as we cannot load upgrades for a savegame otherwise (unless we would save the whole upgrades to the file, which I do not want). If we make use of IDs, then they must be per-file IDs. Demanding that an ID is unique globally is much too much work for a upgrade designer. In order to load upgrades anyway we have several options:
I think it makes sense to use the "multiple SpeciesTheme::upgrade(id) methods" aproach. We actually need multiple methods, but just two parameters, a "type" (experience,...) and a (local) ID parameter. Therefore Unit::loadUpgradesFromXML() just needs to call SpeciesTheme::upgrade() with two parameters, which can both be read from the XML file. |