Completely new updates. Rewrote targeting (again) and wander (again.) Cleaned up random double commands (hopefully.) Currently has no group functionality for poaching.
http://pastebin.com/BnrpXxN3
Here are the changes.
Code:
def no_players()
return false if GameObj.loot.find { |obj| obj.noun == 'disk' and obj.name !~ /#{Char.name}/}
return false if checkpcs or $ambusher_here
return true
end
def do_hunt()
spam() if UserVars.op['spam']
start_watch()
message('Bigshot hunting')
# loop
target = nil
just_arrived = true
last_attack = 0
$ambusher_here = false
start_exec_script( <<-eos
while(line = get);
break unless running?('bigshot');
$ambusher_here = true if line =~ /^\w+ leaps from hiding to attack/;
end;
eos
)
while true
while( (target = find_target(target, just_arrived)) && !should_rest? && no_players == true)
echo target if $bigshot_debug
if( (Time.now.to_i - last_attack > 15) || just_arrived )
@followers.add_event(:ATTACK)
last_attack = Time.now.to_i
end
attack(target)
just_arrived = false
loot() if $ambusher_here == false
end
echo "Exiting attack loop" if $bigshot_debug
gather_ammo()
if(should_rest?)
break
else
prepare_for_movement()
target = bs_wander()
sleep 1
just_arrived = true
end
end
unspam()
end
Code:
def attack(target)
commands = find_routine(target)
echo commands if $bigshot_debug
commands.each do |i|
break unless valid_target?(target)
break if wounded? || $bigshot_should_rest
break if $ambusher_here
stand()
cast_signs()
cmd( i, target )
end
echo commands.size if $bigshot_debug
#sleep 1 if commands.size == 0
end
Code:
def cmd( command, npc = nil, stance_dance = true )
command = command.dup
if( command.class.to_s == 'Array' )
stance_dance = false if command.any? { |j| j =~ /stance/ }
command.each do |i|
echo i if $bigshot_debug
cmd( i, npc, stance_dance )
end
return
end
# check mana/stamina
if( command =~ /(.*)\(([s|m])(\d+)\)$/ )
if( $2 == 's' )
return if !checkstamina($3.to_i)
elsif( $2 == 'm' )
return if !checkmana($3.to_i)
end
command = $1
end
if( command =~ /force\s+(.*)\s+(?:till|until)\s+(\d+)/ )
cmd_force( $1, $2.to_i, npc )
return
end
# sub id
command.gsub!( /target/, "##{npc.id}" ) if !npc.nil?
# waitrt/waitcastrt
unless( command =~ /^nudgeweapons?/ )
waitrt?
waitcastrt? if command =~ /^\d+|incant/
end
# change_stance
stand()
unless( command =~ /^(?:\d+|wait|sleep|wand|berserk|script|hide|nudgeweapon)/ )
change_stance(@HUNTING_STANCE) if stance_dance
end
return if npc && !valid_target?(npc)
if( command =~ /^(\d+)(.*)$/ )
cmd_spell( $1.to_i, $2.strip, npc )
elsif( command =~ /^throw/i )
cmd_throw( npc )
elsif( command =~ /^k?weed/i )
cmd_weed( command, npc )
elsif( command =~ /^wand\s+(.*)/i )
cmd_wand(npc)
elsif( command =~ /^hide/i )
cmd_hide()
elsif( command =~ /^mstrike/i )
cmd_mstrike( command, npc )
elsif( command =~ /^fire/i )
cmd_ranged(npc)
elsif( command =~ /^berserk/i )
cmd_berserk()
elsif( command =~ /^script\s+(.*?)(\s|$)(.*)/i )
cmd_run_script( $1, $3 )
elsif( command =~ /^sleep\s+(\d+)/i )
cmd_sleep( $1, npc )
elsif( command =~ /^stance\s+(.*)/i )
change_stance($1)
elsif( command =~ /^wait\s+(\d+)/i )
wait_for_swing( $1.to_i, npc )
elsif( command =~ /^nudgeweapons?\s*/i )
cmd_nudge_weapons
else
return if command =~ /1030/ && checkmana < 10
return if $ambusher_here
echo "inside cmd: #{command}" if $bigshot_debug
bs_put command
end
end
Code:
def bs_wander()
wander_last_room = nil
wander = proc {
room = Room.current
next_room_options = room.wayto.keys - @HUNTING_BOUNDARIES
if next_room_options.length > 1
next_room_options.delete_if { |option| option == wander_last_room }
end
next_room = next_room_options[rand(next_room_options.length)]
way = room.wayto[next_room]
if way.class == String
sleep 0.3
move(way)
else
way.call
end
cast_signs(true)
wander_last_room = room.id.to_s
}
while true # wander, check for players
echo "no_players: #{no_players}" if $bigshot_debug
npcs = GameObj.npcs
npcs.delete_if { |npc| (npc.status =~ /dead|gone/) }
sort_npcs.each { |i| return i if valid_target?( i, true ) and no_players == true and GameObj.npcs.size > 0 }
return if should_rest?
wander.call
sleep 0.1
$ambusher_here = false
end
end