diff --git a/scripts/BlackArts.lic b/scripts/BlackArts.lic index a3f48f1d2..47230a2d4 100644 --- a/scripts/BlackArts.lic +++ b/scripts/BlackArts.lic @@ -6,14 +6,16 @@ contributors: Deysh, Tysong, Gob game: Gemstone tags: alchemy - version: 1.2.4 + version: 1.2.5 Improvements: Major_change.feature_addition.bugfix - v1.2.4 (2025-01-09) - - added messaging for moth cloak + v1.2.5 (2025-01-10) + - bugfix for finding correct mortar for grinding tasks =end =begin + v1.2.4 (2025-01-09) + - added messaging for moth cloak v1.2.3 (2024-12-31) - typo mortars should be mortar - bugfix in using 709 and GameObj.targets @@ -5134,7 +5136,8 @@ module BlackArts /Reaching over your shoulder/, /^As you draw/, /^Ribbons of.*?light/, - /^An eclipse of spectral moths/ + /^An eclipse of spectral moths/, + /^You aren't assigned that task right now/ ) @put_regex = Regexp.union( @@ -8754,6 +8757,32 @@ module BlackArts end end + def self.find_mortar_for_task + # Check if it's in sight first + mortar = (GameObj.room_desc.to_a + GameObj.loot.to_a).find { |obj| obj.noun =~ /mortar/ }.id + + return mortar unless mortar.nil? + + # If no mortar then check inside the stuff + (GameObj.room_desc.to_a + GameObj.loot.to_a).each do |item| + ["in", "on", "under", "behind"].each { |location| + lines = Util.get_lines("look #{location} #{item}", %r{(.*?)<\/a>/) + mortar_match = matches.find { |_, noun, description| noun.match?(/\bmortars?\b/) || description.match?(/\bmortars?\b/) } + + # return ID if it exists + if mortar_match + return mortar_match[0] + end + } + end + + Util.msg('error', " Not able to find a mortar for grinding reps. Report this to EO on the discord scripting channel.") + Util.msg('error', " Method: Tasks.grind_ingredients | Class: #{Char.prof} | Room: #{Room.current.id} | GameObj.npcs: #{GameObj.npcs} | GameObj.room_desc: #{GameObj.room_desc} | GameObj.loot: #{GameObj.loot}") + end + def self.grind_ingredients Guild.get_cauldron Inventory.free_hands(both: true) @@ -8771,10 +8800,8 @@ module BlackArts Util.msg('error', " Method: Tasks.grind_ingredients | Class: #{Char.prof} | Room: #{Room.current.id} | NPCs: #{GameObj.npcs} | Room_desc: #{GameObj.room_desc}") end - result = Util.get_res('get mortar', BlackArts.data.get_regex) - if result =~ /^Get what\?/ - Util.get_res('get stone mortar', BlackArts.data.get_regex) - end + task_mortar = Tasks.find_mortar_for_task + Util.get_res("get ##{task_mortar}", BlackArts.data.get_regex) shelf = GameObj.room_desc.find { |obj| obj.noun == 'shelf' } || GameObj.loot.find { |obj| obj.noun == 'shelf' } @@ -8802,11 +8829,11 @@ module BlackArts exit end - give_result = Util.get_res("give my mortar to #{clerk}", /^\[You have/) + give_result = Util.get_res("give ##{task_mortar} to #{clerk}", /^\[You have/) break unless give_result =~ /\[You have [0-9]+ repetitions? remaining\.\]/ } - Util.get_res('put mortar', BlackArts.data.put_regex) + Util.get_res("put ##{task_mortar}", BlackArts.data.put_regex) end def self.grind_mine(reps)