PDA

View Full Version : zzherb script for anything forageable



zzentar
08-12-2014, 02:34 PM
I have finished this script and dont plan on any changes.

forages anything forageable and returns you to the starting room

no longer requires you to stow everything, allows you to keep shield or staff but will not run until you have at least one hand open.

if you mistype or just get location wrong, it will tell you and then tell you all locations that the forageable is found


if you mistype or just get herb name wrong, it will tell you and then will list guesses of what you meant

last change is a timer just to make you all happy when you see it took 92 seconds to do your task

format is ;zzherb <herb> qty <location (optional)>

for more info ;repo info zzherb

or just download and try it ...... ;repo download zzherb

Whirlin
08-12-2014, 02:37 PM
I've been using this for a long time, predominantly for ayana leaves/weeds/lichen/berries/whatnots, and it's amazing.


While it may take a while to get the syntax down, it's still more straight forward than the next best alternative foraging script on the repo (that I could find anyway).

Allereli
08-12-2014, 02:46 PM
will it take out a haste scroll and invoke/cast? will it minor sanct?

zzentar
08-12-2014, 02:46 PM
I did all I could to make it user friendly. If you have an old version, download again. It now tells you if you have item and location wrong and tries to guess what you meant

zzentar
08-12-2014, 02:48 PM
will it take out a haste scroll and invoke/cast? will it minor sanct?

no and it wont uncurse cursed herbs either

ThatDamnTep
08-16-2014, 12:35 AM
Neat. I have a little script that some people might find handy as an add on. When I was still playing I used this to maintain my own little personal forageable tag database. As long as it's running it will check the current room to see if whatever you just found was tagged in that room. If not it will push it in and save the room number and herb name to a text file that will repopulate your personal map DB whenever it starts.

forage_tags


=begin
This script will add tags to rooms for items that you forage if they do not already exist.
It will write any new tags in to tags.txt (located in your lich directory).
Just start it up and it will run in the background.
Be sure to add it to your ;favs
-Tep
=end
silence_me

unless $SAFE == 0
respond "#{script.name} must be trusted to work"
exit
end

unless File.exists?('tags.txt')
File.open("#{$lich_dir}tags.txt", 'a')
end

