PDA

View Full Version : Introducing SmartHunt



Yasutoshi
05-18-2014, 11:28 AM
A couple of notes before you read further:


This script was never intended to compete with or replace bigshot.
This script was originally intended as a wrapper class for the SmartMonk script.
If you find anything in this script useful and want to use code or ideas in your own scripts, it is highly recommended and okay!
Improvement, diversity, and open source are the keys to changing the world.


What is SmartHunt anyhoo?

Originally intended as a wrap-around class for smartmonk, the script initially focused on monks and unarmed combat agendas. Since I've been working on it, I decided it might be beneficial to other characters so I have subsequently changed the script so that any class or style can use it. Is this script better than Bigshot? In some minor ways, yes, and in some major ways, no. Bigshot is a really handy and useful script. However, one thing I like to do is to be able to control what I do in the game with 100% certainty and the best way for me to do that is to write my own script. As I'm an avid ruby programmer and ruby on rails coder, I love challenges. I wrote this script over 5 days time. So, in effect, it is a 5-day old script (if version 1.0.0 is accurate).

What do I need to use this script effectively?


;repo download smarthunt
;repo download askgenie
;repo download useherbs


These are the only 3 scripts you need to use things right away. However, if you are a monk or you use unarmed combat, then you also want to download smartmonk. If it changes later on, it will have further customizations.

For unarmed combat download:


;repo download smartmonk


Optional scripts you may want to use with this?


;repo download waggle
;repo download sloot


What features does this script have?


This script is multi-threaded meaning it has multiple threads and processes multiple actions simultaneously.
It requires Ruby 1.9 or higher and has been tested with Ruby 2.0.
This script has built in monster reports. While the script is running use ;askgenie report.
This script has built in timers. While the script is running it will report automatically or you can use ;askgenie timer.
This timers can be set to determine how long you want to use the script for (30 min, 1 hour, 4 hours, 8 hours, etc.).
This script has built in help. While the script is running use ;askgenie help.
Askgenie uses unique send to communicate with Smarthunt.
This script has built in status checks for dead, bound, stunned, health, encumbrance, blessings, etc.
This script has a built in room navigator that "you" can fully customize the route. No boundary usage.
This script recognizes Voln and symbols, including courage, protection, preservation, etc. and allows pre-buffing.
This script allows you to pre-buff cmans.
And more...


Monster Reports

With Voln enabled and hunting undead

6505

Without Voln enabled

6506

Monster reports allow you to see how many monsters you've killed over the course of the script and over the course of the last hunt. It tells you how many of each type you killed, including their name. If you have voln enabled, it assumes you are hunting undead and also provides you a favor calculation earnings report. If you have voln enabled and are not hunting undead, simply ignore the favor report altogether. It's only providing you a report for if you were actively hunting undead during that session.

Timers

6507

Timers provide you a way to see how long the script has been active and out of what maximum time you've allotted until the script will be ending. You can access this by using ;askgenie timer. Once the timer has finished completely, your entire session will be neatly wrapped up and you'll go back home until you exit. Depending on your report settings, you can determine if the script automatically reports to you during your sessions.

Other Routines

The normal routine begins like this:


Smarthunt starts its engines.
Smarthunt begins prebuffing based on your settings.
Smarthunt travels to your starting room locator and begins to self-navigate based off what you've chosen.
Smarthunt looks for monsters but if people are in the room it bypasses the room and continues looking for more monsters.
Once monsters are found and no people are around, smarthunt uses your combat script settings (example smartmonk) to hunt the monster.
Afterwards, depending on your settings, smarthunt searches and loots the monster.
During the entire hunting session, smarthunt actively checks all statuses to ensure you are still in good shape to fight.
Once you reach maxxed (will provide settings for this later on), it mops up and takes you home.
Depending on your health, smarthunt then checks to see if you need healing and uses your herbs to heal (currently uses ;useherbs).
Depending on your loot sell script, smarthunt then goes and does the entire sell and deposit routine (I recommend some version of sloot).
Smarthunt then takes you back to your home resting spot and processes various tasks until you are Fresh and Clear (again will probably add customizations later on for this).
Rinse and repeat until your complete timer is finished.


See more below:

Yasutoshi
05-18-2014, 11:29 AM
Settings

We have to have settings right?

;smarthunt setup

65086509

One is a settings for a lowbie or newbie and the other is the settings for a voln master. Take a peek at them. Want to know what each setting is or does, you can use ;askgenie help while smarthunt is active. It will open to the help file the first time it is launched. But, here is the help file example:

6510

Again, at the time of this writing this was version 1.0.1 so I will be improving subsequent versions along with the GUI interface. Consider this basic.

Room Locator Customizer

First, I recommend either using ;uberbars or ;rnum as they both give you the room numbers of the areas you are in. The big question will be why didn't I want to add boundaries? The only answer I can provide is that I'm pretty OCD and I want my character to run the rooms the way I want him to run. If a hunting area has a rotary, I may want my character to run around that rotary 7 times before he continues into other areas. Why? Because I'm OCD! I like running around in circles!

So, how do you do this? Pretty simple:

Given 5 rooms and you wanted to go right to left as an example (these are hypothetical room numbers)

101,102,103,104,105,104,103,102

The first room is 101 - the script takes you to the 101 room. It then runs all the way to 105 and then back because you told it to. When it gets to 102, it starts over which happens to be ... 101!

So, how do you remember things the easy way when creating a loop? Start with the first room and work your way around the other rooms until you are at the last room before the start of the loop.

Given 3 rooms (yeah I have to be easy)

Assume that this route only has easterly and westerly movement:

101,102,103,102
= to
start, east, east, west
= then when loop starts again (let's pretend it's run it three times)

101,102,103,102
101,102,103,102
101,102,103,102

Looks like:

start, east, east, west
west, east, east, west
west, east, east, west, etc.

As Jim Carrey would say, it keeps going, .. and going.. around... and around.. again, and again, and again...

If you use the word "lowbie" instead of room numbers, it will take you to the thyril/relnak hunting area. I put this in there so you can see how it works without adventuring into dangerous areas.

The Script

Version now 1.4.4



=begin
Script SmartHunt
Author Yasutoshi, Monk
Date May 26 2014
Version 1.4.4
Description Originally a Hunting Wrapper for use with smartmonk and Voln but can now be used by any class or affiliation
Scripts Needed smarthunt, askgenie, (optional: smartmonk)

SETUP
.................| Command: ;smarthunt setup
.................| Command: ;smarthunt
.................| Command: ;askgenie help
.................| Command: ;askgenie hunting
.................| Command: ;askgenie report
.................| Command: ;askgenie timer
=end

# Add a round_to, ceil_to, and floor_to functionality (small change) to class float
# Allows me to do (4.11345798).round_to(2) => 4.11
class Float
def round_to(x)
(self * 10**x).round.to_f / 10**x
end

def ceil_to(x)
(self * 10**x).ceil.to_f / 10**x
end

def floor_to(x)
(self * 10**x).floor.to_f / 10**x
end
end

VERSION = '1.4.4'
$TITLE = "SmartHunt: v. (#{VERSION})"

unless RUBY_VERSION.to_f >= 1.9
echo "================================================== ==========="
echo " Your Ruby version needs to be 1.9 or higher to use threads. "
echo "================================================== ==========="
exit
end

class SmartHunt

attr_accessor :variable, :debug

def initialize(variable, debug=0)

@msg = nil
@target = nil
@people = nil
@my_status = nil
@current_room = nil
@end_this_now = false
@time = nil
@time_end = nil
@im_dead = false
@stunned = false
@go_back_early = false
@num_of_hunts = 0
@total_monsters_array = []
@target_array = []
@debug = debug
@variable = variable
silence_me if @debug == 0
script_init

end

def script_init
if @variable[1] == 'setup'
setup
else
pause_and_help
start
end
end

def setup
gui
setup_info
end

def pause_and_help
unless UserVars.smarthunt['sm_show_help_and_pause'] == 'no'
help
echo ".| "
echo ".| ================================================== ==========================================="
echo ".| Press ;u to unpause this script at any time. You can change this behavior in setup. "
echo ".| ================================================== ==========================================="
pause_script
end
end

