BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: craized on December 06, 2005, 07:10:01 am

Title: Another Modified TowerAttack
Post by: craized on December 06, 2005, 07:10:01 am
TOWER ATTACK MODULE (http://www.craized.net/junk/bebot/highlight.php?TowerAttack)

Description:
A module that displays tower attacks in pgroup and/or gc. Redid all notification messages (I think). And updated for the new patch.

Commands

!battle

!victory
Title: Another Modified TowerAttack
Post by: Wanuarmi on December 06, 2005, 08:44:13 am
dont you need the new AOChat.php to interpret the new messages? if not great job!
Title: Another Modified TowerAttack
Post by: craized on December 06, 2005, 08:48:55 am
This module is not completed. There are a couple of little tweaked things. This uses the AOChat.php from http://bebot.fieses.net/viewtopic.php?t=203 You also have to modify your Bot.php as described in that thread. It's not completely straight forward, but I'd say its worth it.
Title: Another Modified TowerAttack
Post by: craized on December 07, 2005, 02:23:32 pm
Tower notifications have reached my expectations and I'll now consider them complete.
Title: Re: Another Modified TowerAttack
Post by: Xenixa on January 11, 2006, 09:38:00 am
Using this one myself now. Made a little change however, because I'm running Alreadythere's Persistent Whois cache module (http://bebot.link/index.php/topic,223.0.html) figured the TowerAttacks module could use the whois cache also.

Replaced this:
Code: [Select]
    function info($name) {
        $content = $this -> bot -> get_site('http://www.anarchy-online.com/character/bio/d/'.$this -> bot -> dimension.'/name/'.strtolower($name).'/bio.xml');
        $user['nick'] = $this -> bot -> xmlparse($content, 'nick');
        $user['profession'] = $this -> bot -> xmlparse($content, 'profession');
        $user['level'] = $this -> bot -> xmlparse($content, 'level');
        $user['title'] = $this -> bot -> xmlparse($content, 'profession_title');
        $user['AT'] = $this -> bot -> xmlparse($content, 'defender_rank');
        $user['AI'] = $this -> bot -> xmlparse($content, 'defender_rank_id');
        $user['org'] = $this -> bot -> xmlparse($content, 'organization_name');
        $user['rank'] = $this -> bot -> xmlparse($content, 'rank');
        $user['faction'] = $this -> bot -> xmlparse($content, 'faction');
        $this -> user = $user;
    }

With This:
Code: [Select]
    function info($name) {
        $who = $this -> bot -> whois -> lookup($name);
        $user['nick'] = $who['nick'];
        $user['profession'] = $who['profession'];
        $user['level'] = $who['level'];
        $user['org'] = $who['org'];
        $user['faction'] = $who['faction'];
        $this -> user = $user;
    }

Works like a Champ. :)
Title: Re: Another Modified TowerAttack
Post by: Xenixa on May 07, 2006, 11:45:52 am
As I noted in Wolfbiters thread here - http://bebot.link/index.php/topic,378.msg2312/topicseen.html#msg2312
I've updated this module to show LCA info.
You can Get it Here (ftp://xen.afraid.org/bebot_files/TowerAttack.php)

Other changes incl:
- Uses and parses Tower Messages from AOChat.php 1.19 and the custom version mentioned in this thread.
- Requires as stated above in the previous post, Alreadythere's whois module.
- Search battles by playfield, EX: !battle Lush - will return all recent battles in Lush Fields. The search uses the sql LIKE function for matching.

This is mostly for Bebot 0.3.2 and above. I havn't tested it with any of the older bot versions but it should work.
One last note. I had to disable Craized's anti-spam code for the Tower Alerts. PHP 5 was freaking out over it. Looking at making another method for that routine but if anyone else wants to take a stab at it, feel free.
Title: Re: Another Modified TowerAttack
Post by: Alreadythere on May 09, 2006, 08:40:51 pm
Great work Xenika, thanks :)

Always wanted to do something like that myself, but never got around to it.
Now I just got to add the zone to the victories table.
Title: Re: Another Modified TowerAttack
Post by: Pharexys on May 13, 2006, 02:16:11 pm
As I noted in Wolfbiters thread here - http://bebot.link/index.php/topic,378.msg2312/topicseen.html#msg2312
I've updated this module to show LCA info.
You can Get it Here (ftp://xen.afraid.org/bebot_files/TowerAttack.php)

Other changes incl:
- Uses and parses Tower Messages from AOChat.php 1.19 and the custom version mentioned in this thread.
- Requires as stated above in the previous post, Alreadythere's whois module.
- Search battles by playfield, EX: !battle Lush - will return all recent battles in Lush Fields. The search uses the sql LIKE function for matching.

This is mostly for Bebot 0.3.2 and above. I havn't tested it with any of the older bot versions but it should work.
One last note. I had to disable Craized's anti-spam code for the Tower Alerts. PHP 5 was freaking out over it. Looking at making another method for that routine but if anyone else wants to take a stab at it, feel free.




Awesome, loving it already :P
Title: Re: Another Modified TowerAttack
Post by: Mephistobane on June 26, 2006, 07:27:56 pm
so,will Xenixa's work with having JUST installed the whois cache(meaning it hasn't had time to put anything into the cache yet)?

and the link to the AOchat.php thing is broke, i would have liked to have looked at that thread :D

anyways, it says meh bot crashs whenever it does a member lookup (Towerattack.php line 305) cuz member_lookup() is a non-object,or soemthing. sorry i dont have anything to paste atm, i clicked and the bot log disappeared. i'm thinking this is because there's nothing in the cache yet so i turned towerattack.php off a while until it does.

if anyone has comments they are welcome.
Title: Re: Another Modified TowerAttack
Post by: Barvaz on July 21, 2006, 06:32:54 pm
hey, the tower_attack table gets clean after some time? atm i got 3 pages of battles, so i wonder, it gets clean every day or after some limit of battle? 32 battles in the tower_attack table now
Title: Re: Another Modified TowerAttack
Post by: Tsuyoi on July 21, 2006, 07:22:48 pm
Afaik, the module has a limiter on how many battles it shows, regardless of how many are in the history table.

Code: [Select]
$result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 13');

If you've removed that limit, then it'll spam the entire table, but if not, it'll only give you the last 13 battles.

In Xenixa's version (incase that's the one you're refering to) it's modified to 20:

Code: [Select]
$result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 20');

So if it's displaying too many results each time, you may want to look for those sections of the code and see if something is missing.  Hope that info helps :)
Title: Re: Another Modified TowerAttack
Post by: Barvaz on July 22, 2006, 01:41:20 am
cool, thanks :)

