Difference between revisions of "Buildings Model Quickpad"

From FreeOrionWiki
Jump to: navigation, search
(New Effect: SetEnabling, New Condition: Enabled)
 
(53 intermediate revisions by 11 users not shown)
Line 1: Line 1:
This is a draft pseudo-brainstorming attempt to resolve some issues with the current buildings model.  Nothing (new) here has been passed.
+
==New==
 +
===Empire Templates===
 +
====What?====
 +
* Want to be able to have some buildings unlocked at start of game.
 +
** In future, want to be able to have different empires start with different buildings unlocked at the start of the game, so "unlocked at start" shouldn't be a property of the building, but of something attached to each in-game empire.
 +
* Want to reduce amount of hard-coded game numbers, to be replaced by effects
 +
** In future, want to be able to have different empires have different effects groups for those that replace the hard-coded game numbers
  
==Issues==
+
====How?====
 +
Have a new xml file that contains "empire template" definitions. 
  
The non-effects details of the buildings model need to be worked outSome isses to consider include:
+
Aside: Could perhaps be called a "culture", but this term might be used for something else as wellIt probably can't be called just "empire" since in game, "empire" already refers to the set of planets and ships and related info that a player controls; I'll call this set the "in-game empire".
  
===Prerequisites (non-Tech)===
+
An empire template would be a attached to a player's in-game empire.  At the start of the game, all players, Human and AI, would be assigned empire templates for their in-game empires.  Multiple players' empires could have the same template.  This would be like having two empires in MOO3 that are of the same race.  They would be separately in-game empires, but based on the same empire template and thus would have the same starting techs and empire-specific bonuses or penalties.
  
Besides the technologies that unlock a particular building, we may want to be able to restrict where and when a building can be producedPossible restrictions include:
+
Empire templates would act like techs that their associated in-game empire knows.  They would have effects that would work just like tech effects, and they could unlock buildingsThey would be different from techs in that they wouldn't appear on the tech screen, wouldn't be reserached, and in future, wouldn't be tradeable or stealable, and would never be referred to by in-character game text.  By that, I mean that other empires in the game will probably specifically offer to trade for particular techs you know, so in-game characters know that "Techs" as a game concept exist.  In-game characters would not know about "empire templates", however, and would perceive their effects as inherent to the in-game empires they are associated with.
* Requiring the presence of another building first
+
* Requiring a particular special to be present, and/or be known to exists on or in the planet, system, empire or galaxy
+
* Requiring a particular planetary environment, star colour, minimum population, meter values, etc. for a building to be produced
+
* Future: Some sort of Civ3-like special resources model, of somewhat more complexity than the above requirements for particular specials
+
  
===Limits===
+
To make a building unlocked at the start of the game, it would be added to the <unlocks> tag of the template.
  
Similar to prerequisites, but opposite in effect, limits indicate when a particular building may not be built, despite all other requirements being metPossible limits include:
+
Empire templates could, and IMO should, also replace many of the current hard-coded effect-type bonuses to planets.  Until we add races, empire templates should include a set of effects that determine the maximum population numbers and default meter levels of planetsPlanets should default to 0 for all their max meters, and would get the current hard-coded increases to max meters of planets from the effects of its empire template.
* A limit on the number of buildings of a particular type on or in a planet, system, empire or galaxy, or within a certain distance.
+
  
This could be implimented using some sort of "building stacking group", similar to the stacking groups used with techs.
+
For now, since empires haven't been decided on and aren't scheduled for a while, there only needs to be a single "Default" empire template.  
  
===Maintainance===
+
====Also...====
  
We can already specify the maintainance cost for buildings, as indicated in the [[Effects]] page, but this idea needs to be extended to cover what happens if maintainance is not paid.  This may be integrated with the following section, Building Enabling.
+
A similar mechanism should be created to replace all hard-coded adjustments to meters that occur in the game with effects-defined adjustments.  These include:
 +
* Setting max population of planets due to type, size, environment, etc.
 +
* Bonuses to meters due to focus effects
 +
* Bonuses to planet health meters due to environment type
 +
