From c1e75770d34285378c01d49b737d4d7cef08ca6b Mon Sep 17 00:00:00 2001 From: "Ryan P. McKinnon" <15917743+mrhoribu@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:00:38 -0500 Subject: [PATCH 1/3] fix(ebounty.lic): v1.9.4 and optimize location_list Updated version to 1.9.4 and optimized location_list logic. --- scripts/ebounty.lic | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/ebounty.lic b/scripts/ebounty.lic index fe6a211f6..5a5f8bfeb 100644 --- a/scripts/ebounty.lic +++ b/scripts/ebounty.lic @@ -10,10 +10,12 @@ game: Gemstone tags: bounty, adventure's guild, advguild, bounties required: Lich >= 5.12.10 - version: 1.9.3 + version: 1.9.4 Version Control: Major_change.feature_addition.bugfix + v1.9.4 (2025-02-04) + - optimize location_list finding in forage_find room logic v1.9.3 (2025-02-04) - bugfix in forage_find room v1.9.2 (2025-01-27) @@ -2959,12 +2961,7 @@ module EBounty location_list.each do |room| next if room.eql?(Room.current.id) - if Room.current.path_to(room).nil? - location_list.delete(room) - else - travel = Map.estimate_time(Room.current.path_to(room)) - location_list.delete(room) if travel.to_i > 90 - end + location_list.delete(room) if shortest_distances[room].to_i > 90 end return location_list @@ -2981,12 +2978,7 @@ module EBounty location_list.each do |room| next if room.eql?(Room.current.id) - if Room.current.path_to(room).nil? - location_list.delete(room) - else - travel = Map.estimate_time(Room.current.path_to(room)) - location_list.delete(room) if travel.to_i > 90 - end + location_list.delete(room) if shortest_distances[room].to_i > 90 end return location_list From a077748023b835dac87e404dcabdfce3ed5e5b4e Mon Sep 17 00:00:00 2001 From: "Ryan P. McKinnon" <15917743+mrhoribu@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:15:08 -0500 Subject: [PATCH 2/3] Refactor forage_find method for herb location filtering Refactor forage_find method to improve readability and efficiency by using case expressions and filtering location lists more effectively. --- scripts/ebounty.lic | 78 ++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/scripts/ebounty.lic b/scripts/ebounty.lic index 5a5f8bfeb..3315c3adb 100644 --- a/scripts/ebounty.lic +++ b/scripts/ebounty.lic @@ -2926,62 +2926,52 @@ module EBounty def self.forage_find(herb, herb_fix, location) EBounty.msg("debug", " #{__method__} | caller: #{caller[0]}") - case herb - when /ayana (weed|lichen|berry|root)/ - herb = 'ayana leaf' - when /ayana'al (weed|lichen|berry|root)/ - herb = "ayana'al leaf" - when 'trollear mushroom' - herb = 'trollfear mushroom' - end + # Normalize herb names + herb = case herb + when /ayana (weed|lichen|berry|root)/ + 'ayana leaf' + when /ayana'al (weed|lichen|berry|root)/ + "ayana'al leaf" + when 'trollear mushroom' + 'trollfear mushroom' + else + herb + end herb_alt = herb.gsub(/^some /, "") + herb_pattern = /#{Regexp.escape(herb)}|#{Regexp.escape(herb_alt)}|#{Regexp.escape(herb_fix)}/ - # Grab all the rooms that mostly match. - location_list = [] - Room.list.find_all do |r| - if r.tags.any? { |tag| (tag.end_with? herb) || ((herb.start_with? tag) && herb =~ /ayana/) || (herb.end_with? tag) } - location_list.push(r.id) - end - end + # Find rooms with matching herb tags + location_list = Room.list.select do |r| + r.tags.any? { |tag| tag.end_with?(herb) || (herb.start_with?(tag) && herb =~ /ayana/) || herb.end_with?(tag) } + end.map(&:id) - # Reject the rooms with herbs that don't match - location_list = location_list.reject do |room| - !Room[room].tags.any? { |tag| tag =~ /#{herb}|#{herb_alt}|#{herb_fix}/ } + # Filter to rooms where tags actually match the herb pattern + location_list.select! do |room_id| + Room[room_id].tags.any? { |tag| tag =~ herb_pattern } end - # This is for CLI herb foraging - # ;ebounty forage "" for example ;ebounty forage "some acantha leaf" 3 - if location == "nearest" - _previous, shortest_distances = Room.current.dijkstra - location_list.delete_if { |room_id| shortest_distances[room_id].nil? } - location_list = location_list.sort { |a, b| shortest_distances[a] <=> shortest_distances[b] } - - location_list = location_list.first(10) - - location_list.each do |room| - next if room.eql?(Room.current.id) - location_list.delete(room) if shortest_distances[room].to_i > 90 + # Apply location filter if not "nearest" + if location != "nearest" + location_pattern = /#{Regexp.escape(location.strip)}/ + location_list.select! do |room_id| + Room[room_id].location.to_s =~ location_pattern end - - return location_list - end - - # Reject the locations that don't match - location_list = location_list.reject do |room| - Room[room].location.to_s !~ /#{location.strip}/ end + # Calculate distances and filter by reachability and distance _previous, shortest_distances = Room.current.dijkstra - location_list.delete_if { |room_id| shortest_distances[room_id].nil? } - location_list = location_list.sort { |a, b| shortest_distances[a] <=> shortest_distances[b] } + current_room_id = Room.current.id - location_list.each do |room| - next if room.eql?(Room.current.id) - location_list.delete(room) if shortest_distances[room].to_i > 90 - end + location_list = location_list.select do |room_id| + distance = shortest_distances[room_id] + distance && distance <= 90 + end.sort_by { |room_id| shortest_distances[room_id] } + + # Limit to 10 nearest if location is "nearest" + location_list = location_list.first(10) if location == "nearest" - return location_list + location_list end def self.forage_bounty(herb, quantity, location = "nearest") From 0ca5090b79fe16cfeb1efd29977d22276384e109 Mon Sep 17 00:00:00 2001 From: "Ryan P. McKinnon" <15917743+mrhoribu@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:20:50 -0500 Subject: [PATCH 3/3] fix: Remove unused variable in distance calculation Removed unused variable 'current_room_id' from distance calculation. --- scripts/ebounty.lic | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/ebounty.lic b/scripts/ebounty.lic index 3315c3adb..f1dac67f6 100644 --- a/scripts/ebounty.lic +++ b/scripts/ebounty.lic @@ -2961,7 +2961,6 @@ module EBounty # Calculate distances and filter by reachability and distance _previous, shortest_distances = Room.current.dijkstra - current_room_id = Room.current.id location_list = location_list.select do |room_id| distance = shortest_distances[room_id]