Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+16 -1
View File
@@ -463,6 +463,11 @@ export class GameServer {
this.#send(player, { type: "chat", text });
}
// a mod's server script to its client script, see ctx.net
send_mod_message(player: ServerPlayer, channel: string, data: unknown) {
this.#send(player, { type: "mod", channel, data });
}
teleport(player: ServerPlayer, x: number, y: number, z: number) {
Object.assign(player, { x, y, z });
player.fall_distance = 0;
@@ -765,6 +770,7 @@ export class GameServer {
break;
case "select_slot":
if (is_int(message.slot) && message.slot >= 0 && message.slot < 9) {
if (message.slot !== player.selected_slot) player.attack_strength_ticker = 0;
player.selected_slot = message.slot;
}
break;
@@ -783,6 +789,11 @@ export class GameServer {
case "suggest":
this.#suggest(player, message.id, message.text);
break;
case "mod":
if (typeof message.channel === "string") {
this.mods.receive(player, message.channel, message.data);
}
break;
}
}
@@ -838,7 +849,11 @@ export class GameServer {
return;
}
const source = { type: "physical", cause: "player_attack", attacker: player, by_player: true } as const;
if (entity.hurt(player.attribute(ATTRIBUTES.attack_damage), source)) {
// like minecraft, attacking again before the attack speed allows hits weaker
const strength = player.attack_strength();
player.attack_strength_ticker = 0;
const damage = player.attribute(ATTRIBUTES.attack_damage) * (0.2 + strength * strength * 0.8);
if (entity.hurt(damage, source)) {
player.vitals.add_exhaustion(EXHAUSTION.attack);
}
}