use of net.runelite.api.Skill in project runelite by runelite.
the class RSClientMixin method boostedSkillLevelsChanged.
@FieldHook("boostedSkillLevels")
@Inject
public static void boostedSkillLevelsChanged(int idx) {
Skill[] skills = Skill.values();
if (idx >= 0 && idx < skills.length - 1) {
Skill updatedSkill = skills[idx];
BoostedLevelChanged boostedLevelChanged = new BoostedLevelChanged();
boostedLevelChanged.setSkill(updatedSkill);
eventBus.post(boostedLevelChanged);
}
}
use of net.runelite.api.Skill in project runelite by runelite.
the class AttackIndicatorPluginTest method testHiddenWidget.
/*
* Verify that attack style widgets are hidden when filtered with the AttackIndicatorPlugin.
*/
@Test
public void testHiddenWidget() {
ConfigChanged warnForAttackEvent = new ConfigChanged();
warnForAttackEvent.setGroup("attackIndicator");
warnForAttackEvent.setKey("warnForAttack");
warnForAttackEvent.setNewValue("true");
attackPlugin.onConfigChanged(warnForAttackEvent);
// Set up mock widgets for atk and str attack styles
Widget atkWidget = mock(Widget.class);
Widget strWidget = mock(Widget.class);
when(client.getWidget(WidgetInfo.COMBAT_STYLE_ONE)).thenReturn(atkWidget);
when(client.getWidget(WidgetInfo.COMBAT_STYLE_TWO)).thenReturn(strWidget);
// Set widgets to return their hidden value in widgetsToHide when isHidden() is called
when(atkWidget.isHidden()).thenAnswer(x -> isAtkHidden());
when(strWidget.isHidden()).thenAnswer(x -> isStrHidden());
// equip type_4 weapon type on player
when(client.getSetting(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(WeaponType.TYPE_4.ordinal());
attackPlugin.onEquippedWeaponTypeChange(new VarbitChanged());
// Verify there is a warned skill
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
assertTrue(warnedSkills.contains(Skill.ATTACK));
// Enable hiding widgets
ConfigChanged hideWidgetEvent = new ConfigChanged();
hideWidgetEvent.setGroup("attackIndicator");
hideWidgetEvent.setKey("removeWarnedStyles");
hideWidgetEvent.setNewValue("true");
attackPlugin.onConfigChanged(hideWidgetEvent);
when(attackConfig.removeWarnedStyles()).thenReturn(true);
// verify that the accurate attack style widget is hidden
assertTrue(atkWidget.isHidden());
// add another warned skill
ConfigChanged warnForStrengthEvent = new ConfigChanged();
warnForStrengthEvent.setGroup("attackIndicator");
warnForStrengthEvent.setKey("warnForStrength");
warnForStrengthEvent.setNewValue("true");
attackPlugin.onConfigChanged(warnForStrengthEvent);
// verify that the aggressive attack style widget is now hidden
assertTrue(strWidget.isHidden());
// disable hiding attack style widgets
hideWidgetEvent.setGroup("attackIndicator");
hideWidgetEvent.setKey("removeWarnedStyles");
hideWidgetEvent.setNewValue("false");
attackPlugin.onConfigChanged(hideWidgetEvent);
when(attackConfig.removeWarnedStyles()).thenReturn(false);
// verify that the aggressive and accurate attack style widgets are no longer hidden
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_ONE));
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_THREE));
}
use of net.runelite.api.Skill in project runelite by runelite.
the class AttackIndicatorPlugin method updateWarning.
private void updateWarning(boolean weaponSwitch) {
warnedSkillSelected = false;
if (attackStyle != null) {
for (Skill skill : attackStyle.getSkills()) {
if (warnedSkills.contains(skill)) {
if (weaponSwitch) {
// TODO : chat message to warn players that their weapon switch also caused an unwanted attack style change
}
warnedSkillSelected = true;
break;
}
}
}
hideWarnedStyles(config.removeWarnedStyles());
}
use of net.runelite.api.Skill in project runelite by runelite.
the class AttackIndicatorPlugin method hideWarnedStyles.
private void hideWarnedStyles(boolean enabled) {
WeaponType equippedWeaponType = WeaponType.getWeaponType(equippedWeaponTypeVarbit);
if (equippedWeaponType == null) {
return;
}
AttackStyle[] attackStyles = equippedWeaponType.getAttackStyles();
// Iterate over attack styles
for (int i = 0; i < attackStyles.length; i++) {
if (attackStyles[i] == null) {
continue;
}
boolean warnedSkill = false;
for (Skill skill : attackStyles[i].getSkills()) {
if (warnedSkills.contains(skill)) {
warnedSkill = true;
break;
}
}
// Magic staves defensive casting mode
if (equippedWeaponType == WeaponType.TYPE_18) {
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_DEFENSIVE_SPELL_BOX, enabled && (warnedSkills.contains(Skill.DEFENCE) || warnedSkill));
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_DEFENSIVE_SPELL_ICON, enabled && (warnedSkills.contains(Skill.DEFENCE) || warnedSkill));
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_DEFENSIVE_SPELL_SHIELD, enabled && (warnedSkills.contains(Skill.DEFENCE) || warnedSkill));
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_DEFENSIVE_SPELL_TEXT, enabled && (warnedSkills.contains(Skill.DEFENCE) || warnedSkill));
}
// Remove appropriate combat option
switch(i) {
case 0:
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_STYLE_ONE, enabled && warnedSkill);
break;
case 1:
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_STYLE_TWO, enabled && warnedSkill);
break;
case 2:
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_STYLE_THREE, enabled && warnedSkill);
break;
case 3:
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_STYLE_FOUR, enabled && warnedSkill);
break;
case 4:
widgetsToHide.put(equippedWeaponType, WidgetInfo.COMBAT_SPELLS, enabled && warnedSkill);
break;
default:
log.warn("Unreachable default case for equipped weapon type attack styles");
}
}
}
Aggregations