Introduction
This will be a kind of specification/explanation as there is no implementation yet.
The idea is to move more modding ability to a generic XML syntax that currently requires very specific code support (e.g. by specialized tags). For instance now units can require one of a list of specific resources but if you want to require all of the list you need a new tag. And that functionality is specific to units only and for buildings it might look different again.
Definitions
Since this is an abstraction approach, first some definitions (some new, some old):
Game objects are the major objects that are instantiated in the Civ4 game world and have a representation in memory for each instance.
That are:
Game objects can have game object modifiers (GOMs, that includes buildings, promotions, features, terrains, resources, traits, ...). Game objects either have a specific GOM or not (so you can query a GAMEOBJECT_CITY if it has the GOM_BUILDING BUILDING_PALACE or not).
Expressions
Now I want to add boolean expressions (conditions) and integer expressions that are evaluated in the context of a game object and return a boolean/integer. They could be used in the XML where now there are either fixed booleans or fixed integers. The limitations are that they can only be used where the results are not used for long term caching, especially cached accumulated values. In general there also needs to be a code change at each position it is used that replaces the integer or boolean with an expression variable.
As an example: Currently you can have a property source that produces 5 crime per turn. Using an integer expression you could have it produce (unhappiness + population) / 2 crime per turn.
Values
Boolean Expressions
Operators
Boolean Expressions
Integrators/Aggregators
This evaluates expressions on related game objects and then aggregates the result.
Boolean Expressions
The XML syntax for all of that is not yet decided.
This will be a kind of specification/explanation as there is no implementation yet.
The idea is to move more modding ability to a generic XML syntax that currently requires very specific code support (e.g. by specialized tags). For instance now units can require one of a list of specific resources but if you want to require all of the list you need a new tag. And that functionality is specific to units only and for buildings it might look different again.
Definitions
Since this is an abstraction approach, first some definitions (some new, some old):
Game objects are the major objects that are instantiated in the Civ4 game world and have a representation in memory for each instance.
That are:
- Game - only one is present, it represents everything that is global
- Team - a group of players that are permanently allied and share tech and some wonder effects
- Player - in a normal single player Civ4 game without set up teams there is no real difference between player and team
- City
- Unit
- Plot
Game objects can have game object modifiers (GOMs, that includes buildings, promotions, features, terrains, resources, traits, ...). Game objects either have a specific GOM or not (so you can query a GAMEOBJECT_CITY if it has the GOM_BUILDING BUILDING_PALACE or not).
Expressions
Now I want to add boolean expressions (conditions) and integer expressions that are evaluated in the context of a game object and return a boolean/integer. They could be used in the XML where now there are either fixed booleans or fixed integers. The limitations are that they can only be used where the results are not used for long term caching, especially cached accumulated values. In general there also needs to be a code change at each position it is used that replaces the integer or boolean with an expression variable.
As an example: Currently you can have a property source that produces 5 crime per turn. Using an integer expression you could have it produce (unhappiness + population) / 2 crime per turn.
Values
Boolean Expressions
- Global Define Value
- Option Value
- Boolean Attribute
- Has GOM
- Global Define Value
- Integer Attribute
- Property
- Constant (integer literal)
Operators
Boolean Expressions
- Boolean Expression AND Boolean Expression
- Boolean Expression OR Boolean Expression
- NOT Boolean Expression
- Boolean Expression EQUAL Boolean Expression
- IF Boolean Expression THEN Boolean Expression ELSE Boolean Expression
- Integer Expression EQUAL Integer Expression, similar for other comparisons of ints
- Integer Expression PLUS Integer Expression
- Integer Expression MINUS Integer Expression
- Integer Expression * Integer Expression
- Integer Expression / Integer Expression
- Integer Expression MODULO Integer Expression
- ABS Integer Expression
- IF Boolean Expression THEN Integer Expression ELSE Integer Expression
- Probably more
Integrators/Aggregators
This evaluates expressions on related game objects and then aggregates the result.
Boolean Expressions
- IntegrateAND Boolean Expression - True if the expression evaluates true on all related objects
- IntegrateOR Boolean Expression - True if any are true
- IntegrateSUM Integer Expression - Sum of the integer expression evaluated on the related objects
- IntegrateMEAN Integer Expression - Mean of the expression evaluated on the related objects
- IntegrateNUM Boolean Expression - Number of related objects for which the boolean expression evaluates to true
The XML syntax for all of that is not yet decided.