Skip to content
Closed
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
123 changes: 123 additions & 0 deletions scripts/efamgo2.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
=begin

Ever had your familiar/eye stranded somewhere?

This script tells your familiar to walk to a room#.
It's not fool-proof since they sometimes cannot enter certain areas.

Note:
The script will pause if there's a special procedure for the area.
It's up to you to figure out what to tell you pet from then on.
Unpause the script when you resolve the special procedures.

--Drafix

Fork of famgo2.lic by Drafix.

author: elanthia-online
contributors: Drafix, Dissonance
game: any
tags: movement, step2, go2, move2, familiar, eye
version: 1.0.0

Change Log:
v1.0.0 (2025-05-01)
- initial release and fork from famgo2.lic
- add support for u##### (real ID#s)
=end

module EFAMGO2
# make sure we have proper input
unless Script.current.vars[1] =~ /^u?[0-9]+$/
Lich::Messaging.mono("usage: #{$lich_char}#{script.name} <room number>")
exit
end
Comment on lines +31 to +34
Copy link
Contributor

@mrhoribu mrhoribu May 1, 2025

Choose a reason for hiding this comment

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

Should be included inside of a method that is called outside of the of module

module Name
  # module contents
  def self.do_something
    # method contents
  end
end

if Script.current.vars[1] =~ /^u?[0-9]+$/
  Name.do_something
else
  Lich::Messaging.mono("usage: #{$lich_char}#{Script.current.name} <room number>")
  exit
end


Map.load if Map.list.empty?
seeking = $go2_use_seeking
$go2_use_seeking = false
before_dying { $go2_use_seeking = seeking }
$step2_path = []
fam = 'familiar' if Lich::Gemstone::Stats.prof == 'Wizard'
fam = 'eye' if Lich::Gemstone::Stats.prof == 'Sorcerer'

# determine if the user provided a real room number (u#) or a lich room number, and if it exists
if Script.current.vars[1] =~ /^[0-9]+$/
unless (destination_room = Room[script.vars[1]])
Lich::Messaging.msg("error", "destination room was not found in the map database")
exit
end
elsif Script.current.vars[1] =~ /^u[0-9]+$/
unless (destination_room = Room[Map.ids_from_uid((Script.current.vars[1])[1..-1].to_i).first])
Lich::Messaging.msg("error", "destination room was not found in the map database")
exit
end
end

# force the familiar to look, so that we can get the current location
fput("tell #{fam} to look")
fput("look #{Char.name}")
line = get until line == 'At yourself?'

# strip the real room number from the room name, turn it into an integer, find the lich room # from the real room number, and then get the room
# unless start_room = Room[Map.ids_from_uid(/(\d+)/.match(XMLData.familiar_room_title.strip)[1].to_i).first]
unless (start_room = Room[modify_room_display(XMLData.familiar_room_title.strip)])
Lich::Messaging.msg("error", "familiar's room is unknown")
exit
end

# if you want to go where your are, then we're done here
if start_room == destination_room
Lich::Messaging.msg("warn", "start room and destination room are the same")
exit
end

# start moving to the destination
unless $step2_path and (s = $step2_path.index(start_room.id)) and (d = $step2_path.index(destination_room.id)) and (s < d)
previous, _ = Map.dijkstra(start_room.id, destination_room.id)
unless previous[destination_room.id]
Lich::Messaging.msg("error", "error: failed to find a path between your current room (#{start_room.id}) and destination room (#{destination_room.id})")
exit
end
$step2_path = [destination_room.id]
$step2_path.push(previous[$step2_path[-1]]) until previous[$step2_path[-1]].nil?
$step2_path.reverse!
nil
end

while (room = Room[$step2_path[$step2_path.index(start_room.id) + 1].to_s])
way = start_room.wayto[$step2_path[$step2_path.index(start_room.id) + 1].to_s]

if start_room == destination_room
Lich::Messaging.msg("info", 'Your familiar has arrived.')
exit
elsif way.class == String
if way =~ /([a-z]+) (.*)/
if $1 == 'go'
fput("tell #{fam} to go #{$2}")
elsif $1 == 'climb'
fput("tell #{fam} to go #{$2}")
end
else
fput("tell #{fam} to go #{way}")
end

sleep 0.01
start_room = room
elsif way.class == Proc
if way.inspect =~ /(?:go|climb) (.+?)'/
fput("tell #{fam} to go #{$1}")
elsif way.inspect =~ /(northeast|northwest|southeast|southwest|north|east|south|west|up|down|out)/
fput("tell #{fam} to go #{$1}")
end

start_room = room
else
Lich::Messaging.msg("error", "error in the map database")
exit
end
end

# we're done, take a look to show where we finished
fput("tell #{fam} to look")
end