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?
October 06, 2008, 08:58:42 AM

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.4.x Custom/Unofficial Modules > Topic: Updated Loot.php
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Updated Loot.php  (Read 568 times)
0 Members and 1 Guest are viewing this topic.
Hyde
Rookie
**
Offline Offline

Posts: 37


Updated Loot.php
« on: August 19, 2007, 01:00:51 AM »

Upgrading a couple of raidbots from 2.x to 4.1. I didn't do the original installs so I don't know where our original "Loot.php" came from, but I've left the original credits intact. I don't claim authorship, just fixed/cleaned up a bit.

This version doesn't have a re-roll function, just the basic commands from the original module. Our org likes this better than !raffle (though that's still there too) and we don't use a points system atm.

Code:
<?
/*
* Loot Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
... Modifications 2007-08-18 by Doctorhyde@RK2 for BeBot 4.1
  * Updated to use the 'Colors.inc' file (note: symlink or copy 'Colors.inc'
    from your "modules" to "custom/modules" if you're putting this script
    in "custom/modules").
  * Updated to use the "security -> check_access()" function instead of the
    "admin -> in_group()" function.
*/

/*
Add a "_" at the beginning of the file (_Loot.php) if you do not want it to be loaded.
*/

include_once("Colors.inc");

$loot = new Rolls($bot);


$commands["tell"]["rem"] = &$loot;
$commands["tell"]["add"] = &$loot;
$commands["pgmsg"]["loot"] = &$loot;
$commands["pgmsg"]["add"] = &$loot;
$commands["pgmsg"]["rem"] = &$loot;
$commands["pgmsg"]["roll"] = &$loot;
$commands["pgmsg"]["mode"] = &$loot;
$commands["pgmsg"]["list"] = &$loot;
$commands["pgmsg"]["clear"] = &$loot;

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

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

        /*
        This gets called on a tell with the command
        */
        function tell($name, $msg) {
                if(preg_match("/^" . $this -> bot -> commpre . "rem ([0-9]+)/i", $msg, $info)) {
                        unset($this -> loot[$info[1]][$name]);
                        $this -> bot -> send_pgroup(Higlight($name)." removed from rolls in slot ".Highlight("#" . $info[1]));
                        $this -> bot -> send_tell($name, Highlight($name)." removed from rolls in slot ".Highlight("#".$info[1]));
                }
                if(preg_match("/^" . $this -> bot -> commpre . "add ([0-9]+)/i", $msg, $info)) {
                        $this -> add($name, $info[1]);
                        $this -> bot -> send_tell($name, $this -> addmsg);
                }
        }

        /*
        This gets called on a msg in the privgroup with the command
        */
        function pgmsg($name, $msg) {
                if(preg_match("/^" . $this -> bot -> commpre . "loot (.*)/i", $msg, $info)) {
                        $this -> loot($info[1], $name);
                }
                if(preg_match("/^" . $this -> bot -> commpre . "add ([0-9]+)/i", $msg, $info)) {
                        $this -> add($name, $info[1]);
                }
                if(preg_match("/^" . $this -> bot -> commpre . "list/i", $msg)) {
                        $this -> rlist();
                }
                if(preg_match("/^" . $this -> bot -> commpre . "mode ?(.*)/i", $msg, $info)) {
                        if(!$info[1]) {
                                $this -> bot -> send_pgroup("Loot mode currently set to ".Highlight($this -> mode).".");
                        }
                        if(!$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> security -> check_access($name, "leader") || $this -> bot -> security -> check_access($name, "admin")) {
                                if(!$this -> lead) {
                                        if($info[1] == single) {
                                                $this -> mode = "single";
                                                $this -> bot -> send_pgroup("Roll mode changed to ".Highlight("single loot").".");
                                        } else if($info[1] == multi) {
                                                $this -> mode = "multi";
                                                $this -> bot -> send_pgroup("Roll mode changed to ".Highlight("multiple loot").".");
                                        }
                                        } else {
                                        $this -> bot -> send_pgroup("You cannot change the loot mode while rolling is in progress.");
                                }
                        }
                }

                if(preg_match("/^" . $this -> bot -> commpre . "rem ([0-9]+)/i", $msg, $info)) {
                        unset($this -> loot[$info[1]][$name]);
                        $this -> bot -> send_pgroup(Highlight($name)." removed from rolls in slot ".Highlight("#".$info[1]));
                }
                if(preg_match("/^" . $this -> bot -> commpre . "roll/i", $msg)) {
                        if($this -> lead == $name || !$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> security -> check_access($name, "leader") || $this -> bot -> security -> check_access($name, "admin")) {
                                $this -> roll($name);
                        }
                }
                if(preg_match("/^" . $this -> bot -> commpre . "clear/i", $msg)) {
                        if($this -> lead == $name || !$this -> lead || $this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> security -> check_access($name, "leader") || $this -> bot -> security -> check_access($name, "admin")) {
                                unset($this -> loot);
                                unset($this -> lead);
                                $this -> bot -> send_pgroup(Highlight($name)."<font color=#FF0000> cancelled the loot rolls in progress");
                        }
                }
        }

        function add($name, $slot) {
                unset($present);
                if($this -> loot[$slot]) {
                        if($this -> mode == 'single') {
                                $slots = array_keys($this -> loot);
                                foreach($slots as $key=>$sslot) {
                                        $list = array_keys($this -> loot[$sslot]);
                                        foreach($list as $playerslot=>$player) {
                                                if($player == $name) {
                                                        unset($this -> loot[$sslot][$player]);
                                                        $present = true;
                                                }
                                        }
                                }
                                if($present == true) {
                                        $this -> addmsg = Highlight($name)." changed to slot ".Highlight("#$slot");
                                        } else {
                                        $this -> addmsg = Highlight($name)." assigned to slot ".Highlight("#$slot");
                                }
                                $this -> loot[$slot][$name] = true;
                                } else {
                                $this -> loot[$slot][$name] = true;
                                $this -> addmsg = Highlight($name)." assiged to slot ".Highlight("#$slot");
                        }
                        } else {
                        $this -> addmsg = "There is currently no roll in slot $slot";
                }
                $this -> bot -> send_pgroup($this -> addmsg);
        }

        function loot($msg, $name) {
                if($this -> lead == $name || !$this -> lead) {
                        $this -> lead = $name;
                        $count = count($this -> loot)+1;
                        $this -> loot[$count][item] = $msg;
                        $this -> bot -> send_pgroup(Highlight($msg)." being rolled in slot ".Highlight("#".$count));
                }
        }

        function roll($name){
                $num = 1;
                if($this -> bot -> commands[pgmsg][leader] -> raidleader == $name || $this -> bot -> security -> check_access($name, "leader") || $this -> bot -> security -> check_access($name, "admin") || $this -> lead == $name || !$this -> lead) {
                        foreach($this -> loot as $slot) {
                                unset($winner);
                                $users = array();
                                $item = $slot[item];
                                unset($slot[item]);
                                $list = $slot;
                                $users = array_keys($slot);
                                $rolling = $users;
                                $count = count($slot)-1;
                                for($i = 1; $i <= 10000; $i++) {
                                        $list[$users[rand(0, $count)]] += 1;
                                }
                                natsort($list);
                                foreach($list as $name => $points) {
                                        $winner = $name;
                                }
                                if(!$winner) {
                                        $winner = "[ none ]";
                                }
                                $this -> bot -> send_pgroup("<font color=#FF0000>$winner</font> won the roll for ".Highlight($item)." in slot ".Highlight("#".$num)."!");
                                unset($this -> loot[$num]);
                                unset($this -> lead);
                                $num++;
                        }
                }
        }

        function rlist() {
                $num = 0;
                foreach($this -> loot as $slot) {
                        unset($msg);
                        $num++;
                        $msg .= "Rolling on item ".Highlight($slot[item])." in slot ".Highlight("#$num").": ";
                        if(count($slot) == 1) {
                                $msg .= "[ none ]";
                                } else {
                                $list = array_keys($slot);
                                foreach($list as $key=>$player) {
                                        if($player != "item") {
                                                $msg .= "(".Highlight($player).") ";
                                        }
                                }
                        }
                        $this -> bot -> send_pgroup($msg);
                }
        }
}
?>

