Skip to content

Commit

Permalink
Merge branch 'rpherbig:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
OdnaZvezda authored Nov 27, 2023
2 parents fb9cfe9 + 19fa758 commit 94681e3
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 15 deletions.
20 changes: 7 additions & 13 deletions pick.lic
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Pick

@picking_room_id = Room.current.id

@refill_town = @settings.refill_town
@lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town || @settings.fang_cove_override_town || @settings.hometown]

if @debug
echo "Settings..."
Expand Down Expand Up @@ -134,12 +134,6 @@ class Pick
echo "- assumed_difficulty: #{@assumed_difficulty}"
end

if @settings.refill_town
@lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town]
else
@lockpick_costs = picking_data['lockpick_costs'][@settings.fang_cove_override_town || @settings.hometown]
end

if args.refill
refill_ring
elsif stop_picking?
Expand Down Expand Up @@ -325,16 +319,16 @@ class Pick
return
end

if @refill_town
DRCM.ensure_copper_on_hand(cost * lockpicks_needed, @settings, @refill_town)
else
if @refill_town.nil?
DRCM.ensure_copper_on_hand(cost * lockpicks_needed, @settings)
else
DRCM.ensure_copper_on_hand(cost * lockpicks_needed, @settings, @refill_town)
end

if @refill_town
DRCT.refill_lockpick_container(@settings.lockpick_type, @refill_town, @lockpick_container, lockpicks_needed)
else
if @refill_town.nil?
DRCT.refill_lockpick_container(@settings.lockpick_type, @settings.fang_cove_override_town || @settings.hometown, @lockpick_container, lockpicks_needed)
else
DRCT.refill_lockpick_container(@settings.lockpick_type, @refill_town, @lockpick_container, lockpicks_needed)
end
end

Expand Down
25 changes: 24 additions & 1 deletion profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ use_skeleton_key: false
use_lockpick_ring: true
skip_lockpick_ring_refill: false
# If skip_lockpick_ring_refill is false and your hometown doesn't have a locksmith shop, add the nearest town with a shop here.
refill_town: Shard
refill_town:
# If you set 'use_lockpick_ring: false' then specify
# the container that holds your loose lockpicks.
# If you set 'use_lockpick_ring: true' then specify
Expand Down Expand Up @@ -2530,3 +2530,26 @@ task_forage_settings:
wait_in_place: true
# Show verbose debug messaging
debug: false

# Settings for the tome script, which trains scholarship using books from shops like Tomes of Lore
tome_settings:
# Name of tome. If using quit_early, it must be one of these exact names:
# tel'athi treatise, mikkhalbamar manuscript, spiritwood tome, field guide, brinewood book, kuwinite codex, smokewood codex, togball manual
tome_name:
# Try to stow the tome before finishing the last page, which comes with a 50% concentration hit and not much scholarship at higher ranks
quit_early: true
# Target mindstates to train to
scholarship_limit: 30
# If true, the script will remain running in the background until specific conditions are met that allow for training
# If false, the script will run actively, focusing on studying until you hit your scholarship goal, and exit.
passive: true
# A list of scripts that are safe to get a tome out and study while running. Only include scripts where you'll have at least 1 hand free
passive_scripts:
- appraisal
- attunement
- first-aid
- outdoorsmanship
- crossing-repair
- task-forage
debug: false

2 changes: 1 addition & 1 deletion task-forage.lic
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class TaskForage

