Far out in the Long Night a ring of nightglass spires stands on the ice: the Still Court, where a great pale stag, the Hush, sleeps. Make a Star chime from evensteel, starglass and hush silk and ring it at the altar. It gores and charges (hit it while it's dazed), star crystals shield it until you break them, and a cold pulse hurts anyone away from a light. Beat it for its antler, starglass and a Hush crown. Never on Peaceful.
| 1 | --!strict |
| 2 | -- The Hush's own tests: `potluck-server --test=hush`. |
| 3 | local test = require("@potluck/test@0.9") |
| 4 | local world = require("@potluck/world@0.33") |
| 5 | |
| 6 | local function v(x: number, y: number, z: number): vector |
| 7 | return vector.create(x, y, z) |
| 8 | end |
| 9 | |
| 10 | local function pos(p): vector |
| 11 | for _, q in world.players() do |
| 12 | if q.id == p.id then |
| 13 | return q.position |
| 14 | end |
| 15 | end |
| 16 | error("no such player") |
| 17 | end |
| 18 | |
| 19 | -- a flat, dry stretch in the Long Night for the court to open on |
| 20 | local function night(): vector |
| 21 | for x = 26200, 29000, 211 do |
| 22 | for z = 140, 4000, 173 do |
| 23 | local at = v(x + 0.5, 0, z + 0.5) |
| 24 | if world.biome(at) == "long_night" then |
| 25 | local top = world.top(at.x, at.z) |
| 26 | if world.block(v(at.x, top, at.z)) ~= "Ice" and top > 20 then |
| 27 | return v(at.x, top + 1.02, at.z) |
| 28 | end |
| 29 | end |
| 30 | end |
| 31 | end |
| 32 | error("no Long Night found") |
| 33 | end |
| 34 | |
| 35 | local function kind(name: string): { number } |
| 36 | return world.creatures(test.kind(name)) |
| 37 | end |
| 38 | |
| 39 | -- find_block sees 16 round a point: look over a grid round the player |
| 40 | local function seek(at: vector, name: string): vector? |
| 41 | for dx = -48, 48, 24 do |
| 42 | for dz = -48, 48, 24 do |
| 43 | test.wait(0) |
| 44 | for dy = -16, 16, 16 do |
| 45 | local found = world.find_block(at + v(dx, dy, dz), 16, name) |
| 46 | if found then |
| 47 | return found |
| 48 | end |
| 49 | end |
| 50 | end |
| 51 | end |
| 52 | return nil |
| 53 | end |
| 54 | |
| 55 | -- waits for a court to open near a player, and finds its altar |
| 56 | local function court(p): vector |
| 57 | for _ = 1, 60 do |
| 58 | test.wait(1) |
| 59 | local altar = seek(pos(p), "Still altar") |
| 60 | if altar then |
| 61 | test.wait(2) |
| 62 | return altar |
| 63 | end |
| 64 | end |
| 65 | error("no court opened") |
| 66 | end |
| 67 | |
| 68 | test.case("a court opens in the Long Night, and a chime at its altar wakes the Hush", function() |
| 69 | test.danger("normal") |
| 70 | local p = test.player("Ada", { survival = true, carrying = { ["Star chime"] = 1 } }) |
| 71 | test.move(p, night()) |
| 72 | local altar = court(p) |
| 73 | test.same(world.block(altar - v(0, 1, 0)), "Duskstone bricks", "a duskstone floor") |
| 74 | test.check(world.find_block(altar, 12, "Starglass") ~= nil, "star crystals in it") |
| 75 | test.check(world.find_block(altar, 12, "Nightglass") ~= nil, "spires round it") |
| 76 | test.move(p, altar + v(0, 0, 6)) |
| 77 | test.wait(3) |
| 78 | test.same(#kind("The Hush (still)"), 1, "it sleeps") |
| 79 | test.hold(p, "Star chime") |
| 80 | test.use_block(p, altar) |
| 81 | test.wait(2) |
| 82 | test.same(#kind("The Hush"), 1, "the chime wakes it") |
| 83 | test.check(world.has(p, "Star chime") == 0, "the chime is used up") |
| 84 | end) |
| 85 | |
| 86 | test.case("starlight shields it until the crystals are broken, and Peaceful leaves it asleep", function() |
| 87 | test.danger("normal") |
| 88 | local p = test.player("Ada", { survival = true, carrying = { ["Star chime"] = 1, ["Iron pickaxe"] = 1, ["Iron sword"] = 1 } }) |
| 89 | test.move(p, night()) |
| 90 | local altar = court(p) |
| 91 | test.move(p, altar + v(0, 0, 6)) |
| 92 | test.wait(2) |
| 93 | test.hold(p, "Star chime") |
| 94 | test.use_block(p, altar) |
| 95 | test.wait(2) |
| 96 | local id = kind("The Hush")[1] |
| 97 | test.check(id ~= nil, "awake") |
| 98 | local h = test.creature(id) |
| 99 | if not h then |
| 100 | return |
| 101 | end |
| 102 | test.hold(p, "Iron sword") |
| 103 | test.move(p, h.position + v(0, 0, 2)) |
| 104 | local before = h.health |
| 105 | test.hit(p, h) |
| 106 | h = test.creature(id) |
| 107 | test.check(h ~= nil, "still there") |
| 108 | if not h then |
| 109 | return |
| 110 | end |
| 111 | local shielded = before - h.health |
| 112 | test.check(shielded > 0 and shielded <= 1.5, "a shielded blow counts a quarter") |
| 113 | -- break the four crystals |
| 114 | test.hold(p, "Iron pickaxe") |
| 115 | for _, d in { v(4, 0, 4), v(-4, 0, 4), v(4, 0, -4), v(-4, 0, -4) } do |
| 116 | test.move(p, altar + d + v(1, 0, 1)) |
| 117 | test.dig(p, altar + d) |
| 118 | end |
| 119 | test.hold(p, "Iron sword") |
| 120 | h = test.creature(id) |
| 121 | if not h then |
| 122 | return |
| 123 | end |
| 124 | test.move(p, h.position + v(0, 0, 2)) |
| 125 | test.wait(1) |
| 126 | h = test.creature(id) |
| 127 | if not h then |
| 128 | return |
| 129 | end |
| 130 | local mid = h.health |
| 131 | test.hit(p, h) |
| 132 | h = test.creature(id) |
| 133 | if h then |
| 134 | test.check(mid - h.health >= 3, "an open blow counts in full") |
| 135 | end |
| 136 | test.danger("peaceful") |
| 137 | test.wait(3) |
| 138 | test.same(#kind("The Hush"), 0, "none on Peaceful") |
| 139 | end) |