ArrayIndexOutOfBoundsException with Combat.selectIndex() with target index last and weapon with 3 styles
Description of the bug (be specific):
When calling Combat.selectIndex() with value 3, an array index out of bounds exception is thrown. I'd imagine this is because there is only 3 options, 0 = attack, 1 = strength, 2 = defence, or 0 = accurate, 1 = rapid, 2 = longrange. However, when you call Combat.getSelectedStyleIndex() with defence selected, and wearing a weapon with only 3 styles, it will return 3, which is inconsistent with the above. This causes an exception if you try to do the following (which works in every other scenario):
// Precondition: Player is wearing a weapon with 3 attack styles, with the last (generally defence) style selected
targetIndex = Combat.getSelectedStyleIndex() // 3
// do stuff
Combat.selectIndex(1);
// do stuff
if (Combat.getSelectedStyleIndex() != targetIndex )
Combat.selectIndex(targetIndex ); // throws an exception
Therefore, Combat.getSelectedStyleIndex() is not consistent with Combat.setIndex() in this case.
How often the bug occurs: Any time when calling Combat.selectIndex() with value 3, when using a weapon with 3 attack styles. (If you call Combat.getSelectedStyleIndex() when the third option is selected, it returns 3, skipping 2)
Triggers of the bug (if known): Described above
Java version: N/A
Max Heap Size: N/A
TRiBot client version: N/A
Looking Glass (yes/no): N/A
Operating System: N/A
Script Name: N/A
TRiBot Old-School or RS3: N/A
Client Debug: N/A
Bot Debug:
[15:11:05] java.lang.ArrayIndexOutOfBoundsException: 3
[15:11:05] at org.tribot.api2007.Combat.selectIndex(cd:138)
[15:11:05] at scripts.Test.run(Test.java:14)
[15:11:05] at java.lang.Thread.run(Unknown Source)
Where line 14:
Combat.selectIndex(3);
Screenshots (if any):