From 490c6d42ec18ebeae1275933159fa2ec40196778 Mon Sep 17 00:00:00 2001 From: randy Date: Sun, 27 Oct 2024 21:06:08 -0600 Subject: [PATCH] Autocast changes - All God staves can autocast, and autocast is now independent of active spellbook. --- .../combat/equipment/WeaponInterface.java | 61 +++++++++++++++---- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/Server/src/main/core/game/node/entity/combat/equipment/WeaponInterface.java b/Server/src/main/core/game/node/entity/combat/equipment/WeaponInterface.java index cb74f3fa6..6a38729fe 100644 --- a/Server/src/main/core/game/node/entity/combat/equipment/WeaponInterface.java +++ b/Server/src/main/core/game/node/entity/combat/equipment/WeaponInterface.java @@ -46,10 +46,20 @@ public final class WeaponInterface extends Component { private static final int[] SLAYER_STAFF_SPELL_IDS = { 22, 31, 45, 48, 52, 55 }; /** - * The void staff spell ids + * The void and guthix staff spell ids */ private static final int[] VOID_STAFF_SPELL_IDS = { 22, 42, 45, 48, 52, 55 }; + /** + * The saradomin staff spell ids + */ + private static final int[] SARADOMIN_STAFF_SPELL_IDS = { 22, 41, 45, 48, 52, 55 }; + + /** + * The zamorak staff spell ids + */ + private static final int[] ZAMORAK_STAFF_SPELL_IDS = { 22, 43, 45, 48, 52, 55 }; + /** * The default attack animations. */ @@ -333,13 +343,23 @@ public final class WeaponInterface extends Component { * @return The component id for the autocast select tab. */ public int getAutospellId(int spellId) { - boolean modern = player.getSpellBookManager().getSpellBook() == Components.MAGIC_192; - int[] data = modern ? MODERN_SPELL_IDS : ANCIENT_SPELL_IDS; - if (modern && player.getEquipment().getNew(3).getName().equalsIgnoreCase("Slayer's staff")) { + //boolean modern = player.getSpellBookManager().getSpellBook() == Components.MAGIC_192; + boolean modern = !player.getEquipment().getNew(3).getName().equalsIgnoreCase("Ancient Staff") && !player.getEquipment().getNew(3).getName().contains("uriel's staff"); + int[] data = MODERN_SPELL_IDS; + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Ancient Staff") || player.getEquipment().getNew(3).getName().contains("uriel's staff")) { + data = ANCIENT_SPELL_IDS; + } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Slayer's staff")) { data = SLAYER_STAFF_SPELL_IDS; } - if (modern && player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace")) { + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace") || player.getEquipment().getNew(3).getName().equalsIgnoreCase("Guthix Staff")) { data = VOID_STAFF_SPELL_IDS; + } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Saradomin Staff")) { + data = SARADOMIN_STAFF_SPELL_IDS; + } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Zamorak Staff")) { + data = ZAMORAK_STAFF_SPELL_IDS; } for (int i = 0; i < data.length; i++) { if (data[i] == spellId) { @@ -355,14 +375,24 @@ public final class WeaponInterface extends Component { * @param adjustAttackStyle If the attack style should be adjusted. */ public void selectAutoSpell(int buttonId, boolean adjustAttackStyle) { - boolean modern = player.getSpellBookManager().getSpellBook() == Components.MAGIC_192; - int[] data = modern ? MODERN_SPELL_IDS : ANCIENT_SPELL_IDS; - if (modern && player.getEquipment().getNew(3).getName().equalsIgnoreCase("Slayer's staff")) { + //boolean modern = player.getSpellBookManager().getSpellBook() == Components.MAGIC_192; + boolean modern = !player.getEquipment().getNew(3).getName().equalsIgnoreCase("Ancient Staff") && !player.getEquipment().getNew(3).getName().contains("uriel's staff"); + int[] data = MODERN_SPELL_IDS; + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Ancient staff") || player.getEquipment().getNew(3).getName().contains("uriel's staff")) { + data = ANCIENT_SPELL_IDS; + } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Slayer's staff")) { data = SLAYER_STAFF_SPELL_IDS; } - if (modern && player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace")) { + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace") || modern && player.getEquipment().getNew(3).getName().equalsIgnoreCase("Guthix Staff")) { data = VOID_STAFF_SPELL_IDS; } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Saradomin Staff")) { + data = SARADOMIN_STAFF_SPELL_IDS; + } + if (player.getEquipment().getNew(3).getName().equalsIgnoreCase("Zamorak Staff")) { + data = ZAMORAK_STAFF_SPELL_IDS; + } CombatSpell current = player.getProperties().getAutocastSpell(); if (buttonId >= data.length) { return; @@ -455,15 +485,20 @@ public final class WeaponInterface extends Component { return; } player.setAttribute("autocast_select", true); - int id = player.getSpellBookManager().getSpellBook() == 193 ? 797 : 319; + //int id = player.getSpellBookManager().getSpellBook() == 193 ? 797 : 319; + int id = 319; + boolean ancient = player.getEquipment().getNew(3).getName().equalsIgnoreCase("Ancient staff") || player.getEquipment().getNew(3).getName().contains("uriel's staff"); boolean slayer = player.getEquipment().getNew(3).getName().equalsIgnoreCase("Slayer's staff"); - boolean mace = player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace"); + boolean mace = player.getEquipment().getNew(3).getName().equalsIgnoreCase("Void knight mace") || player.getEquipment().getNew(3).getName().equalsIgnoreCase("Guthix Staff") || player.getEquipment().getNew(3).getName().equalsIgnoreCase("Saradomin Staff") || player.getEquipment().getNew(3).getName().equalsIgnoreCase("Zamorak Staff"); if (slayer) { id = 310; } if (mace) { id = 406; } + if (ancient) { + id = 797; + } Component component = new Component(id); component.getDefinition().setTabIndex(0); component.getDefinition().setType(InterfaceType.TAB); @@ -480,7 +515,7 @@ public final class WeaponInterface extends Component { if (current != WeaponInterfaces.STAFF) { return false; } - if (player.getSpellBookManager().getSpellBook() == SpellBookManager.SpellBook.LUNAR.getInterfaceId()) { + /* if (player.getSpellBookManager().getSpellBook() == SpellBookManager.SpellBook.LUNAR.getInterfaceId()) { if (message) { player.getPacketDispatch().sendMessage("You can't autocast Lunar magic."); } @@ -492,7 +527,7 @@ public final class WeaponInterface extends Component { player.getPacketDispatch().sendMessage("You can only autocast ancient magicks with an Ancient or Zuriel's staff."); } return false; - } + } */ return true; }