BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: jjones666 on February 25, 2007, 01:49:27 am

Title: Nano formulas module
Post by: jjones666 on February 25, 2007, 01:49:27 am
One thing I saw from the !guides module was that having the nano formula locations in the bot was bloody handy.  As we had a great codebase for searching database with Wolfbiter's !symb module, I spent the last few weeks taking a look at the in game nanos.

Information was taken from a variety of places, I checked all of the SL gardens myself - from what I remember RK nanos info mostly came from Jexai's, SL quest info from AO-Universe.  As I mentioned 99.9% of the coding is Wolfbiter's original module.

- added all SL garden nanos.
- added all RK store nanos.
- added all RK mission nanos.
- added all RK dynaboss nanos.
- added all RK unique mob nanos.
- added all general type nanos.
- added SL static dungeon nanos.
- added SL quest nanos.
- added SL nanos which drop from random mobs.
- added SL jobe zone nanos (keeper and shade only).
- added LE VP nanos.
- search limited to 200 nanos to prevent bot crashing.

Obviously, this will work in same manner as the !symb module.  Requires Glara's new module settings module (you can turn the icon display on and off in !settings).

As most of the work is manually done, its possibly got a few bad entries, please let me know if you find any.

Theres a nice little menu if you just do !nano, you can also see most of the searchterms in there.

