Alch constant

This commit is contained in:
Scott Burns
2019-05-22 01:44:24 +02:00
parent c7ba38347f
commit 0c2cf31b0d
4 changed files with 13 additions and 14 deletions

View File

@@ -97,4 +97,9 @@ public class Constants
* All game-play actions operate within multiples of this duration. * All game-play actions operate within multiples of this duration.
*/ */
public static final int GAME_TICK_LENGTH = 600; public static final int GAME_TICK_LENGTH = 600;
/**
* Used when getting High Alchemy value - multiplied by general store price.
*/
public static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
} }

View File

@@ -45,6 +45,7 @@ import lombok.Value;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.Constants.CLIENT_DEFAULT_ZOOM; import static net.runelite.api.Constants.CLIENT_DEFAULT_ZOOM;
import static net.runelite.api.Constants.HIGH_ALCHEMY_CONSTANT;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.ItemComposition; import net.runelite.api.ItemComposition;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -187,9 +188,6 @@ public class ItemManager
private final Color outlineColor; private final Color outlineColor;
} }
// Used when getting High Alchemy value - multiplied by general store price.
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
private final Client client; private final Client client;
private final ScheduledExecutorService scheduledExecutorService; private final ScheduledExecutorService scheduledExecutorService;
private final ClientThread clientThread; private final ClientThread clientThread;
@@ -425,7 +423,7 @@ public class ItemManager
return 1000; return 1000;
} }
return (int) (getItemComposition(itemID).getPrice() * HIGH_ALCHEMY_CONSTANT); return (int) Math.max(1, getItemComposition(itemID).getPrice() * HIGH_ALCHEMY_CONSTANT);
} }
/** /**

View File

@@ -98,8 +98,6 @@ import net.runelite.client.util.Text;
) )
public class GroundItemsPlugin extends Plugin public class GroundItemsPlugin extends Plugin
{ {
// Used when getting High Alchemy value - multiplied by general store price.
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
// ItemID for coins // ItemID for coins
private static final int COINS = ItemID.COINS_995; private static final int COINS = ItemID.COINS_995;
@@ -322,7 +320,7 @@ public class GroundItemsPlugin extends Plugin
for (ItemStack is : items) for (ItemStack is : items)
{ {
composition = itemManager.getItemComposition(is.getId()); composition = itemManager.getItemComposition(is.getId());
Color itemColor = getHighlighted(composition.getName(), itemManager.getItemPrice(is.getId()) * is.getQuantity(), Math.round(composition.getPrice() * HIGH_ALCHEMY_CONSTANT) * is.getQuantity()); Color itemColor = getHighlighted(composition.getName(), itemManager.getItemPrice(is.getId()) * is.getQuantity(), itemManager.getAlchValue(is.getId()) * is.getQuantity());
if (itemColor != null) if (itemColor != null)
{ {
if (config.notifyHighlightedDrops() && itemColor.equals(config.highlightedColor())) if (config.notifyHighlightedDrops() && itemColor.equals(config.highlightedColor()))
@@ -483,7 +481,7 @@ public class GroundItemsPlugin extends Plugin
final int itemId = item.getId(); final int itemId = item.getId();
final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId; final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
final int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT); final int alchPrice = itemManager.getAlchValue(realItemId);
int durationMillis; int durationMillis;
if (client.isInInstancedRegion()) if (client.isInInstancedRegion())
{ {
@@ -614,7 +612,7 @@ public class GroundItemsPlugin extends Plugin
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId(); final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemComposition.getId();
final int itemPrice = itemManager.getItemPrice(realItemId); final int itemPrice = itemManager.getItemPrice(realItemId);
final int price = itemPrice <= 0 ? itemComposition.getPrice() : itemPrice; final int price = itemPrice <= 0 ? itemComposition.getPrice() : itemPrice;
final int haPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT) * quantity; final int haPrice = itemManager.getAlchValue(realItemId);
final int gePrice = quantity * price; final int gePrice = quantity * price;
final Color hidden = getHidden(itemComposition.getName(), gePrice, haPrice, itemComposition.isTradeable()); final Color hidden = getHidden(itemComposition.getName(), gePrice, haPrice, itemComposition.isTradeable());
final Color highlighted = getHighlighted(itemComposition.getName(), gePrice, haPrice); final Color highlighted = getHighlighted(itemComposition.getName(), gePrice, haPrice);
@@ -767,7 +765,7 @@ public class GroundItemsPlugin extends Plugin
{ {
final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final ItemComposition itemComposition = itemManager.getItemComposition(itemId);
final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId; final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId;
final int alchPrice = Math.round(itemComposition.getPrice() * HIGH_ALCHEMY_CONSTANT); final int alchPrice = itemManager.getAlchValue(realItemId);
final int gePrice = itemManager.getItemPrice(realItemId); final int gePrice = itemManager.getItemPrice(realItemId);
return getHidden(itemComposition.getName(), gePrice, alchPrice, itemComposition.isTradeable()) != null; return getHidden(itemComposition.getName(), gePrice, alchPrice, itemComposition.isTradeable()) != null;

View File

@@ -48,7 +48,6 @@ public class HighAlchemyOverlay extends WidgetItemOverlay
private final HighAlchemyPlugin plugin; private final HighAlchemyPlugin plugin;
private final int alchPrice; private final int alchPrice;
private final int alchPriceNoStaff; private final int alchPriceNoStaff;
private static final float HIGH_ALCHEMY_CONSTANT = 0.6f;
@Inject @Inject
public HighAlchemyOverlay(ItemManager itemManager, HighAlchemyPlugin plugin, HighAlchemyConfig config) public HighAlchemyOverlay(ItemManager itemManager, HighAlchemyPlugin plugin, HighAlchemyConfig config)
@@ -107,9 +106,8 @@ public class HighAlchemyOverlay extends WidgetItemOverlay
{ {
return 0; return 0;
} }
ItemComposition itemComp = itemManager.getItemComposition(id);
float haValue = itemComp.getPrice() * HIGH_ALCHEMY_CONSTANT; return itemManager.getAlchValue(id);
return Math.round(haValue);
} }
private int getHAProfit(int haPrice, int gePrice, int alchCost) private int getHAProfit(int haPrice, int gePrice, int alchCost)