net.runelite.api.Varbits Java Examples

The following examples show how to use net.runelite.api.Varbits. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AntiDragPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onVarbitChanged(VarbitChanged varbitChanged)
{
	boolean currentStatus = client.getVar(Varbits.PVP_SPEC_ORB) == 1;

	if (currentStatus != inPvp)
	{
		inPvp = currentStatus;

		if (!inPvp && !config.onShiftOnly())
		{
			setDragDelay();
		}
		else
		{
			resetDragDelay();
		}
	}

}
 
Example #2
Source File: NightmareZoneOverlay.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void renderAbsorptionCounter()
{
	int absorptionPoints = client.getVar(Varbits.NMZ_ABSORPTION);
	if (absorptionPoints == 0)
	{
		if (absorptionCounter != null)
		{
			removeAbsorptionCounter();
			absorptionCounter = null;
		}
	}
	else if (config.moveOverlay())
	{
		if (absorptionCounter == null)
		{
			addAbsorptionCounter(absorptionPoints);
		}
		else
		{
			absorptionCounter.setCount(absorptionPoints);
		}
	}
}
 
Example #3
Source File: IdleNotifierPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkLowHitpoints()
{
	if (config.getHitpointsThreshold() == 0)
	{
		return false;
	}
	if (client.getRealSkillLevel(Skill.HITPOINTS) > config.getHitpointsThreshold())
	{
		if (client.getBoostedSkillLevel(Skill.HITPOINTS) + client.getVar(Varbits.NMZ_ABSORPTION) <= config.getHitpointsThreshold())
		{
			if (!notifyHitpoints)
			{
				notifyHitpoints = true;
				return true;
			}
		}
		else
		{
			notifyHitpoints = false;
		}
	}

	return false;
}
 
Example #4
Source File: MaxHitCalculator.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
AttackStyle getAttackStyle()
{
	int equippedWeaponTypeId = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE);
	int attackStyleId = client.getVar(VarPlayer.ATTACK_STYLE);

	AttackStyle[] attackStyles = WeaponType.getWeaponType(equippedWeaponTypeId).getAttackStyles();

	if (attackStyleId < attackStyles.length)
	{
		AttackStyle attackStyle = attackStyles[attackStyleId];
		if (attackStyle != null)
		{
			return attackStyle;
		}
	}

	return AttackStyle.OTHER;
}
 
Example #5
Source File: KingdomPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void setKingdomResourceDistribution()
{
	int hardwoodButton, cookedFishButton, herbsButton;

	favor = client.getVar(Varbits.KINGDOM_FAVOR);
	coffer = client.getVar(Varbits.KINGDOM_COFFER);

	hardwoodButton = client.getVar(Varbits.KINGDOM_WORKERS_HARDWOOD_BUTTON);
	cookedFishButton = client.getVar(Varbits.KINGDOM_WORKERS_FISH_COOKED_BUTTON);
	herbsButton = client.getVar(Varbits.KINGDOM_WORKERS_HERBS_BUTTON);

	ResourceType herbsOrFlax = herbsButton == 0 ? ResourceType.HERBS : ResourceType.FLAX;
	ResourceType cookedOrRaw = cookedFishButton == 0 ? ResourceType.RAW_FISH : ResourceType.COOKED_FISH;
	ResourceType hardwoodType = hardwoodButton == 0 ? ResourceType.HARDWOOD_MAHOGANY
		: hardwoodButton == 1 ? ResourceType.HARDWOOD_TEAK : ResourceType.HARDWOOD_BOTH;

	personalKingdom.resourceDistribution = new HashMap<>();
	personalKingdom.resourceDistribution.put(herbsOrFlax, client.getVar(Varbits.KINGDOM_WORKERS_HERBS));
	personalKingdom.resourceDistribution.put(cookedOrRaw, client.getVar(Varbits.KINGDOM_WORKERS_FISHING));
	personalKingdom.resourceDistribution.put(hardwoodType, client.getVar(Varbits.KINGDOM_WORKERS_HARDWOOD));
	personalKingdom.resourceDistribution.put(ResourceType.MINING, client.getVar(Varbits.KINGDOM_WORKERS_MINING));
	personalKingdom.resourceDistribution.put(ResourceType.WOOD, client.getVar(Varbits.KINGDOM_WORKERS_WOOD));
	personalKingdom.resourceDistribution.put(ResourceType.FARM, client.getVar(Varbits.KINGDOM_WORKERS_FARM));
}
 
