Skip to content

Commit

Permalink
fix: read notes
Browse files Browse the repository at this point in the history
- jewelry smelter and smelter now use TRSMap
  • Loading branch information
Torwent committed Aug 22, 2024
1 parent 9597326 commit 21f3f0f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 88 deletions.
103 changes: 47 additions & 56 deletions wasp_jewelry_smelter.simba
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,34 @@ type
NECKLACE, BRACELET, AMULET
);

ERSFurnace = (EDGEVILLE_FURNACE, FALADOR_FURNACE, PRIFDDINAS_FURNACE);
ERSFurnace = (EDGEVILLE, FALADOR, PRIFDDINAS);

var
CurrentMetal = ERSMetalType.GOLD;
CurrentStone = ERSStoneType.EMERALD;
CurrentJewel = ERSJewelType.RING;
CurrentFurnace = ERSFurnace.EDGEVILLE_FURNACE;
CurrentFurnace = ERSFurnace.EDGEVILLE;

type
EJewelCrafterState = (
HOVER_BANK,
OPEN_BANK,
WITHDRAW_MOULD,
WITHDRAW_BARS,
WITHDRAW_GEMS,
DEPOSIT_JEWELS,
DEPOSIT_RANDOM_ITEM,
HOVER_BANK, OPEN_BANK,
WITHDRAW_MOULD, WITHDRAW_BARS, WITHDRAW_GEMS,
DEPOSIT_JEWELS, DEPOSIT_RANDOM_ITEM,

OPEN_COLLECT,
HANDLE_COLLECT,
OPEN_COLLECT, HANDLE_COLLECT,

OPEN_FURNACE,
CRAFT_JEWEL,
WAIT_CRAFT,
OPEN_FURNACE, CRAFT_JEWEL, WAIT_CRAFT,

CLOSE_INTERFACE,

LEVEL_UP,
CLOSE_CONTEXT,
LEVEL_UP, CLOSE_CONTEXT,

END_SCRIPT,
OUT_OF_SUPPLIES
END_SCRIPT, OUT_OF_SUPPLIES
);

TJewelryCrafter = record(TBaseBankScript)
State: EJewelCrafterState;
Furnace: TRSObject;
Furnace: TRSObjectV2;

Mould, Bar, Gem, Jewel: TRSBankItem;
Materials: TRSItemArray;
Expand All @@ -75,34 +66,11 @@ begin
inherited;
end;

procedure TJewelryCrafter.SetupFurnaces();
begin
case CurrentFurnace of
ERSFurnace.EDGEVILLE_FURNACE:
begin
Self.RSW.SetupRegions([RSRegions.VARROCK]);
Self.Furnace := RSObjects.EdgevilleFurnace;
end;

ERSFurnace.FALADOR_FURNACE:
begin
Self.RSW.SetupRegions([RSRegions.FALADOR]);
Self.Furnace := RSObjects.FaladorFurnace;
end;

ERSFurnace.PRIFDDINAS_FURNACE:
begin
Self.RSW.SetupRegions([RSRegions.PRIFDDINAS]);
Self.Furnace := RSObjects.PrifddinasFurnace;
end;
end;
end;

procedure TJewelryCrafter.SetupItems();
begin
case CurrentMetal of
ERSMetalType.SILVER: Self.Bar := TRSBankItem.Setup('Silver bar', 13);
ERSMetalType.GOLD: Self.Bar := TRSBankItem.Setup('Gold bar', 13);
ERSMetalType.GOLD: Self.Bar := TRSBankItem.Setup('Gold bar', 13);
end;

case CurrentStone of
Expand Down Expand Up @@ -217,16 +185,21 @@ begin
Self.Materials += Self.Gem.Item;
end;


procedure TJewelryCrafter.Init(maxActions: UInt32; maxTime: UInt64); override;
begin
inherited;

Self.SetupFurnaces();
Self.SetupItems();
case CurrentFurnace of
//ERSFurnace.AL_KHARID: Map.SetupChunk(ERSChunk.AL_KHARID);
ERSFurnace.EDGEVILLE: Map.SetupChunk(ERSChunk.EDGEVILLE);
ERSFurnace.FALADOR: Map.SetupChunk(ERSChunk.FALADOR);
ERSFurnace.PRIFDDINAS: Map.SetupChunk(ERSChunk.PRIFDDINAS);
end;

if WLSettings.RemoteInput.HUDDebug then
DebugObjectArray += Self.Furnace;
Objects.Setup(Map.Objects(), @Map.Walker);
Self.Furnace := Objects.Get('Furnace');

Self.SetupItems();
end;


Expand Down Expand Up @@ -389,14 +362,14 @@ begin