def setup_info
echo ".| ================================================== ==========================================="
echo ".| ----------------------------------------Settings---------------------------------------------"
echo ".| ================================================== ==========================================="
echo ".| Are you a cleric?:........................| #{UserVars.smarthunt['sm_ami_cleric']}"
echo ".| Are you a monk?:..........................| #{UserVars.smarthunt['sm_ami_monk']} "
echo ".| Are you unarmed?:.........................| #{UserVars.smarthunt['sm_ami_unarmed']} "
echo ".| What combat script do you want to use?:...| #{UserVars.smarthunt['sm_combat_script']} "
echo ".| Ready weapon/shield before hunting?:......| #{UserVars.smarthunt['sm_ready_equipment']}"
echo ".| Hand Equipment (eg. handwraps):...........| #{UserVars.smarthunt['sm_hands']} "
echo ".| Foot Equipment (eg. footwraps):...........| #{UserVars.smarthunt['sm_feet']} "
echo ".| Member of Voln?:..........................| #{UserVars.smarthunt['sm_voln']} "
echo ".| Auto Bless Hands and Feet?:...............| #{UserVars.smarthunt['sm_autobless']} "
echo ".| # sym of courage to use per hunt?:........| #{UserVars.smarthunt['sm_courage']} "
echo ".| # sym of protect to use per hunt?:........| #{UserVars.smarthunt['sm_protect']} "
echo ".| # of climbing ranks? (used for gy gate)...| #{UserVars.smarthunt['sm_climbing_skill']} "
echo ".| What buff script used? (waggle | none):...| #{UserVars.smarthunt['sm_buff_script']} "
echo ".| CMANs to use during buffing (sep by , ):..| #{UserVars.smarthunt['sm_buff_cmans']} "
echo ".| Default Loot Script:......................| #{UserVars.smarthunt['sm_loot_script']} "
echo ".| Default Loot Script Sell Command:.........| #{UserVars.smarthunt['sm_loot_script_sell']} "
echo ".| Enable Locksmith?:........................| #{UserVars.smarthunt['sm_enable_locksmith']}"
echo ".| Primary Loot Bag:.........................| #{UserVars.smarthunt['sm_primary_bag']} "
echo ".| Overflow Loot Bag:........................| #{UserVars.smarthunt['sm_secondary_bag']} "
echo ".| % of Health before Herb Use (0.80):.......| #{UserVars.smarthunt['sm_safe_health']} "
echo ".| Encumbrance Value Check (Def. 40):........| #{UserVars.smarthunt['sm_encumbrance_value']} "
echo ".| Avg Monster Level to be Hunted:...........| #{UserVars.smarthunt['sm_monster_level']} "
echo ".| Max minutes to use script:................| #{UserVars.smarthunt['sm_minutes_to_hunt']} "
echo ".| Minutes until timer reports:..............| #{UserVars.smarthunt['sm_minutes_for_report']} "
echo ".| Mana Driven Hunting?:.....................| #{UserVars.smarthunt['sm_need_mana_to_hunt']}"
echo ".| End hunting when mana below amount:.......| #{UserVars.smarthunt['sm_amount_of_mana']}"
echo ".| Start hunting when mind is this level:....| #{UserVars.smarthunt['sm_mind_start_hunting']}"
echo ".| Stop hunting when mind is this level:.....| #{UserVars.smarthunt['sm_mind_stop_hunting']}"
echo ".| Top off spells when resting (mind level)..| #{UserVars.smarthunt['sm_waggle_when_mind']}"
echo ".| Use bread before sleep/meditate?..........| #{UserVars.smarthunt['sm_use_bread']}"
echo ".| Spell number for bread:...................| #{UserVars.smarthunt['sm_use_bread_spellnum']}"
echo ".| Rooms Array (e.g. 1201,1203,1205,etc):....| #{UserVars.smarthunt['sm_rooms_array']} "
echo ".| Rooms Array (home,bank,gems,pawn,lock):...| #{UserVars.smarthunt['sm_rooms_array_core']} "
echo ".| Safe Room for herbuse:....................| #{UserVars.smarthunt['sm_rooms_safe']}"
echo ".| Movement Speed? (slow, medium, fast):.....| #{UserVars.smarthunt['sm_movement_speed']}"
echo ".| Show help and pause at start of script?:..| #{UserVars.smarthunt['sm_show_help_and_pause']} "
echo ".| ================================================== ==========================================="
end

def get_custom_settings
if (UserVars.smarthunt['sm_hands']) && (UserVars.smarthunt['sm_feet'])
# Character Name and level
@character_name = XMLData.name.to_s.downcase
@character_level = XMLData.level.to_i
# Character Class
@monk = UserVars.smarthunt['sm_ami_monk']
# Unarmed
@am_i_unarmed = UserVars.smarthunt['sm_ami_unarmed']
# Combat Script
@combat_script = UserVars.smarthunt['sm_combat_script']
# Blessable equipment
@blessable_hands = UserVars.smarthunt['sm_hands']
@blessable_feet = UserVars.smarthunt['sm_feet']
# Voln and symbols
@voln = UserVars.smarthunt['sm_voln']
@auto_bless = UserVars.smarthunt['sm_autobless']
@sym_of_courage = UserVars.smarthunt['sm_courage'].to_i
@sym_of_protect = UserVars.smarthunt['sm_protect'].to_i
# Climb Skill
@climbing_skill = UserVars.smarthunt['sm_climbing_skill']
# Buff Script
@buff_script = UserVars.smarthunt['sm_buff_script']
# CMAN Buffs
@cman_buffs = UserVars.smarthunt['sm_buff_cmans'].split(",")
# Loot Script and bags
@default_loot_script = UserVars.smarthunt['sm_loot_script']
@default_loot_script_sell_command = UserVars.smarthunt['sm_loot_script_sell']
@enable_locksmith = UserVars.smarthunt['sm_enable_locksmith']
@primary_bag = UserVars.smarthunt['sm_primary_bag']
@secondary_bag = UserVars.smarthunt['sm_secondary_bag']
# Health Target for useherbs
@safe_health = UserVars.smarthunt['sm_safe_health']
@check_target_health = (XMLData.max_health.to_f * @safe_health.to_f).to_i
# Encumbrance
@encumbrance_value = UserVars.smarthunt['sm_encumbrance_value']
# Monster level
@monster_level = UserVars.smarthunt['sm_monster_level'].to_i
# Timers
@hunt_x_minutes = UserVars.smarthunt['sm_minutes_to_hunt'].to_i
@timer_length = @hunt_x_minutes * 60
@reporting_x_minutes = UserVars.smarthunt['sm_minutes_for_report'].to_i
@timer_reporting_intervals = @reporting_x_minutes * 60
@timer_status_intervals = 10 # every 10 seconds, timer will check status # Arch Wights - 7225,7226,7227,7228,7231,7232,7235,7236,7237,7238, 7239,7240,7241,7240,7242,7240,7239,7238,7237,7236, 7235,7232,7233,7234,7228,7230
# Example Hunting Ground Scenario (Ghoul Masters and Tomb Wights)
@rooms_array = UserVars.smarthunt['sm_rooms_array'].split(",") #eg. 7207,7208,7249,7250,7248,7209,7210,7211,7212,7247, 7246,7214,7213,7212,7211,7210,7209,7248,7250,7249, 7208,7207
# Town Spots # Example home, bank, gemshop, pawnshop, locksmith
@rooms_array_core = UserVars.smarthunt['sm_rooms_array_core'].split(",") #eg. 8671,400,1776,408,5612
@home = @rooms_array_core[0]
@bank = @rooms_array_core[1]
@gemshop = @rooms_array_core[2]
@pawnshop = @rooms_array_core[3]
@locksmith = @rooms_array_core[4]
# WL Graveyard Areas
@graveyard_back_gate = 4141
@graveyard_crypt = 4142
@graveyard_front_gate = 4140
# Other WL Areas
@voln_courtyard = 3600
else
@variable = nil
setup
end
end

def start
get_custom_settings
echo "Starting up Script Engines in 10 sec..."
10.times do |this|
sleep 1
echo ".........."
end
script_threads
end

def script_threads
# Creating a timer thread process and a hunting thread process (multi-threaded)
timer = Thread.new{ my_timer(@timer_length,@timer_reporting_intervals, @timer_status_intervals) } # TIMER
talker = Thread.new{ reporting } # UNIQUE CHAT AND SEND TO SCRIPT
gy_gate = Thread.new{ check_for_gy_gate } # CHECKS FOR GY GATE
im_hunting = Thread.new{ start_hunting } # ACTIVELY HUNTS
# Joining Threads
timer.join
talker.join
gy_gate.join
im_hunting.join
end

def start_hunting
unless @end_this_now == true
if UserVars.smarthunt['sm_ready_equipment'] == 'yes'
multifput "ready weapon", "ready shield"
end
echo "***** BUFFING *****" if @debug == 1
buff_myself
fput "stance defensive"
echo "***** TRAVELLING *****" if @debug == 1
rooms_or_custom
echo "***** BEGINNING TO HUNT *****" if @debug == 1
echo "***** start_hunting method is now active *****" if @debug == 1
room_locator # movement through the rooms and hunting
else
end_this_script
end
end

def room_locator
unless @end_this_now == true
unless @stunned == true
check_my_health
@rooms_array.each do |room|
mana_driven_hunting
gotoroom(room)
monsters_or_players
check_experience
end
room_locator
end
else
end_this_script
end
end

