Skip to content

ApplyEffect implementation #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 109 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b489a30
gamestate: Apply*Effect components.
heinezen Sep 1, 2024
80e2219
gamestate: Create Apply*Effect components for new entities.
heinezen Sep 1, 2024
43d7869
gamestate: API interface for Apply*Effect abilities.
heinezen Sep 1, 2024
52f6350
gamestate: Fix checking ability parents.
heinezen Sep 1, 2024
1eabf0a
gamestate: Add Resistance component.
heinezen Sep 7, 2024
302442e
gamestate: Add basic system skeleton for applying effects.
heinezen Sep 7, 2024
e5fe7f8
gamestate: resistance definitions.
heinezen Sep 7, 2024
70cd03e
gamestate: API layer for nyan effects.
heinezen Sep 7, 2024
a4889d3
gamestate: API layer for nyan resistances.
heinezen Sep 7, 2024
9d250e0
gamestate: Add LineOfSight component.
heinezen Sep 7, 2024
c77b7d4
gamestate: LineOfSight definitions.
heinezen Sep 7, 2024
84c3e10
gamestate: Add missing definitions for already implemented abilities.
heinezen Sep 7, 2024
aec2515
gamestate: Allow fractional values for attributes.
heinezen Sep 8, 2024
4210137
gamestate: Calculate application for discrete FLAC effects.
heinezen Sep 8, 2024
f1854f9
gamestate: Decrease log level of unrecognized components.
heinezen Sep 13, 2024
89fc488
gamestate: ApplyEffect command.
heinezen Sep 14, 2024
8ba2da5
gamestate: Rename command classes and make them 'final'.
heinezen Sep 14, 2024
6651428
gamestate: Add condition for ApplyEffect command in activity system.
heinezen Sep 15, 2024
0ca5cae
convert: Add new activity conditions for applying effects.
heinezen Sep 15, 2024
89b1bb4
gamestate: Handle ApplyEffect in activity system.
heinezen Sep 15, 2024
161fdd9
gamestate: Fix time calculations for applying effects.
heinezen Sep 15, 2024
0c19cd4
gamestate: Move animation property handling to helper function.
heinezen Sep 15, 2024
86a8407
gamestate: Animate effect application.
heinezen Sep 15, 2024
5140fb8
curve: Add compress argument for curve operations.
heinezen Oct 16, 2024
f17bf32
curve: Rename argument for keyframes to 'keyframe'.
heinezen Oct 16, 2024
3172a12
curve: Compress operation on keyframe insertion.
heinezen Oct 16, 2024
2c8a0ca
curve: Compress method for curves.
heinezen Oct 18, 2024
6f68941
curve: Add new unit tests for compress() method.
heinezen Oct 18, 2024
524eba4
curve: Fix compression method.
heinezen Oct 18, 2024
ca990b4
curve: Pass through compression args.
heinezen Oct 19, 2024
a3c1533
curve: Compress during curve sync.
heinezen Oct 19, 2024
dd1799a
renderer: Compress sync on animations curve.
heinezen Oct 19, 2024
72972ed
renderer: Make fetching from render entity more reliable.
heinezen Oct 20, 2024
d3db56b
curve: Fix compilation for oider clang versions.
heinezen Oct 20, 2024
5bd571d
curve: Concept for curve values.
heinezen Oct 20, 2024
a13f53d
doc: Add documentation for curve compression.
heinezen Oct 22, 2024
f5ab0ce
gamestate: Add activity node type for branching on value.
heinezen Nov 4, 2024
06fda20
gamestate: Handle XorSwichGate in activity system.
heinezen Nov 5, 2024
0942901
gamestate: Add unit tests for activity node types.
heinezen Nov 5, 2024
66b848f
gamestate: Make a lookup function for next comand switching.
heinezen Nov 5, 2024
4a558da
convert: Use new switch gate for command branching.
heinezen Nov 5, 2024
5384808
gamestate: Init new XorSwitchGate activity node type from nyan.
heinezen Nov 7, 2024
0d31469
gamestate: Resolve lookup func and node ID mapping for switch condition.
heinezen Apr 7, 2025
3340d0d
gamestate: Correctly subtract/add applied attribute value.
heinezen Apr 7, 2025
4a614a3
gamestate: Fix missing convert effect type.
heinezen Apr 9, 2025
e288d78
convert: Fix generated path of shared media files in modpack.
heinezen Apr 9, 2025
7497f36
gamestate: Only add apply effect command to game entities with matchi…
heinezen Apr 10, 2025
b55186f
curve: Fix wrong assertion for interpolation.
heinezen Apr 10, 2025
923550d
util: Get absolute difference between two fixed point values.
heinezen Apr 10, 2025
2688292
curve: Fix overflow for interpolation time offsets.
heinezen Apr 10, 2025
3b2c13e
util: Add concepts for fixed point types.
heinezen Apr 11, 2025
8c1fef0
curve: Cleanup docstrings in KeyframeContainer class.
heinezen Apr 11, 2025
c5718d1
input: Use ID texture in input game controller.
heinezen Apr 20, 2025
e17306c
input: Send ApplyEffect command to simulation.
heinezen Apr 20, 2025
fd912d4
util: Fix writeability check for Directory class.
heinezen Apr 20, 2025
e210dd1
renderer: Update docstrings.
heinezen Apr 21, 2025
ffb39bb
renderer: Swap order of texture targets in world render stage.
heinezen Apr 21, 2025
f8fbbab
renderer: Add r32ui as supported output format for writing texture to…
heinezen Apr 21, 2025
7291e3f
gamestate: Process ApplyEffect command from input system.
heinezen Apr 21, 2025
39f04de
renderer: Update docstring format for texture.h.
heinezen Apr 21, 2025
b99e462
renderer: Allow resizing texture without recreating it.
heinezen Apr 21, 2025
506811e
renderer: Resize all texture targets in render stages with new resize…
heinezen Apr 21, 2025
c18e1b6
input: Remove unnecessary resize callback for ID texture.
heinezen Apr 21, 2025
dd0ef37
renderer: Check if all textures of render target have the same size.
heinezen Apr 21, 2025
1ff79a0
renderer: Figure out attachment points with switch command.
heinezen Apr 21, 2025
832ccdd
gamestate: Reserve some game entity IDs for internal use.
heinezen Apr 22, 2025
9b97310
convert: Change ability with range to use Ranged property.
heinezen May 4, 2025
550ebb4
convert: Fix pylint complaints.
heinezen May 4, 2025
4cbd25f
convert: Add new nyan objects for API 0.5.0.
heinezen May 10, 2025
473ab63
gamestate: Refactor location of activity gate function definitions.
heinezen May 10, 2025
0664b63
gamestate: Allow passing nyan objects in condition/switch functions.
heinezen May 10, 2025
8326a51
convert: Change nyan objects for nyan API 0.5.0.
heinezen May 10, 2025
b2472dc
gamestate: Consolidate NextCommand condition functions into one.
heinezen May 10, 2025
9bdc78f
gamestate: Store current target of command.
heinezen May 11, 2025
4465265
gamestate: Allow checking for the Ranged property in nyan API.
heinezen May 11, 2025
d4eb1b2
gamestate: Remove obsolete ranged apply effect abilities.
heinezen May 11, 2025
ca1289b
gamestate: Add reverse lookup for ability fqon to ability type.
heinezen May 11, 2025
07f1465
gamestate: Use switch statement for component assignment to new entity.
heinezen May 11, 2025
280fd7d
gamestate: Pass state to condition functions.
heinezen May 11, 2025
443f1e5
gamestate; Define initial game entity IDs as constants.
heinezen May 11, 2025
118d792
gamestate: Add lookup for ability type to component type.
heinezen May 11, 2025
467725f
gamestate: Add condition for checking if a target is in range of an a…
heinezen May 11, 2025
29a409a
gamestate: Store target of entity when receiving events.
heinezen May 11, 2025
581325b
convert: Add range check before apply effect ability in activity,
heinezen May 11, 2025
8227138
gamestate: Add API interface for checking generic API objects.
heinezen May 11, 2025
d6a4a77
gamestate: More reliable method to find API parent of nyan object.
heinezen May 11, 2025
cb6d7f3
gamestate: Add method for checking if game entity/player exists.
heinezen May 11, 2025
754607c
input: Fix type of target ID send in command.
heinezen May 11, 2025
1354cd2
gamestate: Make TargetInRange condition accessible for activity system.
heinezen May 11, 2025
65da27b
gamestate: Remove unnecessary parameters from ApplyEffect system.
heinezen May 11, 2025
484aa7d
convert: Add task nodes to nyan API loader.
heinezen May 11, 2025
ba79d39
convert: Add clear queue task to default activity.
heinezen May 11, 2025
a776a65
curve: Fix breakout condition when clearing queue.
heinezen May 11, 2025
ea4cda9
gamestate: Use clear queue task in activity system.
heinezen May 11, 2025
6fc81d7
gamestate: Make apply effect system use command information.
heinezen May 17, 2025
730b7ab
gamestate: Remove separate queue for command queue targets.
heinezen May 18, 2025
77f5516
gamestate: Add system for moving to target.
heinezen May 18, 2025
5b212aa
gamestate: Private default movement to deestination.
heinezen May 18, 2025
f0cd440
convert: Move to target in default unit activity.
heinezen May 18, 2025
032ce8a
gamestate: Handle MoveToTarget task activity type.
heinezen May 18, 2025
9863658
gamestate: Fix wrong log messages.
heinezen May 18, 2025
82dc155
gamestate: Clear command queue by default when new command is sent fr…
heinezen May 18, 2025
fbe05ad
convert: Add activity node for checking if the game entity has an abi…
heinezen May 18, 2025
782a152
gamestate: Add condition function for AbilityUsable check.
heinezen May 18, 2025
fd7d4ce
gamestate: Turn entity towards target before applying effect.
heinezen May 18, 2025
5f45145
doc: Move system descriptions into code docs.
heinezen May 18, 2025
0b3297b
doc: Move component descriptions into code docs.
heinezen May 18, 2025
996c77d
cfg: Update modpack version of converted games.
heinezen May 18, 2025
6dc3ca7
convert: Fix semantic version comparison.
heinezen May 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions cfg/converter/games/game_editions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ expansions = []
]

[AOC.targetmods.aoe2_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "1.0c"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[AOCDEMO]
Expand All @@ -63,9 +63,9 @@ expansions = []
blend = ["data/blendomatic.dat"]

[AOCDEMO.targetmods.trial_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "Trial"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[AOK]
Expand Down Expand Up @@ -145,9 +145,9 @@ expansions = []
]

[AOE1DE.targetmods.de1_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "1.0a"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[ROR]
Expand Down Expand Up @@ -185,9 +185,9 @@ expansions = []
]

[ROR.targetmods.aoe1_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "1.0a"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[HDEDITION]
Expand Down Expand Up @@ -229,9 +229,9 @@ expansions = []
]

[HDEDITION.targetmods.hd_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "5.8"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[AOE2DE]
Expand Down Expand Up @@ -278,9 +278,9 @@ expansions = []
]

[AOE2DE.targetmods.de2_base]
version = "0.6.0"
version = "0.7.0"
versionstr = "Update 118476+"
min_api_version = "0.5.0"
min_api_version = "0.6.0"


[SWGB]
Expand Down Expand Up @@ -320,6 +320,6 @@ expansions = ["SWGB_CC"]
]

[SWGB.targetmods.swgb_base]
version = "0.5.1"
version = "0.6.0"
versionstr = "1.1-gog4"
min_api_version = "0.5.0"
min_api_version = "0.6.0"
29 changes: 29 additions & 0 deletions doc/code/curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Curves are an integral part of openage's event-based game simulation.
1. [Queue](#queue)
2. [Unordered Map](#unordered-map)
3. [Array](#array)
4. [Compression](#compression)


## Motivation
Expand Down Expand Up @@ -133,6 +134,9 @@ Modify operations insert values for a specific point in time.
| `set_insert(t, value)` | Insert a new keyframe value at time `t` |
| `set_last(t, value)` | Insert a new keyframe value at time `t`; delete all keyframes after time `t` |
| `set_replace(t, value)` | Insert a new keyframe value at time `t`; remove all other keyframes with time `t` |
| `compress(t)` | Remove redundant keyframes at and after time `t`; see [Compression] for more info |

[Compression]: #compression

**Copy**

Expand Down Expand Up @@ -292,3 +296,28 @@ Modify operations insert values for a specific point in time.
| Method | Description |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| `sync(Curve, t)` | Replace all keyframes from self after time `t` with keyframes from source `Curve` after time `t` |


## Compression

Curves support basic lossless compression by removing redundant keyframes from the curve.
Keyframes are considered redundant if they do not change any interpolation results, i.e.
the result of `get(t)` does not change.

The most straight-forward way to use compression with primitive curves is the `compress(t)`
method. `compress(t)` iterates over the curve and removes all redundant keyframes after
or at time `t`. The runtime has linear complexity `O(n)` based on the number of elements
in the keyframe container.

Furthermore, primitive curves support incremental compression during insertion for the
`set_insert(t, value)` and `set_last(t, value)` methods via their `compress` argument.
If compression is active, `(t, value)` is only inserted when it is not a redundant
keyframe. `sync(Curve, t)` also supports compression with a flag `compress` passed as
an argument.

Compression may be used in cases where the size should be kept small, e.g. when the curve
is transferred via network or recorded in a replay file. Another application of compression
is in the [renderer](/doc/code/renderer/README.md) for the discrete curves storing an object's
animations. Since compression removes redundant animation entries, the renderer can determine
when the current animation has started much easier as this is then returned by the keyframe
time in `frame(t)`.
71 changes: 60 additions & 11 deletions doc/code/game_simulation/activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ configurable.

1. [Motivation](#motivation)
2. [Architecture](#architecture)
3. [Node Types](#node-types)
3. [Workflow](#workflow)
1. [Initialization](#initialization)
2. [Advancing in the graph](#advancing-in-the-graph)
4. [Node Types](#node-types)


## Motivation
Expand All @@ -32,7 +35,20 @@ and event triggers that indicate which path to take next. By traversing the node
its paths, the game entities actions are determined. The currently visited node in the graph
corresponds to the current action of a unit.

Activities are reusable, i.e. they are intended to be shared by many game entities Usually,
Advancement to the next node can be initiated in several ways, depending on the
[node type](#node-types) of the current node.
It can happen automatically or be triggered by an event. In the latter case,
the event is handled by the `GameEntityManager` which calls an activity *system*
that processes the event to choose the next node.

Advancing in the graph, i.e. visiting nodes and performing actions costs no ingame time. Time
delays of actions, e.g. for using an game mechanic like movement, are instead handled by
scheduling and waiting for events at certain nodes in the graph (e.g. `XOR_EVENT_GATE` nodes).
This means that when running the activity system, the directed edges of the nodes are followed
until a node that waits for an event is reached. This allows the activity graph to support
complex action chains that can be executed in sequence.

Activities are reusable, i.e. they are intended to be shared by many game entities. Usually,
all game entities of the same type should share the same behaviour, so they get assigned
the same activity node graph.

Expand All @@ -45,14 +61,47 @@ representation. You don't need to know BPMN to understand the activity control f
we explain everything important about the graphs in our documentation. However,
you can use available [BPMN tools](https://bpmn.io/) to draw activity node graphs.

## Node Types
Like all game data, activities and node types for game entities are defined via the
[nyan API](doc/nyan/openage-lib.md).


## Workflow

![Activity Workflow](images/activity_workflow.png)

### Initialization

When a game entity is spawned, the engine first checks whether entity's `GameEntity` API object
has an ability `Activity` assigned. If that is the case, the activity graph is loaded from
the corresponding API objects defining the graph. Most of this step involves creates the
nodes and connections for the graph as well as mapping the API objects to node actions.

The loaded activity graph is stored in a `Activity` component that is assigned to the game
entity. At this point, the activity state of the entity is still uninitialized which allows
the entity or the component to be cached for faster assignment to entities using the same graph.
To let the entity become active, the `init(..)` method of the Activity component should be
called after the entity is completely initialized. This sets the activity state to the start
node of the actvity graph.

### Advancing in the graph

After the game entity is spawned, the `GameEntityManager` is called once to trigger the initial
behavior of the game entity. This advances the activity state until the first event branch where
an event is required for further advancement. The `GameEntityManager` now waits for events
for the entity to further advance in the graph.

A game entity's current activity state is stored in its `Activity` component in form of
a reference to the current node. Additionally, the components stores the list of events
the entity currently waits for to advance.

## Node Types

| Type | Inputs | Outputs | Description |
| ---------------- | ------ | ------- | ------------------------- |
| `START` | 0 | 1 | Start of activity |
| `END` | 1 | 0 | End of activity |
| `TASK_SYSTEM` | 1 | 1 | Run built-in system |
| `TASK_CUSTOM` | 1 | 1 | Run custom function |
| `XOR_EVENT_GATE` | 1 | 1+ | Wait for event and branch |
| `XOR_GATE` | 1 | 1+ | Branch on condition |
| Type | Description | Inputs | Outputs |
| ----------------- | ------------------------- | ------ | ------- |
| `START` | Start of activity | 0 | 1 |
| `END` | End of activity | 1 | 0 |
| `TASK_SYSTEM` | Run built-in system | 1 | 1 |
| `TASK_CUSTOM` | Run custom function | 1 | 1 |
| `XOR_EVENT_GATE` | Wait for event and branch | 1 | 1+ |
| `XOR_GATE` | Branch on condition | 1 | 1+ |
| `XOR_SWITCH_GATE` | Branch on value | 1 | 1+ |
130 changes: 0 additions & 130 deletions doc/code/game_simulation/components.md

This file was deleted.

Loading
Loading