I've seen a lot of posts lately from people who are unable to get Bigshot working exactly the way they want it to and some people have expressed that they wish they knew how to code in Ruby so they can write their own scripts so I'm posting up this simple hunting script as a teaching exercise to those who want to learn more about coding in lich.
Feel free to ask any questions about anything you don't understand. If you don't know much about coding in lich then one day you just might be able to write your very own custom hunting that does everything exactly the way you want it to do.
Here is the script with a few features to get you started:
Code:
target_names = /kobold|squirrel|rolton/
$my_target = GameObj.npcs.find{ |npc| npc.name =~ target_names && npc.type =~ /aggressive/ }
if $my_target == nil
echo "No target found!"
exit
end
def this_script_hide_me
until hidden?
waitrt?
fput "hide"
end
end
def this_script_stand_me
until standing?
waitrt?
fput "stand"
end
end
def this_script_keep_haste
Spell[506].cast if (!Spell[506].active?) && (Spell[506].affordable?) && (Spell[506].known?)
end
def this_script_stun_target
Spell[505].cast($my_target) if (Spell[505].affordable?) && (Spell[505].known?) && ($my_target.status !~ /stun/)
end
def this_script_kill_target
Spell[901].cast($my_target) if (Spell[901].affordable?) && (Spell[901].known?)
end
def this_script_ambush_target
critter_needs_to_be_legged = true
waitrt?
if ($my_target.status =~ /prone|sit|lay|kneel|stun|sleep/i)
result = dothistimeout "ambush ##{$my_target.id} head", 2, /round(time)?|You cannot aim that high|does not have a/i
if result =~ /round(time)?/i
critter_needs_to_be_legged = nil
elsif result =~ /does not have a/
critter_needs_to_be_legged = nil
fput "attack ##{$my_target.id}"
elsif result =~ /You cannot aim that high/
nil
elsif result.nil?
nil
end
end
if (critter_needs_to_be_legged)
result = dothistimeout "ambush ##{$my_target.id} left leg", 2, /round(time)?|does not have a/i
if result =~ /round(time)?/i
nil
elsif result =~ /does not have a/
fput "attack ##{$my_target.id}"
elsif result.nil?
fput "attack ##{$my_target.id}"
end
end
end
start_script "loot" if !running? "loot"
loop{
break if ($my_target.status =~ /dead|gone/)
this_script_keep_haste
this_script_stand_me
this_script_stun_target
this_script_kill_target
sleep 1
}
if $my_target.status =~ /dead/
echo "Target dead!"
waitrt?
start_script "waitloot"
wait_while { running?('waitloot') }
elsif $my_target.status =~ /gone/
echo "Target gone!"
end
Here is that same code with some information:
Code:
###This is a regex where you put the names of critters you want the script to scan the current room for to kill.
target_names = /kobold|squirrel|rolton/
###This tells the script to set the variable $my_target to any NPC in the room that matches the target_names above and that the NPC is also aggressive.
$my_target = GameObj.npcs.find{ |npc| npc.name =~ target_names && npc.type =~ /aggressive/ }
###This tells the script to exit if no target was found.
if $my_target == nil
echo "No target found!"
exit
end
###This is a simple way to make sure your character keeps inputting HIDE until they are hidden. If this is run while you are already hidden then it will do nothing.
def this_script_hide_me
until hidden?
waitrt?
fput "hide"
end
end
###Same as the hide above except it makes sure you are standing before moving on.
def this_script_stand_me
until standing?
waitrt?
fput "stand"
end
end
###This checks to see if haste (506) is not active on your character, that your character has enough mana to cast 506, and that your character knows 506. If all of those are true it will cast 506 on yourself.
def this_script_keep_haste
Spell[506].cast if (!Spell[506].active?) && (Spell[506].affordable?) && (Spell[506].known?)
end
###This checks if your character has enough mana to cast Hand of Tonis (505) and that your character knows 505 and that your target is not already stunned. If all of those are true it will cast 505 on your target.
def this_script_stun_target
Spell[505].cast($my_target) if (Spell[505].affordable?) && (Spell[505].known?) && ($my_target.status !~ /stun/)
end
###Basically same as above except it doesn't check for stun status and this is checking for Minor Shock (901)
def this_script_kill_target
Spell[901].cast($my_target) if (Spell[901].affordable?) && (Spell[901].known?)
end
###This first sets the variable critter_needs_to_be_legged to true (which basically just means the variable has a value).
###Your character will then wait for any hard roundtime they are in, if they aren't in roundtime it will do nothing there.
###It will then check if your current target is prone, sitting, kneeling, or stunned, if any of that is true your character will then attempt to ambush the target's head.
###If your character ambushed the head the script sets critter_needs_to_be_legged to nil (which basically means the variable has no value) and moves on.
###If your character cannot aim that high then the script moves on.
###If for some reason the critter doesn't have a head then the script set critter_needs_to_be_legged to nil and your character will just do a simple attack on the target.
###If the script does not see "roundtime", "you cannot aim that high" "does not have a" in a 2 second timeframe then the script simply moves on.
###If critter_needs_to_be_legged is set to true then your character will attempt to ambush the critter's left leg.
###If your character attacked the leg (and thus you see a "roundtime") then the script will move on.
###If your target does not have a leg then your character will do a simple attack on the target.
###If the script doesn't see "roundtime" or "does not have a" in a 2 second time frame then your character will do a simple attack on the target.
def this_script_ambush_target
critter_needs_to_be_legged = true
waitrt?
if ($my_target.status =~ /prone|sit|lay|kneel|stun|sleep/i)
result = dothistimeout "ambush ##{$my_target.id} head", 2, /round(time)?|You cannot aim that high|does not have a/i
if result =~ /round(time)?/i
critter_needs_to_be_legged = nil
elsif result =~ /does not have a/
critter_needs_to_be_legged = nil
fput "attack ##{$my_target.id}"
elsif result =~ /You cannot aim that high/
nil
elsif result.nil?
nil
end
end
if (critter_needs_to_be_legged)
result = dothistimeout "ambush ##{$my_target.id} left leg", 2, /round(time)?|does not have a/i
if result =~ /round(time)?/i
nil
elsif result =~ /does not have a/
fput "attack ##{$my_target.id}"
elsif result.nil?
fput "attack ##{$my_target.id}"
end
end
end
###This tells the script to start the script "loot" if "loot" is not already running. You are running loot, right?
start_script "loot" if !running? "loot"
###This is where the magic happens. This is where you tell the script what coommands you want it to do and when. If your target is dead or no longer in the room with you then the loop is broken and it moves to the bit of code beyond the loop.
loop{
break if ($my_target.status =~ /dead|gone/)
this_script_keep_haste
this_script_stand_me
this_script_stun_target
this_script_kill_target
sleep 0.1
}
###If your target is dead then the script will wait until you're out of roundtime if you're in it then it will start "waitloot" then it will wait until "waitloot" is done running. Once all of that is done the script exits.
if $my_target.status =~ /dead/
echo "Target dead!"
waitrt?
start_script "waitloot"
wait_while { running?('waitloot') }
####This is if your target simply left before you could kill it. It just exits.
elsif $my_target.status =~ /gone/
echo "Target gone!"
end
So here are some ways to setup the loop part of the script with what's already in the script.
Code:
loop{
break if ($my_target.status =~ /dead|gone/)
this_script_keep_haste
this_script_stand_me
this_script_stun_target
this_script_kill_target
sleep 0.1
}
This tells the script to run the keep haste part of the script, then it will run the stand me part, then it will run the stun target, then it will run kill target. It will keep doing this in this exact order over and over again until your target is dead or gone.
Basically it will cast haste if your character needs it, it will then stand your character up if they are not already standing, it will then cast Hand of Tonis on your target if your target is not already stunned, then it will cast 901 on your target. Once it has done all of that the script will then check if your target is dead or gone, if it's not dead or gone it starts all over again.
You could also do this:
Code:
loop{
break if ($my_target.status =~ /dead|gone/)
this_script_stand_me
this_script_hide_me
this_script_ambush_target
sleep 0.1
}
This will make sure you're standing if you're not already standing, then it will hide you if you're not already hidden, then it will attempt to ambush your target's head if your target is not standing or stunned, if your target isn't prone or stunned or if you can't aim for its head then it will ambush your target's left leg. It will then repeat this process until your target is dead or gone.
Feel free to ask any questions or if you want your script to do something else not already mentioned here.