def give_item
echo 'give_item' if @debug
case DRC.bput("give #{@task_giver}", 'and says, "Thanks,', '^What is it you\'re trying to give?',
case DRC.bput("give #{@item} to #{@task_giver}", 'and says, "Thanks,', '^What is it you\'re trying to give?',
' I have a few things here for you, thank you so much for your help', 'Mags sighs and says')
when /^What is it you're trying to give?/
find_giver
Expand Down
134 changes: 134 additions & 0 deletions tome.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
custom_require.call(%w[common common-items drinfomon events])
class Tome
def initialize
arg_definitions = [
[
{ name: 'active', regex: /active/i, optional: true, description: 'Actively study until a scholarship goal is reached (as opposed to passively waiting for the appropriate time)' },
{ name: 'debug', regex: /debug/i, optional: true, description: 'Verbose messaging for troubleshooting' }
]
]

args = parse_args(arg_definitions)
@settings = get_settings
@tome_settings = @settings.tome_settings
@debug = args.debug

@tome = @tome_settings['tome_name']
@quit_early = @tome_settings['quit_early']
@scholarship_limit = @tome_settings['scholarship_limit'] || 34
@passive_scripts = @tome_settings['passive_scripts']
@passive = args.active ? false : @tome_settings['passive']
@no_use_rooms = @settings.sanowret_no_use_rooms

@penultimate_pages = {
'tel\'athi treatise' => "Most S'Kra, whether they call them such or not, are familiar with the Eight Gifts",
'mikkhalbamar manuscript' => "In both cases the rituals involving consignment are nearly identical",
'spiritwood tome' => "Faenella is the goddess of creativity, revelry, and pride.",
'field guide' => "Sacred to Harawep, wildling spiders are a sentient race that is associated with the cult of the Spidersworn",
'brinewood book' => "While Merelew observed the stars and the moons crown,",
'kuwinite codex' => "But, she is a great warrior with the fury of a mother",
'smokewood codex' => "Rumor also has it that the Empire had great powers of magic or technology",
'togball manual' => "A team may not enter the opposing team's Blood Zone"
}

if @quit_early
Flags.add('study-complete', Regexp.new(@penultimate_pages[@tome]))
else
Flags.add('study-complete', /^Having finished your studies,/)
end

echo @tome_settings.to_yaml if @debug
echo @args.to_yaml if @debug

monitor_routine
end

def should_train?
return false if DRSkill.getxp('Scholarship') >= @scholarship_limit
return true unless @passive
return false if hiding? || invisible?
return false if DRC.left_hand && DRC.right_hand && !DRCI.in_hands?(@tome)
return false if @no_use_rooms.any? { |name| /#{name}/ =~ DRRoom.title || name.to_s == Room.current.id.to_s }
if @passive_scripts.any? { |name|
echo "Passive script: #{name}" if Script.running?(name) && @debug
Script.running?(name)
}
return true
else
return false
end
end

def pause_scripts
until (@scripts_to_unpause = DRC.safe_pause_list)
echo("Cannot pause, trying again in 30 seconds.")
pause 30
end
end

# If at any time during a pausing period the primary training script exits, then safely store the book and go back into waiting mode.
def pause_safely(duration)
end_time = Time.now + duration

while Time.now < end_time
if !should_train?
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
return false
end
pause 1
end
return true
end

def monitor_routine
loop do
if DRSkill.getxp('Scholarship') >= @scholarship_limit && !@passive
DRC.fix_standing
exit
end
Flags.reset('study-complete')
if !@passive
DRC.bput('sit', 'You sit', 'You are already sitting', 'You rise', 'While swimming?') unless sitting?
end

pause 10 until should_train? and DRStats.concentration == 100
next unless should_train?

pause_scripts if @passive
unless DRCI.get_item?(@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
next
end
result = DRC.bput("study my #{@tome}", "You immerse yourself in the wisdom of your", "You are unable to focus on studying your", "However, you find that you lack the concentration to focus on your studies", "Considering that you are in combat,", "However, you realize that you were already reading this book")
DRC.safe_unpause_list @scripts_to_unpause if @passive
case result
when /^You are unable to focus on studying your/,
/^However, you find that you lack the concentration to focus on your studies/,
/^Considering that you are in combat,/
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
pause 10
next
end
next unless pause_safely(10) # Wait for at least one page to be read

# Pause until we finish reading, the valid passive script completes, or concentration hits 100
# (which only will happen if we finished reading but somehow missed the completion flag - e.g., if another script stowed the book)
pause 1 until Flags['study-complete'] or !should_train? or DRStats.concentration == 100
pause_scripts if @passive
DRCI.stow_item?(@tome)
DRC.safe_unpause_list @scripts_to_unpause if @passive
end
end
end

before_dying do
Flags.delete('study-complete')
DRC.fix_standing
DRCI.stow_item?(@tome) if DRCI.in_hands?(@tome)
end

Tome.new

0 comments on commit 94681e3

Please sign in to comment.