L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 04:57:23 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > 0.5.x Custom/Unofficial Modules > Topic: TowerAttack
Pages: [1]   Go Down
« previous next »
Print
Author Topic: TowerAttack  (Read 736 times)
0 Members and 1 Guest are viewing this topic.
Nogoal
Rookie
**
Offline Offline

Posts: 61


TowerAttack
« on: August 20, 2007, 08:14:23 AM »

Someone modified TowerAttack in the past to show the Hugemap numbers. I liked it so I modified TowerAttack every time a new version was released. Could be nice to add it to SVN/releases so I don't have to do it again  Grin and others could benefit from it too.

http://aotn.binarywastes.net/TowerAttack.rar

Output:
[Org Msg]Les Rebelles Francophones has attacked Battle Ants in Broken Shores at 870x3471 (x4). Attacker: Drakinos (136 Engineer)

[Battle]
Broken Shores (870x3471)
LCA: x4 - Near Clan Outpost (L100-150)
Time: October 4th, 2007 08:23 GMT
Attacker: Drakinos (136 Engineer)
Attacking Guild: Les Rebelles Francophones
Defending Guild: Battle Ants

[Victory]
October 3rd, 2007 20:14 GMT
Stret West Bank
Winner: Shadow Legacy
Looser: =ACF= Resistance



PS: You might need to add some lines to your xml files for colours.
PPS: LCA module is needed. You can find it here.
« Last Edit: October 04, 2007, 04:21:09 AM by Nogoal » Logged
Dabaron
Apprentice
***
Offline Offline

Gender: Male
Posts: 145


Re: TowerAttack
« Reply #1 on: September 23, 2007, 12:49:07 PM »

I've been modifying this one a little bit (modified a couple colors, added a message to be sent to irc, made it always relay to pgroup, etc) but I can't get the irc relay to work.  Here are the changes I made, let me know what I'm doing wrong here...

Code:
if (!empty($off_guild)) {
if (empty($off_side)) { $off_side = "error"; }
$msg = "##" . $off_side . "##" . $off_guild . "##end## has attacked ##" . $def_side . "##" .
$def_guild . "##end## in " . $zone . " at " . $x_coords . "x" . $y_coords. " (" . $lcanum . "). Attacker: ##" . $off_side . "##" .
$off_player . "##end## (" . $player["level"] . " " . $player["profession"] . ")";
$ircmsg = "[Tower Attack]" . $off_player . " (" . $player["level"] . " " . $player["profession"] . ") of " . $off_guild . "(" . $off_side . ") has attacked " .$def_guild . " (" . $def_side . ") in " . $zone;
}
else {
if (empty($off_side)) { $off_side = "error"; }
$msg = "##" . $off_side . "##" . $off_player . "##end## (" . $player["level"] . " " . $player["profession"] . ") just attacked ##" . $def_side . "##" .
$def_guild . "##end## in " . $zone . " at " . $x_coords . "x" . $y_coords. " (" . $lcanum . ").";
$ircmsg = "[Tower Attack]" . $off_player . " (" . $player["level"] . " " . $player["profession"] . ") has attacked " . $def_guild . " (" . $def_side . ") in " . $zone;
}

Then added this:

Code:
if ($this -> bot -> settings -> get("Towerattack", "Spam"))
{
if ($this -> bot -> guildbot)
{
$this -> bot -> send_gc($msg);
$this -> bot -> send_pgroup($msg);
$this -> bot -> commands["tell"]["irc"] -> irc_send_local($ircmsg);
}
else
{
$this -> bot -> send_pgroup($msg);
$this -> bot -> commands["tell"]["irc"] -> irc_send_local($ircmsg);
}
}

It is going to gc and pgroup as I wanted, but nothing relays to irc.  Looking at bot window it dosen't show that its even trying and I can't figure out why.
Logged
Dabaron
Apprentice
***
Offline Offline

Gender: Male
Posts: 145


Re: TowerAttack
« Reply #2 on: September 23, 2007, 01:33:07 PM »

Ok, nevermind.  As strange as this sounds I put the same modified module into another bot I run and it relays to IRC fine, just that one bot dosen't.  I'll have to look at that and figure out what its doing different.
Logged
Dabaron
Apprentice
***
Offline Offline

Gender: Male
Posts: 145


Re: TowerAttack
« Reply #3 on: September 24, 2007, 12:58:28 AM »

Ok, working in all my bots now.  I will post the changes I've made.  I have added the orbital strike info (stolen from here), changed a little with colors to match what I like, and for my use I always relay to both gc, pgroup, and irc so added that in (easy to remove that part if you don't want it).

Code:
<?php
/*
* TowerAttack.php - Handle Tower attack events.
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg Stensås, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*
* File last changed at $LastChangedDate$
* Revision: $Id$
*/