i still need to learn php damnit :P
Title: Re: Another Modified TowerAttack
Post by: pusikas on January 03, 2007, 10:48:46 pm
Damn, I can never download stuff that Xenixa posts. :( Can someone post a copy?
Title: Re: Another Modified TowerAttack
Post by: Malosar on January 03, 2007, 10:54:43 pm
Here you go. Not sure if it's exactly the same one but it supports the latest version of tower broadcast messages and whois cache.
Title: Re: Another Modified TowerAttack
Post by: pusikas on January 03, 2007, 11:33:51 pm
I'm almost sure that this is not it. Does not make use of the LCA module. :)
Title: Re: Another Modified TowerAttack
Post by: Xenixa on January 04, 2007, 02:56:57 am
so,will Xenixa's work with having JUST installed the whois cache(meaning it hasn't had time to put anything into the cache yet)?

and the link to the AOchat.php thing is broke, i would have liked to have looked at that thread :D

anyways, it says meh bot crashs whenever it does a member lookup (Towerattack.php line 305) cuz member_lookup() is a non-object,or soemthing. sorry i dont have anything to paste atm, i clicked and the bot log disappeared. i'm thinking this is because there's nothing in the cache yet so i turned towerattack.php off a while until it does.

if anyone has comments they are welcome.

Yes, in a nut shell if you have a just installed the whois cache module anytime a tower attack happens this module calls on that whois module which in turn looks for the name of attacker in the local DB, if it doesn't find it it pulls from FC server. Once it has that info it cache's it and sends it back to the TowerAttack module which originally requested it.

And since there still seems to be a problem with my FTP server(which is running but for some reason not accessable) I'll attach my latest version(knock off the .txt to use).

Note: You still need the Whoiscache and LCA(with supporting SQL file) modules for this version to work.
Also note as I mentioned a ways back I also worked out a new solution to a Anti-Battle spam filter.

Enjoy. :)
Title: Re: Another Modified TowerAttack
Post by: pusikas on January 04, 2007, 11:36:46 am
Works with my 2.10 bot, I love it. :) Thanks for posting as attachment.
Title: Re: Another Modified TowerAttack
Post by: pusikas on March 27, 2007, 06:33:35 pm
Added settings to control where the module puts itw output. Requires Glarawyn's Settings module, me thinks. Careful, default is not to output at all.
Title: Re: Another Modified TowerAttack
Post by: shadowballs on March 28, 2007, 12:28:43 am
first off, after some tweaking I just love BeBot. :)

