Skip to content

Commit 5715fda

Browse files
committed
docs: rewrite ai-goals and gamerules in casual tone
1 parent 6c0ef27 commit 5715fda

2 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/content/docs/world/ai-goals.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: AI & Goals
33
description: Mob AI behavior system in LCEMP.
44
---
55

6-
LCEMP uses a priority-based goal system for mob AI. Each mob owns two `GoalSelector` instances -- one for general behaviors and one for targeting -- and each selector manages a list of `Goal` objects that compete for execution based on priority and control flag compatibility.
6+
LCEMP uses a priority-based goal system for mob AI. Each mob owns two `GoalSelector` instances, one for general behaviors and one for targeting. Each selector manages a list of `Goal` objects that compete for execution based on priority and control flag compatibility.
77

88
## Goal (base class)
99

@@ -17,13 +17,13 @@ Every AI behavior inherits from `Goal` and implements its lifecycle methods:
1717
| `start()` | No-op | Called once when the goal begins executing |
1818
| `stop()` | No-op | Called once when the goal stops executing |
1919
| `tick()` | No-op | Called every tick while the goal is running |
20-
| `setRequiredControlFlags(flags)` | -- | Sets the bitmask of control channels this goal uses |
20+
| `setRequiredControlFlags(flags)` | (none) | Sets the bitmask of control channels this goal uses |
2121
| `getRequiredControlFlags()` | Returns `0` | Returns the control flag bitmask |
2222
| `setLevel(level)` | No-op | 4J addition: updates level pointer when loading from schematics |
2323

2424
### Control flags
2525

26-
Goals declare which "control channels" they require via a bitmask passed to `setRequiredControlFlags()`. Two goals can run simultaneously only if their control flags do not overlap (bitwise AND is zero). This prevents, for example, two movement goals from conflicting.
26+
Goals declare which "control channels" they need through a bitmask passed to `setRequiredControlFlags()`. Two goals can run at the same time only if their control flags don't overlap (bitwise AND is zero). This prevents things like two movement goals from conflicting with each other.
2727

2828
The `TargetGoal` base class defines `TargetFlag = 1` as a standard flag for targeting behaviors.
2929

@@ -34,21 +34,21 @@ The scheduler that manages and ticks a set of goals.
3434
### Internal structure
3535

3636
Goals are wrapped in `InternalGoal` objects that store:
37-
- `prio` -- integer priority (lower = higher priority)
38-
- `goal` -- pointer to the `Goal` instance
39-
- `canDeletePointer` -- ownership flag for memory management (4J addition)
37+
- `prio`: integer priority (lower = higher priority)
38+
- `goal`: pointer to the `Goal` instance
39+
- `canDeletePointer`: ownership flag for memory management (4J addition)
4040

4141
Two lists are maintained:
42-
- `goals` -- all registered goals
43-
- `usingGoals` -- goals currently executing
42+
- `goals`: all registered goals
43+
- `usingGoals`: goals currently executing
4444

4545
### Tick behavior
4646

47-
Every `newGoalRate` ticks (default: 3), the selector performs a full evaluation cycle:
47+
Every `newGoalRate` ticks (default: 3), the selector runs a full evaluation cycle:
4848

4949
1. **For each registered goal:**
50-
- If currently running and either `canUseInSystem()` fails or `canContinueToUse()` returns false, call `stop()` and remove from `usingGoals`
51-
- If not running and both `canUseInSystem()` and `canUse()` pass, add to start list and `usingGoals`
50+
- If it's currently running and either `canUseInSystem()` fails or `canContinueToUse()` returns false, call `stop()` and remove from `usingGoals`
51+
- If it's not running and both `canUseInSystem()` and `canUse()` pass, add to start list and `usingGoals`
5252
2. **Call `start()` on all newly added goals**
5353
3. **Call `tick()` on all running goals**
5454

@@ -65,18 +65,18 @@ On non-evaluation ticks, only `canContinueToUse()` is checked for running goals,
6565

