diff --git a/wasp_jewelry_smelter.simba b/wasp_jewelry_smelter.simba index bb3d00c..9ed90eb 100644 --- a/wasp_jewelry_smelter.simba +++ b/wasp_jewelry_smelter.simba @@ -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; @@ -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 @@ -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; @@ -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(); @@ -428,6 +401,7 @@ type StoneTypeSelector: TLabeledCombobox; JewelTypeSelector: TLabeledCombobox; FurnaceSelector: TLabeledCombobox; + Config: TConfigJSON; end; procedure TJewelryCrafterConfig.StartScript(sender: TObject); override; @@ -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'); @@ -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 @@ -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 @@ -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; @@ -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; diff --git a/wasp_smelter.simba b/wasp_smelter.simba index 83bdb67..400b8e6 100644 --- a/wasp_smelter.simba +++ b/wasp_smelter.simba @@ -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 = ( @@ -46,7 +44,7 @@ type TSmelter = record(TBaseBankScript) State: ESmelterState; - Furnace: TRSObject; + Furnace: TRSObjectV2; Ore1, Ore2, Bar: TRSBankItem; Materials: TRSItemArray; @@ -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 @@ -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; @@ -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); @@ -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(); @@ -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; @@ -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'); @@ -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 @@ -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();