Example #6
Source File: ChatCommandsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private boolean gambleCountSubmit(ChatInput chatInput, String value)
{
	final int gc = client.getVar(Varbits.BA_GC);
	final String playerName = client.getLocalPlayer().getName();

	executor.execute(() ->
	{
		try
		{
			chatClient.submitGc(playerName, gc);
		}
		catch (Exception ex)
		{
			log.warn("unable to submit gamble count", ex);
		}
		finally
		{
			chatInput.resume();
		}
	});

	return true;
}
 
Example #7
Source File: FairyRingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void setWidgetTextToDestination()
{
	Widget fairyRingTeleportButton = client.getWidget(WidgetInfo.FAIRY_RING_TELEPORT_BUTTON);
	if (fairyRingTeleportButton != null && !fairyRingTeleportButton.isHidden())
	{
		String destination;
		try
		{
			FairyRings fairyRingDestination = getFairyRingDestination(client.getVar(Varbits.FAIRY_RING_DIAL_ADCB),
				client.getVar(Varbits.FAIRY_RIGH_DIAL_ILJK), client.getVar(Varbits.FAIRY_RING_DIAL_PSRQ));
			destination = fairyRingDestination.getDestination();
		}
		catch (IllegalArgumentException ex)
		{
			destination = "Invalid location";
		}

		fairyRingTeleportButton.setText(destination);
	}
}
 
Example #8
Source File: DailyTasksPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void checkBonemeal(boolean dailyReset)
{
	if (client.getVar(Varbits.DIARY_MORYTANIA_MEDIUM) == 1)
	{
		int collected = client.getVar(Varbits.DAILY_BONEMEAL_STATE);
		int max = BONEMEAL_PER_DIARY;
		if (client.getVar(Varbits.DIARY_MORYTANIA_HARD) == 1)
		{
			max += BONEMEAL_PER_DIARY;
			if (client.getVar(Varbits.DIARY_MORYTANIA_ELITE) == 1)
			{
				max += BONEMEAL_PER_DIARY;
			}
		}
		if (dailyReset || collected < max)
		{
			sendChatMessage(BONEMEAL_MESSAGE);
		}
	}
}
 
Example #9
Source File: BankPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private Item[] getBankTabItems()
{
	final ItemContainer container = client.getItemContainer(InventoryID.BANK);
	if (container == null)
	{
		return null;
	}

	final Item[] items = container.getItems();
	int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB);

	if (currentTab > 0)
	{
		int startIndex = 0;

		for (int i = currentTab - 1; i > 0; i--)
		{
			startIndex += client.getVar(TAB_VARBITS.get(i - 1));
		}

		int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1));
		return Arrays.copyOfRange(items, startIndex, startIndex + itemCount);
	}

	return items;
}
 
Example #10
Source File: FishingPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
	if (!config.trawlerNotification() || client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();

	if ((regionID == TRAWLER_SHIP_REGION_NORMAL || regionID == TRAWLER_SHIP_REGION_SINKING)
		&& client.getVar(Varbits.FISHING_TRAWLER_ACTIVITY) <= TRAWLER_ACTIVITY_THRESHOLD)
	{
		if (!trawlerNotificationSent)
		{
			notifier.notify("[" + client.getLocalPlayer().getName() + "] has low Fishing Trawler activity!");
			trawlerNotificationSent = true;
		}
	}
	else
	{
		trawlerNotificationSent = false;
	}
}
 
