Sign in
creature

Bramble Boars

by Potluck · version 1 · Checked for all ages

Bristly wild boars that root about in the woods by day. Leave them be: come too close in survival and one snorts, stamps and charges, then goes back to its rooting. They're tough, but bop one enough and it leaves leather, bristles and meat to cook. On a Peaceful world they never charge; on a Hard one they hit harder and come back at you sooner.

1--!strict
2local test = require("@potluck/test@0.7")
3local world = require("@potluck/world@0.22")
4
5local function boars(): { number }
6 return world.creatures(test.kind("Bramble Boar"))
7end
8
9-- a grassy wood high in the sky, well away from the Green: where it
10-- stands, for a player to stand
11local function wood(): vector
12 local g = world.spot("green")
13 local cx, cz, y = math.floor(g.x) + 90, math.floor(g.z), 90
14 for dx = -20, 20 do
15 for dz = -20, 20 do
16 world.set_block(vector.create(cx + dx, y, cz + dz), "Grass")
17 if dx % 8 == 4 and dz % 8 == 4 then
18 for dy = 1, 3 do
19 world.set_block(vector.create(cx + dx, y + dy, cz + dz), "Oak log")
20 end
21 end
22 end
23 test.wait(0)
24 end
25 return vector.create(cx + 0.5, y + 1, cz + 0.5)
26end
27
28test.case("boars root about in the woods by day", function()
29 local p = test.player("Ada")
30 local at = wood()
31 test.move(p, at)
32 test.wait(14)
33 test.check(#boars() >= 1, "a boar turned up")
34end)
35
36test.case("come too close and one charges, then leaves you be a while", function()
37 test.danger("normal")
38 local p = test.player("Ada", { survival = true })
39 local at = wood()
40 test.move(p, at)
41 world.spawn(test.kind("Bramble Boar"), at + vector.create(3, 0, 0))
42 -- it looks about a few seconds first, then snorts and comes
43 for _ = 1, 40 do
44 test.wait(0.25)
45 if test.health(p) < 20 then
46 break
47 end
48 end
49 local hurt = test.health(p)
50 test.check(hurt < 20, "charged")
51 test.wait(4)
52 test.same(test.health(p), hurt, "and rests before another")
53end)
54
55test.case("on a Peaceful world they never charge", function()
56 test.danger("peaceful")
57 local p = test.player("Ada", { survival = true })
58 local at = wood()
59 test.move(p, at)
60 local id = world.spawn(test.kind("Bramble Boar"), at + vector.create(2, 0, 0))
61 test.wait(6)
62 test.same(test.health(p), 20, "not charged")
63 test.hit(p, test.creature(id))
64 test.wait(3)
65 test.same(test.health(p), 20, "not even when bopped")
66end)
67
68test.case("beaten, one leaves leather, bristles and meat", function()
69 test.danger("peaceful")
70 local p = test.player("Ada", { survival = true, carrying = { ["Iron sword"] = 1 } })
71 local at = wood()
72 test.move(p, at)
73 test.hold(p, "Iron sword")
74 local id = world.spawn(test.kind("Bramble Boar"), at + vector.create(2, 0, 0))
75 test.wait(0.2)
76 test.hit(p, test.creature(id))
77 test.check(test.creature(id) ~= nil, "tough")
78 test.hit(p, test.creature(id))
79 test.same(test.creature(id), nil, "beaten with two good bops")
80 test.check(world.has(p, "Leather") >= 1, "leather")
81 test.check(world.has(p, "Bristles") >= 1, "bristles")
82 test.check(world.has(p, "Raw meat") >= 1, "meat")
83 test.same(world.xp(p), 5, "and some XP")
84end)