PHP (http://www.jjones.co.uk/files/nano.php)
SQL (http://www.jjones.co.uk/files/nano.zip)
Help (http://www.jjones.co.uk/files/nano.txt)

Cheers,

-jj-

EDIT: includes Wolfbiter's fix posted below.
EDIT: module tested with bebot 0.2.11.
EDIT: spelling error fixed, help added (thanks Pusikas).
EDIT: helpfile updated - SQL updated to 17.2 - added exact string search (thanks Wolfbiter).
EDIT: SQL updated to 17.3.
Title: Re: Nano formulas module
Post by: Wolfbiter on February 25, 2007, 02:59:26 am
Code: [Select]
        function make_chatcommand($link, $title)
        {
return '<a href=\'chatcmd:///tell '.$this->bot->botname.' '.$this->bot->commpre.$link.'\'>' . $title . '</a>';
        }

Will cause problem on bots with stupid (regexp) triggers.

use:
Code: [Select]
        function make_chatcommand($link, $title)
        {
return '<a href=\'chatcmd:///tell '.$this->bot->botname.' <pre>'.$link.'\'>' . $title . '</a>';
        }
Title: Re: Nano formulas module
Post by: buff on February 28, 2007, 09:48:40 pm
tried it today and did a search w/ !nano adv
then i get spammed from bot and eventually had to restart bot to stop the spam

bot will respond w/  found 2xx result with (page 1 of 2) then next is (page 2 of 2) then next is (page 1 of 2)(page 2 of 2) and go on

thought i would point it out so u can look into it ;)
Title: Re: Nano formulas module
Post by: jjones666 on February 28, 2007, 09:58:27 pm
[Uprising] Jackjonez: !nano adv
[Uprising] Uprnet: 231 nano formulas found (displaying only 1-200) :: click to view (page 1 of 4)
[Uprising] Uprnet: 231 nano formulas found (displaying only 1-200) :: click to view (page 2 of 4)
[Uprising] Uprnet: 231 nano formulas found (displaying only 1-200) :: click to view (page 3 of 4)
[Uprising] Uprnet: 231 nano formulas found (displaying only 1-200) :: click to view (page 4 of 4)

Can you confirm what version of bebot you run, this was fixed ages ago?

Cheers,

-jj-
Title: Re: Nano formulas module
Post by: jjones666 on March 01, 2007, 08:09:00 am
Fix here:
http://bebot.link/index.php/topic,234.0

Would advise update to latest Bebot ASAP.

-jj-
Title: Re: Nano formulas module
Post by: jjones666 on March 05, 2007, 01:08:42 pm
As all mentioned problems were fixed, I added this to the A-Z.

Any comments on bad data yet or further problems with the plugin itself?

Cheers,

-jj-

p.s. tidied up the post somewhat also where problems had been fixed.
Title: Re: Nano formulas module
Post by: pusikas on March 05, 2007, 02:18:38 pm
The help you get from !nano uses the word "nansense" under location. Is that supposed to mean "Nascence", or "Nonsense"?  ;D

Edit: actually, the whole PHP file uses nansense... I, uhm... consider this a bug. ^^
Another Edit: wrong writing is in SQL as well
Title: Re: Nano formulas module
Post by: pusikas on March 05, 2007, 02:32:27 pm
And since my org kept bugging me that there was a helpfile missing, I turned the output of !nano into a helpfile. Changed nansense into nascence, tho, so may not work with JJ's php until he fixes it. :)
Title: Re: Nano formulas module
Post by: jjones666 on March 10, 2007, 03:42:02 pm
Updated .php and .sql to fix spelling error, you will need to drop and reimport database.  Added the help file to first post.

Thanks,

-jj-
Title: Re: Nano formulas module
Post by: Earth on March 21, 2007, 07:02:03 am
How do I upload into SQL?
Title: Re: Nano formulas module
Post by: Malosar on March 21, 2007, 06:27:51 pm
For SQL manipulation, use a program called SQLYog. It's free and fairly easy to use compared to most. You can edit existing data, create/modify tables, import/export data etc.
Title: Re: Nano formulas module
Post by: pusikas on March 22, 2007, 12:28:13 pm
When I do something like
Code: [Select]
!nano Empowered Partial Reflective Fieldto see in what garden it is sold, I get 2 pages of hits, all nanos listed containing at least one of the four words in their name. Would it be possible to change the module to look for an exact hit when I put the searchstring into quotes? So that
Code: [Select]
!nano "Empowered Partial Reflective Field"returns only one hit? Or maybe something like
Code: [Select]
!nano exact Empowered Partial Reflective FieldOr maybe change the module so that the nanos are ordered by the number of "hits", meaning words that match in their name. Although I guess that would be harder to code than the two above suggestions.

I have tried to change that myself, but without much success yet. Gotta admit that  I have trouble understanding some parts of the code. ???
Title: Re: Nano formulas module
Post by: jjones666 on March 22, 2007, 01:48:29 pm
Yeah the advantage to the current system is that you can use as many search terms as you like, ie. !nano soldier 100-125 slquest or whatever.  So in the first case you're doing four seperate searches hence large amount of hits.  The code is Wolfbiter's baby, and offhand, I can't think if this change is possible.  Normally, I simply look by profession/QL for quickest results.

-jj-
Title: Re: Nano formulas module
Post by: Wolfbiter on March 22, 2007, 03:39:41 pm
I might look over my search methods after the weekend (if I feel like it or remember it) for something along the lines of "bla bla", I've had some other instances where this would have been usefull.

EDIT

Well.. sometimes I can't let go of an idea...

Code: [Select]
function nano($input)
{
$input = explode(" ",strtolower($input));
$type = false;
...
Replace that bit with
Code: [Select]
function nano($input)
{
$hftext = false;
$ftext = false;
preg_match_all('¤"([^"]+)"¤U',$input,$exact,PREG_SET_ORDER);
foreach ($exact as $loop) {
$ftext = ($ftext ? $ftext." or ":"")."name like '%".$loop[1]."%'";
$hftext = (!$hftext ? "'$loop[1]'" : $hftext.", '$loop[1]'");
}
$input = preg_replace('¤".+"¤',"",$input);
$input = preg_replace('|\s\s+|',' ',$input);
$input = explode(" ",strtolower($input));
$type = false;
...
//$ftext = false; <- if this isn't commented out the stuff in "" wont be searched for.
//$hftext = false; <- same here

I've not tested it with a real script, I'll leave that up to jj, but it *should* work.

EDIT2
Corrected a typo
Title: Re: Nano formulas module
Post by: pusikas on March 22, 2007, 04:28:44 pm
Normally, I simply look by profession/QL for quickest results.

Thanks for mentioning this, it did not occur to me, and would help as well, ofc. Currently plyaing a new soldier. I use auno.org to dig up the nanos I want, but I do not trust the site to give me valid info on where to buy SL nanos. Hence my asking. Is not the first time this has come up, tho. Some peeps from org told me they'd like exact matches before. I just did not see why this would be good until I had the need myself.  ;D
Title: Re: Nano formulas module
Post by: pusikas on March 23, 2007, 03:28:05 am
Wolfbiter, put in your code, and this is what I get:
Code: [Select]
!nano Empowered Partial Reflective Field
114 nano formulas found :: click to view (page 1 of 2)
114 nano formulas found :: click to view (page 2 of 2)

Header of the output shows this:
Matching name: 'empowered', 'partial', 'reflective', 'field'

Code: [Select]
!nano "Empowered Partial Reflective Field"
31 nano formulas found :: click to view

Header of the output shows this:
Matching name: 'Empowered Partial Reflective Field', '"empowered', 'partial', 'reflective', 'field"'

As you can see, it narrowed the search down, but not quite in the way expected... :) It finds fewer nanos, but only because it adds the quotes to empowered and to field.

I am not sure that copying your strange "¤"-symbol really works for me, tho. At least it looks kinda different when I paste it into putty. :) What the hell does it do?
Title: Re: Nano formulas module
Post by: Wolfbiter on March 23, 2007, 03:46:02 am
¤ is just delimiter for regexp code (since I use | in the regexp). Did you // the $hftext, and $ftext lines? Did you add the preg_replace line? You can relace ¤ with | in the preg_replace stuff.
Title: Re: Nano formulas module
Post by: pusikas on March 23, 2007, 05:46:08 am
yep, I commented out the two variables after the block you posted. So they are not reset to false after the block has run.
Title: Re: Nano formulas module
Post by: Wolfbiter on March 23, 2007, 08:02:31 am
Code: [Select]
$intput = preg_replace('¤".+"¤',"",$input);
Spot the typo...
Title: Re: Nano formulas module
Post by: pusikas on March 23, 2007, 03:24:41 pm
Oh dear, that's PHP for you. Sometimes I miss good old Pascal, where you had to declare variables in a seperate block. :D Will try it out right away when I get home from work.
Title: Re: Nano formulas module
Post by: Vhab on March 24, 2007, 08:08:58 am
that's scary. i've lost count on many times i typoed input as intput. typo stealer!
Title: Re: Nano formulas module
Post by: pusikas on March 24, 2007, 11:01:18 am
Hmmm... still does not work for me. Now I do not get any hits, no matter what I set in quotes. Even if the name of the nano is only one word long.

Code: [Select]
To [bot]: !nano Empowered Partial Reflective Field
[bot]: 114 nano formulas found :: click to view (page 1 of 2)
[bot]: 114 nano formulas found :: click to view (page 2 of 2)
To [bot]: !nano "Empowered Partial Reflective Field"
[bot]: No matches found.
To [Vbot]: !nano "Extreme Prejudice"
[bot]: No matches found.
To [bot]: !nano "rapid weapon"
[bot]: No matches found.
To [bot]: !nano "Miniaturization"
[bot]: No matches found.
To [Vbot]: !nano "miniaturization"
[Vbot]: No matches found.

This is what my code looks like:

Code: [Select]
                function nano($input)
                {
                        $hftext = false;
                        $ftext = false;
                        preg_match_all('¤"([^"]+)"¤U',$input,$exact,PREG_SET_ORDER);
                        foreach ($exact as $loop) {
                                $ftext = ($ftext ? $ftext." or ":"")."name like '%".$loop[1]."%'";
                                $hftext = (!$hftext ? "'$loop[1]'" : $hftext.", '$loop[1]'");
                        }
                        $input = preg_replace('¤".+"¤',"",$input);
                        $input = preg_replace('|\s\s+|',' ',$input);
                        $input = explode(" ",strtolower($input));
                        $type = false;
                        $prof = false;
                        $ql = false;
                        // $ftext = false;
                        $hql = false;
                        // $hftext = false;
                        $location = false;

I can't spot any more obvious blunders...
Title: Re: Nano formulas module
Post by: Wolfbiter on March 24, 2007, 11:06:24 am
Echo the query somewhere and check what it is (best way to spot errors).
Title: Re: Nano formulas module
Post by: pusikas on March 24, 2007, 04:25:09 pm
This is what I got:

Code: [Select]
To [bot]: !nano "Empowered Partial Reflective Field"
[bot]: select * from nanos where (lowql=lowql) and (lowql=lowql) and (profession='adventurer') and (name like '%Empowered Partial Reflective Field%') ORDER BY lowql, profession
[bot]: select * from nanos where (lowql=lowql) and (lowql=lowql) and (profession='adventurer') and (name like '%Empowered Partial Reflective Field%') ORDER BY lowql, profession LIMIT 0, 200
[bot]: No matches found.

No idea where the adventurer stuff comes from... But it does not work for advy nanos, either, which kinda amazes me:

Code: [Select]
To [bot]: !nano "Improved Friend of the Wild"
[bot]: select * from nanos where (lowql=lowql) and (lowql=lowql) and (profession='adventurer') and (name like '%Improved Friend of the Wild%') ORDER BY lowql, profession
[bot]: select * from nanos where (lowql=lowql) and (lowql=lowql) and (profession='adventurer') and (name like '%Improved Friend of the Wild%') ORDER BY lowql, profession LIMIT 0, 200
[bot]: No matches found.

 These are the original queries plus the tell-lines I added:

Code: [Select]
$count = $this->bot->db->select("select * from nanos where (".(!$ql ? "lowql=lowql" : $ql).") and (".(!$loc ? "lowql=lowql" : $loc).") and (".(!$type ? "lowql=lowql" : $type).") and (".(!$ftext ? "lowql=lowql" : $ftext).") ORDER BY lowql, profession");
$this->bot->send_tell("Luuv", "select * from nanos where (".(!$ql ? "lowql=lowql" : $ql).") and (".(!$loc ? "lowql=lowql" : $loc).") and (".(!$type ? "lowql=lowql" : $type).") and (".(!$ftext ? "lowql=lowql" : $ftext).") ORDER BY lowql, profession");
$qry = "select * from nanos where (".(!$ql ? "lowql=lowql" : $ql).") and (".(!$loc ? "lowql=lowql" : $loc).") and (".(!$type ? "lowql=lowql" : $type).") and (".(!$ftext ? "lowql=lowql" : $ftext).") ORDER BY lowql, profession LIMIT 0, 200";
$this->bot->send_tell("Luuv", $qry);

Edit: Just occured to me that he search for the advy nano can't work. The Nano Crystal does not have the word "improved" in it... !nano "Friend of the Wild" gives two matches, as it should. So, thanks, it works now, but only for advy nanos. ^^*

This is, btw, another downside of the way the module works. It looks for nano crystals, not for nanos. But the names of some of the nanos differ from that of their crystal. For example, the nano "Ranged Energy Weapon Mastery" comes from the crystal "Nano Crystal (LR Energy Weapon Mastery)". Not a real problem, the improved nanos are more of a prob.
Title: Re: Nano formulas module
Post by: Wolfbiter on March 24, 2007, 05:44:01 pm
Profession is part of the original script, same with searching for nano crystals.. this is jj's code, I just added the "" search stuff so I'll let him work out what's wrong with it adding adventurer ;)

But what happends if you do !nano soldier "empowered partial reflective field"?
Title: Re: Nano formulas module
Post by: pusikas on March 24, 2007, 05:54:25 pm
weeee... that works. nice nice!  :D
Title: Re: Nano formulas module
Post by: jjones666 on March 26, 2007, 01:05:12 am
updated module:

- exact search string works now ie. !nano "guardian of might" (thanks Wolfbiter!).
- help file updated.
- code cleaned up somewhat.
- sql updated to include LE 17.2 nanos.

to-do:

- add nano name instead of item name (by the way, in the meantime static dungeon nanos are searchable).
Title: Re: Nano formulas module
Post by: pusikas on March 26, 2007, 10:31:09 am
Hey, and you removed the odd references to $symb in the code. I refrained from complaining about those, because I was complaining too much already. :)

But... you current code references a table called items.nanos, not just nanos. That will cause problems for many peeps. :(
Title: Re: Nano formulas module
Post by: jjones666 on March 26, 2007, 12:15:44 pm
ROFL, I always **** up the items.nanos (should be just nanos), again I shouldn't publish any module after midnight ;-p

I'll change it as soon as I get home from work.

And yeah, I did tidy the code up somewhat, with help from Wolfbiter, I'm surprised he didn't kick me on still having $symbs in there :-)

-jj-
Title: Re: Nano formulas module
Post by: jjones666 on March 26, 2007, 07:26:20 pm
Ok, fixed the .PHP, if you downloaded before now, please re-download.

-jj-
Title: Re: Nano formulas module
Post by: shadowballs on March 28, 2007, 05:43:12 pm
my quest for a great guild-bot continues and Ive noticed some problems with the !nano script. after Ive installed this script one of my guilder's typed !nano and dropped a ID into the chat, while the bot replied and showed a list with the nano that the ID would make I noticed later on that I got some warnings in the bot log.

Code: [Select]
[2007-03-28 12:31:55]   [GROUP] [MSG]   [Wanted] Laradvy: !nano [link]Instruction Disc (Chaotic Entropy)[/link]
Warning: preg_grep(): Compilation failed: missing ) at offset 8 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 158
Warning: preg_grep(): Compilation failed: missing ) at offset 8 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 164
Warning: preg_grep(): Unknown modifier 'a' in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 158
Warning: preg_grep(): Unknown modifier 'a' in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 164
[2007-03-28 12:31:56]   [GROUP] [MSG]   [Wanted] Wanbot: 6 nano formulas found :: [link]click to view[/link]

