From a0c6522fbcb46806707d227f49b7ba2e3e2ba9b7 Mon Sep 17 00:00:00 2001 From: vk Date: Wed, 22 Sep 2021 21:09:53 +0000 Subject: [PATCH] Fix broad bolts on turroths and kurasks --- .../node/entity/skill/slayer/KuraskNPC.java | 6 +++--- .../node/entity/skill/slayer/TurothNPC.java | 6 +++--- .../node/entity/skill/slayer/SlayerUtils.kt | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 Server/src/main/kotlin/rs09/game/node/entity/skill/slayer/SlayerUtils.kt diff --git a/Server/src/main/java/core/game/node/entity/skill/slayer/KuraskNPC.java b/Server/src/main/java/core/game/node/entity/skill/slayer/KuraskNPC.java index d3a80343b..cde7e0474 100644 --- a/Server/src/main/java/core/game/node/entity/skill/slayer/KuraskNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/slayer/KuraskNPC.java @@ -6,6 +6,8 @@ import core.game.node.entity.player.Player; import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.world.map.Location; import core.plugin.Initializable; +import org.rs09.consts.Items; +import rs09.game.node.entity.skill.slayer.SlayerUtils; /** * Handles the kurask npc. @@ -41,9 +43,7 @@ public final class KuraskNPC extends AbstractNPC { boolean effective = false; if (state.getAttacker() instanceof Player) { final Player player = (Player) state.getAttacker(); - if ((state.getWeapon() != null && state.getWeapon().getId() == 4158) || (state.getAmmunition() != null && state.getAmmunition().getItemId() == 4160) || (state.getWeapon() != null && state.getWeapon().getId() == 13290) || (state.getSpell() != null && state.getSpell().getSpellId() == 31 && player.getSpellBookManager().getSpellBook() == SpellBook.MODERN.getInterfaceId()) || (state.getAmmunition() != null && state.getAmmunition().getItemId() == 881)) { - effective = true; - } + effective = new SlayerUtils(player).hasBroadWeaponEquipped(state); } if (!effective) { state.setEstimatedHit(0); diff --git a/Server/src/main/java/core/game/node/entity/skill/slayer/TurothNPC.java b/Server/src/main/java/core/game/node/entity/skill/slayer/TurothNPC.java index c36239f22..7299fae07 100644 --- a/Server/src/main/java/core/game/node/entity/skill/slayer/TurothNPC.java +++ b/Server/src/main/java/core/game/node/entity/skill/slayer/TurothNPC.java @@ -6,6 +6,8 @@ import core.game.node.entity.player.Player; import core.game.node.entity.player.link.SpellBookManager.SpellBook; import core.game.world.map.Location; import core.plugin.Initializable; +import org.rs09.consts.Items; +import rs09.game.node.entity.skill.slayer.SlayerUtils; /** * Handles the turoth npc. @@ -41,9 +43,7 @@ public final class TurothNPC extends AbstractNPC { boolean effective = false; if (state.getAttacker() instanceof Player) { final Player player = (Player) state.getAttacker(); - if ((state.getWeapon() != null && state.getWeapon().getId() == 4158) || (state.getAmmunition() != null && state.getAmmunition().getItemId() == 4160) || (state.getWeapon() != null && state.getWeapon().getId() == 13290) || (state.getSpell() != null && state.getSpell().getSpellId() == 31 && player.getSpellBookManager().getSpellBook() == SpellBook.MODERN.getInterfaceId())) { - effective = true; - } + effective = new SlayerUtils(player).hasBroadWeaponEquipped(state); } if (!effective) { state.setEstimatedHit(0); diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/slayer/SlayerUtils.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/slayer/SlayerUtils.kt new file mode 100644 index 000000000..cf4cd4170 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/slayer/SlayerUtils.kt @@ -0,0 +1,18 @@ +package rs09.game.node.entity.skill.slayer + +import core.game.node.entity.combat.BattleState +import core.game.node.entity.player.Player +import core.game.node.entity.player.link.SpellBookManager.SpellBook +import org.rs09.consts.Items + +class SlayerUtils(val player: Player) { + + fun hasBroadWeaponEquipped(state: BattleState): Boolean { + return (state.weapon != null && state.weapon.id == Items.LEAF_BLADED_SPEAR_4158 || + state.weapon != null && state.weapon.id == Items.LEAF_BLADED_SWORD_13290 || + state.ammunition != null && (state.ammunition.itemId == Items.BROAD_ARROW_4160 || state.ammunition.itemId == Items.BROAD_TIPPED_BOLTS_13280) || + state.spell != null && state.spell.spellId == 31 && player.spellBookManager + .spellBook == SpellBook.MODERN.interfaceId + ) + } +} \ No newline at end of file