From aac3a2ba6241252de97de0594c82a831d4b3fee0 Mon Sep 17 00:00:00 2001 From: MahtraDR <93822896+MahtraDR@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:42:09 +1300 Subject: [PATCH 1/2] [scripts][remedy] Move from bputs to DRCI functions Largely just cleanup from bputs to DRCI functions. Switching to `DRCI.lower_item?` fixes many issues folks have been having. --- remedy.lic | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/remedy.lic b/remedy.lic index ce45b2a756..7aeb012dee 100644 --- a/remedy.lic +++ b/remedy.lic @@ -104,13 +104,13 @@ class Remedy end # buy ingredients if missing - if @water == 'water' && DRC.bput("tap my #{@water}", 'You tap', 'I could not find what you were referring to.') == 'I could not find what you were referring to.' + if @water == 'water' && DRCI.exists?(@water) buy_item('water') end - if @alcohol == 'alcohol' && DRC.bput("tap my #{@alcohol}", 'You tap', 'I could not find what you were referring to.') == 'I could not find what you were referring to.' + if @alcohol == 'alcohol' && DRCI.exists?(@alcohol) buy_item('alcohol') end - if ['coal nugget', 'nugget'].include?(@catalyst) && DRC.bput("tap my #{@catalyst}", 'You tap', 'I could not find what you were referring to.') == 'I could not find what you were referring to.' + if ['coal nugget', 'nugget'].include?(@catalyst) && DRCI.exists?(@catalyst) buy_item('coal') end DRC.wait_for_script_to_complete('buff', ['remedy']) @@ -132,9 +132,9 @@ class Remedy # this is to prevent issues getting herbs if someone has less than 25 in @herb_container # there are still issues when herbs are in a different container (not @bag or @herb_container), script will still run fine - if (name == @herb1 || name == @herb2) && @settings.herb_container && DRC.bput("tap #{name} in #{@herb_container}", 'You tap', 'I could not find what you were referring to.', 'You lightly tap') == 'You tap' + if (name == @herb1 || name == @herb2) && @settings.herb_container && DRCI.exists?(name, @herb_container) DRCC.get_crafting_item(name, @herb_container, [name], @belt) # Look for herbs in herb_container - elsif (name == @herb1 || name == @herb2) && DRC.bput("tap #{name} in #{@bag}", 'You tap', 'I could not find what you were referring to.', 'You lightly tap') == 'You tap' + elsif (name == @herb1 || name == @herb2) && DRCI.exists?(name, @bag) DRCC.get_crafting_item(name, @bag, [name], @belt) # Look for herbs in bag elsif at_feet DRCC.get_crafting_item(name, @bag, nil, @belt) # This elsif used primarily to get bowl/mortar etc. from at our feet after lowering it. @@ -171,10 +171,10 @@ class Remedy if @settings.master_crafting_book DRCC.find_recipe2(@chapter, @recipe_name, @settings.master_crafting_book, @book_type) else - DRCC.get_crafting_item("remed book", @bag, @bag_items, @forging_belt) + DRCC.get_crafting_item("remedy book", @bag, @bag_items, @forging_belt) echo('*** You will need to upgrade to a journeyman or master book before 176 ranks! ***') if DRSkill.getrank('Alchemy') == 175 DRCC.find_recipe2(@chapter, @recipe_name) - DRCC.stow_crafting_item("remed book", @bag, @forging_belt) + DRCC.stow_crafting_item("remedy book", @bag, @forging_belt) end if ('red flower').include?(@herb1) @@ -184,8 +184,7 @@ class Remedy end get_item(@container) - DRC.bput('swap', 'You move', 'You have nothing') unless DRC.right_hand =~ /#{@container}/i # lower ground only works if the container is in the right hand. - DRC.bput("lower ground", 'You lower') # lower to count and combine herbs. Switched to just lower ground so it works with all containers. + DRCI.lower_item?(@container) # count herb, less than 25 get more herbs, otherwise stow and continue # added to handle herb containers, and modified to combine up to 25 @@ -196,16 +195,15 @@ class Remedy # in cases where it won't get more herbs, it takes a longer route to get herbs from other bags (not @bag nor @herb_container) @count = DRC.bput("count my #{@herb1}", '^You count out \d+').scan(/\d+/).first.to_i while @count < 25 - DRC.bput("put my #{@herb1} in my #{@container}", 'You put', 'already has something in it.', 'you count off and place only that many inside') + DRCI.put_away_item?(@herb1, @container) fput("stow my #{@herb1}") # in case there are extra - DRC.bput("get my #{@container}", 'You pick up', 'You get') + get_item(@container) # stow then get, to prevent getting herbs from container (i.e. mortar) stow_item(@container) - DRC.bput("get my #{@herb1}", 'You get', 'What were you referring to?', 'You are already holding that.') # using DRC.bput instead of get_item to keep script running when it cannot get the herb + DRCI.get_item?(@herb1) # Using the DRCI method for some reason I don't understand, but because it used this method in long form before get_item(@container) - DRC.bput('swap', 'You move', 'You have nothing') unless DRC.right_hand =~ /#{@container}/i # lower ground only works if the container is in the right hand. - DRC.bput("lower ground", 'You lower') # lower to count and combine herbs. Switched to just lower ground so it works with all containers. - DRC.bput("get #{@herb1} from #{@container}", 'You get', 'What were you referring to?') + DRCI.lower_item?(@container) + DRCI.get_item?(@herb1, @container) # Using the DRCI method for some reason I don't understand, but because it used this method in long form before if DRC.bput("combine my #{@herb1}", 'You combine', 'too large to add', 'You must be holding both') == 'You must be holding both' @count = 25 # 25 used to break loops else @@ -218,11 +216,10 @@ class Remedy f_stack = DRC.bput("count my first #{@herb1}", 'You count out \d+ pieces').scan(/\d+/).first.to_i s_stack = DRC.bput("count my second #{@herb1}", 'I could not find', 'You count out \d+ pieces').scan(/\d+/).first.to_i if f_stack == 75 - DRC.bput("stow my second #{@herb1}", "You put") + DRCI.put_away_item?("second #{@herb1}") elsif s_stack == 75 - DRC.bput("stow my first #{@herb1}", "You put") + DRCI.put_away_item?("first #{@herb1}") end - # stow_item(@herb1) end end end @@ -313,12 +310,13 @@ class Remedy Flags.reset('remedy-alcohol') if DRC.bput("#{@alcohol_verb} #{@alcohol} in my #{@container}", 'Roundtime', 'You toss', 'You cannot find a way to add that as an ingredient') == 'You cannot find a way to add that as an ingredient' stow_item(DRC.left_hand) - if DRC.bput("get alcohol from #{@alcohol}", 'You get', 'What were you referring to') == 'What were you referring to' + unless DRCI.get_item?("alcohol", @alcohol) get_item('alcohol') end - DRC.bput("put alcohol in my #{@container}", 'Roundtime', 'You toss', 'You cannot find a way to add that as an ingredient') + unless DRCI.put_away_item?("alcohol", @container) waitrt? - fput("put alcohol in my #{@alcohol}") + DRCI.put_away_item?("alcohol", @alcohol) + end end waitrt? stow_item(DRC.left_hand) From ba3bda858278edcc8906d531c1698942874dab27 Mon Sep 17 00:00:00 2001 From: MahtraDR <93822896+MahtraDR@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:46:36 +1300 Subject: [PATCH 2/2] More changes, and rubocop. --- remedy.lic | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/remedy.lic b/remedy.lic index 7aeb012dee..14ed78df15 100644 --- a/remedy.lic +++ b/remedy.lic @@ -291,12 +291,13 @@ class Remedy Flags.reset('remedy-water') if DRC.bput("#{@water_verb} #{@water} in my #{@container}", 'Roundtime', 'You toss', 'You cannot find a way to add that as an ingredient') == 'You cannot find a way to add that as an ingredient' stow_item(DRC.left_hand) - if DRC.bput("get water from #{@water}", 'You get', 'What were you referring to') == 'What were you referring to' + unless DRCI.get_item?("water", @water) get_item('water') end - DRC.bput("put water in my #{@container}", 'Roundtime', 'You toss', 'You cannot find a way to add that as an ingredient') - waitrt? - fput("put water in my #{@water}") + unless DRCI.put_away_item?("water", @container) + waitrt? + DRCI.put_away_item?("water", @water) + end end waitrt? stow_item(DRC.left_hand) @@ -314,8 +315,8 @@ class Remedy get_item('alcohol') end unless DRCI.put_away_item?("alcohol", @container) - waitrt? - DRCI.put_away_item?("alcohol", @alcohol) + waitrt? + DRCI.put_away_item?("alcohol", @alcohol) end end waitrt?