Logged

Doctorhyde/Jexyll/Goraud@RK2
Ebag333
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 132


Re: Updated Loot.php
« Reply #1 on: August 20, 2007, 12:56:09 AM »

I personally like Craized's version (that I updated to work with then 3.0, and later 4.x and 5.x).

http://svn.shadow-realm.org/index.py/BeBot/branches/BeBot_RAID/modules/Loot_RAID.php?view=co
Logged
johskar
Rookie
**
Offline Offline

Posts: 47


Re: Updated Loot.php
« Reply #2 on: March 08, 2008, 02:45:24 PM »

*Thread necro*
Ebag got that updated crazied version somewhere as the link you used now fails as the module is missing?

Nvm... found it Smiley
« Last Edit: March 08, 2008, 03:16:34 PM by johskar » Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > 0.4.x Custom/Unofficial Modules > Topic: Updated Loot.php
« previous next »
 
Jump to:  

Recent
!items database
by cthulhu
[October 05, 2008, 11:36:16 AM]

Supplies needed module
by viper
[October 05, 2008, 11:11:13 AM]

Assist
by Foxy
[October 05, 2008, 05:09:02 AM]

How's 0.5.x coming? Wonde...
by Hyde
[October 04, 2008, 04:59:20 PM]

TWC
by Elesar1
[October 04, 2008, 12:55:59 PM]

Org in AoC
by Alreadythere
[October 04, 2008, 04:50:00 AM]

OnlineOrg
by Slacklin
[October 04, 2008, 03:06:00 AM]

Learning .NET, Mono, C#, ...
by Vhab
[October 04, 2008, 02:39:03 AM]

guild taxes module for ag...
by Elesar1
[October 03, 2008, 09:06:09 AM]

MediaControl
by Elesar1
[October 03, 2008, 08:38:18 AM]
Stats
Members
Total Members: 983
Latest: Titerris
Stats
Total Posts: 10740
Total Topics: 1448
Online Today: 15
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 3
Guests: 34
Total: 37
Sudoka
cthulhu
Karsta

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.615 seconds with 28 queries. (Pretty URLs adds 0.029s, 4q)
Loading...