Sign in
creature

The Gloam

by Potluck · version 1 · Checked for all ages

The Gloam, a great beast of the dark that drinks the light, sleeps in a hollow under the moonsilver vaults: open a vault's moon seal and a stair behind its coffer goes down to it. Make a Moon bell at a workbench from moonsilver and what the night's creatures leave, ring it at the altar and the Gloam wakes. It slams, then snuffs the lamps and sends its shades (light them again to reach it), then rages. Beat it for its heart, a dawn cloak and a dawn stone on the Green. Never on Peaceful.

1--!strict
2-- The Gloam's own tests: `potluck-server --test=gloam`. Only this creation
3-- runs, so with no Moonsilver Vaults here its hollow opens on its own near
4-- a player far down. When the vaults' blocks are known (other creations'
5-- tests made them, in the same game), it waits for a sanctum, so the tests
6-- build one out of moonstone (a Rust test opens one behind a real vault).
7local test = require("@potluck/test@0.9")
8local world = require("@potluck/world@0.30")
9
10local function v(x: number, y: number, z: number): vector
11 return vector.create(x, y, z)
12end
13
14local function kind(name: string): { number }
15 return world.creatures(test.kind(name))
16end
17
18local vaults = (pcall(world.kind, "Moonsilver coffer"))
19
20-- a little cave far down under where a player stands
21local function cave(p): vector
22 local x, z, y = math.floor(p.position.x), math.floor(p.position.z), -100
23 for dx = -4, 4 do
24 for dz = -4, 4 do
25 world.set_block(v(x + dx, y - 1, z + dz), "Stone")
26 world.set_block(v(x + dx, y + 3, z + dz), "Stone")
27 for dy = 0, 2 do
28 world.set_block(v(x + dx, y + dy, z + dz), "Air")
29 end
30 end
31 test.wait(0)
32 end
33 if vaults then
34 -- a vault's sanctum: moonstone floor and roof, walls two either side
35 -- and the back wall three north, open to the south
36 for dx = -2, 2 do
37 for dz = -3, 0 do
38 for dy = -1, 3 do
39 local wall = dy == -1 or dy == 3 or math.abs(dx) == 2 or dz == -3
40 world.set_block(v(x + dx, y + dy, z + dz), if wall then "Moonstone" else "Air")
41 end
42 end
43 end
44 end
45 return v(x + 0.5, y, z + 0.5)
46end
47
48-- waits for the hollow to open near a player there, and finds its altar:
49-- just north, or behind the sanctum at the foot of its stair
50local function hollow(p, at: vector): vector
51 test.move(p, at)
52 for _ = 1, 30 do
53 test.wait(1)
54 local altar = world.find_block(at, 16, "Gloam altar") or world.find_block(at + v(0, -8, -22), 16, "Gloam altar")
55 if altar then
56 test.wait(1)
57 return altar
58 end
59 end
60 error("no hollow opened")
61end
62
63-- into the hollow south of the altar, and the bell rung
64local function ring(p, altar: vector)
65 test.move(p, altar + v(0, 0, 5))
66 test.wait(2)
67 test.hold(p, "Moon bell")
68 test.use_block(p, altar)
69 test.wait(0.5)
70end
71
72test.case("far down a hollow opens, and a Moon bell at its altar wakes the Gloam", function()
73 test.danger("normal")
74 local p = test.player("Ada", { survival = true, carrying = { ["Moon bell"] = 1 } })
75 local altar = hollow(p, cave(p))
76 test.same(world.block(altar - v(0, 1, 0)), "Gloamstone", "a gloamstone floor")
77 test.check(world.find_block(altar, 12, "Moon lamp") ~= nil, "lamps round it")
78 test.move(p, altar + v(0, 0, 5))
79 test.wait(2)
80 test.same(#kind("The Gloam (asleep)"), 1, "it sleeps")
81 ring(p, altar)
82 test.same(#kind("The Gloam"), 1, "it wakes")
83 test.same(world.has(p, "Moon bell"), 0, "the bell rang")
84 test.check(test.heard("roar") >= 1, "with a roar")
85 local lowest = 20
86 for _ = 1, 20 do
87 test.wait(0.5)
88 lowest = math.min(lowest, test.health(p))
89 end
90 test.check(lowest < 20, "and it fights")
91end)
92
93test.case("beaten in three parts: the lamps go out, it's shielded till they're lit, and it leaves its heart", function()
94 test.danger("gentle")
95 local p = test.player("Ada", { survival = true, carrying = { ["Moon bell"] = 1, ["Iron sword"] = 1 } })
96 local altar = hollow(p, cave(p))
97 ring(p, altar)
98 test.hold(p, "Iron sword")
99 local id = kind("The Gloam")[1]
100 test.check(id ~= nil, "awake")
101 local dark, shades, shielded, raged = false, 0, false, false
102 for _ = 1, 400 do
103 local g = test.creature(id)
104 if not g then
105 break
106 end
107 world.heal(p, 20)
108 raged = raged or g.phase == 3
109 local snuffed = world.find_block(altar, 12, "Snuffed moon lamp")
110 if snuffed then
111 if not dark then
112 dark = true
113 shades = #kind("Gloam shade")
114 -- while it's dark a blow does a quarter as much
115 local before = g.health
116 test.hit(p, g)
117 local drop = before - test.creature(id).health
118 shielded = drop > 0.5 and drop < 1.5
119 test.wait(0.5)
120 end
121 test.use_block(p, snuffed)
122 else
123 test.hit(p, g)
124 test.wait(0.5)
125 end
126 end
127 test.same(test.creature(id), nil, "beaten")
128 test.check(dark, "it drank the light")
129 test.check(shades >= 1, "and sent its shades")
130 test.check(shielded, "shielded while the lamps were out")
131 test.check(raged, "and raged at the end")
132 test.same(#kind("Gloam shade"), 0, "its shades go with it")
133 test.same(world.has(p, "Gloam's heart"), 1, "its heart")
134 test.same(world.has(p, "Dawn cloak"), 1, "a dawn cloak")
135 test.check(world.has(p, "Moonsilver ingot") >= 3, "and moonsilver")
136 test.check(world.xp(p) >= 100, "and XP")
137 local card = test.asked(p)
138 test.same(card and card.title, "The Gloam is beaten", "a card says so")
139 local g = world.spot("green")
140 local x, z = math.floor(g.x) + 5, math.floor(g.z) + 5
141 test.check(world.find_block(v(x, world.top(x, z), z), 4, "Moon lamp") ~= nil, "a dawn stone on the Green")
142 -- and the hollow rests a while before it gathers again
143 test.wait(3)
144 test.same(#kind("The Gloam (asleep)"), 0, "nothing stirs yet")
145end)
146
147test.case("it settles when you go, and the bell stays in the altar", function()
148 test.danger("normal")
149 local p = test.player("Ada", { survival = true, carrying = { ["Moon bell"] = 1 } })
150 local at = cave(p)
151 local altar = hollow(p, at)
152 ring(p, altar)
153 test.same(#kind("The Gloam"), 1, "awake")
154 test.move(p, at)
155 test.wait(17)
156 test.same(#kind("The Gloam"), 0, "it settles")
157 test.same(#kind("The Gloam (asleep)"), 1, "back to sleep")
158 test.move(p, altar + v(0, 0, 5))
159 test.hold(p, nil)
160 test.use_block(p, altar)
161 test.wait(0.5)
162 test.same(#kind("The Gloam"), 1, "the bell in the altar wakes it again")
163end)
164
165test.case("never on Peaceful", function()
166 test.danger("peaceful")
167 local p = test.player("Ada", { survival = true, carrying = { ["Moon bell"] = 1 } })
168 local altar = hollow(p, cave(p))
169 ring(p, altar)
170 test.wait(2)
171 test.same(#kind("The Gloam (asleep)"), 0, "nothing sleeps there")
172 test.same(#kind("The Gloam"), 0, "nothing wakes")
173 test.same(world.has(p, "Moon bell"), 1, "the bell's kept")
174end)
175
176test.case("the bell hums toward the hollow", function()
177 test.danger("normal")
178 local p = test.player("Ada", { survival = true, carrying = { ["Moon bell"] = 1 } })
179 test.hold(p, "Moon bell")
180 test.use_item(p, v(0, 1, 0))
181 test.check(string.find(test.shown(p, "gloam") or "", "Find a moonsilver vault", 1, true) ~= nil, "no hollow yet")
182 local at = cave(p)
183 hollow(p, at)
184 test.move(p, at + v(0, 0, 40))
185 test.use_item(p, v(0, 1, 0))
186 test.check(string.find(test.shown(p, "gloam") or "", "hums north", 1, true) ~= nil, test.shown(p, "gloam") or "nothing")
187end)