Physical and arcane damage

This commit is contained in:
2026-09-30 09:56:53 -03:00
parent 88659bb7af
commit 9e580f175e
9 changed files with 54 additions and 75 deletions
+10 -9
View File
@@ -32,28 +32,29 @@ export interface PlayerTarget extends Attacker {
readonly name: string;
}
export type DamageType = "physical" | "arcane" | "absolute";
// what hurt something. cause is for mods and death messages, like "fall", "drown" or "mob_attack"
export interface DamageSource {
type: DamageType;
cause: string;
// who did it, which knockback pushes away from
attacker?: Attacker;
by_player?: boolean;
// fire resistance stops it
fire?: boolean;
// armor doesn't help, like drowning, falling and starving
bypasses_armor?: boolean;
// even invulnerable entities are hurt, like falling out of the world
bypasses_invulnerability?: boolean;
}
export const DAMAGE = {
generic: { cause: "generic" },
fall: { cause: "fall", bypasses_armor: true },
drown: { cause: "drown", bypasses_armor: true },
on_fire: { cause: "on_fire", fire: true, bypasses_armor: true },
void: { cause: "void", bypasses_armor: true, bypasses_invulnerability: true },
magic: { cause: "magic", bypasses_armor: true },
wither: { cause: "wither", bypasses_armor: true },
generic: { cause: "generic", type: "physical" },
fall: { cause: "fall", type: "physical" },
drown: { cause: "drown", type: "physical" },
on_fire: { cause: "on_fire", fire: true, type: "arcane" },
void: { cause: "void", bypasses_invulnerability: true, type: "absolute" },
magic: { cause: "magic", type: "arcane" },
wither: { cause: "wither", type: "arcane" },
} satisfies Record<string, DamageSource>;
// what entities can see and do in the world, the entity manager is one