Blackjack update (#656)

* (More) efficient blackjacking

isKnockedOut is no longer being used to swap menu entrys. So it was removed

Added other message to trigger knockout tick. This pickpockets the bandit when he aggros you preventing trading damage and better xp/h

* Pickpocket toggle and changes

Toggleable pickpocket on aggro to save food which means less trips
Made both strings static and global
This commit is contained in:
vanni
2019-06-19 18:53:00 -04:00
committed by Ganom
parent 94e013d81d
commit 6b5863d363
2 changed files with 67 additions and 12 deletions

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2019, gazivodag <https://github.com/gazivodag>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.blackjack;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("blackjack")
public interface BlackjackConfig extends Config
{
@ConfigItem(
keyName = "pickpocketOnAggro",
name = "Pickpocket when aggro\'d",
description = "Switches to \"Pickpocket\" when bandit is aggro\'d. Saves food at the cost of slight xp/h."
)
default boolean pickpocketOnAggro()
{
return false;
}
}

View File

@@ -26,6 +26,7 @@
*/
package net.runelite.client.plugins.blackjack;
import com.google.inject.Provides;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@@ -35,6 +36,7 @@ import net.runelite.api.GameState;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.Plugin;
@@ -48,38 +50,49 @@ import org.apache.commons.lang3.RandomUtils;
* Authors gazivodag longstreet
*/
@PluginDescriptor(
name = "Blackjack",
description = "Allows for one-click blackjacking, both knocking out and pickpocketing",
tags = {"blackjack", "thieving"},
type = PluginType.SKILLING,
enabledByDefault = false
name = "Blackjack",
description = "Allows for one-click blackjacking, both knocking out and pickpocketing",
tags = {"blackjack", "thieving"},
type = PluginType.SKILLING,
enabledByDefault = false
)
@Singleton
@Slf4j
public class BlackjackPlugin extends Plugin
{
private static final String SUCCESS_BLACKJACK = "You smack the bandit over the head and render them unconscious.";
private static final String FAILED_BLACKJACK = "Your blow only glances off the bandit's head.";
private static final int POLLNIVNEACH_REGION = 13358;
private long nextKnockOutTick = 0;
@Inject
private Client client;
@Inject
private MenuManager menuManager;
private boolean isKnockedOut = false;
private long nextKnockOutTick = 0;
@Inject
private BlackjackConfig config;
@Provides
BlackjackConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(BlackjackConfig.class);
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
if (client.getGameState() != GameState.LOGGED_IN ||
client.getVar(Varbits.QUEST_THE_FEUD) < 13 ||
client.getLocalPlayer().getWorldLocation().getRegionID() != POLLNIVNEACH_REGION)
client.getVar(Varbits.QUEST_THE_FEUD) < 13 ||
client.getLocalPlayer().getWorldLocation().getRegionID() != POLLNIVNEACH_REGION)
{
return;
}
String option = Text.removeTags(event.getOption().toLowerCase());
String target = Text.removeTags(event.getTarget().toLowerCase());
if (isKnockedOut && nextKnockOutTick >= client.getTickCount())
if (nextKnockOutTick >= client.getTickCount())
{
MenuUtil.swap(client, "pickpocket", option, target);
}
@@ -94,9 +107,8 @@ public class BlackjackPlugin extends Plugin
{
if (event.getType() == ChatMessageType.SPAM)
{
if (event.getMessage().equals("You smack the bandit over the head and render them unconscious."))
if (event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && config.pickpocketOnAggro()))
{
isKnockedOut = true;
nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4);
}
}