Sign in
creature

Rockjaws

by Potluck · version 1 · Checked for all ages

Stony things that lie in wait in the dark of caves, looking just like a lump of rock against the wall. Come too close in survival and one wakes, lunges and bites, then lumbers after you before settling down as a rock again. Look for the seam of its mouth. They're hard as stone, so a pickaxe beats them twice as fast, and a beaten one leaves flint and sometimes whatever ore it swallowed. None on a Peaceful world, and fewer on a Gentle one.

1--!strict
2-- Rockjaws' own tests: `potluck-server --test=rockjaws`.
3local test = require("@potluck/test@0.9")
4local world = require("@potluck/world@0.25")
5
6-- a cave dug out under where a player stands, a row at a time
7local function cave(p): vector
8 local x, z, y = math.floor(p.position.x), math.floor(p.position.z), -24
9 for dx = -14, 14 do
10 for dz = -14, 14 do
11 world.set_block(vector.create(x + dx, y - 1, z + dz), "Stone")
12 for dy = 0, 4 do
13 world.set_block(vector.create(x + dx, y + dy, z + dz), "Air")
14 end
15 world.set_block(vector.create(x + dx, y + 5, z + dz), "Stone")
16 end
17 test.wait(0)
18 end
19 return vector.create(x + 0.5, y, z + 0.5)
20end
21
22local function all(): { number }
23 local out = {}
24 for _, k in { "Rockjaw", "Rockjaw (still)" } do
25 for _, id in world.creatures(test.kind(k)) do
26 table.insert(out, id)
27 end
28 end
29 return out
30end
31
32test.case("they lie in wait in caves, still as rock", function()
33 test.danger("normal")
34 local p = test.player("Ada", { survival = true })
35 local at = cave(p)
36 test.move(p, at)
37 test.wait(16)
38 local list = all()
39 test.check(#list >= 1, "a rockjaw lies about")
40 local c = test.creature(list[1])
41 local was = c.position
42 test.wait(3)
43 if c.kind == "Rockjaw (still)" then
44 test.check(vector.magnitude(c.position - was) < 0.1, "it doesn't move")
45 end
46end)
47
48test.case("come close and one wakes and bites, then settles again", function()
49 test.danger("normal")
50 local p = test.player("Ada", { survival = true })
51 local at = cave(p)
52 test.move(p, at + vector.create(-8, 0, 0))
53 local id = world.spawn(test.kind("Rockjaw (still)"), at + vector.create(4, 0, 0))
54 test.wait(1)
55 test.same(test.creature(id).kind, "Rockjaw (still)", "still")
56 test.move(p, at + vector.create(2, 0, 0))
57 test.wait(1)
58 test.same(test.creature(id).kind, "Rockjaw", "it woke")
59 test.wait(4)
60 test.check(test.health(p) < 20, "and bit")
61 -- off to the cave's far corner, out of its reach
62 test.move(p, at + vector.create(-12, 0, -12))
63 test.wait(16)
64 test.same(test.creature(id).kind, "Rockjaw (still)", "it settled again")
65end)
66
67test.case("a pickaxe beats one faster, and it leaves flint", function()
68 test.danger("normal")
69 local p = test.player("Ada", { survival = true, carrying = { ["Iron pickaxe"] = 1 } })
70 local at = cave(p)
71 test.move(p, at)
72 local id = world.spawn(test.kind("Rockjaw"), at + vector.create(2, 0, 0))
73 test.wait(0.2)
74 test.hold(p, "Iron pickaxe")
75 for _ = 1, 3 do
76 test.hit(p, test.creature(id))
77 end
78 test.same(test.creature(id), nil, "beaten")
79 test.check(world.has(p, "Flint") >= 1, "flint")
80 test.same(world.xp(p), 6, "and some XP")
81end)