Yasutoshi
05-20-2014, 02:02 PM
Added the makings of a combat script for spell weavers / spell casters. It's called SmartSorcerer. It can be used with SmartHunt now or it can be run independently. Make sure you have downloaded the latest versions. You can use this with any spellcaster as it primarily allows you to specify your primary and secondary attack spells, mana costs, whether or not you want to use wands, etc.
Run ;smartsorcerer setup for more details.
Script Version 3.1.0
=begin
Script SmartSorcerer
Author Yasutoshi, Monk
Date May 20 2014
Version 3.1.0
Description Can be used on its own or with a hunting wrapper like smarthunt (;repo download smarthunt)
Scripts Needed none
SETUP
.................| Command: ;smartsorcerer setup
=end
VERSION = '3.1.0'
$TITLE = "SmartSorcerer: v. (#{VERSION})"
class SmartSorcerer
attr_accessor :variable, :debug
def initialize(variable, debug=0)
@msg = nil
@target = nil
@my_status = nil
@debug = debug
@variable = variable
@mode = "none"
silence_me if @debug == 0
@variable[1] == 'setup' ? setup : start
end
def setup
gui
echo "..........| Settings Saved!"
echo ""
echo "..........| Primary Attack Spell: #{UserVars.smartsorcerer['sorc_primary_spell']}"
echo "..........| Secondary Attack Spell: #{UserVars.smartsorcerer['sorc_secondary_spell']}"
echo "..........| Primary Spell Mana: #{UserVars.smartsorcerer['sorc_primary_spell_mana']} | Secondary Spell Mana: #{UserVars.smartsorcerer['sorc_secondary_spell_mana']}"
echo "..........| - Make sure you only place wands you want to use in your wand bag. -"
echo "..........| Primary Wand Bag: #{UserVars.smartsorcerer['sorc_primary_bag']}"
echo "..........| Use Wands during Hunting?: #{UserVars.smartsorcerer['sorc_use_wands']}"
echo "..........| At what mana do you use wands?: #{UserVars.smartsorcerer['sorce_use_wands_mana']}"
echo "..........| - If you don't want to use a loot script, specify the word none -"
echo "..........| Default Loot Script: #{UserVars.smartsorcerer['sorc_loot_script']}"
end
def shutdown
Script.self.kill
end
def creature_status(fromwhere)
echo "#{fromwhere}: Status of Creature is: #{@target.status}"
end
def start
get_custom_settings
@target = GameObj.npcs.find { |npc| npc.status.nil? }
if @target
open_attack
@msg = check_match_conditions
echo "start method and msg = #{@msg}" if @debug == 1
fight_on
else
shutdown
end
end
def get_custom_settings
if (UserVars.smartsorcerer['sorc_primary_spell']) && (UserVars.smartsorcerer['sorc_primary_spell_mana'])
# setup has been completed
else
@variable = nil
setup
end
end
def check_match_conditions
return matchwait('Cast at what?','It looks like somebody already','What were you referring to?', '(Forcing stance down to guarded)', "have a spell prepared!" ,'Roundtime')
end
def get_wand
wand_bag = [GameObj[UserVars.smartsorcerer['sorc_primary_bag']]]
wand_bag.each { |bag|
if (wands = bag.contents.find_all { |o| o.type.include?('wand') })
wands.each do |wand|
fput "get #{wand} from my #{bag}" and return
end
else
return
end
}
end
def check_wand
if GameObj.right_hand.to_s == 'wand'
true
else
get_wand
end
end
def wand_routine
# echo "Started wand routine"
check_wand
if (GameObj.right_hand.to_s == 'wand') && (UserVars.smartsorcerer['sorc_use_wands'] == 'yes')
fput "wave my wand at ##{@target.id}"
waitcastrt?
else
primary_spell
end
end
def primary_spell
if checkmana UserVars.smartsorcerer['sorc_primary_spell_mana'].to_i
fput "prep #{UserVars.smartsorcerer['sorc_primary_spell']}"
fput "cast ##{@target.id}"
else
secondary_spell
end
end
def secondary_spell
if checkmana UserVars.smartsorcerer['sorc_secondary_spell_mana'].to_i
fput "prep #{UserVars.smartsorcerer['sorc_secondary_spell']}"
fput "cast ##{@target.id}"
else
shutdown
end
end
def what_spell_to_cast
# creature_status('what_spell_to_cast')
if (@target.status != 'dead') && (@target.status != 'gone')
# echo "#{checkmana} and #{UserVars.smartsorcerer['sorce_use_wands_mana'].to_i}"
if checkmana <= UserVars.smartsorcerer['sorce_use_wands_mana'].to_i
wand_routine
else
primary_spell
end
else
if @target.status == 'gone'
shutdown
else
return
end
end
end
def open_attack
what_spell_to_cast
waitcastrt?
@msg = check_match_conditions
fput "stance defensive"
fight_on
end
def loot_em_up
if GameObj.right_hand.to_s == 'wand'
sleep 1
fput "put my wand in my #{UserVars.smartsorcerer['sorc_primary_bag']}"
end
unless UserVars.smartsorcerer['sorc_loot_script'] == 'none'
start_scripts "#{UserVars.smartsorcerer['sorc_loot_script']}"
wait_while {running? "#{UserVars.smartsorcerer['sorc_loot_script']}"}
else
shutdown
end
end
def fight_on
# creature_status('fight_on')
if @target.status == 'dead'
fput "stance defensive"
loot_em_up
elsif ( @msg =~ /It looks like somebody already did the job for you./ )
fput "stance defensive"
loot_em_up
elsif ( @msg =~ /What were you referring to?/ )
fput "stance defensive"
shutdown
elsif ( @msg =~ /Cast at what?/ )
fput "stance defensive"
fput "release"
shutdown
elsif ( @msg =~ /You don't have a spell prepared!/ )
sleep 3
open_attack
else
open_attack
end
end
def gui
Gtk.queue {
$SORC_WINDOW = Gtk::Window.new
$SORC_WINDOW.title = $TITLE
$SORC_WINDOW.set_border_width(10)
$SORC_BOX = Gtk::VBox.new(false)
$SORC_BOX.set_border_width(5)
$SORC_VERTICAL_BOX1 = Gtk::VBox.new(false, 0)
$SORC_WINDOW.add($SORC_BOX)
$SORC_NOTEBOOK = Gtk::Notebook.new
$SORC_NOTEBOOK.set_show_border(true)
$SORC_BOX.add($SORC_NOTEBOOK)
$SORC_NOTEBOOK.append_page($SORC_VERTICAL_BOX1, Gtk::Label.new(' Configuration Settings '))
$SORC_ENTRY = Hash.new
$SORC_TABLE_SIZE = Hash.new
}
Gtk.queue {
$SORC_TABLE1 = Gtk::Table.new(4, 1, false)
$SORC_TABLE1.row_spacings=2
$SORC_TABLE1.column_spacings=2
$SORC_VERTICAL_BOX1.pack_start($SORC_TABLE1, false, false, 0)
}
def self.add_label_entry(table, label, variable)
size = $SORC_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.smartsorcerer[variable].to_s
entry.set_width_request(157)
table.attach(entry, 1, 2, size, size + 1)
$SORC_ENTRY[variable] = entry
$SORC_TABLE_SIZE[table] += 1
end
Gtk.queue {
$SORC_ENTRY = Hash.new
add_label_entry($SORC_TABLE1, " Default Attack Spell.........| ", 'sorc_primary_spell')
add_label_entry($SORC_TABLE1, " Mana Cost of Primary.........| ", 'sorc_primary_spell_mana')
add_label_entry($SORC_TABLE1, " Secondary Attack Spell.........| ", 'sorc_secondary_spell')
add_label_entry($SORC_TABLE1, " Mana Cost of Secondary.........| ", 'sorc_secondary_spell_mana')
add_label_entry($SORC_TABLE1, " Primary Wand Bag........| ", 'sorc_primary_bag')
add_label_entry($SORC_TABLE1, " Use wands during hunt?:.......| ", 'sorc_use_wands')
add_label_entry($SORC_TABLE1, " At what mana target do you (use wands?):.......| ", 'sorce_use_wands_mana')
add_label_entry($SORC_TABLE1, " Default Loot ScriptL........| ", 'sorc_loot_script')
}
Gtk.queue {
$SORC_WINDOW.signal_connect("delete_event") {
$SORC_SETUP_COMPLETED = true
}
}
Gtk.queue {
$SORC_WINDOW.show_all
}
$SORC_SETUP_COMPLETED = false
until($SORC_SETUP_COMPLETED)
sleep 1
end
UserVars.smartsorcerer ||= Hash.new
$SORC_ENTRY.keys.each { |key|
UserVars.smartsorcerer[key] = $SORC_ENTRY[key].text.strip.downcase
}
UserVars.save()
Gtk.queue {
$SORC_WINDOW.destroy
}
end
end
combat = SmartSorcerer.new(variable)
Enjoy.
Run ;smartsorcerer setup for more details.
Script Version 3.1.0
=begin
Script SmartSorcerer
Author Yasutoshi, Monk
Date May 20 2014
Version 3.1.0
Description Can be used on its own or with a hunting wrapper like smarthunt (;repo download smarthunt)
Scripts Needed none
SETUP
.................| Command: ;smartsorcerer setup
=end
VERSION = '3.1.0'
$TITLE = "SmartSorcerer: v. (#{VERSION})"
class SmartSorcerer
attr_accessor :variable, :debug
def initialize(variable, debug=0)
@msg = nil
@target = nil
@my_status = nil
@debug = debug
@variable = variable
@mode = "none"
silence_me if @debug == 0
@variable[1] == 'setup' ? setup : start
end
def setup
gui
echo "..........| Settings Saved!"
echo ""
echo "..........| Primary Attack Spell: #{UserVars.smartsorcerer['sorc_primary_spell']}"
echo "..........| Secondary Attack Spell: #{UserVars.smartsorcerer['sorc_secondary_spell']}"
echo "..........| Primary Spell Mana: #{UserVars.smartsorcerer['sorc_primary_spell_mana']} | Secondary Spell Mana: #{UserVars.smartsorcerer['sorc_secondary_spell_mana']}"
echo "..........| - Make sure you only place wands you want to use in your wand bag. -"
echo "..........| Primary Wand Bag: #{UserVars.smartsorcerer['sorc_primary_bag']}"
echo "..........| Use Wands during Hunting?: #{UserVars.smartsorcerer['sorc_use_wands']}"
echo "..........| At what mana do you use wands?: #{UserVars.smartsorcerer['sorce_use_wands_mana']}"
echo "..........| - If you don't want to use a loot script, specify the word none -"
echo "..........| Default Loot Script: #{UserVars.smartsorcerer['sorc_loot_script']}"
end
def shutdown
Script.self.kill
end
def creature_status(fromwhere)
echo "#{fromwhere}: Status of Creature is: #{@target.status}"
end
def start
get_custom_settings
@target = GameObj.npcs.find { |npc| npc.status.nil? }
if @target
open_attack
@msg = check_match_conditions
echo "start method and msg = #{@msg}" if @debug == 1
fight_on
else
shutdown
end
end
def get_custom_settings
if (UserVars.smartsorcerer['sorc_primary_spell']) && (UserVars.smartsorcerer['sorc_primary_spell_mana'])
# setup has been completed
else
@variable = nil
setup
end
end
def check_match_conditions
return matchwait('Cast at what?','It looks like somebody already','What were you referring to?', '(Forcing stance down to guarded)', "have a spell prepared!" ,'Roundtime')
end
def get_wand
wand_bag = [GameObj[UserVars.smartsorcerer['sorc_primary_bag']]]
wand_bag.each { |bag|
if (wands = bag.contents.find_all { |o| o.type.include?('wand') })
wands.each do |wand|
fput "get #{wand} from my #{bag}" and return
end
else
return
end
}
end
def check_wand
if GameObj.right_hand.to_s == 'wand'
true
else
get_wand
end
end
def wand_routine
# echo "Started wand routine"
check_wand
if (GameObj.right_hand.to_s == 'wand') && (UserVars.smartsorcerer['sorc_use_wands'] == 'yes')
fput "wave my wand at ##{@target.id}"
waitcastrt?
else
primary_spell
end
end
def primary_spell
if checkmana UserVars.smartsorcerer['sorc_primary_spell_mana'].to_i
fput "prep #{UserVars.smartsorcerer['sorc_primary_spell']}"
fput "cast ##{@target.id}"
else
secondary_spell
end
end
def secondary_spell
if checkmana UserVars.smartsorcerer['sorc_secondary_spell_mana'].to_i
fput "prep #{UserVars.smartsorcerer['sorc_secondary_spell']}"
fput "cast ##{@target.id}"
else
shutdown
end
end
def what_spell_to_cast
# creature_status('what_spell_to_cast')
if (@target.status != 'dead') && (@target.status != 'gone')
# echo "#{checkmana} and #{UserVars.smartsorcerer['sorce_use_wands_mana'].to_i}"
if checkmana <= UserVars.smartsorcerer['sorce_use_wands_mana'].to_i
wand_routine
else
primary_spell
end
else
if @target.status == 'gone'
shutdown
else
return
end
end
end
def open_attack
what_spell_to_cast
waitcastrt?
@msg = check_match_conditions
fput "stance defensive"
fight_on
end
def loot_em_up
if GameObj.right_hand.to_s == 'wand'
sleep 1
fput "put my wand in my #{UserVars.smartsorcerer['sorc_primary_bag']}"
end
unless UserVars.smartsorcerer['sorc_loot_script'] == 'none'
start_scripts "#{UserVars.smartsorcerer['sorc_loot_script']}"
wait_while {running? "#{UserVars.smartsorcerer['sorc_loot_script']}"}
else
shutdown
end
end
def fight_on
# creature_status('fight_on')
if @target.status == 'dead'
fput "stance defensive"
loot_em_up
elsif ( @msg =~ /It looks like somebody already did the job for you./ )
fput "stance defensive"
loot_em_up
elsif ( @msg =~ /What were you referring to?/ )
fput "stance defensive"
shutdown
elsif ( @msg =~ /Cast at what?/ )
fput "stance defensive"
fput "release"
shutdown
elsif ( @msg =~ /You don't have a spell prepared!/ )
sleep 3
open_attack
else
open_attack
end
end
def gui
Gtk.queue {
$SORC_WINDOW = Gtk::Window.new
$SORC_WINDOW.title = $TITLE
$SORC_WINDOW.set_border_width(10)
$SORC_BOX = Gtk::VBox.new(false)
$SORC_BOX.set_border_width(5)
$SORC_VERTICAL_BOX1 = Gtk::VBox.new(false, 0)
$SORC_WINDOW.add($SORC_BOX)
$SORC_NOTEBOOK = Gtk::Notebook.new
$SORC_NOTEBOOK.set_show_border(true)
$SORC_BOX.add($SORC_NOTEBOOK)
$SORC_NOTEBOOK.append_page($SORC_VERTICAL_BOX1, Gtk::Label.new(' Configuration Settings '))
$SORC_ENTRY = Hash.new
$SORC_TABLE_SIZE = Hash.new
}
Gtk.queue {
$SORC_TABLE1 = Gtk::Table.new(4, 1, false)
$SORC_TABLE1.row_spacings=2
$SORC_TABLE1.column_spacings=2
$SORC_VERTICAL_BOX1.pack_start($SORC_TABLE1, false, false, 0)
}
def self.add_label_entry(table, label, variable)
size = $SORC_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.smartsorcerer[variable].to_s
entry.set_width_request(157)
table.attach(entry, 1, 2, size, size + 1)
$SORC_ENTRY[variable] = entry
$SORC_TABLE_SIZE[table] += 1
end
Gtk.queue {
$SORC_ENTRY = Hash.new
add_label_entry($SORC_TABLE1, " Default Attack Spell.........| ", 'sorc_primary_spell')
add_label_entry($SORC_TABLE1, " Mana Cost of Primary.........| ", 'sorc_primary_spell_mana')
add_label_entry($SORC_TABLE1, " Secondary Attack Spell.........| ", 'sorc_secondary_spell')
add_label_entry($SORC_TABLE1, " Mana Cost of Secondary.........| ", 'sorc_secondary_spell_mana')
add_label_entry($SORC_TABLE1, " Primary Wand Bag........| ", 'sorc_primary_bag')
add_label_entry($SORC_TABLE1, " Use wands during hunt?:.......| ", 'sorc_use_wands')
add_label_entry($SORC_TABLE1, " At what mana target do you (use wands?):.......| ", 'sorce_use_wands_mana')
add_label_entry($SORC_TABLE1, " Default Loot ScriptL........| ", 'sorc_loot_script')
}
Gtk.queue {
$SORC_WINDOW.signal_connect("delete_event") {
$SORC_SETUP_COMPLETED = true
}
}
Gtk.queue {
$SORC_WINDOW.show_all
}
$SORC_SETUP_COMPLETED = false
until($SORC_SETUP_COMPLETED)
sleep 1
end
UserVars.smartsorcerer ||= Hash.new
$SORC_ENTRY.keys.each { |key|
UserVars.smartsorcerer[key] = $SORC_ENTRY[key].text.strip.downcase
}
UserVars.save()
Gtk.queue {
$SORC_WINDOW.destroy
}
end
end
combat = SmartSorcerer.new(variable)
Enjoy.