/*
Needed for TowerAttack
*/
$db -> query("CREATE TABLE IF NOT EXISTS " . $db -> define_tablename("tower_attack", "true") . "
              (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
              time int,
              off_guild VARCHAR(50),
              off_side VARCHAR(10),
              off_player VARCHAR(20),
              off_level int,
              off_profession VARCHAR(15),
              def_guild VARCHAR(50),
              def_side VARCHAR(10),
              zone VARCHAR(50),
              x_coord INT,
              y_coord INT)"
);

$db -> query("CREATE TABLE IF NOT EXISTS " . $db -> define_tablename("tower_result", "true") . "
              (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
              time int,
              win_guild VARCHAR(50),
              win_side VARCHAR(10),
              lose_guild VARCHAR(50),
              lose_side VARCHAR(10))"
);


$towerAttack = new TowerAttack($bot);


$commands["tell"]["battle"] = &$towerAttack;
$commands["tell"]["victory"] = &$towerAttack;
$commands["tell"]["orbs"] = &$towerAttack;

$commands["pgmsg"]["battle"] = &$towerAttack;
$commands["pgmsg"]["victory"] = &$towerAttack;
$commands["pgmsg"]["orbs"] = &$towerAttack;

$commands["gc"]["battle"] = &$towerAttack;
$commands["gc"]["victory"] = &$towerAttack;
$commands["gc"]["orbs"] = &$towerAttack;

$commands["gmsg"]["All Towers"][] = &$towerAttack;
$commands["gmsg"]["Tower Battle Outcome"][] = &$towerAttack;
$commands["gmsg"]["Tower Battle Outcome"][] = &$towerAttack;
$commands['gmsg']['Org Msg'][] = &$towerAttack;
$cron["5sec"][] = &$towerAttack;


/*
The Class itself...
*/
class TowerAttack
{
var $bot;



/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function TowerAttack (&$bot)
{
$this -> bot = &$bot;

        
$this -> bot -> accesscontrol -> create("all", "battle", "GUEST");
        
$this -> bot -> accesscontrol -> create("all", "victory", "GUEST");
$this -> bot -> accesscontrol -> create("orbs", "victory", "MEMBER");

$this -> bot -> settings -> create("TowerAttack", "Spam", TRUE, "Is spamming of tower attacks into org chat on or off?");

$this -> help['description'] = 'Handle tower attack events.';
$this -> help['command']['battle']="Shows recent tower attacks.";
$this -> help['command']['victory'] = "Shows recent tower victories.";
$this -> help['command']['orbs']= "Show Orb Lock Times.";
$this -> help['notes'] = "The bot MUST be in the top-three rank of the guild for this module to work.";

$this -> index = 1;
}



/*
This gets called on a tell
*/
function tell($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "battle/i", $msg))
$this -> bot -> send_tell($name, $this -> battle_blob());
if (preg_match("/^" . $this -> bot -> commpre . "victory$/i", $msg))
$this -> bot -> send_tell($name, $this -> victory_blob());
else if (preg_match("/^" . $this -> bot -> commpre . "orbs$/i", $msg))
$this -> bot -> send_tell($name, $this -> orbtimes());
}



/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "battle/i", $msg))
$this -> bot -> send_pgroup($this -> battle_blob());
if (preg_match("/^" . $this -> bot -> commpre . "victory$/i", $msg))
$this -> bot -> send_pgroup($this -> victory_blob());
else if (preg_match("/^" . $this -> bot -> commpre . "orbs$/i", $msg))
$this -> bot -> send_pgroup($this -> orbtimes());
}



/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "battle/i", $msg))
$this -> bot -> send_gc($this -> battle_blob());
if (preg_match("/^" . $this -> bot -> commpre . "victory$/i", $msg))
$this -> bot -> send_gc($this -> victory_blob());
else if (preg_match("/^" . $this -> bot -> commpre . "orbs$/i", $msg))
$this -> bot -> send_gc($this -> orbtimes());
}


    
/* Called to colorize faction string */
    
function factioncolor($side) {
        
$side = "##" . strtolower($side) . "##" . $side . "##end##";
        return(
$side);
}

/*
Makes the victory results
*/
function victory_blob()
{
$battle = "<font color=CCInfoHeadline>:::: Recent Battle Results ::::</font>\n\n<font color=CCInfoText>";

$result = $this -> bot -> db -> select("SELECT time, win_guild, win_side, lose_guild, lose_side FROM #___tower_result ORDER BY time DESC LIMIT 0, 15");
foreach ($result as $res)
{
$battle .= "<font color=CCInfoHeader>" . gmdate($this -> bot -> settings -> get("Time", "FormatString"), $res[0]) . " GMT</font>\n";
            
$battle .= "Winner: <font color=CCCCTextColor>" . stripslashes($res[1]) . "</font> <font color=CCCCHeaderColor>(" . $this -> factioncolor($res[2]) . ")</font>\n";
            
$battle .= "Loser: <font color=CCCCTextColor>" . stripslashes($res[3]) . "</font>  <font color=CCCCHeaderColor>(" . $this -> factioncolor($res[4]) . ")</font>\n";
$battle .= "\n";
}
return "Tower Battles Won: " . $this -> bot -> make_blob("click to view", $battle);
}



