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

Posts: 46


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: 50


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
[request] Raid timers
by Elesar1
[Today at 04:41:09 PM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11144
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 0
Guests: 14
Total: 14

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