Skip to content

Commit

Permalink
Merge pull request #1736 from Deysh/BlackArts
Browse files Browse the repository at this point in the history
[blackarts] v1.2.5 bugfix for finding correct mortar for grinding tasks
  • Loading branch information
mrhoribu authored Jan 11, 2025
2 parents 6ddb6e6 + f638da2 commit 9ae53ff
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions scripts/BlackArts.lic
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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{<container|There is nothing|In|On|Under|Behind}).join(' ')

# Find the first match containing "mortars"
matches = lines.scan(/.*?exist="(-?\d+)" noun="(.*?)">(.*?)<\/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)
Expand All @@ -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' }

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9ae53ff

Please sign in to comment.