collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Updated Loot.php  (Read 6971 times)

0 Members and 1 Guest are viewing this topic.

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Updated Loot.php
« on: August 19, 2007, 08: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: [Select]
<?
/*
* 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);
                }
        }
}
?>

Doctorhyde/Jexyll/Goraud@RK2

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Updated Loot.php
« Reply #1 on: August 20, 2007, 07: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

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: Updated Loot.php
« Reply #2 on: March 08, 2008, 08: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 :)
« Last Edit: March 08, 2008, 09:16:34 pm by johskar »
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

* Who's Online
  • Dot Guests: 299
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal