Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions scripts/ebounty.lic
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
game: Gemstone
tags: bounty, adventure's guild, advguild, bounties
required: Lich >= 5.12.10
version: 1.9.4
version: 1.9.5

Version Control:
Major_change.feature_addition.bugfix
v1.9.5 (2025-02-06)
- bugfix in forage_bounty when using optional location in CLI argument
v1.9.4 (2025-02-04)
- optimize location_list finding in forage_find room logic
v1.9.3 (2025-02-04)
Expand Down Expand Up @@ -2952,7 +2954,7 @@ module EBounty
end

# Apply location filter if not "nearest"
if location != "nearest"
if !location.eql?("nearest")
location_pattern = /#{Regexp.escape(location.strip)}/
location_list.select! do |room_id|
Room[room_id].location.to_s =~ location_pattern
Expand All @@ -2968,12 +2970,12 @@ module EBounty
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"
location_list = location_list.first(10) if location.eql?("nearest")

location_list
end

def self.forage_bounty(herb, quantity, location = "nearest")
def self.forage_bounty(herb, quantity, location = "nearest", bounty_bypass: false)
EBounty.msg("debug", " #{__method__} | caller: #{caller[0]} | herb: #{herb} | quantity: #{quantity} | location: #{location}")

herb = herb == "trollear mushroom" ? "trollfear mushroom" : herb
Expand All @@ -2984,7 +2986,7 @@ module EBounty
current_room = Room.current.id
amount = StowList.stow_list[:default].contents.find_all { |i| i.name =~ /#{herb}/ }.length

if location == "nearest"
if location.eql?("nearest") || bounty_bypass
forage_item = herb
if (amount >= quantity.to_i)
EBounty.msg("yellow", " Default container has #{amount} #{amount > 1 ? forage_item + 's' : forage_item}. Quantity requested: #{quantity.to_i}")
Expand All @@ -3002,8 +3004,8 @@ module EBounty
location_list = Task.forage_find(herb, forage_item, location)

unless location_list.length.positive?
echo "No #{herb} found at #{location}" if location != "nearest"
echo "No #{herb} found" if location == "nearest"
echo "No #{herb} found at #{location}" if !location.eql?("nearest")
echo "No #{herb} found" if location.eql?("nearest")
EBounty.exit_script
end

Expand Down Expand Up @@ -3113,7 +3115,7 @@ module EBounty
if (XMLData.injuries.any? { |_a, h| h['wound'] > 1 || h['scar'] > 1 } || Char.percent_health < 70) && !EBounty.data.settings[:skip_healing]
return_room = Room.current.id
EBounty.go2_rest
if location == 'nearest'
if location.eql?('nearest') || bounty_bypass
EBounty.check_health
else
Task.prep
Expand Down Expand Up @@ -3145,10 +3147,10 @@ module EBounty
fput "stop 1011" if lines.grep(/Song of Peace/).any?
end

if location != "nearest"
Task.forage_return
else
if location.eql?("nearest") || bounty_bypass
EBounty.go2(current_room)
else
Task.forage_return
end
end

Expand Down Expand Up @@ -3696,7 +3698,7 @@ when 'forage'
end
EBounty::Task.forage_bounty(Bounty.task.herb, Bounty.task.number, Bounty.task.area)
elsif Script.current.vars[4].is_a?(String)
EBounty::Task.forage_bounty(Script.current.vars[2], Script.current.vars[3].to_i, Script.current.vars[4])
EBounty::Task.forage_bounty(Script.current.vars[2], Script.current.vars[3].to_i, Script.current.vars[4], bounty_bypass: true)
else
EBounty::Task.forage_bounty(Script.current.vars[2], Script.current.vars[3].to_i)
end
Expand Down