forked from 2009Scape/Server
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.
This commit is contained in:
parent
e9085a8270
commit
3cdf7767eb
3 changed files with 39 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
31
Server/src/main/core/api/SnowscapeAPI.kt
Normal file
31
Server/src/main/core/api/SnowscapeAPI.kt
Normal file
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue