Removed magic numbers

This commit is contained in:
Bishop 2026-07-26 11:56:56 -05:00
parent c31b643c0b
commit 43e53f7658

View file

@ -365,6 +365,8 @@ public final class WeaponInterface extends Component {
* @param adjustAttackStyle If the attack style should be adjusted.
*/
public void selectAutoSpell(int buttonId, boolean adjustAttackStyle, boolean forgetAutocast) {
int stdAutocastBookChild = 83;
int defAutocastBookChild = 183;
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")) {
@ -391,8 +393,8 @@ public final class WeaponInterface extends Component {
}
if (buttonId < 0) {
player.getProperties().setAutocastSpell(null);
setComponentVisibility(player, Components.WEAPON_STAFF_SEL_90, 83, false);
setComponentVisibility(player, Components.WEAPON_STAFF_SEL_90, 183, false);
setComponentVisibility(player, Components.WEAPON_STAFF_SEL_90, defAutocastBookChild, false);
setComponentVisibility(player, Components.WEAPON_STAFF_SEL_90, stdAutocastBookChild, false);
if (adjustAttackStyle && current != null) {
setAttackStyle(3);
player.getProperties().getCombatPulse().updateStyle();
@ -400,8 +402,8 @@ public final class WeaponInterface extends Component {
return;
}
boolean defensive = player.getSettings().getAttackStyleIndex() == 3;
player.getPacketDispatch().sendInterfaceConfig(Components.WEAPON_STAFF_SEL_90, 183, defensive);
player.getPacketDispatch().sendInterfaceConfig(Components.WEAPON_STAFF_SEL_90, 83, !defensive);
player.getPacketDispatch().sendInterfaceConfig(Components.WEAPON_STAFF_SEL_90, defAutocastBookChild, defensive);
player.getPacketDispatch().sendInterfaceConfig(Components.WEAPON_STAFF_SEL_90, stdAutocastBookChild, !defensive);
current = (CombatSpell) (modern ? SpellBookManager.SpellBook.MODERN.getSpell(data[buttonId]) : SpellBookManager.SpellBook.ANCIENT.getSpell(data[buttonId]));
player.getProperties().setAutocastSpell(current);
setAttribute(player, attributeAutocastButtonId, buttonId);