Ive tried that myself now with a ID for Complete Healing and the same thing happened again. from what I can tell, it looks like the search engine runs into troubles when the search contains an instruction disk.

Search 1.
Using a real Instruction Disc (Complete Healing) that I drop into the chat gives me a result list containing 6 nano's and the bot log spams the listed warnings above and the results window has the following header
Code: [Select]
Nanos
Matching name: 'itemref://147107/147107/169', '<a', 'href=>instruction', 'disc', '(complete', 'healing)'

Search 2.
Typing !nano Instruction Disc (Complete Healing) gives me a search result of 18 nano's, and these warnings
Code: [Select]
[2007-03-28 15:26:24]   [GROUP] [MSG]   [Wanted] Shadowballs: !nano Instruction Disc (Complete Healing)
Warning: preg_grep(): Compilation failed: missing ) at offset 9 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 158
Warning: preg_grep(): Compilation failed: missing ) at offset 9 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 164
Warning: preg_grep(): Compilation failed: unmatched parentheses at offset 7 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 158
Warning: preg_grep(): Compilation failed: unmatched parentheses at offset 7 in C:\Program Files (x86)\BeBot_v0.2.11\modules\Nano.php on line 164

Search 3.
Typing !nano Instruction Disc Complete Healing yields a search result of 27 nano's and no warnings.

