Change giant chestplate to regen 3
This commit is contained in:
@@ -13,7 +13,7 @@ necklaces and belts, for any mod's items. They're in 2 columns left of the playe
|
||||
Shift clicking a curio in the inventory puts it in the first slot it fits.
|
||||
|
||||
A slot type only shows up once some item is in its tag. The base game's one curio is the giant chestplate, a body curio
|
||||
that gives 20 more max health while worn, and regeneration II after 10 seconds without being hurt, so the body slot is
|
||||
that gives 20 more max health while worn, and regeneration III after 10 seconds without being hurt, so the body slot is
|
||||
always there.
|
||||
|
||||
### Making an Item a Curio
|
||||
@@ -56,13 +56,13 @@ The Power Glove from Artifacts:
|
||||
|
||||
An item with the `bworld:curio_unhurt_effect` component gives the wearer a
|
||||
[status effect](../../docs/modding/entities/players.md#status-effects) once they've gone `after` ticks without being
|
||||
hurt, and keeps it on them until they're hurt again. The giant chestplate's regeneration II after 10 seconds:
|
||||
hurt, and keeps it on them until they're hurt again. The giant chestplate's regeneration III after 10 seconds:
|
||||
|
||||
```json
|
||||
"components": {
|
||||
"bworld:curio_unhurt_effect": { "effect": "bworld:regeneration", "amplifier": 1, "after": 200 }
|
||||
"bworld:curio_unhurt_effect": { "effect": "bworld:regeneration", "amplifier": 2, "after": 200 }
|
||||
}
|
||||
```
|
||||
|
||||
It's given 2.5 seconds at a time, so it lasts up to that long after they're hurt. A stronger one they already have, like
|
||||
from a potion, is left alone.
|
||||
It's given two of regeneration's heals at a time (1.2 seconds for regeneration III), so it lasts up to that long after
|
||||
they're hurt. A stronger one they already have, like from a potion, is left alone.
|
||||
|
||||
@@ -22,8 +22,8 @@ interface UnhurtEffect {
|
||||
}
|
||||
|
||||
// how long each unhurt effect is given for, topped up whenever it runs out, so it outlasts being hurt by at most this.
|
||||
// a multiple of regeneration I and II's ticks between heals, so topping it up keeps their pace
|
||||
const UNHURT_EFFECT_TICKS = 50;
|
||||
// two of regeneration's heals at that level (every 50 ticks, halving each level), so topping it up keeps its pace
|
||||
const unhurt_effect_ticks = (amplifier: number) => Math.max(1, 50 >> amplifier) * 2;
|
||||
|
||||
export function register_curios(ctx: ServerContext) {
|
||||
const active = active_slots(ctx.tags);
|
||||
@@ -111,7 +111,7 @@ export function register_curios(ctx: ServerContext) {
|
||||
// only once what they have runs out, or when it's weaker. a stronger one, like from a potion, is left alone
|
||||
const current = player.effect(effect);
|
||||
if (current && current.amplifier >= amplifier) continue;
|
||||
player.add_effect(effect, UNHURT_EFFECT_TICKS, { amplifier });
|
||||
player.add_effect(effect, unhurt_effect_ticks(amplifier), { amplifier });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -132,7 +132,7 @@ Deno.test("the giant chestplate goes in the body slot and gives 20 more health w
|
||||
assertEquals(curios_items(t.take(1))[body], {
|
||||
id: "bworld:giant_chestplate",
|
||||
count: 1,
|
||||
lore: "When worn:\n+20 Max Health\nAfter 10s unhurt: Regeneration II",
|
||||
lore: "When worn:\n+20 Max Health\nAfter 10s unhurt: Regeneration III",
|
||||
});
|
||||
assertEquals(alice.max_health, 40);
|
||||
|
||||
@@ -156,7 +156,7 @@ Deno.test("the giant chestplate goes in the body slot and gives 20 more health w
|
||||
assertEquals(t.game.players()[0].health, 20);
|
||||
});
|
||||
|
||||
Deno.test("the giant chestplate gives regeneration II after 10 seconds without being hurt", async () => {
|
||||
Deno.test("the giant chestplate gives regeneration III after 10 seconds without being hurt", async () => {
|
||||
const t = await setup();
|
||||
t.send(1, { type: "chat", text: "/give bworld:giant_chestplate" });
|
||||
const slot = last_container(t.take(1), "inventory").findIndex((i: Msg) => i?.id === "bworld:giant_chestplate");
|
||||
@@ -168,17 +168,17 @@ Deno.test("the giant chestplate gives regeneration II after 10 seconds without b
|
||||
for (let i = 0; i < 199; i++) t.game.tick();
|
||||
assertEquals(regeneration(), undefined);
|
||||
t.game.tick();
|
||||
assertEquals(regeneration()?.amplifier, 1);
|
||||
assertEquals(regeneration()?.amplifier, 2);
|
||||
// it keeps being topped up while they stay unhurt
|
||||
for (let i = 0; i < 200; i++) t.game.tick();
|
||||
assertEquals(regeneration()?.amplifier, 1);
|
||||
assertEquals(regeneration()?.amplifier, 2);
|
||||
|
||||
// being hurt starts the 10 seconds again, what they were given runs out
|
||||
t.game.damage_player(alice, 2, "test");
|
||||
for (let i = 0; i < 199; i++) t.game.tick();
|
||||
assertEquals(regeneration(), undefined);
|
||||
t.game.tick();
|
||||
assertEquals(regeneration()?.amplifier, 1);
|
||||
assertEquals(regeneration()?.amplifier, 2);
|
||||
});
|
||||
|
||||
Deno.test("everyone sees what a player wears that has a worn model, and players joining later too", async () => {
|
||||
|
||||
Reference in New Issue
Block a user