I run it in my guild chat, and as some people in my guild are more or less heavily into PvP a functioning !battle command is a must, and youre detailed commands would suit us perfect. Ive sucsessfully installed whoiscache and LCA which both works (more or less, whoiscache spams alot of notices during updates)

well, Ive downloaded the updated Towerattack.php file and when someone tries the !battle I get a >>clicky<< in our chat but when I open it up its empty and if I check the bot's logs this shows up every time someone does a !battle command

Code: [Select]
Warning: Invalid argument supplied for foreach() in C:\Program Files (x86)\BeBot_v0.2.11\modules\TowerAttack.php on line 148
Im no php whizz so what could be wrong here?
Title: Re: Another Modified TowerAttack
Post by: Blueeagle on March 28, 2007, 02:44:42 am
The "Invalid argument supplied for foreach()" warning occures when you attempt to run a foreach-loop on a value that is not an array.

This frequently occures when you neglect to error check if the result returned from $this -> bot -> db -> select() is infact an array and not ie. false.

The code causing the warning here is probably
Code: [Select]
    function battle_blob($pf)
    {
if ($pf != null) {
        $result = $this -> bot -> db -> select("SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack WHERE zone LIKE '%$pf%' ORDER BY time DESC LIMIT 0, 20");
        }
        else {
        $result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 20');
        }
        if (!empty($pf)){
$battle = "<center><font color=CCInfoHeadline>:::: <u>Recent Tower Battles for ".$pf."</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
        }
        else {
        $battle = "<center><font color=CCInfoHeadline>:::: <u>All Recent Tower Battles</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
        }
        foreach ($result as $res) {

Where the warning is generated by the last line. However that line is not the actual reason for the warning to be generated.

The reason is that the one of the above two calls to $this -> bot -> db -> select() that is actually called does not return any results.

This would be because there are no battles registered in the database. This should have been handled with a graceful exit, but such is omitted here. A graceful exit would look something like:

Code: [Select]
    function battle_blob($pf)
    {
if ($pf != null) {
        $result = $this -> bot -> db -> select("SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack WHERE zone LIKE '%$pf%' ORDER BY time DESC LIMIT 0, 20");
        }
        else {
        $result = $this -> bot -> db -> select('SELECT time, off_guild, off_side, off_player, off_level, off_profession,
        def_guild, def_side, zone, x_coord, y_coord FROM tower_attack ORDER BY time DESC LIMIT 0, 20');
        }
        if (empty($result))
        {
                return("No battles found");
        }
        if (!empty($pf)){
$battle = "<center><font color=CCInfoHeadline>:::: <u>Recent Tower Battles for ".$pf."</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
        }
        else {
        $battle = "<center><font color=CCInfoHeadline>:::: <u>All Recent Tower Battles</u> ::::</font></center>\n\n".'<font color=CCInfoText>';
        }
        foreach ($result as $res) {

Keep in mind that I have note checked the code nor looked closely if it will work or not. It is just an example.

Now, this still isn't the source of the problem which is that no battles has been entered into your battle table. Now if you've upgraded the TowerAttack module you also need to upgrade the table holding the data, or at the very least delete it.

I am suspecting that your log also contains warnings about MYSQL not being able to insert data into the tower_attack table as it is in the wrong format.

You can attempt to fix this by deleting the tower_attack table in your mysql database. To do this open the mysql command prompt and use the database that BeBot uses (refer to your conf/MySQL.conf file if you're uncertain about the details).

There you run the commands:
Code: [Select]
DROP TABLE tower_attack;
DROP TABLE tower_result;

When you re-start BeBot it should re-create the two tables in the right format. Now you just need to wait until someone kills some towers.

Also note that your bot needs to be in the top three ranks of your org to recieve the ALL TOWERS channel needed to populate the tower_attack table.

Hope that helps.
Title: Re: Another Modified TowerAttack
Post by: shadowballs on March 28, 2007, 03:21:11 am
hmm..  okay.  I allready had the tables but they where empty so I guess it was only my impatience that had any errors  ::)
I guess Ill just have to be patient and wait until someone actually attacks some towers before I complain any more :P

Anyhows, thanks for you're help
Title: Re: Another Modified TowerAttack
Post by: Blueeagle on March 28, 2007, 05:15:22 am
Yeah, an empty table will also cause that warning. That's where the graceful exit comes into play. :)

edit: Typo
SimplePortal 2.3.7 © 2008-2024, SimplePortal