def cleanup_after_hunting
gotoroom(@home) # Let's go to our home spot
@num_of_hunts += 1 # Count hunting sessions
sleep 3 # We'll sleep 3 seconds before continuing
useherbs # Let's use herbs just to be on the safe side and clean ourselves up if needed
uselocksmith if @enable_locksmith == 'yes' # Use our own locksmith instead of sloots
sell_using_loot_script # Sell using loot script sell command
gotoroom(@home) # Go back home
full_report
@go_back_early = false
end

def mana_driven_hunting
if UserVars.smarthunt['sm_need_mana_to_hunt'] == 'yes'
echo "Prematurely ending hunting" if @debug == 1
unless checkmana UserVars.smarthunt['sm_amount_of_mana']
echo "Not enough mana" if @debug == 1
end_hunting
else
#echo "Still have mana? (#{checkmana}): #{checkmana UserVars.smarthunt['sm_amount_of_mana']}"
end
end
end

def end_this_script
cleanup_after_hunting
kill_myself
end

def end_hunting
cleanup_after_hunting
lets_sleep_for_awhile
end

def monsters_or_players
mana_driven_hunting
if UserVars.smarthunt['sm_undead'] == 'yes'
@target = find_undead_target
else
@target = GameObj.npcs.find { |npc| npc.status.nil? || npc.status == 'lying down' }
end
if @target
# found monsters so check if other players are in the room
@people = GameObj.pcs.find { |pc| pc.status.nil? }
if @people
return
else
# no players found in the room so we can attack the monster
start_script "#{@combat_script}"
wait_while {running? "#{@combat_script}"}
# killed the monster so we can loot it
unless @default_loot_script == 'none'
start_script "#{@default_loot_script}"
wait_while {running? "#{@default_loot_script}"}
end
sleep 2
# What Monsters have we faught in total and during this hunting session?
@total_monsters_array << "#{@target.name}"
@target_array << "#{@target.name}"
# check my health
check_my_health
# rebless items if I'm in voln and am fighting with hands and feet
rebless_items if ((@voln == 'yes') && (@auto_bless == 'yes'))
# let's just double check and be sure that we don't have any weird items in our hands
# afterall, we're monks!
clear_all_hands
# If I'm encumbered I definitely want to return home
am_i_encumbered?
# before we start to roam again, let's check if there are other monsters in our room
monsters_or_players
end
else
# no monsters or people so go on to the next room
return
end
end

def cast_spell_on_self(number)
fput "prep #{number}"
fput "cast"
waitcastrt?
end

def buff_with_voln
unless @sym_of_protect == 0
(@sym_of_protect).times do
fput "sym of protection"
end
end
unless @sym_of_courage == 0
(@sym_of_courage).times do
fput "sym of courage"
end
end
end

def buff_myself
unless @buff_script == 'none'
start_script "#{@buff_script}"
wait_while {running? "#{@buff_script}"}
sleep 2
@cman_buffs.each do |buff|
fput "cman #{buff}"
sleep 1
end
buff_with_voln if @voln == 'yes'
end
end

def lets_sleep_for_awhile
use_bread
cleric_meditate
sleep 60
fput "look"
if percentmind <= UserVars.smarthunt['sm_mind_start_hunting'].to_i
@target_array = []
start_hunting
elsif (percentmind > UserVars.smarthunt['sm_mind_start_hunting'].to_i)
unless UserVars.smarthunt['sm_waggle_when_mind'].to_s == 'none'
if (percentmind <= UserVars.smarthunt['sm_waggle_when_mind'].to_i)
start_script "#{@buff_script}"
wait_while {running? "#{@buff_script}"}
lets_sleep_for_awhile
else
lets_sleep_for_awhile
end
else
lets_sleep_for_awhile
end
else
lets_sleep_for_awhile
end
end

def use_bread
if UserVars.smarthunt['sm_use_bread'] == 'yes'
fput "prep #{UserVars.smarthunt['sm_use_bread_spellnum']}"
fput "cast"
waitcastrt?
sleep 1
5.times { |i| fput "eat my #{GameObj.right_hand}" }
end
end

def cleric_meditate
# You wake from your meditation, yet a deep feeling of relaxation remains present.
if UserVars.smarthunt['sm_ami_cleric'] == 'yes'
fput "meditate"
sleep 135
end
end

# ------------------------------------------------------------------------------------------------------------
# MINI METHODS, STATUS CHECKS, AND MERCHANTS |
# ------------------------------------------------------------------------------------------------------------

# BLESS ITEMS (VOLN) __________________________________________________ _______

def check_blessings
return matchwait('A faint aura', 'You see nothing unusual')
end