case Self.State of
EJewelCrafterState.HOVER_BANK: Self.HoverBank();
EJewelCrafterState.OPEN_BANK: Bank.WalkOpen();
EJewelCrafterState.OPEN_BANK: Banks.WalkOpen();
EJewelCrafterState.WITHDRAW_MOULD: Self.Withdraw(Self.Mould);
EJewelCrafterState.WITHDRAW_BARS: Self.Withdraw(Self.Bar);
EJewelCrafterState.WITHDRAW_GEMS: Self.Withdraw(Self.Gem);
EJewelCrafterState.DEPOSIT_JEWELS: Bank.DepositItem(Self.Jewel, True);
EJewelCrafterState.DEPOSIT_RANDOM_ITEM: Bank.DepositRandomItems(Self.Materials);

EJewelCrafterState.OPEN_COLLECT: CollectBox.WalkOpen();
EJewelCrafterState.OPEN_COLLECT: CollectBoxes.WalkOpen();
EJewelCrafterState.HANDLE_COLLECT: Self.HandleCollectBox(Self.Materials);

EJewelCrafterState.OPEN_FURNACE: Self.OpenFurnace();
Expand Down Expand Up @@ -428,6 +401,7 @@ type
StoneTypeSelector: TLabeledCombobox;
JewelTypeSelector: TLabeledCombobox;
FurnaceSelector: TLabeledCombobox;
Config: TConfigJSON;
end;

procedure TJewelryCrafterConfig.StartScript(sender: TObject); override;
Expand Down Expand Up @@ -484,6 +458,7 @@ var
tab: TTabSheet;
begin
Self.Setup('Wasp Jewelry Crafter');
Self.Config.Setup('wasp-jewelry-crafter');
Self.Start.SetOnClick(@Self.StartScript);

Self.AddTab('Script Settings');
Expand All @@ -498,8 +473,15 @@ begin
SetLeft(TControl.AdjustToDPI(50));
SetTop(TControl.AdjustToDPI(200));
SetStyle(csDropDownList);
AddItemArray(['Edgeville', 'Falador', 'Prifddinnas']);
SetItemIndex(Ord(CurrentFurnace));
AddItemArray([
//'Al Kharid',
'Edgeville', 'Falador', 'Prifddinnas'
]);

if Self.Config.Has('furnace') then
SetItemIndex(Self.Config.GetInt('furnace'))
else
SetItemIndex(Ord(CurrentFurnace));
end;

with Self.JewelTypeSelector do
Expand All @@ -513,8 +495,11 @@ begin
'Tiara', 'Holy symbol', 'Unholy symbol', 'Bolts', 'Ring',
'Necklace', 'Bracelet', 'Amulet'
]);
SetItemIndex(Ord(CurrentJewel));
ComboBox.setOnChange(@Self.JewelSelectorOnChange);
if Self.Config.Has('jewel') then
SetItemIndex(Self.Config.GetInt('jewel'))
else
SetItemIndex(Ord(CurrentJewel));
ComboBox.SetOnChange(@Self.JewelSelectorOnChange);
end;

with Self.StoneTypeSelector do
Expand All @@ -528,7 +513,10 @@ begin
'None', 'Opal', 'Jade', 'Red topaz', 'Sapphire', 'Emerald',
'Ruby', 'Diamond', 'Dragonstone', 'Onyx', 'Zenyte'
]);
SetItemIndex(Ord(CurrentStone));
if Self.Config.Has('stone') then
SetItemIndex(Self.Config.GetInt('stone'))
else
SetItemIndex(Ord(CurrentStone));
ComboBox.SetOnChange(@Self.StoneSelectorOnChange);
end;

Expand All @@ -540,7 +528,10 @@ begin
SetTop(Self.StoneTypeSelector.GetTop());
SetStyle(csDropDownList);
AddItemArray(['Silver', 'Gold']);
SetItemIndex(Ord(CurrentMetal));
if Self.Config.Has('bar') then
SetItemIndex(Self.Config.GetInt('bar'))
else
SetItemIndex(Ord(CurrentMetal));
SetEnabled(False);
end;

Expand Down
67 changes: 35 additions & 32 deletions wasp_smelter.simba
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ type
BRONZE, IRON, SILVER, STEEL, GOLD, MITHRIL, ADAMANT, RUNITE, MOLTEN_GLASS
);

ERSFurnace = (
EDGEVILLE_FURNACE, FALADOR_FURNACE
);
ERSFurnace = (EDGEVILLE, FALADOR, PRIFDDINAS);

var
CurrentBar = ERSBarType.GOLD;
CurrentFurnace = ERSFurnace.EDGEVILLE_FURNACE;
CurrentFurnace = ERSFurnace.EDGEVILLE;

type
ESmelterState = (
Expand Down Expand Up @@ -46,7 +44,7 @@ type
TSmelter = record(TBaseBankScript)
State: ESmelterState;

Furnace: TRSObject;
Furnace: TRSObjectV2;

Ore1, Ore2, Bar: TRSBankItem;
Materials: TRSItemArray;
Expand All @@ -65,23 +63,6 @@ begin
inherited;
end;

procedure TSmelter.SetupFurnaces();
begin
case CurrentFurnace of
ERSFurnace.EDGEVILLE_FURNACE:
begin
RSW.SetupRegions([RSRegions.VARROCK]);
Furnace := RSObjects.EdgevilleFurnace;
end;

ERSFurnace.FALADOR_FURNACE:
begin
RSW.SetupRegions([RSRegions.FALADOR]);
Furnace := RSObjects.FaladorFurnace;
end;
end;
end;

procedure TSmelter.SetupItems();
begin
case CurrentBar of
Expand Down Expand Up @@ -163,11 +144,17 @@ procedure TSmelter.Init(maxActions: UInt32; maxTime: UInt64); override;
begin
inherited;

Self.SetupFurnaces();
Self.SetupItems();
case CurrentFurnace of
//ERSFurnace.AL_KHARID: Map.SetupChunk(ERSChunk.AL_KHARID);
ERSFurnace.EDGEVILLE: Map.SetupChunk(ERSChunk.EDGEVILLE);
ERSFurnace.FALADOR: Map.SetupChunk(ERSChunk.FALADOR);
ERSFurnace.PRIFDDINAS: Map.SetupChunk(ERSChunk.PRIFDDINAS);
end;

if WLSettings.RemoteInput.HUDDebug then
DebugObjectArray += Furnace;
Objects.Setup(Map.Objects(), @Map.Walker);
Self.Furnace := Objects.Get('Furnace');

Self.SetupItems();
end;


Expand Down Expand Up @@ -240,7 +227,7 @@ end;

function TSmelter.OpenFurnace(): Boolean;
begin
if Furnace.WalkSelectOption(['Smelt']) then
if Self.Furnace.WalkSelectOption(['Smelt']) then
begin
Minimap.WaitPlayerMoving(300, 10000);
Result := Make.IsOpen(8000);
Expand Down Expand Up @@ -366,12 +353,12 @@ begin

case Self.State of
ESmelterState.HOVER_BANK: Self.HoverBank();
ESmelterState.OPEN_BANK: Bank.WalkOpen();
ESmelterState.OPEN_BANK: Banks.WalkOpen();
ESmelterState.WITHDRAW_MATERIALS: Self.Withdraw();
ESmelterState.DEPOSIT_BAR: Self.Deposit();
ESmelterState.DEPOSIT_RANDOM_ITEM: Bank.DepositRandomItems(Self.Materials);

ESmelterState.OPEN_COLLECT: CollectBox.WalkOpen();
ESmelterState.OPEN_COLLECT: CollectBoxes.WalkOpen();
ESmelterState.HANDLE_COLLECT: Self.HandleCollectBox(Self.Materials);

ESmelterState.OPEN_FURNACE: Self.OpenFurnace();
Expand Down Expand Up @@ -401,12 +388,16 @@ type
TSmelterConfig = record(TScriptForm)
BarTypeSelector: TLabeledCombobox;
FurnaceSelector: TLabeledCombobox;
Config: TConfigJSON;
end;

procedure TSmelterConfig.StartScript(sender: TObject); override;
begin
CurrentBar := ERSBarType(Self.BarTypeSelector.GetItemIndex());
CurrentFurnace := ERSFurnace(Self.FurnaceSelector.GetItemIndex());

Self.Config.Put('bar', Ord(CurrentBar));
Self.Config.Put('furnace', Ord(CurrentFurnace));
inherited;
end;

Expand All @@ -415,6 +406,7 @@ var
tab: TTabSheet;
begin
Self.Setup('Wasp Smelter');
Self.Config.Setup('wasp-smelter');
Self.Start.SetOnClick(@Self.StartScript);

Self.AddTab('Script Settings');
Expand All @@ -430,7 +422,11 @@ begin
SetTop(TControl.AdjustToDPI(200));
SetStyle(csDropDownList);
AddItemArray(['Bronze', 'Iron', 'Silver', 'Steel', 'Gold', 'Mithril', 'Adamantite', 'Runite', 'Molten glass']);
SetItemIndex(Ord(CurrentBar));

if Self.Config.Has('bar') then
SetItemIndex(Self.Config.GetInt('bar'))
else
SetItemIndex(Ord(CurrentBar));
end;

with Self.FurnaceSelector do
Expand All @@ -440,8 +436,15 @@ begin
SetLeft(Self.BarTypeSelector.GetRight() + TControl.AdjustToDPI(15));
SetTop(Self.BarTypeSelector.GetTop());
SetStyle(csDropDownList);
AddItemArray(['Edgeville', 'Falador']);
SetItemIndex(Ord(CurrentFurnace));
AddItemArray([
//'Al Kharid',
'Edgeville', 'Falador', 'Prifddinnas'
]);

if Self.Config.Has('furnace') then
SetItemIndex(Self.Config.GetInt('furnace'))
else
SetItemIndex(Ord(CurrentFurnace));
end;

Self.CreateAntibanManager();
Expand Down

0 comments on commit 21f3f0f

Please sign in to comment.