ConsumeHandler

Manages consumable items like food and potions. It handles loading, inventory scanning, and consumption logic with cooldowns and effects.


type ERSConsumable

type
  ERSConsumable = (
    FOOD, PRAYER, ENERGY, POISON, ANTI_FIRE, STRENGTH_BOOST, ATTACK_BOOST,
    DEFENCE_BOOST, RANGING_BOOST, MAGIC_BOOST
  );

Defines the categories of consumables available.


type TRSConsumableItem

  TRSConsumableItem = record
    Name: String;
    Category: ERSConsumable;
    CooldownMs: Int64;
    DurationMs: Int64;
    IsComboFood: Boolean;
    Points: Int64;
  end;

Represents a single consumable item with its properties.


type TRSConsumables

  TRSConsumables = record
    Name: String;
    Consumables: TRSConsumableItemArray;
    IsSetup: Boolean;
    MinInvPoints: Int64;
    ActiveConsumables: TRSConsumableItemArray;
    Timers: array of TCountDown;
    CooldownTimers: array [ERSConsumable] of TCountDown;
  end;

Manages all aspects of item consumption.


TRSConsumables.Setup

procedure TRSConsumables.Setup();

Initializes the consume handler by loading data from consumables.json. Must be called before other operations.


TRSConsumables.Find

function TRSConsumables.Find(consumableType: ERSConsumable): TRSConsumableItemArray;

Scans inventory for all consumables of a specific category.


TRSConsumables.FindAll

function TRSConsumables.FindAll(): TRSConsumableItemArray;

Scans inventory for all available consumables of any category.


TRSConsumables.Count

function TRSConsumables.Count(consumableType: ERSConsumable): Int32;

Counts the number of items of a specific consumable category in inventory.


TRSConsumables.Has

function TRSConsumables.Has(consumableType: ERSConsumable): Boolean;

Checks if the inventory has at least one item of a specific category.


TRSConsumables.GetBest

function TRSConsumables.GetBest(consumableType: ERSConsumable): TRSConsumableItem;

Finds the best consumable of a category from inventory based on Points.


TRSConsumables.CanConsume

function TRSConsumables.CanConsume(consumableType: ERSConsumable): Boolean;

Checks if a consumable can be used, considering active effects.


TRSConsumables.HasEnoughPoints

function TRSConsumables.HasEnoughPoints(consumableType: ERSConsumable): Boolean;

Checks if total points of a consumable type meet the MinInvPoints threshold.


TRSConsumables.Consume

function TRSConsumables.Consume(consumableType: ERSConsumable; fastMouse: TMouse = Mouse; useFast: Boolean = False): Boolean;

Consumes the best item of a specified category from inventory.