Example #11
Source File: ScreenshotPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onPlayerDeath(PlayerDeath event)
{
	Player player = event.getPlayer();
	if (player == client.getLocalPlayer() && config.screenshotPlayerDeath())
	{
		takeScreenshot("Death", "Deaths");
	}
	if (config.screenshotKills() && (config.pvpKillScreenshotMode() == PvPKillScreenshotMode.ON_KILL ||
		config.pvpKillScreenshotMode() == PvPKillScreenshotMode.BOTH))
	{
		if (client.getLocalPlayer().getInteracting() != null && client.getLocalPlayer().getInteracting() == player)
		{
			takeScreenshot("KO " + player.getName(), "PvP Kills");
		}
	}

	int tob = client.getVar(Varbits.THEATRE_OF_BLOOD);
	if (config.screenshotFriendDeath() && player != client.getLocalPlayer() && player.getName() != null
		&& (player.isFriend() || player.isFriendsChatMember()
		|| (client.getVar(Varbits.IN_RAID) == 1 || tob == 2 || tob == 3)))
	{
		takeScreenshot("Death " + player.getName(), "Deaths");
	}
}
 
Example #12
Source File: PyramidPlunderPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onGameTick(GameTick tick)
{
	if (isInPyramidPlunder())
	{
		if (timer == null)
		{
			int ppTimer = client.getVar(Varbits.PYRAMID_PLUNDER_TIMER);
			Duration remaining = PYRAMID_PLUNDER_DURATION.minus(ppTimer, RSTimeUnit.GAME_TICKS);
			timer = new PyramidPlunderTimer(remaining, itemManager.getImage(PHARAOHS_SCEPTRE), this,
				config, client);
			infoBoxManager.addInfoBox(timer);
		}
	}
	else if (timer != null)
	{
		infoBoxManager.removeInfoBox(timer);
		timer = null;
	}
}
 
Example #13
Source File: BankPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Item[] getBankTabItems()
{
	final ItemContainer container = client.getItemContainer(InventoryID.BANK);
	if (container == null)
	{
		return null;
	}

	final Item[] items = container.getItems();
	int currentTab = client.getVar(Varbits.CURRENT_BANK_TAB);

	if (currentTab > 0)
	{
		int startIndex = 0;

		for (int i = currentTab - 1; i > 0; i--)
		{
			startIndex += client.getVar(TAB_VARBITS.get(i - 1));
		}

		int itemCount = client.getVar(TAB_VARBITS.get(currentTab - 1));
		return Arrays.copyOfRange(items, startIndex, startIndex + itemCount);
	}

	return items;
}
 
Example #14
Source File: ItemStatPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Widget getInventoryContainer()
{
	if (client.isResized())
	{
		if (client.getVar(Varbits.SIDE_PANELS) == 1)
		{
			return client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_INVENTORY_CONTAINER);
		}
		else
		{
			return client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_CONTAINER);
		}
	}
	else
	{
		return client.getWidget(WidgetInfo.FIXED_VIEWPORT_INVENTORY_CONTAINER);
	}
}
 
Example #15
Source File: NightmareZonePlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void checkAbsorption()
{
	int absorptionPoints = client.getVar(Varbits.NMZ_ABSORPTION);

	if (!absorptionNotificationSend)
	{
		if (absorptionPoints < config.absorptionThreshold())
		{
			notifier.notify("Absorption points below: " + config.absorptionThreshold());
			absorptionNotificationSend = true;
		}
	}
	else
	{
		if (absorptionPoints > config.absorptionThreshold())
		{
			absorptionNotificationSend = false;
		}
	}
}
 
Example #16
Source File: PyramidPlunderPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onGameTick(GameTick tick)
{
	if (isInPyramidPlunder())
	{
		if (timer == null)
		{
			int ppTimer = client.getVar(Varbits.PYRAMID_PLUNDER_TIMER);
			Duration remaining = PYRAMID_PLUNDER_DURATION.minus(ppTimer, RSTimeUnit.GAME_TICKS);
			timer = new PyramidPlunderTimer(remaining, itemManager.getImage(PHARAOHS_SCEPTRE), this,
				config, client);
			infoBoxManager.addInfoBox(timer);
		}
	}
	else if (timer != null)
	{
		infoBoxManager.removeInfoBox(timer);
		timer = null;
	}
}
 
