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 01/10] 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 02/10] 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 03/10] 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 04/10] 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 05/10] 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 From 1fb848e030e1b5ca4d017db89e2a43dff318349d Mon Sep 17 00:00:00 2001 From: Nyt3 Date: Wed, 22 Nov 2023 14:17:34 -0500 Subject: [PATCH 06/10] Updated hometown detection logic --- pick.lic | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pick.lic b/pick.lic index 566c89df8a..a53f0a22e4 100644 --- a/pick.lic +++ b/pick.lic @@ -102,7 +102,7 @@ class Pick @picking_room_id = Room.current.id - @refill_town = @settings.refill_town + @refill_town = @settings.refill_town = @settings.refill_town.to_s if @debug echo "Settings..." @@ -134,10 +134,10 @@ class Pick echo "- assumed_difficulty: #{@assumed_difficulty}" end - if @settings.refill_town - @lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town] - else + if @refill_town.empty? @lockpick_costs = picking_data['lockpick_costs'][@settings.fang_cove_override_town || @settings.hometown] + else + @lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town] end if args.refill From 591b959c4cc924dbacabf81db3ee60bfd2062a39 Mon Sep 17 00:00:00 2001 From: Nyt3 Date: Wed, 22 Nov 2023 14:28:38 -0500 Subject: [PATCH 07/10] Updated refill_ring logic --- pick.lic | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pick.lic b/pick.lic index a53f0a22e4..fa218c517e 100644 --- a/pick.lic +++ b/pick.lic @@ -325,16 +325,16 @@ class Pick return end - if @refill_town - DRCM.ensure_copper_on_hand(cost * lockpicks_needed, @settings, @refill_town) - else + if @refill_town.empty? 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.empty? 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 From ee22cfb4a6c3277b5af143069cd3ecbcdec8f5e4 Mon Sep 17 00:00:00 2001 From: Nyt3 Date: Sun, 26 Nov 2023 11:49:37 -0500 Subject: [PATCH 08/10] Removed Shard from refill_town base.yaml --- profiles/base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/base.yaml b/profiles/base.yaml index 64b7994281..57f959d16c 100644 --- a/profiles/base.yaml +++ b/profiles/base.yaml @@ -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 From 99b6bb6dd0067f239f2f32fed44710a24fc411c4 Mon Sep 17 00:00:00 2001 From: Nyt3 Date: Sun, 26 Nov 2023 11:57:13 -0500 Subject: [PATCH 09/10] Updated town detection logic, updated refill_pick check to nil instead of empty --- pick.lic | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pick.lic b/pick.lic index fa218c517e..d4605ae084 100644 --- a/pick.lic +++ b/pick.lic @@ -102,7 +102,7 @@ class Pick @picking_room_id = Room.current.id - @refill_town = @settings.refill_town = @settings.refill_town.to_s + @lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town || @settings.fang_cove_override_town || @settings.hometown] if @debug echo "Settings..." @@ -134,12 +134,6 @@ class Pick echo "- assumed_difficulty: #{@assumed_difficulty}" end - if @refill_town.empty? - @lockpick_costs = picking_data['lockpick_costs'][@settings.fang_cove_override_town || @settings.hometown] - else - @lockpick_costs = picking_data['lockpick_costs'][@settings.refill_town] - end - if args.refill refill_ring elsif stop_picking? @@ -325,13 +319,13 @@ class Pick return end - if @refill_town.empty? + 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.empty? + 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) From 0fcff0cdf30ae8b801001cea4400b1ed2bd2c147 Mon Sep 17 00:00:00 2001 From: BinuDR <36463075+BinuDR@users.noreply.github.com> Date: Sun, 26 Nov 2023 21:24:16 -0600 Subject: [PATCH 10/10] Update tome.lic Added events to custom require. --- tome.lic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tome.lic b/tome.lic index 411493dc64..6c01986490 100644 --- a/tome.lic +++ b/tome.lic @@ -1,4 +1,4 @@ -custom_require.call(%w[common common-items drinfomon]) +custom_require.call(%w[common common-items drinfomon events]) class Tome def initialize arg_definitions = [