def rebless_items
@msg = nil
# check hands
fput "look at my #{@blessable_hands}"
@msg = check_blessings
if ( @msg =~ /You see nothing unusual, except for a small enchanter's glyph./ )
fput "remove #{@blessable_hands}"
fput "sym of bless my #{@blessable_hands}"
fput "wear my #{@blessable_hands}"
else
echo "Hand Items are still blessed so do nothing" if @debug == 1
end
@msg = nil
# check hands
fput "look at my #{@blessable_feet}"
@msg = check_blessings
if ( @msg =~ /You see nothing unusual, except for a small enchanter's glyph./ )
fput "remove #{@blessable_feet}"
fput "sym of bless my #{@blessable_feet}"
fput "wear my #{@blessable_feet}"
else
echo "Foot Items are still blessed so do nothing" if @debug == 1
end
end

# CLEAR ALL ITEMS FROM HANDS _________________________________________________

def clear_all_hands
if @am_i_unarmed == 'yes'
fput "stance defensive"
# left hand
if GameObj.left_hand.to_s != nil
fput "put #{GameObj.left_hand} in my #{@primary_bag}"
end
# right hand
if GameObj.right_hand.to_s != nil
fput "put #{GameObj.right_hand} in my #{@primary_bag}"
end
end
end

# CHECK MY STATUS __________________________________________________ __________

def my_status
if Char.dead? == true
goto_imdead unless @im_dead == true
elsif (Char.stunned? == true) or (Char.bound? == true)
@stunned = true
kill_script "#{@combat_script}"
fput "stance defensive"
clear_all_hands
check_my_health
# rebuff focus
=begin
if @monk == 'yes'
if checkmana 16
fput "prep 1216"
fput "cast"
sleep 4
end
end
=end
@stunned = false
else
# no longer have a status of stunned and just in case, let's make sure we've set things back to normal
if @stunned == true
sleep 2
kill_script "#{@combat_script}"
@stunned = false
end
# if no longer dead then let's end that as well
if Char.dead? == false
@im_dead = false
end
end
end

# CHECK HEALTH __________________________________________________ _____________

def check_my_health
if checkhealth < @check_target_health.to_i
echo "Health is at #{checkhealth} so using herbs."
kill_script "#{@combat_script}"
clear_all_hands
if UserVars.smarthunt['sm_rooms_safe'] != nil
gotoroom(UserVars.smarthunt['sm_rooms_safe'])
useherbs
else
useherbs
end
end
end

# CHECK ENCUMBRANCE __________________________________________________ ________

def am_i_encumbered?
enc_value = XMLData.encumbrance_value.to_i
if enc_value >= @encumbrance_value.to_i
end_hunting
else
return
end
end

# CHECK EXPERIENCE __________________________________________________ _________

def check_experience
#echo "percenmind is #{percentmind} and stop is #{UserVars.smarthunt['sm_mind_stop_hunting'].to_i}"
#echo "is it ? #{percentmind(UserVars.smarthunt['sm_mind_stop_hunting'].to_i)}"
if percentmind(UserVars.smarthunt['sm_mind_stop_hunting'].to_i)
end_hunting
else
return
end
end

# USE HERBS __________________________________________________ ________________

def useherbs
fput "stance defensive"
start_script 'useherbs'
wait_while {running? 'useherbs'}
end

# USE LOCKSMITH __________________________________________________ ____________

def uselocksmith
@have_primary_boxes = false
@have_secondary_boxes = false
primary_bag = [GameObj[UserVars.smarthunt['sm_primary_bag']]]
secondary_bag = [GameObj[UserVars.smarthunt['sm_secondary_bag']]]
primary_bag.each { |bag|
if (more_boxes = bag.contents.find_all { |o| o.type.include?('box') })
unless more_boxes.nil? or more_boxes.empty?
@have_primary_boxes = true #Found Boxes in primary bag
end
end
}
secondary_bag.each { |bag|
if (more_boxes = bag.contents.find_all { |o| o.type.include?('box') })
unless more_boxes.nil? or more_boxes.empty?
@have_secondary_boxes = true #Found Boxes in secondary bag
end
end
}
unless (@have_primary_boxes == false) && (@have_secondary_boxes == false)
gotoroom('bank')
fput "withdraw 10000 silver"
sleep 1
gotoroom('locksmith')
if @have_primary_boxes == true
primary_bag.each { |bag|
if (more_boxes = bag.contents.find_all { |o| o.type.include?('box') })
more_boxes.each do |box|
sell_boxes(box, UserVars.smarthunt['sm_primary_bag'])
end
end
}
end
sleep 5
if @have_secondary_boxes == true
secondary_bag.each { |bag|
if (more_boxes = bag.contents.find_all { |o| o.type.include?('box') })
more_boxes.each do |box|
sell_boxes(box, UserVars.smarthunt['sm_secondary_bag'])
end
end
}
end
gotoroom('bank')
sleep 1
fput "deposit all"
clear_all_hands
end
end

def sell_boxes(box,bag,right_hand=nil)
if GameObj.right_hand.name.to_s == "Empty"
fput "get #{box} from my #{bag}"
if GameObj.right_hand.to_s == box.to_s
sleep 1
fput "ring bell"
sleep 1
fput "pay"
sleep 1
fput "open my #{box}"
fput "get coins"
sleep 3
fput "empty #{box} in my #{bag}"
sleep 5
fput "put #{box} in casket"
fput "put #{box} in waste"
sleep 1
end
if right_hand != nil
fput "get #{right_hand} from my #{bag}"
end
else
target = GameObj.right_hand.noun
fput "put #{GameObj.right_hand.noun} in my #{bag}"
sell_boxes(box,bag,target)
end
end

# SELL EVERYTHING __________________________________________________ __________

def sell_using_loot_script
unless @default_loot_script == 'none'
unless @default_loot_script_sell_command == 'none'
start_script "#{@default_loot_script}", [ "#{@default_loot_script_sell_command}" ]
wait_while {running? "#{@default_loot_script}"}
else
start_script "#{@default_loot_script}"
wait_while {running? "#{@default_loot_script}"}
end
end
end

# TIMERS AND COMPOMENTS __________________________________________________ ____

def my_timer(seconds, reporting_intervals, status_intervals)
i,j,k = 0,0,0
while i <= seconds
if (j.to_f / status_intervals.to_f) >= 1.0
j = 0
# check status and health
my_status
end
if (k.to_f / reporting_intervals.to_f) >= 1.0
k = 0
# report timers
time = Time.at(i).gmtime.strftime('%R:%S')
echo "Reporting Timer Status: #{time} HH:MM:SS out of #{Time.at(seconds).gmtime.strftime('%R:%S') } HH:MM:SS."
end
sleep 1
i += 1
j += 1
k += 1
@time = Time.at(i).gmtime.strftime('%R:%S')
@time_end = Time.at(seconds).gmtime.strftime('%R:%S')
end
echo "Timer Reached: Ended at at #{Time.now} so heading home"
@end_this_now = true
end

def reporting
loop {
msg = unique_get.strip
if msg == 'report'
monster_report
elsif msg == 'timer'
timer_report
elsif msg == 'help'
help
elsif msg == 'hunting'
hunting_area_reports
else
echo "Valid commands are help, hunting, report, and timer."
end
}
end

def check_for_gy_gate
loop {
sleep 5
if Room.current.id.to_s == '4141'
if checkmana 7
fput "prep 1207"
fput "cast gate"
waitcastrt?
end
end
if Room.current.id.to_s == '4140'
if @climbing_skill >= 14
multifput "climb gate", "jump"
else
if checkmana 7
fput "prep 1207"
fput "cast gate"
waitcastrt?
end
end
end
}
end

def goto_imdead
@im_dead = true
kill_script "#{@combat_script}"
fput "sym of preservation" if @voln == true
monster_report
kill_myself
end

def kill_myself
echo "Exiting in 1 minute"
sleep 60
Script.self.kill
end

# FAVOR CALCULATION __________________________________________________ ________

def calculate_favor_gained
(((@character_level.to_f / 15.0) * @monster_level.to_f).round_to(3)).ceil
end

def calculate_favor_spent_per_hunt
@base_mult = 1.110
@base_adj = ((0.020 * @character_level.to_f).round_to(3))
@favor_cost = ((@base_mult + @base_adj).round_to(3) * @character_level.to_f).ceil
@favor_per_hunt = 0
@hunt_courage = 0
@hunt_protect = 0
if @voln == 'yes'
# Courage Calc
unless @sym_of_courage == 0
@hunt_courage = @favor_cost * @sym_of_courage
end
# Protect Calc
unless @sym_of_protect == 0
@hunt_protect = @favor_cost * @sym_of_protect
end
end
@favor_per_hunt = @hunt_courage + @hunt_protect
end

# ------------------------------------------------------------------------------------------------------------
# GOTO SCRIPTS |
# ------------------------------------------------------------------------------------------------------------

def gas_cloud_messages
# a gas cloud
# You notice a gas cloud begin to form above you.
# You notice the gas cloud begin to condense!
# Large sparks begin to form in the center of the gas cloud!
# The static discharges are now audible from the gas cloud, and it looks like it won't be long before it releases some energy.
# The gas cloud begins to dissipate.
end

def gotoroom(room)
start_script 'go2', ["#{room}"]
wait_while {running? 'go2'}
if UserVars.smarthunt['sm_movement_speed'] == 'slow'
sleep 3
elsif UserVars.smarthunt['sm_movement_speed'] == 'medium'
sleep 1
else
# do nothing
end
end

def rooms_or_custom
# if there's more than one variable in the array then it's custom string of rooms [101,102,103,etc.]
# else it's a one word variable which we can send to the correct method below.
if @rooms_array[1]
gotoroom(@rooms_array[0])
else
@rooms_array = __send__(@rooms_array[0])
end
end

# ========== Wehnimer's Landing ==========

def wl_lv3_tl_1
# Whenimer's Landing Sewers Thyrils
[7545,7547,7548,7549,7559,7558,7557,7554,7555,7556, 7555,7554,7553,7552,7551,7550,7546]
end

# Example start area for mid-youngins
def wl_lv3_tl_2
# Wehimer's Landing Sewers Vysans
[7734,7735,7736,7742,7743,7744,7745,7746,7747,7748, 7749,7750,7751,7752,7753,7754,7741,7740,7739,7738, 7737,7736,7735]
end

def wl_lv1_tu_1
# Wehnimer's Landing Sewers lesser shades
[7510,7509,7508,7507,7506,3934,3935,3936,7511,3936, 3935,7502,3935,7503,7504,7503,3935,7505,3935]
end

def wl_lv3_tu_1
# Wehnimer's Landing Graveyard Skeletons, Ghouls, Phantoms
[7173,7174,7175,7176,7177,7178,7179,7180,7181,7183, 7181,7182,7174]
end

def wl_lv16_tu_1
# Whenimer's Landing Graveyard Ghoul Masters, Tomb Wights
[7207,7208,7249,7250,7248,7209,7210,7211,7212,7247, 7246,7214,7213,7212,7211,7210,7209,7248,7250,7249, 7208]
end

def wl_lv20_tu_1
# Whenimer's Landing Graveyard Arch Wights
[7225,7226,7227,7228,7231,7232,7235,7236,7237,7238, 7239,7240,7241,7240,7242,7240,7239,7238,7237,7236, 7235,7232,7233,7234,7228,7230]
end

# ========== Solhaven ==========

def sh_lv4_tl_1
# Solhaven Urghs
[5079,5360,5361,5363,5364,5362,5365,5366,5367,5365, 5362]
end

def sh_lv5_tu_1
# Solhaven Revenants and Mist Wraiths
[9344,9345,9346,9347,9371,9372,9373,9372,9371,9352, 9353,9354,9355,9354,9353,9352,9350,9351,9350,9348, 9349,9348,9347,9346,9345]
end

def sh_lv10_tu_1
# Solhaven Werebears
[9356,9357,9358,9359,9358,9360,9361,9362,9363,9364, 9365,9366,9367,9368,9369,9370,9369,9368,9367,9366, 9365,9364,9363,9362,9361,9360,9358,9357]
end

def wl_lv21_tu_1
# Wood Wights and Rotting Woodsmen
[9033,9034,9035,9036,9037,9038,9039,9040,9041,9042, 9043,9044,9045,9046,9047,9048,9049,9050,9051,9053, 9054,9053,9051,9052,9034]
end

# ------------------------------------------------------------------------------------------------------------
# CREATURES |
# ------------------------------------------------------------------------------------------------------------

def type_escortees
/^(?:traveller|magistrate|merchant|scribe|dignitary |official)$/
end
def type_bandits
/thief|rogue|bandit|mugger|outlaw|highwayman|maraud er|brigand|thug|robber/
end
def type_undead
/zombie rolton|lesser ghoul|skeleton|lesser frost shade|lesser shade|phantom|moaning phantom|ghost|ice skeleton|greater ghoul|revenant|mist wraith|dark apparition|lesser mummy|firephantom|spectral fisherman|bone golem|snow spectre|death dirge|werebear|darkwoode|spectre|shadowy spectre|wraith|tomb wight|wolfshade|ghoul master|ghost wolf|ghostly warrior|dark assassin|rotting krolvin pirate|elder ghoul master|nedum vereri|arch wight|wood wight|ancient ghoul master|nonomino|zombie|crazed zombie|rotting woodsman|roa'ter wormling|carceris|spectral monk|tree spirit|monastic lich|moaning spirit|elder tree spirit|krynch|skeletal ice troll|rotting corpse|rotting farmhand|ghostly mara|ghostly pooka|skeletal giant|rock troll zombie|skeletal soldier|spectral warrior|troll wraith|spectral shade|barghest|spectral woodsman|spectral lord|skeletal warhorse|lesser moor wight|shadow mare|shadow steed|vourkha|greater moor wight|forest bendith|spectral miner|bog wraith|skeletal lord|phantasma|frozen corpse|baesrukha|night mare|gaunt spectral servant|bog wight|ice wraith|lesser vruul|rotting chimera|dybbuk|necrotic snake|waern|banshee|flesh golem|seeker|ethereal mage apprentice|nightmare steed|eidolon|decaying Citadel guardsman|rotting Citadel arbalester|putrefied Citadel herald|phantasmal bestial swordsman|wind wraith|soul golem|greater vruul|naisirc|shrickhen|seraceris|lich qyn'arj|n'ecare|lost soul|vaespilon|spectral triton defender|ethereal triton sentry/
end
def type_living
/carrion worm|black rolton|black-winged daggerbeak|fanged rodent|kobold|mountain rolton|giant rat|slimy little grub|young grass snake|fire ant|rolton|spotted gnarp|giant ant|cave gnome|rabid squirrel|big ugly kobold|goblin|pale crab|fanged goblin|brown gak|thyril|spotted gak|sea nymph|Mistydeep siren|dark vysan|greater ice spider|fire salamander|cave nipper|kobold shepherd|relnak|striped relnak|cave gnoll|hobgoblin|Bresnahanini rolton|velnalin|spotted velnalin|striped gak|white vysan|mountain snowcat|troglodyte|black urgh|water moccasin|cobra|urgh|ridge orc|whiptail|spotted leaper|fanged viper|mongrel kobold|night golem|mongrel hobgoblin|bobcat|coyote|water witch|nasty little gremlin|monkey|spotted lynx|cockatrice|leaper|lesser orc|snowy cockatrice|blood eagle|lesser red orc|hobgoblin shaman|shelfae soldier|lesser burrow orc|greater kappa|greater spider|thrak|crystal crab|greater orc|greater burrow orc|albino tomb spider|mottled thrak|brown spinner|crocodile|manticore|rabid guard dog|great boar|raider orc|cave worm|gnoll worker|giant marmot|shelfae chieftain|Neartofar orc|wall guardian|crystal golem|dark orc|great stag|plumed cockatrice|tawny brindlecat|gnoll thief|deranged sentry|Agresh troll scout|forest troll|grey orc|silverback orc|great brown bear|brown boar|giant weasel|black boar|swamp troll|panther|ridgeback boar|luminescent arachnid|gnoll ranger|large ogre|puma|arctic puma|Neartofar troll|black leopard|humpbacked puma|black bear|Agresh troll warrior|mongrel wolfhound|plains orc warrior|cave troll|phosphorescent worm|hill troll|wind witch|fire guardian|mountain ogre|Agresh bear|mongrel troll|red bear|fire rat|banded rattlesnake|mountain troll|spiked cavern urchin|gnoll guard|giant veaba|plains ogre|forest ogre|mountain goat|black panther|dark shambler|plains orc scout|krolvin mercenary|cave lizard|war troll|fire cat|mountain lion|bighorn sheep|shelfae warlord|plains orc shaman|greenwing hornet|plains lion|thunder troll|krolvin warrior|steel golem|gnoll priest|ogre warrior|massive grahnk|major spider|Agresh troll chieftain|striped warcat|Arachne servant|cave bear|plains orc chieftain|cougar|warthog|crested basilisk|dark panther|centaur|fenghai|Arachne acolyte|tree viper|burly reiver|reiver|ice hound|wolverine|veteran reiver|arctic wolverine|giant albino scorpion|krolvin warfarer|gnoll jarl|jungle troll|Arachne priest|Arachne priestess|troll chieftain|cyclops|Grutik savage|lesser stone gargoyle|snow leopard|giant hawk-owl|fire ogre|dobrem|ki-lin|darken|pra'eda|Grutik shaman|ice troll|arctic manticore|scaly burgee|hooded figure|hisskra warrior|giant albino tomb spider|hunter troll|jungle troll chieftain|mammoth arachnid|ash hag|wild hound|caribou|wild dog|giant fog beetle|mezic|three-toed tegu|hisskra shaman|maw spore|moor hound|sand beetle|tundra giant|colossus vulture|hisskra chieftain|moor witch|cold guardian|lava troll|moor eagle|bog troll|shimmering fungus|water wyrd|snow crone|undertaker bat|dust beetle|krolvin slaver|fire giant|arctic titan|Sheruvian initiate|tusked ursian|huge mein golem|magru|mud wasp|grizzly bear|frost giant|wood sprite|krolvin corsair|vesperti|greater bog troll|stone gargoyle|storm giant|myklian|kiramon worker|lesser ice giant|Sheruvian monk|roa'ter|siren lizard|shan wizard|shan warrior|minor glacei|dark vortece|shan cleric|swamp hag|shan ranger|wasp nest|dreadnought raptor|forest trali shaman|firethorn shoot|polar bear|mastodonic leopard|lesser faeroth|kiramon defender|forest trali|cinder wasp|greater ice giant|major glacei|bog spectre|sand devil|warrior shade|horned vor'taz|red-scaled thrak|greater faeroth|snow madrinol|tomb troll|wooly mammoth|ice golem|lesser ice elemental|sabre-tooth tiger|stone sentinel|animated slush|skayl|tomb troll necromancer|stone troll|glacial morph|lava golem|stone giant|massive pyrothag|black forest viper|massive black boar|fire elemental|black forest ogre|stone mastiff|Illoke mystic|massive troll king|ice elemental|Sheruvian harbinger|grifflet|fire sprite|emaciated hierophant|red tsark|Illoke shaman|muscular supplicant|yeti|lesser griffin|hunch-backed dogmatist|krag yeti|fire mage|krag dweller|storm griffin|lesser minotaur|moulis|csetairi|minotaur warrior|farlook|raving lunatic|minotaur magus|dhu goleras|Vvrael witch|earth elemental|gnarled being|caedera|lesser construct|Vvrael warlock|greater krynch|gremlock|Illoke elder|festering taint|aivren|greater earth elemental|Ithzir scout|Illoke jarl|Ithzir initiate|water elemental|Ithzir janissary|Ithzir herald|triton dissembler|greater construct|Ithzir adept|triton executioner|siren|Ithzir seer|triton combatant|triton radical|war griffin|triton magus|greater water elemental/
end

def find_undead_target
GameObj.npcs.find { |npc| (npc.status.nil? || npc.status == 'lying down') && npc.name =~ type_undead }
end

def find_living_target
GameObj.npcs.find { |npc| (npc.status.nil? || npc.status == 'lying down') && npc.name =~ type_living }
end

# ------------------------------------------------------------------------------------------------------------
# REPORTS |
# ------------------------------------------------------------------------------------------------------------

def full_report
sleep 10
timer_report
monster_report
end

def monster_report
unless @num_of_hunts == 0
echo ".| ================================================== ================================================== ="
echo ".| ------------------------------------------Monster Report---------------------------------------------"
echo ".| ================================================== ================================================== ="
echo ".| Number of total hunting rounds:....................................| #{@num_of_hunts} "
echo ".| Number of Monsters defeated during script session:.................| #{@total_monsters_array.size} "
echo ".| Number of Monsters defeated during this last hunt:.................| #{@target_array.size} "
# Create a hash and iterate through each Monster hunted during the session
b = Hash.new(0)
@target_array.each do |v|
b[v] += 1
end
b.each do |k, v|
echo ".| Monster type killed:........................................... ....| => #{k.to_s.upcase} KIA #{v} Times "
end
if @voln == 'yes'
calculate_favor_spent_per_hunt
@total_favor_earned = (@total_monsters_array.size * calculate_favor_gained)
@total_favor_earned_per_hunt = (@target_array.size * calculate_favor_gained)
@total_favor_spent = @num_of_hunts.to_i * @favor_per_hunt.to_i
@favor_difference = @total_favor_earned - @total_favor_spent
echo ".| Total favor gained during this script session:.....................| #{@total_favor_earned} "
echo ".| Total favor gained during this last hunt:..........................| #{@total_favor_earned_per_hunt} "
echo ".| Total favor spent during this script session:......................| #{@total_favor_spent} "
echo ".| Total favor spent during this last hunt:...........................| #{@favor_per_hunt} "
echo ".| Total Favor Gained after costs:....................................| #{@favor_difference} "
end
echo ".| ================================================== ================================================== ="
echo ".| => End of Monster Report "
else
echo ".| ================================================== ================================================== ="
echo ".| You haven't started to hunt yet or you have not yet finished your first hunt. Wait please.. "
echo ".| Once you have hunted at least once and returned home, you can use the report command at any time. "
echo ".| Thanks from your always amiable fellow reporter! "
echo ".| ================================================== ================================================== ="
end
end

def timer_report
echo ".| ================================================== ================================================== ="
echo ".| Reporting Timer Status: #{@time} HH:MM:SS out of #{@time_end} HH:MM:SS. "
echo ".| ================================================== ================================================== ="
end

def help
echo ".| ================================================== ==========================================="
echo ".| ---------------------------------------- HELP ---------------------------------------------"
echo ".| ================================================== ==========================================="
echo ".| The information below mimics variables in the setup for smarthunt. Each eg. represents an "
echo ".| example given for a valid entry in one of the setting fields. You need to fill in all the "
echo ".| blanks. Do not leave anything empty. "
echo ".| __________________________________________________ ___________________________________________"
echo ".| Are you a Cleric?:........................| Determines whether or not to use cleric spells "
echo ".| Are you a Monk?:..........................| Determines whether or not to use monk spells "
echo ".| Are you unarmed?:.........................| Determines whether or not you are weaponless "
echo ".| What combat script do you want to use?:...| eg. smartmonk - input the name of the script "
echo ".| Hand Equipment (eg. handwraps):...........| Enter the noun. eg. handwraps | gloves "
echo ".| Foot Equipment (eg. footwraps):...........| Enter the noun. eg. footwraps | boots "
echo ".| Ready equipment before hunting?:..........| Uses ready weapon and ready shield so make sure "
echo ".| | that you have set these in the game! "
echo ".| Member of Voln?:..........................| Answers are: eg. yes | no "
echo ".| Are you hunting undead?:..................| If yes, script will only look for undead. "
echo ".| Auto Bless Hands and Feet?:...............| Automatically refreshes blessings. eg. yes | no "
echo ".| # sym of courage to use per hunt?:........| Number of uses (if eg. 4 will stack 4 times) "
echo ".| # sym of protect to use per hunt?:........| Number of uses (if eg. 2 will stack 2 times) "
echo ".| What buff script?:........................| Enter waggle or none or a custom script "
echo ".| CMANs to use during buffing?:.............| Separate by comma eg. slipperymind,surge,etc. "
echo ".| # of climbing ranks?:.....................| Used to determine whether you can climb gates "
echo ".| Default Loot Script:......................| Name of your loot script. eg. sloot | none "
echo ".| Enable Locksmith?:........................| Disable sloot locksmith and use mine instead! "
echo ".| | My locksmith empties the entire chest in the "
echo ".| | default loot container and also tries the "
echo ".| | secondary container for safety. "
echo ".| Default Loot Script Sell Command:.........| e.g. sell | none (if using sloot it is sell) "
echo ".| Primary Loot Bag:.........................| Used for locksmiths and other in-script "
echo ".| Secondary Loot Bag:.......................| Used for locksmiths and other in-script "
echo ".| % of Health before Herb Use (0.80):.......| Must be a float. eg. 0.80 = 80% of max health "
echo ".| Encumbrance Value Check (Def. 40):........| If encumbered hunt will end. Enter a number "
echo ".| | 10=light, 20=somewhat, 30=moderate "
echo ".| | 40=significant, 50=very significant "
echo ".| | 65=heavy, 80=very heavy, 100=extreme "
echo ".| Avg Monster Level to be Hunted:...........| Used for rough favor calculation: eg. 16 "
echo ".| Max minutes to use script:................| Can take any number of minutes. eg. 480 = 8 hrs "
echo ".| Minutes until timer reports:..............| Auto timer reporting. eg. 10 = every 10 minutes "
echo ".| Mana Driven Hunting?:.....................| Options are yes | no "
echo ".| End hunting when mana below amount:.......| If you enter 4 then whenever under 4 your hunt "
echo ".| | will end prematurely. "
echo ".| Start hunting when mind is this level:....| Enter an integer amount for the mind (def 40) "
echo ".| Stop hunting when mind is this level:.....| Enter an integer amount for the mind (def 100) "
echo ".| | 40 = fresh and clear and 100 is maxxed. "
echo ".| Top off spells when resting and mind lvl..| Enter an integer amount or the word none "
echo ".| | If you enter none this feature is turned off. "
echo ".| | If an integer, default buff script will be used."
echo ".| | Recommended is to set this at 62 (muddled) "
echo ".| Eat bread before sleeping or meditating?:.| Yes or No "
echo ".| Spell number for bread?:..................| 203, etc."
echo ".| Rooms Array (e.g. 1201,1203,1205,etc):....| First room is start of hunt. Separate others by "
echo ".| | commas. e.g. 1201,1203,1205,1219 means that "
echo ".| | 1201 is the start of your hunting route and "
echo ".| | 1219 means that is the end of your hunting "
echo ".| | route. The next room at the end should lead "
echo ".| | back to the start so 1219 should connect to "
echo ".| | 1201. "
echo ".| Safe Room:................................| If injured badly during hunting, the script will"
echo ".| | take you to this room so you can herbuse. "
echo ".| Rooms Array (home,bank,gems,pawn,lock):...| First room is home, second is bank, third is "
echo ".| | gemshop, fourth is pawnshop, and last is "
echo ".| | locksmith. Locksmith for WL has unique ring "
echo ".| | bell script in shop so be careful. "
echo ".| Movement speed? (slow, medium, fast):.....| slow (sleep 3 seconds), medium (sleep 1 second) "
echo ".| Show help and pause at start of script?:..| yes | no - Shows this screen at start "
echo ".| ================================================== ==========================================="
end

def hunting_area_reports
echo ".| ================================================== ==========================================="
echo ".| --------------------------------------- HUNTING -------------------------------------------"
echo ".| ================================================== ==========================================="
echo ".| Below is a listing of default custom areas that you can add to the Rooms Array field in the "
echo ".| hunting tab. Just place the Code below and that is it! If you want to assist and make this "
echo ".| script better you can create your custom routes and add them to the forum. "
echo ".| See : http://forum.gsplayers.com/showthread.php?90399-Introducing-SmartHunt "
echo ".| The level of each monster listed below is after the _lv code so _lv3 = level 3, _lv10 = 10 "
echo ".| __________________________________________________ ___________________________________________"
echo ".| ---------- CODE ---------- | ------------------------- DESCRIPTION --------------------------"
echo ".| wl_lv3_tl_1 | Wehnimers Landing Thyrils, Relnaks "
echo ".| wl_lv3_tl_2 | Wehnimers Landing Coastal Cliff Vysans "
echo ".| wl_lv1_tu_1 | Wehnimers Landing Sewers Lesser Shades "
echo ".| wl_lv3_tu_1 | Wehnimers Landing Graveyard Skeletons, Ghouls, Phantoms "
echo ".| wl_lv16_tu_1 | Wehnimers Landing Graveyard Ghoul Masters, Tomb Wights "
echo ".| wl_lv20_tu_1 | Wehnimers Landing Graveyard Arch Wights "
echo ".| sh_lv4_tl_1 | Solhaven Urghs "
echo ".| sh_lv5_tu_1 | Solhaven Revenants and Mist Wraiths "
echo ".| sh_lv10_tu_1 | Solhaven Werebears "
echo ".| wl_lv21_tu_1 | Solhaven Wood Wights, Rotting Woodsmen "
echo ".| ================================================== ==========================================="
end

def gui
Gtk.queue {
$SHUNT_WINDOW = Gtk::Window.new
$SHUNT_WINDOW.title = $TITLE
$SHUNT_WINDOW.set_border_width(10)
$SHUNT_BOX = Gtk::VBox.new(false)
$SHUNT_BOX.set_border_width(5)

$SHUNT_VERTICAL_BOX1 = Gtk::VBox.new(false, 0) # Configuration Settings
$SHUNT_VERTICAL_BOX2 = Gtk::VBox.new(false, 0) # Hunting Options
$SHUNT_VERTICAL_BOX3 = Gtk::VBox.new(false, 0) # Mappable Options
$SHUNT_VERTICAL_BOX4 = Gtk::VBox.new(false, 0) # Melee Options
$SHUNT_VERTICAL_BOX5 = Gtk::VBox.new(false, 0) # Casting Options
$SHUNT_VERTICAL_BOX6 = Gtk::VBox.new(false, 0) # Class Specific
$SHUNT_VERTICAL_BOX7 = Gtk::VBox.new(false, 0) # Voln Options

$SHUNT_WINDOW.add($SHUNT_BOX)
$SHUNT_NOTEBOOK = Gtk::Notebook.new
$SHUNT_NOTEBOOK.set_show_border(true)
$SHUNT_BOX.add($SHUNT_NOTEBOOK)
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX1, Gtk::Label.new(' Main '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX2, Gtk::Label.new(' Hunting '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX3, Gtk::Label.new(' Mappable '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX4, Gtk::Label.new(' Melee '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX5, Gtk::Label.new(' Casting '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX6, Gtk::Label.new(' Classes '))
$SHUNT_NOTEBOOK.append_page($SHUNT_VERTICAL_BOX7, Gtk::Label.new(' Voln '))

$SHUNT_ENTRY = Hash.new
$SHUNT_TABLE_SIZE = Hash.new
}

Gtk.queue {
$SHUNT_TABLE1 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE1.row_spacings=2
$SHUNT_TABLE1.column_spacings=2
$SHUNT_VERTICAL_BOX1.pack_start($SHUNT_TABLE1, false, false, 0)

$SHUNT_TABLE2 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE2.row_spacings=2
$SHUNT_TABLE2.column_spacings=2
$SHUNT_VERTICAL_BOX2.pack_start($SHUNT_TABLE2, false, false, 0)

$SHUNT_TABLE3 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE3.row_spacings=2
$SHUNT_TABLE3.column_spacings=2
$SHUNT_VERTICAL_BOX3.pack_start($SHUNT_TABLE3, false, false, 0)

$SHUNT_TABLE4 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE4.row_spacings=2
$SHUNT_TABLE4.column_spacings=2
$SHUNT_VERTICAL_BOX4.pack_start($SHUNT_TABLE4, false, false, 0)

$SHUNT_TABLE5 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE5.row_spacings=2
$SHUNT_TABLE5.column_spacings=2
$SHUNT_VERTICAL_BOX5.pack_start($SHUNT_TABLE5, false, false, 0)

$SHUNT_TABLE6 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE6.row_spacings=2
$SHUNT_TABLE6.column_spacings=2
$SHUNT_VERTICAL_BOX6.pack_start($SHUNT_TABLE6, false, false, 0)

$SHUNT_TABLE7 = Gtk::Table.new(4, 1, false)
$SHUNT_TABLE7.row_spacings=2
$SHUNT_TABLE7.column_spacings=2
$SHUNT_VERTICAL_BOX7.pack_start($SHUNT_TABLE7, false, false, 0)
}

def self.add_label_entry(table, label, variable, entry_width=250)
size = $SHUNT_TABLE_SIZE[table] || 0

label = Gtk::Label.new(label)
align = Gtk::Alignment.new 1, 0, 0, 0
align.set_padding(4, 0, 3, 4)
align.add(label)
table.attach(align, 0, 1, size, size + 1)

entry = Gtk::Entry.new
entry.text = UserVars.smarthunt[variable].to_s
entry.set_width_request(entry_width)
table.attach(entry, 1, 2, size, size + 1)

$SHUNT_ENTRY[variable] = entry
$SHUNT_TABLE_SIZE[table] += 1
end

Gtk.queue {
$SHUNT_ENTRY = Hash.new

add_label_entry($SHUNT_TABLE1, " Equipment Name (hands):.......| ", 'sm_hands')
add_label_entry($SHUNT_TABLE1, " Equipment Name (feet):.......| ", 'sm_feet')
add_label_entry($SHUNT_TABLE1, " # of Climbing Ranks?:.......| ", 'sm_climbing_skill')
add_label_entry($SHUNT_TABLE1, " Show help and pause at start of script?:.......| ", 'sm_show_help_and_pause')
add_label_entry($SHUNT_TABLE1, " Default Loot Script:.......| ", 'sm_loot_script')
add_label_entry($SHUNT_TABLE1, " Default Loot Script Sell Command:.......| ", 'sm_loot_script_sell')
add_label_entry($SHUNT_TABLE1, " Enable private locksmith?:.......| ", 'sm_enable_locksmith')
add_label_entry($SHUNT_TABLE1, " Primary Loot Bag:.......| ", 'sm_primary_bag')
add_label_entry($SHUNT_TABLE1, " Secondary Loot Bag:.......| ", 'sm_secondary_bag')

add_label_entry($SHUNT_TABLE2, " What combat script do you want to use?:.......| ", 'sm_combat_script')
add_label_entry($SHUNT_TABLE2, " What buff script? (eg. waggle | none):.......| ", 'sm_buff_script')
add_label_entry($SHUNT_TABLE2, " Ready weapon/shield before hunt?:.......| ", 'sm_ready_equipment')
add_label_entry($SHUNT_TABLE2, " Are you hunting undead only?:.......| ", 'sm_undead')
add_label_entry($SHUNT_TABLE2, " Avg Monster Level to be Hunted:.......| ", 'sm_monster_level')
add_label_entry($SHUNT_TABLE2, " Start hunting when mind is this level:.......| ", 'sm_mind_start_hunting')
add_label_entry($SHUNT_TABLE2, " Stop hunting when mind is this level:.......| ", 'sm_mind_stop_hunting')
add_label_entry($SHUNT_TABLE2, " Top off spells when mind is this level:.......| ", 'sm_waggle_when_mind')
add_label_entry($SHUNT_TABLE2, " Encumbrance Value Check (Def. 40):.......| ", 'sm_encumbrance_value')
add_label_entry($SHUNT_TABLE2, " % of Health before Herb Use (0.80):.......| ", 'sm_safe_health')
add_label_entry($SHUNT_TABLE2, " Max minutes to use script:.......| ", 'sm_minutes_to_hunt')
add_label_entry($SHUNT_TABLE2, " Minutes until timer reports:.......| ", 'sm_minutes_for_report')

add_label_entry($SHUNT_TABLE3, " Enter Rooms to hunt (sep by comma):.......| ", 'sm_rooms_array')
add_label_entry($SHUNT_TABLE3, " Enter Rooms for local (sep by comma):.......| ", 'sm_rooms_array_core')
add_label_entry($SHUNT_TABLE3, " Enter a safe room while hunting (herbuse):.......| ", 'sm_rooms_safe')
add_label_entry($SHUNT_TABLE3, " Movement speed? (slow,medium,fast):.......| ", 'sm_movement_speed')

add_label_entry($SHUNT_TABLE4, " Are you unarmed?:.......| ", 'sm_ami_unarmed')
add_label_entry($SHUNT_TABLE4, " CMANs during buffing? (sep by comma):.......| ", 'sm_buff_cmans')

add_label_entry($SHUNT_TABLE5, " Mana Driven Hunting?:.......| ", 'sm_need_mana_to_hunt')
add_label_entry($SHUNT_TABLE5, " End hunting when mana is below this amount:.......| ", 'sm_amount_of_mana')
add_label_entry($SHUNT_TABLE5, " Eat bread before sleeping or meditating?:.......| ", 'sm_use_bread')
add_label_entry($SHUNT_TABLE5, " What spell number to use for bread?:.......| ", 'sm_use_bread_spellnum')

add_label_entry($SHUNT_TABLE6, " Are you a monk?:.......| ", 'sm_ami_monk')
add_label_entry($SHUNT_TABLE6, " Are you a cleric?:.......| ", 'sm_ami_cleric')

add_label_entry($SHUNT_TABLE7, " Member of Voln:.......| ", 'sm_voln')
add_label_entry($SHUNT_TABLE7, " Auto Bless Hands and Feet?:.......| ", 'sm_autobless')
add_label_entry($SHUNT_TABLE7, " # sym of courage to use per hunt?:.......| ", 'sm_courage')
add_label_entry($SHUNT_TABLE7, " # sym of protect to use per hunt?:.......| ", 'sm_protect')
}

Gtk.queue {
$SHUNT_WINDOW.signal_connect("delete_event") {
$SHUNT_SETUP_COMPLETED = true
}
}

Gtk.queue {
$SHUNT_WINDOW.show_all
}

$SHUNT_SETUP_COMPLETED = false
until($SHUNT_SETUP_COMPLETED)
sleep 1
end

UserVars.smarthunt ||= Hash.new
$SHUNT_ENTRY.keys.each { |key|
UserVars.smarthunt[key] = $SHUNT_ENTRY[key].text.strip.downcase
}
UserVars.save()

Gtk.queue {
$SHUNT_WINDOW.destroy
}
end

end

combat = SmartHunt.new(variable)



Let me know if you find any major issues.

Enjoy.

Tgo01
05-18-2014, 01:08 PM
Looks pretty gosh darn sexy.

Yasutoshi
05-19-2014, 12:56 PM
Now updated to rev. 1.1.1.

I fixed quite a few issues and also added my own locksmith routine.

If you run ;smarthunt setup you can type 'yes', 'no', or leave it blank. If yes, then before it runs any type of sell script (like ';sloot sell'), it will do the locksmith routine first. It will withdraw 10,000 from the bank and visit the locksmith. If you use my feature, don't enable sloot's locksmith feature. Why this addition? I didn't like that Sloot was pulling things out of the boxes one at a time and twice it was trying to throw away boxes that had very valuable jewelry inside. My script "empties the entire box" in your primary bag and secondary bags. It checks both primary and secondary bags for boxes. It's fast and clean.

Yasutoshi
05-20-2014, 01:40 PM
Now updated to rev. 1.2.0.


Updated the box selling script.
Added new setup fields for mana users and spell casters
Fixed a few issues with ending hunting and going back home.


I also uploaded a new combat script to the repo called "SmartSorcerer". It can be used by spell casters.

Enjoy.

sperry85
05-20-2014, 09:32 PM
So went to try this out only to find that I fail at getting anything other than the ruby provided on the lich page to work for lich. Downloaded from http://rubyinstaller.org/downloads/. Tried the 1.9.3, 2.0.0, and 2.0.0(x64). Uninstalled 1.8.7 before installing any of the others.

After installing new ones, i would right click on lich.rbw -> open with, then navigate to the bin/rubyw.exe. But it will not actually load as an option to open the file with. Double clicking on lich.rbw gives me the little hourglass symbol for a few seconds then nothing.

Have administer rights. Win7 Ultimate SP1 (64).

C:\Program Files (x86)\SIMU\lich\lich.rbw
C:\Program Files (x86)\Ruby-2.0.0\rubyw.exe

Yasutoshi
05-20-2014, 09:44 PM
So went to try this out only to find that I fail at getting anything other than the ruby provided on the lich page to work for lich. Downloaded from http://rubyinstaller.org/downloads/. Tried the 1.9.3, 2.0.0, and 2.0.0(x64). Uninstalled 1.8.7 before installing any of the others.

After installing new ones, i would right click on lich.rbw -> open with, then navigate to the bin/rubyw.exe. But it will not actually load as an option to open the file with. Double clicking on lich.rbw gives me the little hourglass symbol for a few seconds then nothing.

Have administer rights. Win7 Ultimate SP1 (64).

C:\Program Files (x86)\SIMU\lich\lich.rbw
C:\Program Files (x86)\Ruby-2.0.0\rubyw.exe

Let's back up.


Uninstall that version.
Install the Ruby 2.0.0 (32-bit) (because gems compile and work with 32-bit and some do not work with 64-bit)
Install the Ruby 2.0 Devkit (located on the same page you linked)
Follow the instructions for installing the Devkit
Drop down to a command prompt and type "ruby -v". It should show the correct version of ruby 2.0.0 etc.
Type "gem install gtk2".
To confirm that it works, type "irb" and hit enter. You just entered interactive ruby shell.
type require 'gtk2' and hit enter. You should receive => True. Great!


Now, the version of lich that ships does some really dumb things with your registry. So, to fix that, do the following:

Open regedit.


Go to \\HKEY_CLASSES_ROOT\RubyScript\shell\open\command
Change the default path to the correct path for your newly installed ruby. If you installed it in C:\Ruby200 then you put:
Default => "C:\ruby200\bin\ruby.exe" "%1"



Go to \\HKEY_CLASSES_ROOT\RubyWFile\shell\open\command
Change the default path to the correct path for your newly installed ruby. If you installed it in C:\Ruby200 then you put:
Default => "C:\Ruby200\bin\rubyw.exe" "%1" %*


Done. Try it now...

sperry85
05-20-2014, 10:42 PM
Worked perfectly. Thanks.

Yasutoshi
05-20-2014, 11:17 PM
Great to hear. :)

Yasutoshi
05-21-2014, 01:24 PM
Updated to 1.3.0

Added 3 new variables so make sure you re-run ;smarthunt setup to configure those.



echo ".| Start hunting when mind is this level:....| Enter an integer amount for the mind (def 40) "
echo ".| Stop hunting when mind is this level:.....| Enter an integer amount for the mind (def 100) "
echo ".| | 40 = fresh and clear and 100 is maxxed. "
echo ".| Top off spells when resting and mind lvl..| Enter an integer amount or the word none "
echo ".| | If you enter none this feature is turned off. "
echo ".| | If an integer, default buff script will be used."
echo ".| | Recommended is to set this at 62 (muddled) "


So now you can customize when to start and stop hunting and you can also use your own buff script (eg. waggle) to pre-buff while resting.

Yasutoshi
05-21-2014, 02:47 PM
Updated to 1.3.3

Added several fixes with sleep modes.

Yasutoshi
05-25-2014, 02:36 PM
SmartHunt updated to version 1.4.1

A lot of changes here so definitely make sure you run ;smarthunt setup


Updated the GUI so that it is now tabbed to make it easier to navigate.
The GUI will constantly advance going forward until it is pretty - will include combo boxes, radio menus, etc.
Made the entire script faster. Set it initially slower to diagnose and test but now it is faster.
Added a new custom hunting menu. Type ;askgenie hunting to see the list. You can help contribute.
Started adding in custom class areas like Monk, Cleric, etc.
There's now a post-hunt section for bread/meditate.
There's a new mappable area to enter a safe room. If severely hurt, you will run to the safe room before herbing.
Look over the entire setup and make sure you fill in everything. Later on it will be easier but for now if you feel you should not answer yes in a field that asks you a question, place no or none or 0.


If you have questions let me know.

Yasutoshi
05-26-2014, 02:33 PM
SmartHunt updated to version 1.4.4


Added movement speed to the script.
Under mappable set it for slow, medium, or fast
slow = 3 seconds delay, medium = 1 second delay, fast = no delay
Fixed some targeting bugs
Fixed the GY cast script thread.

CaptContagious
05-27-2014, 11:50 AM
Let's back up.


Uninstall that version.
Install the Ruby 2.0.0 (32-bit) (because gems compile and work with 32-bit and some do not work with 64-bit)
Install the Ruby 2.0 Devkit (located on the same page you linked)
Follow the instructions for installing the Devkit
Drop down to a command prompt and type "ruby -v". It should show the correct version of ruby 2.0.0 etc.
Type "gem install gtk2".
To confirm that it works, type "irb" and hit enter. You just entered interactive ruby shell.
type require 'gtk2' and hit enter. You should receive => True. Great!


Now, the version of lich that ships does some really dumb things with your registry. So, to fix that, do the following:

Open regedit.


Go to \\HKEY_CLASSES_ROOT\RubyScript\shell\open\command
Change the default path to the correct path for your newly installed ruby. If you installed it in C:\Ruby200 then you put:
Default => "C:\ruby200\bin\ruby.exe" "%1"



Go to \\HKEY_CLASSES_ROOT\RubyWFile\shell\open\command
Change the default path to the correct path for your newly installed ruby. If you installed it in C:\Ruby200 then you put:
Default => "C:\Ruby200\bin\rubyw.exe" "%1" %*


Done. Try it now...

So after trying this... Stormfront still won't load for me though the SGE.

Yasutoshi
05-27-2014, 11:13 PM
So after trying this... Stormfront still won't load for me though the SGE.

I'd have to know your setup in order to help.

What ruby version shows up when you type ruby -v from a command prompt?
If you type gem list from a command prompt, do you have the gtk2 gem?
If you go to irb from a command prompt and type require 'gtk2' what is the output?
Where is your ruby version located? In what directory?
Where is your lich located? In what directory?

Provide some information and I can assist you better.

Thanks!

Soulance
05-27-2014, 11:20 PM
I'm having the same issue as well Yasu. Here's my readout when I follow the steps.

*** LOCAL GEMS ***

atk (2.2.0 x86-mingw32)
bigdecimal (1.2.0)
cairo (1.12.9 x86-mingw32)
glib2 (2.2.0 x86-mingw32)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (4.3.2)
pango (2.2.0 x86-mingw32)
pkg-config (1.1.5)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
test-unit (2.0.0.0)

C:\>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require 'gtk2'
LoadError: cannot load such file -- gtk2
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
from (irb):1
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):002:0>
It's installed in \ruby200 and the Dev Kit is in \ruby200\devkit

Yasutoshi
05-28-2014, 11:31 AM
you need to install gtk2.

From a command prompt type:

gem install gtk2

Then test that it works:

From a command prompt type irb.

require 'gtk2'

ROTOR
05-28-2014, 12:40 PM
Would like to try this script. How do I update ruby on a mac. Currently running 1.8.7.

Soulance
05-28-2014, 12:56 PM
When I go to install gtk2 it gives me...

C:\>gem list

*** LOCAL GEMS ***

atk (2.2.0 x86-mingw32)
bigdecimal (1.2.0)
cairo (1.12.9 x86-mingw32)
glib2 (2.2.0 x86-mingw32)
io-console (0.4.2)
json (1.8.1, 1.7.7)
minitest (4.3.2)
pango (2.2.0 x86-mingw32)
pkg-config (1.1.5)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
test-unit (2.0.0.0)

C:\>gem install gtk2
ERROR: While executing gem ... (NoMethodError)
undefined method `size' for nil:NilClass

Yasutoshi
05-28-2014, 10:42 PM
Here are my reg settings in case someone needs them. Keep in mind the location of my ruby version may be different from yours:

657465756576

zinzimir
05-29-2014, 10:07 PM
So after trying this... Stormfront still won't load for me though the SGE.

Remove your SGE and reinstall from Simu download...this worked for me.