Example #17
Source File: FishingPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onVarbitChanged(VarbitChanged event)
{
	if (!config.trawlerNotification() || client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();

	if ((regionID == TRAWLER_SHIP_REGION_NORMAL || regionID == TRAWLER_SHIP_REGION_SINKING)
		&& client.getVar(Varbits.FISHING_TRAWLER_ACTIVITY) <= TRAWLER_ACTIVITY_THRESHOLD)
	{
		if (!trawlerNotificationSent)
		{
			notifier.notify("[" + client.getLocalPlayer().getName() + "] has low Fishing Trawler activity!");
			trawlerNotificationSent = true;
		}
	}
	else
	{
		trawlerNotificationSent = false;
	}
}
 
Example #18
Source File: AntiDragPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void startUp() throws Exception
{
	if (client.getGameState() == GameState.LOGGED_IN)
	{
		clientThread.invokeLater(() ->
		{
			inPvp = client.getVar(Varbits.PVP_SPEC_ORB) == 1;
			if (!config.onShiftOnly() && !inPvp)
			{
				setDragDelay();
			}
		});
	}

	keyManager.registerKeyListener(this);
}
 
Example #19
Source File: WintertodtPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
void onVarbitChanged(VarbitChanged varbitChanged)
{
	int timerValue = client.getVar(Varbits.WINTERTODT_TIMER);
	if (timerValue != previousTimerValue)
	{
		int timeToNotify = config.roundNotification();
		if (timeToNotify > 0)
		{
			int timeInSeconds = timerValue * 30 / 50;
			int prevTimeInSeconds = previousTimerValue * 30 / 50;

			log.debug("Seconds left until round start: {}", timeInSeconds);

			if (prevTimeInSeconds > timeToNotify && timeInSeconds <= timeToNotify)
			{
				notifier.notify("Wintertodt round is about to start");
			}
		}

		previousTimerValue = timerValue;
	}
}
 
Example #20
Source File: BlastMineOreCountOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	final Widget blastMineWidget = client.getWidget(WidgetInfo.BLAST_MINE);

	if (blastMineWidget == null)
	{
		return null;
	}

	if (config.showOreOverlay())
	{
		blastMineWidget.setHidden(true);
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.COAL, client.getVar(Varbits.BLAST_MINE_COAL))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.GOLD_ORE, client.getVar(Varbits.BLAST_MINE_GOLD))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.MITHRIL_ORE, client.getVar(Varbits.BLAST_MINE_MITHRIL))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.ADAMANTITE_ORE, client.getVar(Varbits.BLAST_MINE_ADAMANTITE))));
		panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.RUNITE_ORE, client.getVar(Varbits.BLAST_MINE_RUNITE))));
	}
	else
	{
		blastMineWidget.setHidden(false);
	}

	return super.render(graphics);
}
 
Example #21
Source File: NightmareZoneOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void renderAbsorptionCounter()
{
	int absorptionPoints = client.getVar(Varbits.NMZ_ABSORPTION);
	if (absorptionPoints == 0)
	{
		if (absorptionCounter != null)
		{
			removeAbsorptionCounter();
			absorptionCounter = null;
		}
	}
	else if (config.moveOverlay())
	{
		if (absorptionCounter == null)
		{
			addAbsorptionCounter(absorptionPoints);
		}
		else
		{
			absorptionCounter.setCount(absorptionPoints);
		}
	}
}
 
Example #22
Source File: NightmareZonePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private int calculatePointsPerHour()
{
	Instant now = Instant.now();
	final int currentPoints = client.getVar(Varbits.NMZ_POINTS);

	if (nmzSessionStartTime == null)
	{
		nmzSessionStartTime = now;
	}

	Duration timeSinceStart = Duration.between(nmzSessionStartTime, now);

	if (!timeSinceStart.isZero())
	{
		return (int) ((double) currentPoints * (double) HOUR.toMillis() / (double) timeSinceStart.toMillis());
	}

	return 0;
}
 
Example #23
Source File: NightmareZonePlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private void checkAbsorption()
{
	int absorptionPoints = client.getVar(Varbits.NMZ_ABSORPTION);

	if (!absorptionNotificationSend)
	{
		if (absorptionPoints < config.absorptionThreshold())
		{
			notifier.notify("Absorption points below: " + config.absorptionThreshold());
			absorptionNotificationSend = true;
		}
	}
	else
	{
		if (absorptionPoints > config.absorptionThreshold())
		{
			absorptionNotificationSend = false;
		}
	}
}
 