/*
Makes the battle results
*/
function battle_blob()
{
$battle = "##blob_title##:::: Recent Tower Battles ::::##end##\n\n";

$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"
);
foreach ($result as $res)
{
    $lca = $this -> get_lcainfo($res['8'], $res['9'], $res['10']);
        
$lcanum = "##red##x".$lca['pid']."##end##";
        
$prtlca = "LCA: ".$lcanum."##normal## - ".$lca['name']."##end## ##highlight##(L".$lca['lrng']."-".$lca['hrng'].")##end##\n";

$battle .= "##lightgreen##" . $res[8] . " (" . $res[9] . "x" . $res[10] . ")##end##\n";
$battle .= $prtlca;
$battle .= "Time: ##highlight##" . gmdate($this -> bot -> settings -> get("Time", "FormatString"), $res[0]) . " GMT##end##\n";
if (empty($res[2])) { $res[2] = "error"; }
$battle .= "Attacker: ##" . $res[2] . "##" . $res[3] . " ##end##(" . $res[4] . " " . $res[5] . ")\n";
if (!empty($res[1]))
$battle .= "Attacking Guild: ##" . $res[2] . "##" . stripslashes($res[1]) . "##end##\n";
$battle .= "Defending Guild: ##" . $res[7] . "##" . stripslashes($res[6]) . "##end##\n";
$battle .= "\n";
}
return "Tower Battles: " . $this -> bot -> make_blob("click to view", $battle);
}



/*
This gets called on a msg in the group
*/
function gmsg($name, $group, $msg)
{
$attack = false;
$victory = false;

if (preg_match("/The (clan|neutral|omni) organization (.+) just entered a state of war! (.+) attacked the (clan|neutral|omni) organization (.+)'s tower in (.+) at location \(([0-9]+), ([0-9]+)\)/i", $msg, $info))
{
$off_guild = $info[2];
$off_side = ucfirst(strtolower($info[1]));
$off_player = $info[3];
$def_guild = $info[5];
$def_side = ucfirst(strtolower($info[4]));
$zone = $info[6];
$x_coords = $info[7];
$y_coords = $info[8];
$attack = true;
}
else if (preg_match("/(.+) just attacked the (clan|neutral|omni) organization (.+)'s tower in (.+) at location \(([0-9]+), ([0-9]+)\)/i", $msg, $info))
{
$off_guild = "";
$off_side = "";
$off_player = $info[1];
$def_guild = $info[3];
$def_side = ucfirst(strtolower($info[2]));
$zone = $info[4];
$x_coords = $info[5];
$y_coords = $info[6];
$attack = true;
}
else if (preg_match("/(.+) (Clan|Omni|Neutral) organization (.+) attacked the (Clan|Omni|Neutral) (.+) at their base in (.+). The attackers won!!/i", $msg, $info))
{
$this -> bot -> db -> query("INSERT INTO #___tower_result (time, win_guild, win_side, lose_guild, lose_side) VALUES
                                      ('" 
. time() . "', '" . mysql_escape_string($info[3]) . "', '" . $info[2] . "', '" . mysql_escape_string($info[5]) . "', '" . $info[4] . "')");
}

else if (preg_match("/Blammo! (.+) has launched an orbital attack!/i", $msg, $info))
{
$info[1] = "Somebody";// FIX ME
$this -> orb($info[1]);
}

if ($attack)
{
$player = $this -> bot -> whois -> lookup($off_player);
if (empty($player["level"]))
{
$player["level"] = '?';
}

if (empty($player["profession"]))
{
$player["profession"] = 'Unknown';
}

$lca = $this -> get_lcainfo($zone, $x_coords, $y_coords);
        
$lcanum = "<font color=#FF0000>x".$lca['pid']."</font>";
        
$prtlca = "LCA: ".$lcanum."<font color=CCCCTextColor> - ".$lca['name']."</font> <font color=CCCCHeaderColor>(L".$lca['lrng']."-".$lca['hrng'].")</font>\n";

if (!empty($off_guild)) {
if (empty($off_side)) { $off_side = "error"; }
$msg = "##" . $off_side . "##" . $off_guild . "##end## has attacked ##" . $def_side . "##" .
$def_guild . "##end## in " . $zone . " at " . $x_coords . "x" . $y_coords. " (" . $lcanum . "). Attacker: ##" . $off_side . "##" .
$off_player . "##end## (" . $player["level"] . " " . $player["profession"] . ")";
$ircmsg = "[Tower Attack] " . $off_player . " (" . $player["level"] . " " . $player["profession"] . ") of " . $off_guild . " (" . $off_side . ") has attacked " .$def_guild . " (" . $def_side . ") in " . $zone;
}
else {
if (empty($off_side)) { $off_side = "error"; }
$msg = "##" . $off_side . "##" . $off_player . "##end## (" . $player["level"] . " " . $player["profession"] . ") just attacked ##" . $def_side . "##" .
$def_guild . "##end## in " . $zone . " at " . $x_coords . "x" . $y_coords