6666
### Configuration
6767

68-
- `addGoal(priority, goal, canDeletePointer)` -- registers a goal at the given priority. The `canDeletePointer` flag (default `true`) controls whether the selector owns the goal memory.
69-
- `setNewGoalRate(rate)` -- changes how often full evaluation occurs (default every 3 ticks)
70-
- `setLevel(level)` -- propagates a level pointer change to all goals (4J addition for schematic loading)
68+
- `addGoal(priority, goal, canDeletePointer)`: registers a goal at the given priority. The `canDeletePointer` flag (default `true`) controls whether the selector owns the goal memory.
69+
- `setNewGoalRate(rate)`: changes how often full evaluation happens (default every 3 ticks)
70+
- `setLevel(level)`: sends a level pointer change to all goals (4J addition for schematic loading)
7171

7272
## TargetGoal (base class for targeting)
7373

74-
Abstract base for goals that select an attack target. Provides shared logic for target validation.
74+
Abstract base for goals that pick an attack target. Provides shared logic for target validation.
7575

7676
**Constructor parameters:** `mob`, `within` (search range), `mustSee`, `mustReach`
7777

7878
**Key behavior:**
79-
- `canAttack(target, allowInvulnerable)` -- validates the target is alive, in range, and optionally visible/reachable
79+
- `canAttack(target, allowInvulnerable)`: checks that the target is alive, in range, and optionally visible/reachable
8080
- Maintains a `reachCache` with three states: Empty (0), CanReach (1), CantReach (2)
8181
- `unseenTicks` tracks how long since the target was last visible, up to `UnseenMemoryTicks` (60)
8282
- On `start()`, sets the mob's target
@@ -190,4 +190,4 @@ targetSelector.addGoal(1, HurtByTargetGoal)
190190
targetSelector.addGoal(2, NearestAttackableTargetGoal)
191191
```
192192

193-
Lower priority numbers take precedence. Goals at the same priority level can coexist if their control flags do not conflict.
193+
Lower priority numbers take precedence. Goals at the same priority level can coexist if their control flags don't conflict.

src/content/docs/world/gamerules.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ title: Game Rules
33
description: Configurable game rules in LCEMP.
44
---
55

6-
LCEMP uses a **Console Game Rules** system that is fundamentally different from vanilla Minecraft's simple key-value game rules. Instead of boolean/integer rules like `keepInventory` or `doDaylightCycle`, LCEMP's game rules are a data-driven, hierarchical system primarily used for custom game modes (like Battle, Tumble, Glide) and DLC mashup packs.
6+
LCEMP uses a **Console Game Rules** system that works completely differently from vanilla Minecraft's simple key-value game rules. Instead of boolean/integer rules like `keepInventory` or `doDaylightCycle`, LCEMP's game rules are a data-driven, hierarchical system mainly used for custom game modes (like Battle, Tumble, Glide) and DLC mashup packs.
77

88
## Architecture overview
99

1010
The game rule system has four main layers:
1111

12-
1. **GameRuleManager** -- loads, saves, and manages rule definitions from DLC packs
13-
2. **GameRuleDefinition** -- the static definition/template of a rule (what to do)
14-
3. **GameRule** -- the runtime state of a rule for a specific player or server
15-
4. **GameRulesInstance** -- extends `GameRule` as the top-level container for a player's or server's complete rule state
12+
1. **GameRuleManager**: loads, saves, and manages rule definitions from DLC packs
13+
2. **GameRuleDefinition**: the static definition/template of a rule (what to do)
14+
3. **GameRule**: the runtime state of a rule for a specific player or server
15+
4. **GameRulesInstance**: extends `GameRule` as the top-level container for a player's or server's complete rule state
1616

1717
## ConsoleGameRules constants
1818

@@ -65,7 +65,7 @@ Rules are configured through attributes loaded from XML/binary data:
6565

6666
## GameRuleDefinition
6767

68-
The base class for all rule templates. Defines the static structure of a rule.
68+
The base class for all rule templates. This defines the static structure of a rule.
6969

7070
**Key methods:**
7171

@@ -87,19 +87,19 @@ The base class for all rule templates. Defines the static structure of a rule.
8787

8888
#### CompoundGameRuleDefinition
8989

90-
Base class for rules that contain child rules. Manages a `m_children` vector and delegates hooks to all children.
90+
Base class for rules that contain child rules. Manages a `m_children` vector and passes hooks down to all children.
9191

9292
#### CompleteAllRuleDefinition
9393

94-
Extends `CompoundGameRuleDefinition`. Completes only when **all** child rules are complete. Broadcasts progress updates via `UpdateGameRuleProgressPacket`.
94+
Extends `CompoundGameRuleDefinition`. This one only completes when **all** child rules are complete. It broadcasts progress updates through `UpdateGameRuleProgressPacket`.
9595

9696
#### CollectItemRuleDefinition
9797

98-
Tracks collection of a specific item. Configured with `m_itemId`, `m_auxValue`, and `m_quantity`. Increments progress each time the matching item is collected.
98+
Tracks collection of a specific item. Configured with `m_itemId`, `m_auxValue`, and `m_quantity`. Each time the matching item is collected, the progress goes up.
9999

100100
#### UseTileRuleDefinition
101101

102-
Triggers when a player interacts with a specific tile (block). Can optionally require specific coordinates via `m_useCoords`.
102+
Triggers when a player interacts with a specific tile (block). Can optionally require specific coordinates through `m_useCoords`.
103103

104104
#### UpdatePlayerRuleDefinition
105105

@@ -117,12 +117,12 @@ Extends `CompoundGameRuleDefinition` as the root container for a level's rules.
117117

118118
Each `GameRule` instance tracks the runtime state of a definition for a specific connection (player).
119119

120-
**State storage:** Parameters are stored in `m_parameters`, an `unordered_map<wstring, ValueType>` where `ValueType` is a union of:
120+
**State storage:** Parameters live in `m_parameters`, an `unordered_map<wstring, ValueType>` where `ValueType` is a union of:
121121

122122
- `__int64`, `int`, `char`, `bool`, `float`, `double` (primitive values)
123123
- `GameRule*` (nested rule pointer, flagged with `isPointer = true`)
124124

125-
**Serialization:** `write()` and `read()` serialize all parameters to/from a `DataOutputStream`/`DataInputStream`. Pointer values are recursively serialized; primitive values are stored as `__int64`.
125+
**Serialization:** `write()` and `read()` serialize all parameters to/from a `DataOutputStream`/`DataInputStream`. Pointer values are serialized recursively, and primitive values are stored as `__int64`.
126126

127127
## GameRulesInstance
128128

@@ -133,7 +133,7 @@ Extends `GameRule` with an instance type:
133133
| `eGameRulesInstanceType_ServerPlayer` | Rules applied per-player |
134134
| `eGameRulesInstanceType_Server` | Rules applied server-wide |
135135

136-
Created via `GameRuleDefinition::generateNewGameRulesInstance()` which walks the definition tree and populates parameters.
136+
Created through `GameRuleDefinition::generateNewGameRulesInstance()`, which walks the definition tree and populates parameters.
137137

138138
## GameRuleManager
139139

@@ -157,7 +157,7 @@ Rules are stored in `.grf` files (`GAME_RULE_SAVENAME = "requiredGameRules.grf"`
157157

158158
## Network synchronization
159159

160-
Rule progress updates are sent via `UpdateGameRuleProgressPacket` (packet ID 158). It contains:
160+
Rule progress updates are sent through `UpdateGameRuleProgressPacket` (packet ID 158). It contains:
161161

162162
| Field | Type | Purpose |
163163
|---|---|---|

0 commit comments

Comments
 (0)