Example #24
Source File: IdleNotifierPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private boolean checkLowOxygen()
{
	if (config.getOxygenThreshold() == 0)
	{
		return false;
	}
	if (config.getOxygenThreshold() >= client.getVar(Varbits.OXYGEN_LEVEL) * 0.1)
	{
		if (!notifyOxygen)
		{
			notifyOxygen = true;
			return true;
		}
	}
	else
	{
		notifyOxygen = false;
	}
	return false;
}
 
Example #25
Source File: RaidsPointsOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	if (!plugin.isInRaidChambers())
	{
		return null;
	}

	int totalPoints = client.getVar(Varbits.TOTAL_POINTS);
	int personalPoints = client.getVar(Varbits.PERSONAL_POINTS);
	int partySize = client.getVar(Varbits.RAID_PARTY_SIZE);
	double uniqueChance = totalPoints / 867500f;

	panel.getChildren().clear();
	TableComponent tableComponent = new TableComponent();
	tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);

	tableComponent.addRow("Total:", POINTS_FORMAT.format(totalPoints));
	tableComponent.addRow(client.getLocalPlayer().getName() + ":", POINTS_FORMAT.format(personalPoints));


	if (partySize > 1)
	{
		tableComponent.addRow("Party size:", String.valueOf(partySize));
	}

	tableComponent.addRow("Unique:", UNIQUE_FORMAT.format(uniqueChance));

	panel.getChildren().add(tableComponent);

	return panel.render(graphics);
}
 
Example #26
Source File: AttackStylesPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
@VisibleForTesting
void onVarbitChanged(VarbitChanged event)
{
	int currentAttackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE);
	int currentEquippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE);
	int currentCastingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE);

	if (attackStyleVarbit != currentAttackStyleVarbit || equippedWeaponTypeVarbit != currentEquippedWeaponTypeVarbit || castingModeVarbit != currentCastingModeVarbit)
	{
		boolean weaponSwitch = currentEquippedWeaponTypeVarbit != equippedWeaponTypeVarbit;

		attackStyleVarbit = currentAttackStyleVarbit;
		equippedWeaponTypeVarbit = currentEquippedWeaponTypeVarbit;
		castingModeVarbit = currentCastingModeVarbit;

		updateAttackStyle(equippedWeaponTypeVarbit, attackStyleVarbit,
			castingModeVarbit);
		updateWarning(weaponSwitch);

		// this isn't required, but will hide styles 1 tick earlier than the script event, which fires
		// 1 tick after the combat options is unhidden
		if (weaponSwitch)
		{
			processWidgets();
		}
	}
}
 
Example #27
Source File: AttackStylesPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void start()
{
	resetWarnings();

	attackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE);
	equippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE);
	castingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE);
	updateAttackStyle(
		equippedWeaponTypeVarbit,
		attackStyleVarbit,
		castingModeVarbit);
	updateWarning(false);
	processWidgets();
}
 
Example #28
Source File: DailyTasksPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void checkHerbBoxes(boolean dailyReset)
{
	if (client.getAccountType() == AccountType.NORMAL
		&& client.getVar(VarPlayer.NMZ_REWARD_POINTS) >= HERB_BOX_COST
		&& (client.getVar(Varbits.DAILY_HERB_BOXES_COLLECTED) < HERB_BOX_MAX
		|| dailyReset))
	{
		sendChatMessage(HERB_BOX_MESSAGE);
	}
}
 
Example #29
Source File: KingdomPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void updateKingdomVarbits()
{
	if (throneOfMiscellania || royalTrouble)
	{
		this.favor = client.getVar(Varbits.KINGDOM_FAVOR);
		this.coffer = client.getVar(Varbits.KINGDOM_COFFER);
	}
}
 
Example #30
Source File: WintertodtPluginTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void matchStartingNotification_shouldNotNotify_whenNoneOptionSelected()
{
	when(config.roundNotification()).thenReturn(5);
	when(client.getVar(Varbits.WINTERTODT_TIMER)).thenReturn(25);

	wintertodtPlugin.onVarbitChanged(new VarbitChanged());
	verify(notifier, times(0)).notify("Wintertodt round is about to start");
}