From 2d87242629fc725aaf94a37b57ba8581d7cb5014 Mon Sep 17 00:00:00 2001 From: urbaj-dr <110074842+urbaj-dr@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:13:50 -0500 Subject: [PATCH 1/5] Update task-forage.lic --- task-forage.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task-forage.lic b/task-forage.lic index 6983ec1c59..b456a2049b 100644 --- a/task-forage.lic +++ b/task-forage.lic @@ -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 From 860f37dd4d6596963583bb6cd389f7d646bbb9d6 Mon Sep 17 00:00:00 2001 From: urbaj-dr <110074842+urbaj-dr@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:15:02 -0500 Subject: [PATCH 2/5] Update base.yaml with tome_settings Added settings for the tome script --- profiles/base.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/profiles/base.yaml b/profiles/base.yaml index 7393ffb7bf..f8a5d7fbbb 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -2530,3 +2530,25 @@ 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: + tome_name: kuwinite codex + # 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 + - athletics + debug: false + From b3284a92f98c3d711cfc5a4645981e0bd1d2b4a6 Mon Sep 17 00:00:00 2001 From: urbaj-dr <110074842+urbaj-dr@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:16:49 -0500 Subject: [PATCH 3/5] Creation of tome script Trains scholarship using scholarship books (such as those sold at Tomes of Lore) --- tome.lic | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tome.lic diff --git a/tome.lic b/tome.lic new file mode 100644 index 0000000000..411493dc64 --- /dev/null +++ b/tome.lic @@ -0,0 +1,134 @@ +custom_require.call(%w[common common-items drinfomon]) +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 From e1dbfc83caf2bfb5f7f988a3a73aa6becadebb77 Mon Sep 17 00:00:00 2001 From: urbaj-dr <110074842+urbaj-dr@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:20:25 -0500 Subject: [PATCH 4/5] Update base.yaml with tome_name There shouldn't be a default tome_name --- profiles/base.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profiles/base.yaml b/profiles/base.yaml index f8a5d7fbbb..15c5d3747f 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -2533,7 +2533,9 @@ task_forage_settings: # Settings for the tome script, which trains scholarship using books from shops like Tomes of Lore tome_settings: - tome_name: kuwinite codex + # 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 From b51f2ffcd2a2b50c58b9d35dc7e0f34a71cdd5b9 Mon Sep 17 00:00:00 2001 From: urbaj-dr <110074842+urbaj-dr@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:25:31 -0500 Subject: [PATCH 5/5] Update base.yaml Athletics shouldn't be a default passive script (since holding a tome increases climbing difficulty) --- profiles/base.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/profiles/base.yaml b/profiles/base.yaml index 15c5d3747f..64b7994281 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -2551,6 +2551,5 @@ tome_settings: - outdoorsmanship - crossing-repair - task-forage - - athletics debug: false