to me it seems obvious that the search script cant handle parenthesis as search option so that might need fixing, but what I think would be a good option would be making the search script to search and list only the resulting nano when a ID is dropped into the search. With that function my guilders and anyone else using this script could just drop any ID's they might find into the search and immediately find out if the ID could be worth something or not without having to browse through a bunch of nano's that are partial hits.
Title: Re: Nano formulas module
Post by: Malosar on March 28, 2007, 06:17:23 pm
Dropping an actual item into the search term will cause that. It's not designed to parse itemrefs, just text. The module's purpose is to advise where to obtain nanos, not for looking up what a nano does specifically. You can use !items for that. Or just type in "!nano com heal" etc

FYI, dropping an item will not send the text you see to the bot, it will send something like "itemref://12345/23443/100/Complete Healing/" etc. which is how we use other modules to parse items and find their id's and ql's.
Title: Re: Nano formulas module
Post by: shadowballs on March 28, 2007, 06:35:57 pm
Im aware of that, but what I thought might be a good idea is that if someone do drop an ID into the search the bot could reply with what nano the ID would would produce and whether it was a shop nano, mission loot/roll, dyna or other, just like the way the search lists nano searches.

So if some froob/noob is out hunting and finds the ID for Grid Armor MK I and have no clue whether he should sell it or not and no'one online in the guild that could answer he could use !nano on the ID and get a reply telling saying:
Code: [Select]
QL60 Nano Crystal (Summon Grid Armor Mk I)
 - Location: RK Dyna - Profession: Fixer
