Allow mobs to be hit
This commit is contained in:
@@ -144,6 +144,23 @@ Deno.test("hits push away from the attacker", async () => {
|
||||
assert(mob.vz > 0 && mob.vy > 0, "knocked back, away from the attacker at a smaller z");
|
||||
});
|
||||
|
||||
Deno.test("players hit entities they can reach, pushing them away", async () => {
|
||||
const { spawn, ticks, send } = await floor_game();
|
||||
const mob = spawn(0.5, 100, 2.5);
|
||||
const far = spawn(0.5, 100, 20.5);
|
||||
far.tags.add("stays");
|
||||
ticks(2);
|
||||
|
||||
send(1, { type: "attack_entity", id: mob.id });
|
||||
assertEquals(mob.health, 9);
|
||||
assert(mob.vz > 0, "knocked back, away from alice");
|
||||
assert(mob.last_hurt_by_player !== undefined);
|
||||
|
||||
send(1, { type: "attack_entity", id: far.id });
|
||||
assertEquals(far.health, 10, "too far away");
|
||||
send(1, { type: "attack_entity", id: "nothing" });
|
||||
});
|
||||
|
||||
Deno.test("dying: it drops what it had, falls over for a second and is gone", async () => {
|
||||
const { game, spawn, take, ticks } = await floor_game();
|
||||
const mob = spawn(0.5, 100, 2.5);
|
||||
|
||||
Reference in New Issue
Block a user