Skip to content
Open
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
44 changes: 32 additions & 12 deletions scripts/go2.lic
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
contributors: Deysh, Doug, Gildaren, Sarvatt, Tysong, Xanlin, Dissonance
game: any
tags: core, movement
version: 2.2.13
version: 2.3.0
required: Lich >= 5.4.1

changelog:
2.3.0 (2025-11-26)
Add "unhide" option, when true unhides when hidden. when false(default) and hidden, sets typeahead to 0
Change class checks to is_a? checks
2.2.13 (2025-11-22)
Added support for ;go2 locker taking to public locker or CHE locker as applicable, if Lich version is 5.12.2 or later
Added support for ;go2 guild or ;go2 guild shop to automatically look for the calling character's profession and go to the appropriate guild or guild shop.
Expand Down Expand Up @@ -390,6 +393,7 @@ module Go2
:rogue_password => UserVars.rogue_password,
:delay => CharSettings['delay'],
:typeahead => CharSettings['typeahead'],
:unhide => CharSettings['unhide'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

setup flow can clear unhide by saving nil.

load_go2_settings now includes :unhide, but Setup prunes keys that are not declared in @@categories. Since unhide is not declared there, settings[:unhide] can be missing and Line 450 writes nil back to CharSettings['unhide'].

💡 Proposed fix
@@
       @@categories = {
         general: {
@@
           typeahead: { default: 0 },
+          unhide: { default: false },
           delay: { default: 0 },
@@
-    CharSettings['unhide']                  = settings[:unhide]
+    CharSettings['unhide']                  = settings.fetch(:unhide, CharSettings['unhide'])

Also applies to: 450-450

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/go2.lic` at line 396, The setup flow is accidentally clearing
CharSettings['unhide'] because load_go2_settings adds :unhide but Setup prunes
keys not listed in @@categories so settings[:unhide] can be absent and you end
up writing nil; fix this by either adding :unhide to the class-level
@@categories array so Setup will preserve it, or change the write-back that
assigns CharSettings['unhide'] (where you use settings[:unhide]) to use a
fallback like settings.fetch(:unhide, CharSettings['unhide']) so the existing
value is retained when the key is missing.

:stop_for_dead => CharSettings['stop for dead'],
:get_silvers => CharSettings['get silvers'],
:get_return_silvers => CharSettings['get return trip silvers'],
Expand Down Expand Up @@ -443,6 +447,7 @@ module Go2
UserVars.rogue_password = settings[:rogue_password]
CharSettings['delay'] = settings[:delay]
CharSettings['typeahead'] = settings[:typeahead]
CharSettings['unhide'] = settings[:unhide]
CharSettings['stop for dead'] = settings[:stop_for_dead]
CharSettings['get silvers'] = settings[:get_silvers]
CharSettings['get return trip silvers'] = settings[:get_return_silvers]
Expand Down Expand Up @@ -783,7 +788,7 @@ module Go2
_respond("#{monsterbold_start}= #{opt.capitalize} =#{monsterbold_end}\n")
@@categories[opt.to_sym].each do |id, _|
value = @settings[id]
value.class == Array ? print_array.call(id, value, 1) : print_value.call(id, value, 1)
value.is_a?(Array) ? print_array.call(id, value, 1) : print_value.call(id, value, 1)
end
end
if $frontend == 'stormfront'
Expand All @@ -805,7 +810,7 @@ module Go2
if value == 'reset'
@settings.delete(key)
echo " Reset #{key}"
elsif @settings[key].class == Array
elsif @settings[key].is_a?(Array)
if value =~ /\d/ && @settings[key][value.to_i]
@settings[key].delete_at(value.to_i)
else
Expand All @@ -821,9 +826,9 @@ module Go2

echo " #{key.inspect} is now #{@settings[key].join(', ').inspect}"
else
if @settings[key].class == FalseClass || @settings[key].class == TrueClass
if @settings[key].is_a?(FalseClass) || @settings[key].is_a?(TrueClass)
value = value =~ /^true|1|yes|on/ ? true : false
elsif @settings[key].class == Integer
elsif @settings[key].is_a?(Integer)
value = value.to_i
end

Expand All @@ -849,6 +854,7 @@ module Go2
end
CharSettings['typeahead'] = 0 if CharSettings['typeahead'].nil?
CharSettings['delay'] = 0 if CharSettings['delay'].nil?
CharSettings['unhide'] = false if CharSettings['unhide'].nil?
CharSettings['hide_room_descriptions'] = false if CharSettings['hide_room_descriptions'].nil?
CharSettings['hide_room_titles'] = false if CharSettings['hide_room_titles'].nil?
CharSettings['echo_input'] = true if CharSettings['echo_input'].nil?
Expand All @@ -870,6 +876,7 @@ module Go2
output << ""
output << " options:"
output << " --typeahead=<#> Sets the number of typeahead lines to use."
output << " --unhide=<on|off> Unhides if hidden to prevent movement issues"
output << " --delay=<#> Sets the delay in seconds between movements"
output << " (disables typeahead)."
output << " --echo_input=<on|off> When 'on', echos the script input from when the script was called"
Expand Down Expand Up @@ -935,7 +942,7 @@ module Go2
}

change_map_vaalor_shortcut = proc { |use_shortcut|
unless Map.list.any? { |room| room.timeto.any? { |_adj_id, time| time.class == Proc and time._dump =~ /$go2_use_vaalor_shortcut/ } }
unless Map.list.any? { |room| room.timeto.any? { |_adj_id, time| time.is_a?(StringProc) and time._dump =~ /$go2_use_vaalor_shortcut/ } }
if use_shortcut
Room[16745].timeto['16746'] = 15
Room[16746].timeto['16745'] = 15
Expand Down Expand Up @@ -1031,7 +1038,7 @@ module Go2
output << " - Known Nexus Rooms"
output << "---------------------------------------------------------------"
Map.list.find_all { |iroom| iroom.tags.include?('nexus') }
.each { |iroom| output << "#{iroom.title.first.sub(/^\[/, '').sub(/\]$/, '').ljust(45)} - #{iroom.id.to_s.rjust(5)}" }
.each { |iroom| output << "#{iroom.title.first.sub(/^\[/, '').sub(/\]$/, '').ljust(45)} - #{iroom.id.to_s.rjust(5)}" }
end
respond output
exit
Expand All @@ -1044,6 +1051,7 @@ module Go2
output << " (not used because delay > 0)"
end
output << ""
output << " unhide: #{CharSettings['unhide']}"
output << " delay: #{CharSettings['delay']}"
output << " echo input: #{CharSettings['echo_input'] ? 'on' : 'off'}"
output << "hide room descriptions: #{CharSettings['hide_room_descriptions'] ? 'on' : 'off'}"
Expand Down Expand Up @@ -1172,6 +1180,7 @@ module Go2

target_search_array = Array.new
setting_typeahead = nil
setting_unhide = nil
setting_delay = nil
setting_disable_confirm = false
setting_use_vaalor_shortcut = nil
Expand Down Expand Up @@ -1202,6 +1211,8 @@ module Go2
for var in Script.current.vars[1..-1]
if var =~ /^(?:\-\-)?typeahead=([0-9]+)$/i
setting_typeahead = $1.to_i
elsif (var =~ /^(?:\-\-)?unhide=(on|true|yes|off|false|no)$/i)
setting_unhide = setting_value[$1.downcase]
elsif var =~ /^(?:\-\-)?delay=([0-9\.]+)$/i
setting_delay = $1.to_f
elsif var =~ /^\-\-instability=([0-9]+)$/i
Expand Down Expand Up @@ -1281,6 +1292,10 @@ module Go2
CharSettings['delay'] = setting_delay
echo "delay setting changed to #{setting_delay} seconds"
end
unless setting_unhide.nil?
CharSettings['unhide'] = setting_unhide
echo "go2 #{(setting_unhide ? 'will' : 'will not')} unhide if hidden to prevent movement issues"
end
unless setting_typeahead.nil?
CharSettings['typeahead'] = setting_typeahead
echo "typeahead setting changed to #{setting_typeahead}"
Expand Down Expand Up @@ -1760,9 +1775,9 @@ module Go2
end
if Room.current.wayto.keys.include?(next_id.to_s)
way = Room.current.wayto[next_id.to_s]
if way.class == Proc
if way.is_a?(StringProc)
way.call
elsif way.class == String
elsif way.is_a?(String)
move way
else
echo "error: map database movement is neither a Proc or a String"
Expand Down Expand Up @@ -2124,6 +2139,11 @@ module Go2

# Store start room for future use
UserVars.go2_start_room = start_room.id
if setting_unhide.is_a?(TrueClass) && checkhidden
fput("unhide")
elsif setting_unhide.is_a?(FalseClass) && checkhidden
setting_typeahead = 0
end
Comment on lines +2142 to +2146
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Saved unhide setting is ignored during normal travel.

At Line 2142, behavior depends on setting_unhide, but that variable is only set when --unhide=... is passed on the command line. If users saved CharSettings['unhide'], it is not applied here.

💡 Proposed fix
@@
   if setting_delay.nil?
     setting_delay = CharSettings['delay']
   end
+
+  if setting_unhide.nil?
+    setting_unhide = CharSettings['unhide']
+  end
@@
-  if setting_unhide.is_a?(TrueClass) && checkhidden
-    fput("unhide")
-  elsif setting_unhide.is_a?(FalseClass) && checkhidden
-    setting_typeahead = 0
-  end
+  if checkhidden
+    if setting_unhide
+      fput('unhide')
+    else
+      setting_typeahead = 0
+    end
+  end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/go2.lic` around lines 2142 - 2146, The current branch only honors the
command-line variable setting_unhide but ignores saved CharSettings['unhide'],
so change the logic to fallback to the saved setting when setting_unhide is
nil/unset: read CharSettings['unhide'] into setting_unhide (or use it as a
fallback) before the conditional that checks
setting_unhide.is_a?(TrueClass)/FalseClass; then keep the existing actions
(calling fput("unhide") when true and setting setting_typeahead = 0 when false)
and preserve the checkhidden guard.


loop {
moves_sent = $room_count
Expand Down Expand Up @@ -2335,7 +2355,7 @@ module Go2
end
waitrt?

if room.wayto[next_id].class == Proc
if room.wayto[next_id].is_a?(StringProc)
if setting_drag
echo "error: drag feature can't deal with StringProc movements yet"
exit
Expand All @@ -2352,7 +2372,7 @@ module Go2
break if GameObj.pcs.any? { |pc| pc.status =~ /dead/ }
idx -= 1
break unless (way = Room.current.wayto[path[idx].to_s])
if way.class == Proc
if way.is_a?(StringProc)
way.call
else
move way
Expand Down Expand Up @@ -2402,7 +2422,7 @@ module Go2
break if GameObj.pcs.any? { |pc| pc.status =~ /dead/ }
idx -= 1
break unless (way = Room.current.wayto[path[idx].to_s])
if way.class == Proc
if way.is_a?(StringProc)
way.call
else
move way
Expand Down
Loading