Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+26
View File
@@ -37,6 +37,10 @@ interface Player {
heal(amount: number): void;
feed(nutrition: number, saturation_modifier: number): void;
add_exhaustion(amount: number): void;
attribute(id: string): number;
add_modifier(attribute: string, modifier: AttributeModifier): void;
remove_modifier(attribute: string, id: string): boolean;
}
```
@@ -64,6 +68,28 @@ even when their game isn't running, like in a background tab.
`damage(amount, cause)` hurts them like anything else would. `cause` shows in the `player_damage` and `player_death`
[events](../concepts/events.md) and in the death message. Before events can change the amount or cancel it.
## Attributes
A player's stats are attributes, like Minecraft's: a base value that modifiers change without touching it.
| Attribute | Base | Meaning |
| ---------------------- | ---- | -------------------------------------------------------------------------- |
| `bworld:attack_damage` | 1 | How much their hits do. |
| `bworld:attack_speed` | 4 | Full strength attacks a second. Hitting sooner than that does less damage. |
```ts
player.add_modifier("bworld:attack_damage", { id: "my_mod:rage", amount: 2, operation: "add_value" });
player.attribute("bworld:attack_damage"); // 3
player.remove_modifier("bworld:attack_damage", "my_mod:rage");
```
The value is the base, plus every `add_value`, plus that times the amount of each `add_multiplied_base`, then times 1
plus the amount of each `add_multiplied_total`. A modifier with the same id replaces the old one. Modifiers aren't
saved: a mod that gives them should give them again when the player joins, the way Curios does for worn items.
Like Minecraft, an attack right after the last one, or right after changing the held item, does only a fifth of the
damage, rising to full after `20 / attack_speed` ticks.
## Death
When a player dies, everything they carried falls out where they died, and their tools lose durability (see