From 3cdf7767eb1fa3be7d85c32ab4f09620609b0c87 Mon Sep 17 00:00:00 2001 From: randy Date: Thu, 25 Dec 2025 21:10:40 -0700 Subject: [PATCH] Updated Crumble Undead and created Snowscape API New API will allow creating new global functions without conflicting with upstream changes. Crumble undead now works on more undead, including Barrows brothers and revenants. --- .../skill/magic/modern/CrumbleUndead.java | 4 ++- Server/src/main/core/api/SnowscapeAPI.kt | 31 +++++++++++++++++++ .../node/entity/combat/spell/SpellType.java | 8 +++-- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Server/src/main/core/api/SnowscapeAPI.kt diff --git a/Server/src/main/content/global/skill/magic/modern/CrumbleUndead.java b/Server/src/main/content/global/skill/magic/modern/CrumbleUndead.java index ec23e258f..0c9f896b1 100644 --- a/Server/src/main/content/global/skill/magic/modern/CrumbleUndead.java +++ b/Server/src/main/content/global/skill/magic/modern/CrumbleUndead.java @@ -17,6 +17,8 @@ import core.plugin.Initializable; import core.plugin.Plugin; import org.rs09.consts.Sounds; +import static core.api.SnowscapeAPIKt.*; + /** * Handles the crumble undead spell. * @author Emperor @@ -35,7 +37,7 @@ public final class CrumbleUndead extends CombatSpell { @Override public boolean cast(Entity entity, Node target) { NPC npc = target instanceof NPC ? (NPC) target : null; - if (npc == null || npc.getTask() == null || !npc.getTask().undead) { + if (npc == null || !isUndead(npc)) { ((Player) entity).getPacketDispatch().sendMessage("This spell only affects the undead."); return false; } diff --git a/Server/src/main/core/api/SnowscapeAPI.kt b/Server/src/main/core/api/SnowscapeAPI.kt new file mode 100644 index 000000000..62f397272 --- /dev/null +++ b/Server/src/main/core/api/SnowscapeAPI.kt @@ -0,0 +1,31 @@ +package core.api + +import core.game.node.Node +import core.game.node.entity.Entity +import core.game.node.entity.npc.NPC + +/** + Separate API for Snowscape customizations to reduce impact on upstream code. + +*/ + + + +/** Checks if a given entity is classified as undead. Used for Crumble Undead. + Includes more undead than the default game, notably the Barrows Brothers. +*/ +fun isUndead (entity: Entity): Boolean { + if (entity.getId() in 2025..2030) return true // Barrows brothers + + // Includes any enemy that can be part of an undead slayer task. + val slayerTask = (entity as NPC).getTask() + if (slayerTask != null && slayerTask.undead) return true + + // Final slower check using name. Most cases should be caught by the slayer tasks, but this should guarantee the rest. + val entityName = entity.getName().lowercase() + val undeadNames = arrayOf("zombie","spirit","revenant","ghast","ghost","mummy","shade","skeleton","skogre","zogre","undead","tortured soul","spectre","ankou","banshee","crawling hand") + for (undeadName in undeadNames) { + if (entityName.contains(undeadName)) return true + } + return false +} \ No newline at end of file diff --git a/Server/src/main/core/game/node/entity/combat/spell/SpellType.java b/Server/src/main/core/game/node/entity/combat/spell/SpellType.java index d58dd2887..cd0fb91e8 100644 --- a/Server/src/main/core/game/node/entity/combat/spell/SpellType.java +++ b/Server/src/main/core/game/node/entity/combat/spell/SpellType.java @@ -8,6 +8,7 @@ import core.game.node.entity.player.Player; import core.game.node.item.Item; import static core.api.ContentAPIKt.*; +import static core.api.SnowscapeAPIKt.*; /** * Represents the spell types. @@ -47,11 +48,12 @@ public enum SpellType { CRUMBLE_UNDEAD(1.2) { @Override public int getImpactAmount(Entity e, Entity victim, int base) { - if (((NPC) victim).getTask() != null && ((NPC) victim).getTask().undead) { + // The check in CrumbleUndead.cast() only fires when manual casting. Check again here so that no damage is dealt when autocasting. + if (isUndead(victim)) { return 12 + (e.getSkills().getLevel(Skills.MAGIC) / 10); } - ((Player) e).sendMessage("Your spell does almost no damage, as your target is not undead."); - return 1; + ((Player) e).sendMessage("This spell only affects the undead."); + return 0; } },