Sign in
creature

Duskwasps

by Potluck · version 1 · Checked for all ages

Papery nests that hang under the leaves in the woods at night, each with a few duskwasps buzzing round it. Wander under one in survival and they swarm you and sting, but they won't follow far from home. Pop the wasps with a bop each, or knock the nest down to send them off, and it leaves dusk wax, which a Moon bell takes. A light under the nest calms them, and they're gone by sunrise. None on a Peaceful world, and fewer on a Gentle one.

1--!strict
2-- Duskwasps' own tests: `potluck-server --test=duskwasps`.
3local test = require("@potluck/test@0.9")
4local world = require("@potluck/world@0.30")
5
6local function all(kind: string): { number }
7 return world.creatures(test.kind(kind))
8end
9
10-- a grassy glade high in the sky under a roof of leaves, away from the
11-- Green and its lights: where a player stands in it
12local function glade(): vector
13 local g = world.spot("green")
14 local cx, cz, y = math.floor(g.x) + 90, math.floor(g.z), 90
15 for dx = -16, 16 do
16 for dz = -16, 16 do
17 world.set_block(vector.create(cx + dx, y, cz + dz), "Grass")
18 world.set_block(vector.create(cx + dx, y + 5, cz + dz), "Oak leaves")
19 end
20 test.wait(0)
21 end
22 return vector.create(cx + 0.5, y + 1, cz + 0.5)
23end
24
25test.case("at night a nest hangs under the leaves, and its wasps sting whoever comes close", function()
26 test.danger("normal")
27 test.daytime(0)
28 local p = test.player("Ada", { survival = true })
29 local at = glade()
30 test.move(p, at)
31 test.wait(12)
32 local nests = all("Duskwasp nest")
33 test.check(#nests >= 1, "a nest")
34 test.check(#all("Duskwasp") >= 1, "with wasps")
35 local nest = test.creature(nests[1])
36 test.move(p, vector.create(nest.position.x, at.y, nest.position.z))
37 test.wait(10)
38 test.check(test.health(p) < 20, "they stung")
39 test.daytime(0.4)
40 test.wait(2)
41 test.same(#all("Duskwasp nest") + #all("Duskwasp"), 0, "gone by day")
42end)
43
44test.case("knocking a nest down leaves dusk wax, and a wasp pops with a bop", function()
45 test.danger("normal")
46 test.daytime(0)
47 local p = test.player("Ada", { survival = true })
48 local at = glade()
49 test.move(p, at)
50 local wasp = world.spawn(test.kind("Duskwasp"), at + vector.create(2, 1, 0))
51 local nest = world.spawn(test.kind("Duskwasp nest"), at + vector.create(0, 3.1, 3))
52 test.wait(0.2)
53 test.hit(p, test.creature(wasp))
54 test.same(test.creature(wasp), nil, "one bop pops a wasp")
55 for _ = 1, 3 do
56 test.hit(p, test.creature(nest))
57 end
58 test.check(test.creature(nest) ~= nil, "three bops don't knock a nest down")
59 test.hit(p, test.creature(nest))
60 test.same(test.creature(nest), nil, "four do")
61 test.check(world.has(p, "Dusk wax") >= 1, "dusk wax")
62 test.same(world.xp(p), 7, "and some XP")
63end)
64
65test.case("none on Peaceful", function()
66 test.danger("peaceful")
67 test.daytime(0)
68 local p = test.player("Ada", { survival = true })
69 local at = glade()
70 test.move(p, at)
71 test.wait(12)
72 test.same(#all("Duskwasp nest"), 0, "none on Peaceful")
73end)