* Bonusus or penalties to planet health due to availabilitly or lack of food(This will require a new "FoodSupply" condition that matches planets in a particular range of food supply levels.
 +
* Population, Resource and Construction current meter growth
  
===Building Enabling / Disabling===
+
Placing all these in effects makes modification simple, and allows variation between races or empires.
  
Buildings mostly (exclusively?) do their jobs through their effects groups, which already have activation and scope conditions.  These are very useful and versatile, but they have some limitations that are problematic for buildings.  In particular, we need ways to enable to enable or disable buildings' effects groups for reasons such as:
+
===Building Availability===
* unpained maintainance
+
====What?====
* player choice (requiring UI integration)
+
* Want to be able to write conditions or effects that determine whether already-unlocked buildings can be built at all (distinct from location conditions)
* technology prerequisites (new ones gained or previously known ones lost)
+
* non-tech prerequisites, as discussed above
+
* unmet limits, as discussed above
+
* after a fixed delay, or at a certain time
+
  
===Refinements===
+
Notable quirk:
 +
* Want to be able to limit the number of buildings of a particular type on or in a planet, system, empire or galaxy, or within a certain distance or number of starlane jumps.
  
tzlaine is already working on a way for effects to alter building descriptions for the purpose of refinements.
+
====How?====
 +
* Add a new effect: SetBuildingAvailability effect, which would act essentially the same way as the SetTechAvailability effect.
  
==Solutions?==
+
===Enhanced Prerequisites===
  
A mix of new effects and conditions and non-effects methods will likely be needed to impliment the desired functionalitly.
+
====What?====
 +
* Want to be able to have buildings' or techs' availability to be built or researched depend on things other than whether the player has researched a particular tech or set of techs.
 +
* Want to have "OR" as well as "AND" prerequisites for techs.  eg. must research (at least two of these three techs) AND (this other tech)
 +
* Want to be able to do various cases and combinations:
 +
** Make a tech become available after researching all its prerequisites, or after being made available by an effect.  eg. can research prerequisites, or can find special resource/special that makes tech available without its prerequisites
 +
** Make a tech become available only after researching all its prerequisites and having an effect make it available.  eg. must research prerequisite and must have certain resource/special make tech available; just effect, or just prereqs alone isn't enough.
 +
** Make a tech that has no prerequisite techs, but which is not available at the start of the game: it must be unlocked or granted by an effect
  
===New Condition: TechKnownToEmpire===
+
====How?====
 +
* For techs, create a flag to put in <prereqs> which prevents the tech from ever becoming available due to researching other techs.  This flag might be something like NONEXISTANT_TECH.  The only way to make such a tech available to be researched would be to use the SetTechAvailability effect.  This might be used by a planet special that acts on its source object, to allow the owner of the planet with the special to research a particular tech.
  
This condition would match all objects owned (exclusively or not) by an empire which knows a particular tech.  This would allow effects groups to be activated or not, or their scopes to include or not based on whether they or other empires know a particular tech.  This would be useful for:
+
* For buildings, could add a separate <availability> condition, or can just use existing <location> condition.
* specials that only work if you know a particular tech, such as space anomalies that give bonuses
+
* making buildings obsolete / partly obsolete after discovering a particular tech.  A building could have one function, then stop the old or start new functions when a particular tech is discovered
+
  
===Production Prerequisites===
+
==Future==
  
====Conditions====
+
===Resources===
  
Various conditions would be good to have to restrict or enable building of buildings at particular locationsImmediately relevant ones include many of the current Effects conditions, including:
+
Should have some concept of strategic resources.  Should be able to requiring an empire to have access to a special resource and be able to supply that resource to the build location (ie. not being blockaded) See [[User:Geoff_the_Medio/Musings#Strategic_Resources]].
* Presence of Building on same planet
+
* Presence of Special on same planet
+
* Distance-dependent versions of the above
+
* Empire Affiliation-dependent versions of the above
+
* Planet Environment
+
* Star Colour
+
* Planet Focus Type
+
* Meter Values
+
* Techs Known to Empire doing building (New TechKnownToEmpire condition)
+
* AND, OR & NOT combinations of conditions
+
  
It may be simplest to implement prerequisite conditions using many of the same conditions as are available in activation and scope.
+
===Maintenance===
  
Additional conditions concerning the presence and number of buildings in the empire or galaxy would also be usefulThese may be implimentable using the already available conditions, however. It will be necessary to restrict and enable building production by:
+
We can already specify the maintenance cost for buildings, as indicated in the [[Effects]] page, but this idea needs to be extended to cover what happens if maintenance is not paidThis may be integrated with the following section, Building Enabling.
* Presence of same building elsewhere in empire
+
* Presence of same building anywhere in galaxy
+
  
====Consequences for Production====
+
===Building Enabling / Disabling===
  
The consequence of a production prerequisite not being met is not yet well defined.  There are several options:
+
Buildings mostly (exclusively?) do their jobs through their effects groups, which already have activation and scope conditions.  These are very useful and versatile, but they have some limitations that are problematic for buildings.  In particular, we need ways to enable to enable or disable or change buildings' effects groups for reasons such as:
* Buildings may not have any PP placed towards their completion while prerequisite conditions are not metAny previously applied PP remain spent, and building may be resumed if and when prerequisites are met
+
* unpayed maintainance
* Building production may not be initiated while prerequisite conditions are not met, but if already started, production may continue to completion.
+
* player choice (requiring UI integration)
** This may mean that if a building is paused due to underfunding, it cannot be resumed until prerequisites are met
+
* technology prerequisites (new ones gained or previously known ones lost)
** This may mean that buildings may be paused and resumed even if prerequisites are not met, and that the only restriction is on the  intial first turn of funding, or even the very act of putting the building into the build queue (however this would be problematic, as it would give an incentive to fill the build queue with things you don't currently want to build, lest they become unbuildable due to prerequisites becoming unmet)
+
* non-tech prerequisites, as discussed above
*Building production may not be initiated if prerequisites are not met, and if prerequisites are not met during any turn after initiation but before completion, all progress in production is lost and building is removed from the build queue.
+
* unmet limits, as discussed above
 +
* after a fixed delay, or at a certain time
  
====Note about Tech Condition====
+
==Solutions?==
  
Regarding the above mention of a building prerequisite based on "Techs Known to Empire doing building (New TechKnownToEmpire condition)":  This is distinct from the idea of a tech which unlocks / locks a particular building.  With lock / unlock, the availablility of a building is set by an effect, and is on/off.
+
A mix of new effects and conditions and non-effects methods will likely be needed to impliment the desired functionalitly.
  
This prerequisite would be an additional requirement above and beyond being unlocked.  A particular technology would be required to be researched in order for the building ot be built.  An unlocked building could not be built if this, or any other, prerequisites are not met.
+
===New Effect: ResetTimer, New Condition: TimerValue===
  
===New Effect: SetTimer, New Condition: TimerState ===
+
ResetTimer: Sets building property: Timer, to 0
  
(To be fixed up...)
+
Each turn, timer is increased by 1 (automatically)
  
Set Timer: Sets building property: Timer, to natural number value (integer > 0).
+
TimerValue: Works like MeterValue conditions.  Has <max> and <min>  fields.  UniverseObjects with Timer properties between <min> and <max> are matched.
  
Each turn, timer is reduced by 1 towards 0, or remains at 0 if already = 0.
+
The timer value gives the number of turns since it was last reset.  The TimerValue condition could be used to determine if a fixed number of turns has passed, or to schedule a series of effects groups on different turns.
 
+
TimerState condition has option:  <Activated>
+
 
+
<Activated>1</Activated> means condition matches objects whose timer = 0
+
 
+
<Activated>0</Activated> means condition matches objects whose timer > 0
+
 
+
===Optional: New Effect: SetRegister, New Condition: RegisterValue===
+
 
+
(To be fixed up...)
+
 
+
This extends and replaces the SetTimer and TimerState Conditions.
+
 
+
Each object would have (at least) one externally readable and settable value known as a register.  The value would be accessible like other object properties, as "Source.Register" or "Target.Register", for example.
+
 
+
The SetRegister effect would alter this value just like SetMeter alters meter values, using mathematic expressions where applicable, such as "Target.Register - 1", which would decrement the register by one each turn, replicating the functionality of a timer.
+
 
+
The RegisterValue would function just like the MeterValue condition.  <max> and <min> values would be specified, and all objects whose Register's value is within these ranges would be matched.
+
 
+
===New Condition: GalaxyTurn===
+
 
+
The galaxy would have a property: CurrentTurn, which would return the integer number of the current game turn.  The GalaxyTurn condition would match any object if the GalaxyTurn number was within the range specify in the condition, using <max> and <min>, similar to SetMeter.
+
  
 
===New Effect: SetEnabling, New Condition: Enabled===
 
===New Effect: SetEnabling, New Condition: Enabled===
  
Simialar to the above Register property, objects would have a new binary property "Enabled".
+
Objects would have a new binary property "Enabled".
  
 
The SetEnabled effect would set Enabled to true or false (1 or 0).
 
The SetEnabled effect would set Enabled to true or false (1 or 0).
Line 127: Line 104:
 
====Sidenote: Turn off Maintainance====
 
====Sidenote: Turn off Maintainance====
  
It would also be useful to be able to turn off maintainance fees for buildings that the player has disabled through the UI.
+
It would also be useful to be able to turn off or alter maintainance fees for buildings that the player has disabled through the UI.  This could be done via fields in the building description like <enabledmaintainance> and <disabledmaintainance>, or through a more complicated effects-based system.  The enabled / disabled flags should be sufficient, though.
 +
 
 +
==Other Ideas==
 +
 
 +
===Building Visibility===
 +
 
 +
Being able to set whether a building is visible to non-allied empires of the owner would be useful.  This would ideally be separately settable while the building is under construction, and after it is finished.  This would mean that some buildings are always visible to empires that can see into a system (before and after the buildigns are completed), but some are visible only when complete (not while under construction), or are never visible, or visible while under construction but not when complete.  This could also be represented as a visibility rating, rather than just on/off, similar to the proposed [[User:Geoff_the_Medio/Musings#Starlane_Visbility|starlane visibility]] system.
 +
 
 +
Having buildings be invisible would be useful for setting traps, or honeypot-systems, that look tempting, but which have major negative consequences for any invaders who capture it.  Having buildings be visible while under construction and not when finished, or vice-versa, could make for interesting / fun races against the "clock" to keep something hidden, or sudden surprises when a finished building pops up unexpectedly... and also makes for a strong justification for espionage and detection technology, like with starlanes.

Latest revision as of 13:00, 15 August 2009

New

Empire Templates

What?

  • Want to be able to have some buildings unlocked at start of game.
    • In future, want to be able to have different empires start with different buildings unlocked at the start of the game, so "unlocked at start" shouldn't be a property of the building, but of something attached to each in-game empire.
  • Want to reduce amount of hard-coded game numbers, to be replaced by effects
    • In future, want to be able to have different empires have different effects groups for those that replace the hard-coded game numbers

How?

Have a new xml file that contains "empire template" definitions.

Aside: Could perhaps be called a "culture", but this term might be used for something else as well. It probably can't be called just "empire" since in game, "empire" already refers to the set of planets and ships and related info that a player controls; I'll call this set the "in-game empire".

An empire template would be a attached to a player's in-game empire. At the start of the game, all players, Human and AI, would be assigned empire templates for their in-game empires. Multiple players' empires could have the same template. This would be like having two empires in MOO3 that are of the same race. They would be separately in-game empires, but based on the same empire template and thus would have the same starting techs and empire-specific bonuses or penalties.

Empire templates would act like techs that their associated in-game empire knows. They would have effects that would work just like tech effects, and they could unlock buildings. They would be different from techs in that they wouldn't appear on the tech screen, wouldn't be reserached, and in future, wouldn't be tradeable or stealable, and would never be referred to by in-character game text. By that, I mean that other empires in the game will probably specifically offer to trade for particular techs you know, so in-game characters know that "Techs" as a game concept exist. In-game characters would not know about "empire templates", however, and would perceive their effects as inherent to the in-game empires they are associated with.

To make a building unlocked at the start of the game, it would be added to the <unlocks> tag of the template.

Empire templates could, and IMO should, also replace many of the current hard-coded effect-type bonuses to planets. Until we add races, empire templates should include a set of effects that determine the maximum population numbers and default meter levels of planets. Planets should default to 0 for all their max meters, and would get the current hard-coded increases to max meters of planets from the effects of its empire template.

For now, since empires haven't been decided on and aren't scheduled for a while, there only needs to be a single "Default" empire template.

Also...

A similar mechanism should be created to replace all hard-coded adjustments to meters that occur in the game with effects-defined adjustments. These include:

  • Setting max population of planets due to type, size, environment, etc.
  • Bonuses to meters due to focus effects
  • Bonuses to planet health meters due to environment type
  • Bonusus or penalties to planet health due to availabilitly or lack of food. (This will require a new "FoodSupply" condition that matches planets in a particular range of food supply levels.
  • Population, Resource and Construction current meter growth

Placing all these in effects makes modification simple, and allows variation between races or empires.

Building Availability

What?

  • Want to be able to write conditions or effects that determine whether already-unlocked buildings can be built at all (distinct from location conditions)

Notable quirk:

  • Want to be able to limit the number of buildings of a particular type on or in a planet, system, empire or galaxy, or within a certain distance or number of starlane jumps.

How?

  • Add a new effect: SetBuildingAvailability effect, which would act essentially the same way as the SetTechAvailability effect.

Enhanced Prerequisites

What?

  • Want to be able to have buildings' or techs' availability to be built or researched depend on things other than whether the player has researched a particular tech or set of techs.
  • Want to have "OR" as well as "AND" prerequisites for techs. eg. must research (at least two of these three techs) AND (this other tech)
  • Want to be able to do various cases and combinations:
    • Make a tech become available after researching all its prerequisites, or after being made available by an effect. eg. can research prerequisites, or can find special resource/special that makes tech available without its prerequisites
    • Make a tech become available only after researching all its prerequisites and having an effect make it available. eg. must research prerequisite and must have certain resource/special make tech available; just effect, or just prereqs alone isn't enough.
    • Make a tech that has no prerequisite techs, but which is not available at the start of the game: it must be unlocked or granted by an effect

How?

  • For techs, create a flag to put in <prereqs> which prevents the tech from ever becoming available due to researching other techs. This flag might be something like NONEXISTANT_TECH. The only way to make such a tech available to be researched would be to use the SetTechAvailability effect. This might be used by a planet special that acts on its source object, to allow the owner of the planet with the special to research a particular tech.
  • For buildings, could add a separate <availability> condition, or can just use existing <location> condition.

Future

Resources

Should have some concept of strategic resources. Should be able to requiring an empire to have access to a special resource and be able to supply that resource to the build location (ie. not being blockaded) See User:Geoff_the_Medio/Musings#Strategic_Resources.

Maintenance

We can already specify the maintenance cost for buildings, as indicated in the Effects page, but this idea needs to be extended to cover what happens if maintenance is not paid. This may be integrated with the following section, Building Enabling.

Building Enabling / Disabling

Buildings mostly (exclusively?) do their jobs through their effects groups, which already have activation and scope conditions. These are very useful and versatile, but they have some limitations that are problematic for buildings. In particular, we need ways to enable to enable or disable or change buildings' effects groups for reasons such as:

  • unpayed maintainance
  • player choice (requiring UI integration)
  • technology prerequisites (new ones gained or previously known ones lost)
  • non-tech prerequisites, as discussed above
  • unmet limits, as discussed above
  • after a fixed delay, or at a certain time

Solutions?

A mix of new effects and conditions and non-effects methods will likely be needed to impliment the desired functionalitly.

New Effect: ResetTimer, New Condition: TimerValue

ResetTimer: Sets building property: Timer, to 0

Each turn, timer is increased by 1 (automatically)

TimerValue: Works like MeterValue conditions. Has <max> and <min> fields. UniverseObjects with Timer properties between <min> and <max> are matched.

The timer value gives the number of turns since it was last reset. The TimerValue condition could be used to determine if a fixed number of turns has passed, or to schedule a series of effects groups on different turns.

New Effect: SetEnabling, New Condition: Enabled

Objects would have a new binary property "Enabled".

The SetEnabled effect would set Enabled to true or false (1 or 0).

The Enabled condition would match all objects which have Enabled = True.

The Enabled flag of an object would be altered in a manner similar to the meter values of production centres through various non-effects mechanisms. For example, if a building's maintainance is not paid, or a player uses the UI to disable a building, then Enabled would be set to false. The activation condition for the building's effects would have <Condition::Enabled/>, meaning the effects would only work for enabled buildings.

Sidenote: Turn off Maintainance

It would also be useful to be able to turn off or alter maintainance fees for buildings that the player has disabled through the UI. This could be done via fields in the building description like <enabledmaintainance> and <disabledmaintainance>, or through a more complicated effects-based system. The enabled / disabled flags should be sufficient, though.

Other Ideas

Building Visibility

Being able to set whether a building is visible to non-allied empires of the owner would be useful. This would ideally be separately settable while the building is under construction, and after it is finished. This would mean that some buildings are always visible to empires that can see into a system (before and after the buildigns are completed), but some are visible only when complete (not while under construction), or are never visible, or visible while under construction but not when complete. This could also be represented as a visibility rating, rather than just on/off, similar to the proposed starlane visibility system.

Having buildings be invisible would be useful for setting traps, or honeypot-systems, that look tempting, but which have major negative consequences for any invaders who capture it. Having buildings be visible while under construction and not when finished, or vice-versa, could make for interesting / fun races against the "clock" to keep something hidden, or sudden surprises when a finished building pops up unexpectedly... and also makes for a strong justification for espionage and detection technology, like with starlanes.