data = File.open('tags.txt') { |f| f.read }
data = data.split("\n").collect { |line| line.chomp}
data.each { |line|
if line =~ /([0-9]+): ([A-Z,a-z, ,\, \-, \']+)/
unless Room[$1].tags.include?($2)
Room[$1].tags.push($2)
end
end
}


while line = get
if line =~ /^You forage briefly and manage to find (?:a |an )?(.*)!$/
tag_name = $1
if room = Room.current and not room.tags.include?(tag_name)
room.tags.push(tag_name)
File.open("#{$lich_dir}tags.txt", 'a') { |f| f.puts "#{room.id}: #{tag_name}\n" }
end
end
end

Alashir
08-27-2014, 09:43 PM
When foraging for wild lilac it attempts to stow "wild lilac" instead of just lilac. I suppose stow r, or stow all would also work.

DaCapn
08-28-2014, 12:27 AM
Two things always seem wrong to me in a lich script:
(1) Using stow (it seems appropriate to use lich settings instead of game settings)
(2) Using nouns/names to specify your characters interaction with objects (GameObj makes IDs readily available, they are unique identifiers, and are the easiest way to interact with anything in the game).

Well, more than two things, probably, but definitely those two things.

zzentar
08-28-2014, 03:57 AM
When foraging for wild lilac it attempts to stow "wild lilac" instead of just lilac. I suppose stow r, or stow all would also work.

Thanks for letting me know. Fixed it. Just download it again. There is a weird disjunction between some items name/noun and the items forage name, I had to make special exceptions for each of them. Also the reason you can't just stow left, stow right or stow all is because some people want to keep their shield or rune staff out when foraging.

zzentar
08-28-2014, 06:28 AM
Two things always seem wrong to me in a lich script:
(1) Using stow (it seems appropriate to use lich settings instead of game settings)
(2) Using nouns/names to specify your characters interaction with objects (GameObj makes IDs readily available, they are unique identifiers, and are the easiest way to interact with anything in the game).

Well, more than two things, probably, but definitely those two things.

I completely agree with you that it would be cleaner code to use item IDs. My lich/ruby knowledge is very limited and I did the best I could with what I knew. The problem I came across trying to use IDs was due to the fact the character might have a shield, runestaff or empty hands. The foraging hand would be different for a shield user and a person that is open handed or a staff user. Since the script doesn't know what hand has the foraged item, it doesn't know whether to get GameObj.right_hand.id or GameObj.left_hand.id. I didn't see the need for it when I could just use STOW <foraged item>.

<<Laugh>>

After thinking through the reasons why I didn't use IDs. I realized an easy fix so that I can. All I need to determine forage hand is this:

if checkright.nil?
foragehand = GameObj.right_hand
else foragehand = GameObj.left_hand
end

I will change it to use IDs later today.

I always appreciate criticism and suggestions. I normally learn something from it.

~Zz

DaCapn
08-28-2014, 02:22 PM
I see the intent of the idea but that doesn't actually work, and you probably see why after looking at it a second time. Anyway, you also have the name of the thing you're foraging for.

herb = [GameOb.left_hand,GameObj.right_hand].find { |obj| obj.name =~ /#{herb_name}/i }
fput "put ##{herb.id} in my ##{lootsack.id}"

Even if herb_name has been janked to remove an inner adjective, you can just change the regex to herb_name.gsub(" ",".*")

zzentar
08-28-2014, 02:37 PM
slightly more complicated than I thought, but it is done.

I had huge issues trying to get the ID of Lich.lootsack. I understand why, just it was hard to get it. Lich.lootsack is just a string that describes your lootsack. I had to find a way to pull the particular ''lootsack' into Lich so I could get an ID. This seemed to work for me but I was unsure if it would work universally:

GameObj.inv.each{|obj|
if obj == UserVars.lootsack
lootsack = obj
end
}

I was given some help and found a much easier way:
lootsack = GameObj[UserVars.lootsack]

Other mistake was just retarded. I was trying to assign a variable to a future item that will fill an empty hand:

if checkright.nil?
foragehand = GameObj.right_hand
else foragehand = GameObj.left_hand
end

Lots of lessons learned and now instead of using STOW, now its:
fput "_drag ##{foragehand.id} ##{lootsack.id}"

~Zz

zzentar
08-28-2014, 02:46 PM
I see the intent of the idea but that doesn't actually work, and you probably see why after looking at it a second time. Anyway, you also have the name of the thing you're foraging for.

herb = [GameOb.left_hand,GameObj.right_hand].find { |obj| obj.name =~ /#{herb_name}/i }
fput "put ##{herb.id} in my ##{lootsack.id}"

Even if herb_name has been janked to remove an inner adjective, you can just change the regex to herb_name.gsub(" ",".*")

I don't know how to use regex well enough to fix foragename and to be honest, I am not sure I can learn how to do it. The books I have found don't really explain it that well.

anyway, I am quite proud of this and it works well.

~Zz

zzentar
09-04-2014, 01:27 PM
No idea why it took a week for someone to tell me but Whirlin just told me that zzherb was still broken and the 'stow' command was messing him up.
He sent me the error and I realized that I never copied over my testing version that doesn't use stow to zzherb, so I uploaded the same version that was there before.

If you ;repo download zzherb you will get the fixed version now

Sorry,
~Zz

Enestrie
10-23-2014, 10:55 AM
I love zzherb and it has been great with most foraging tasks.
Recently I had an issue in Rivers Rest with purple clover blossom. When I used the zzherb script, no locations were shown in the River's Rest area. Is this a mapping issue?
Thanks.

Vagabondbard
04-05-2015, 03:40 PM
Where would i put in a command for kneeling?

GBB

zzentar
04-06-2015, 12:02 PM
Where would i put in a command for kneeling?

GBB

I never put in kneeling because its not a smart scrpt and would kneel in front of 20 critters but if you wanted to add a kneel, put this

just before line 222
fput "kneel"


didnt test that but t looks like t would work then get up and move you to next spot

Viekn
04-06-2015, 12:21 PM
I never put in kneeling because its not a smart scrpt and would kneel in front of 20 critters but if you wanted to add a kneel, put this

just before line 222
fput "kneel"


didnt test that but t looks like t would work then get up and move you to next spot

I also just pause the script and kneel myself, that way I retain a bit more control over when I kneel and when I don't.

zzentar
04-07-2015, 12:18 PM
I also just pause the script and kneel myself, that way I retain a bit more control over when I kneel and when I don't.

i like your way better!
~Zz

Gnomad
08-21-2015, 09:07 AM
After Zz passed, I felt a little useless, as one does, so I sat down and added a few features and bugfixes to zzherb in memoriam. I tried to keep it true to Zz's intent; it still barely tries to keep you alive.

That said, I don't want to be seen as trying to make a name for myself on someone's passing, so I figured I'd reach out to the community to see how they feel about it being released more widely. Thoughts?

Allereli
08-21-2015, 11:57 AM
I think he'd be happy someone was interested enough to improve it.

Another time he was so happy was when he finally got a million bounty points for a fixstat. I think he has the record for number of times doing the Solhaven or Icemule to Ta'Vaalor escort task.

Soulance
08-21-2015, 01:53 PM
I agree, thoughtful of you to take a look at it. That way it can live on with Zz's name attached to it.

Just don't screw it up! ;)

elcidcannon
08-21-2015, 02:05 PM
I agree, thoughtful of you to take a look at it. That way it can live on with Zz's name attached to it.

Just don't screw it up! ��

+1

Gnomad
08-21-2015, 06:36 PM
Okay, well here's an overview of what I've done:

Fixed a few bugs: the warning about Lich.vars, and an herb or two that didn't forage for the right thing.
The script will now ignore "a" or "an" before an herb name rather than choking on it.
Sunfist characters will now use Sigil of Resolve
New option: kneel when foraging
New option: 213 when entering a room (doesn't try to recast if you suck at foraging, doesn't care if you fail casting 213)
GUI Setup shamelessly borrowed from Spiffy's sloot because I hate GUI work
;zzherb bounty will maybe figure out what you need to forage for your bounty.

I'm still testing the last one. Haven't seen enough herb bounty messages yet to know I've nailed all the variations.

Soulance
08-22-2015, 07:56 AM
Okay, well here's an overview of what I've done:


Fixed a few bugs: the warning about Lich.vars, and an herb or two that didn't forage for the right thing.
The script will now ignore "a" or "an" before an herb name rather than choking on it.
Sunfist characters will now use Sigil of Resolve
New option: kneel when foraging
New option: 213 when entering a room (doesn't try to recast if you suck at foraging, doesn't care if you fail casting 213)
GUI Setup shamelessly borrowed from Spiffy's sloot because I hate GUI work
;zzherb bounty will maybe figure out what you need to forage for your bounty.

I'm still testing the last one. Haven't seen enough herb bounty messages yet to know I've nailed all the variations.
These sound excellent! And let me know if you want some messages posted here for help.

Did you upload it yet?

Soulance
08-22-2015, 10:44 AM
"Ah, so you're from the Adventurer's Guild? Yes, I do have a task for you. I've been working on a concoction that requires a light blue hydrangea. Unfortunately, I need a specific variety that only grows in Old Ta'Faendryl. If you could retrieve 5 samples for me, I would be most grateful. Keep in mind that I need these samples to be in pristine condition. That means no eating, bundling, or otherwise damaging the samples. You can GIVE them to me as you FORAGE them."

BOUNTY=
The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a light blue hydrangea found in Old Ta'Faendryl. These samples must be in pristine condition. You have been tasked to retrieve 5 samples.

--if that's what you need.

Gnomad
08-26-2015, 05:17 PM
If anyone wants to try this out, ;betazzherb is up on the repo.

Usage:
;betazzherb setup
;betazzherb <herb name> <#> <location (optional)>
;betazzherb bounty (should do the above automatically; will only work if you've already talked to the herbalist)

Try it out, and if (when) the bounty option doesn't work, paste the line you see when you type BOUNTY.

My rogue buddy talked me into adding searching while hiding as well.

Gnomad
09-05-2015, 09:41 AM
Made a few minor tweaks on the regex, and it feels as good as I'll get it without a larger base of users. Anyone ran into any issues?

Soulance
09-05-2015, 09:49 AM
Made a few minor tweaks on the regex, and it feels as good as I'll get it without a larger base of users. Anyone ran into any issues?
Thanks again for doing this. I haven't tested it like I should, but I actually just got an herb bounty so I'll run it again and see if anything comes up.

Soulance
09-05-2015, 10:04 AM
;betazzherb bounty still not working for me in Illy:

Same as above post.

The herbalist's assistant in Ta'Illistim, Jhiseth, is working on a concoction that requires a light blue hydrangea found in Old Ta'Faendryl. These samples must be in pristine condition. You have been tasked to retrieve 5 samples.

Gnomad
09-06-2015, 11:42 PM
Thanks. Slightly different message in OTF bounties than I've seen before. Should be working now.

edit: fixed a bug I introduced. Better now. Damn web pages eating double spaces.

Gnomad
09-07-2015, 07:39 AM
Fixed a bug in the setup routine that would have popped up if you never used the original zzherb.

Also added the ability for it to quickly stow the stuff in your hands if you want, because one of my buddies is never hap--is tired of his baby cleric getting pasted on the way to/from foraging tasks.

Gnomad
09-16-2015, 04:42 PM
TODO: Do not forage a room if another character is currently foraging there. Need to work on this one in the coming days.

As it stands, I figure I'll wait up to 10 seconds if another PC is in a room, and if they forage, mark the room busy and move on. Thoughts?

Soulance
09-16-2015, 05:49 PM
As it stands, I figure I'll wait up to 10 seconds if another PC is in a room, and if they forage, mark the room busy and move on. Thoughts?
I would say 10 seconds is a long time to sit and wait. I know it can take me a few rounds to get what I need. Maybe more like instantly mark the room if someone is there and move on to the next if possible. There's usually more than one room to forage for stuff. Maybe have the "busy" clear after 10 seconds?

Gnomad
09-17-2015, 05:42 PM
I see what you're saying. The way the issue was described to me, in OTF in particular, there's only a few rooms where a lot of the foraging is concentrated, and it's not uncommon to run into another forager. My highest character is nowhere near OTF, so I can't speak to that.

10 seconds max seemed like the safe amount of time to walk in on someone in forage RT and see if they're going for another one or not, but still short enough to not screw up the efficiency of the script. Most of the time, if I run into someone while using the script, they're hunting, not foraging, and I wouldn't want to bail the room.

Thinking on it some more. If I do bail a room for this, though, it wouldn't become available again right away/after 10 seconds. The logic would be too much of a pain, and you could end up looping through a subset of occupied rooms for quite some time. Instead, I could put them on a set of "Plan B" rooms for a second check once all the other ones are done, and just give them one more go before saying, "tough shit, no herbs for now".

Still open to ideas.

Gnomad
10-07-2015, 04:14 PM
Shit I posted on the other boards:


;betazzherb will now notice when you try to forage for a day- or night-only herb at the wrong time. There's no database of herb times or anything, you gotta forage and fail first.

I haven't started looking at skipping rooms with PCs in them yet. Will eventually.

Shoutout to soulance for calling charl to the dais and getting me some nice RPAs, you da real mvp


betazzherb is updated for people using a vt100. (it can do non-gui setup now in the usual --kneel_to_forage=on style)

Quick feature that I should have done a while ago:

;betazzherb bounty <paste entire string from BOUNTY verb here>

For when you want to forage for another character's bounty and do not want to have to parse that shit yourself.

Don't paste what the herbalist said; they use slightly different phrasing and I don't care enough to parse that crap too. Use the result of the BOUNTY verb.

Soulance
10-07-2015, 04:37 PM
Any way to toss in the SEARCH portion of a bountyheirloom into this script seeing as the other aspects are part of the script or is it too much work? Like when you have to search for a lost heirloom in Griffins and want to make sure it's sancted while you stow everything, kneel and search?

Maybe best to leave it out, I dunno. <shrug>

Gnomad
10-07-2015, 09:43 PM
Not easily. Information for finding heirlooms (creature spawn rooms) isn't really tagged in Lich; herbs are. Information from the location verb would be enough for some cases, but not for most of them.

Gnomad
10-16-2015, 10:21 AM
Fixed a bug that kept the bounty option from working for Varunar bounties.

Gnomad
10-16-2015, 03:11 PM
Whoops. Typo in my regex fucked a few things up. New version fixes it.

Gnomad
03-27-2016, 12:49 AM
Added a toggle for bards to not sing 1035 if you don't want to blow your nerves when your songs renew. Also made it so the "sanct" option doesn't even show up if you don't know 213.

I promise I'll add a "sing peace" option soon.

Gnomad
04-09-2016, 10:30 AM
Nice little upgrade to handling the bounty feature:

;betazzherb bounty <name> will now try to pull that character's bounty via LNet and complete it.

The old method of pasting in someone else's bounty string will still work.

Running either of those while you have your own bounty will no longer prioritize your character's bounty.

Pending update:

It will soon skip rooms with people in them. I just need to fix it up so that it doesn't screw up if you're leading a group.

Soulance
04-09-2016, 05:20 PM
;betazzherb bounty <name> will now try to pull that character's bounty via LNet and complete it.
Cool idea. Looking forward to testing it out.

Gnomad
04-11-2016, 08:53 AM
Updated the code that recognizes bounties, so if betazzherb wasn't figuring out your bounty, it might now.

Keep letting me know when these fail!

Gnomad
04-12-2016, 11:48 AM
Bugfix update.