and he would know with that reply that this disk had some significance if he had been told previously that dyna nano's where rare and could be worth alot of money while 'shop' nano's isn't something worth saving

Edit: typo..
Title: Re: Nano formulas module
Post by: Wolfbiter on March 28, 2007, 07:48:03 pm
Adding such a thing isn't a bad idea (I use the same idea for !pb and dropping patterns), but the first post was a "your script is broken" and not "I think you should add this".
Once you make a bad approach (criticize that it's broken when it isn't), people will have a negative first reaction to whatever you say after that (we're humans and lets face it... we suck ass).

Title: Re: Nano formulas module
Post by: jjones666 on March 29, 2007, 12:23:53 am
Wolfbiter <3

... and yes, the reaction was extremely negative here too ;-)

-jj-
Title: Re: Nano formulas module
Post by: jjones666 on April 27, 2007, 01:45:45 am
Updated nano SQL to 17.3.

There are some missing MP nanos, not in VP shop, so I left them out for the time being.

-jj-
Title: Re: Nano formulas module
Post by: tonyuh on May 06, 2007, 06:57:55 pm
hmm.. did you nerf shade nanos on purpose? :P

Code: [Select]
$this->proflist = Array("adventurer","agent","bureaucrat","doctor","enforcer","engineer","fixer","general","keeper","martial¤artist","meta¤physicist","nano¤technician","soldier","trader");

should be

Code: [Select]
$this->proflist = Array("adventurer","agent","bureaucrat","doctor","enforcer","engineer","fixer","general","keeper","martial¤artist","meta¤physicist","nano¤technician","shade","soldier","trader");

Cheers,
Tony
Title: Re: Nano formulas module
Post by: jjones666 on May 06, 2007, 08:40:37 pm
Updated PHP, thank you.

-jj-
Title: Re: Nano formulas module
Post by: porter on May 20, 2007, 06:15:56 pm
One smallish detail caught my eye: Scheol seems to be consistently mistyped Schoel.
Title: Re: Nano formulas module
Post by: mookie on May 26, 2007, 09:58:40 am
jjones download offline? Any alt site to grab updates?
Title: Re: Nano formulas module
Post by: mookie on May 27, 2007, 02:12:42 am
Naming convention problem:
The nanos.sql file creates table nanos and the nanos.php script calls for items.nanos in the sql call. Changed the function to ("select * from nanosdb) and renamed the database table to nanodb. Everything works great after this small change.

Title: Re: Nano formulas module
Post by: Malosar on August 15, 2007, 09:52:26 pm
Any plans to update the SQL with current data?
Title: Re: Nano formulas module
Post by: Hacre on August 16, 2007, 07:34:17 am
Fatal error: Call to a member function on a non-object in /home/ninpo/aobot-test/BeBot/core/nano.php on line 29

Version 0.4.1.  I assumed the new modules settings module is in the latest version (can't find it here on the forums and jj didn't link it)...halp!
Title: Re: Nano formulas module
Post by: Callmefire on August 21, 2007, 06:33:36 pm
Well, ive got a similarly problem:

Fatal error: Cannot use object of type Settings_Core as array in D:\...\Nano.php on line 25


Maybe so can help me out ;)

version 0.4.1 (ive tried it several times, checked it but nothing)
SimplePortal 2.3.7 © 2008-2024, SimplePortal