Archive > 0.5.x Custom/Unofficial Modules

New apf

<< < (3/3)

Heffalomp:
noone made something like this for bebot 0.5/0.6 yet and published? that's a shame...

Khalem:
This is shipped with BeBot by default. See !identify or !bio

Zacix:
This code isn't !identify/bio actually. It's a whole rollsystem, but also a small module to make the list automatically for 13/28/35. Needs some work to make it work for BeBot though :)

Heffalomp:
So... I got a bit drunk not long after my previous post and made a !killed mod in the loot.php, messy code as always...  ::)
And could not at the time find any decent way of keeping the lists on top of bottom, but it works atleast :P
Is it possible for icons to show in loot list if I add the iconid needed somewhere?

--- Code: ---<?

$loot = new Rolls($bot);

/*
The Class itself...
*/
class Rolls extends BaseActiveModule
{
function __construct(&$bot)
{
parent::__construct(&$bot, get_class($this));

$this -> count = 0;

$this -> register_command("pgmsg", "loot", "ANONYMOUS");
$this -> register_command("pgmsg", "add", "ANONYMOUS");
$this -> register_command("pgmsg", "rem", "ANONYMOUS");
$this -> register_command("pgmsg", "list", "ANONYMOUS");
$this -> register_command("pgmsg", "result", "ADMIN");
$this -> register_command("pgmsg", "clear", "ADMIN");
$this -> register_command("pgmsg", "reroll", "ADMIN");
$this -> register_command("pgmsg", "killed", "LEADER");
$this -> register_command("tell", "add", "ANONYMOUS");
$this -> register_command("tell", "rem", "ANONYMOUS");
$this -> register_command("tell", "loot", "ANONYMOUS");
$this -> register_command("tell", "list", "ANONYMOUS");
$this -> register_command("tell", "clear", "ADMIN");
$this -> register_command("tell", "reroll", "ADMIN");
$this -> register_command("tell", "killed", "LEADER");

$this -> register_event("pgleave");

$this -> bot -> core("settings") -> create ("Loot", "Roll", "SINGLE", "Should you be allowed to be added to the roll of more than one slot?", "SINGLE;MULTI");

$this -> bot -> core("colors") -> define_scheme("loot", "highlight", "yellow");

$this -> help['description'] = 'Module to flat roll on items.';
$this -> help['command']['loot <item>']="Adds an item to the roll list.";
$this -> help['command']['add <slot>']="Adds your name to the slot number.  Add 0 removes you from all slots.";
$this -> help['command']['rem <slot>']="Removes your name from the slot number.";
$this -> help['command']['list']="Lists all items and who is rolling for them.";
$this -> help['command']['clear']="Clears all rolls.";
$this -> help['command']['result']="Rolls for all the items and announces winners.";
$this -> help['command']['reroll']="Adds any unwon items from the last roll to a new roll.";
$this -> help['command']['killed <sector number>']="Load roll for sector 13/28/35.";
}

/*
This function handles all the inputs and returns FALSE if the
handler should not send output, otherwise returns a string
sutible for output via send_tell, send_pgroup, and send_gc.
*/
function command_handler($name, $msg, $source)
{ // Start function handler()
if(preg_match("/^loot (.*)/i", $msg, $info))
$this -> loot($info[1], $name);
else if(preg_match("/^reroll/i", $msg, $info))
$this -> reroll($name);
else if(preg_match("/^killed (.*)/i", $msg, $info))
$this -> killed($name, $info[1]);
else if(preg_match("/^add ([0-9]+)/i", $msg, $info))
$this -> add($name, $info[1], false);
else if(preg_match("/^list/i", $msg))
$this -> rlist();
else if(preg_match("/^rem ([0-9]+)/i", $msg, $info))
{
if (isset($this -> loot[$info[1]][$name]))
{
unset($this -> loot[$info[1]][$name]);
$this -> bot -> send_pgroup("##loot_highlight##" . $name . "##end## removed from rolls in slot##loot_highlight## #" . $info[1]);
}
}
else if(preg_match("/^result/i", $msg))
$this -> roll($name);
else if(preg_match("/^clear/i", $msg))
{
unset($this -> loot);
unset($this -> leftovers);
$this -> count = 0;
$this -> bot -> send_pgroup("##loot_highlight##" . $name . "##end## cancelled the loot rolls in progress");
}
else
$this -> bot -> send_help($name);
} // End function handler()

/*
This gets called if someone leaves the privgroup
*/
function pgleave($name)
{
if (isset($this -> loot[$info[1]][$name]))
{
unset($this -> loot[$info[1]][$name]);
$this -> bot -> send_pgroup("##loot_highlight##" . $name . "##end## removed from rolls in slot##loot_highlight## #" . $info[1]);
}
}

/***********************************************************************************************************/
function add($name, $slot)
{
if ($slot == 0)
{
$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]);
}
}
}

$this -> addmsg = "##loot_highlight##" . $name . "##end## removed from all slots.";
}
else
{
$present = false;
if($this -> loot[$slot])
{
if ($this -> bot -> core("settings") -> get('Loot', 'Roll') == "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 = "##loot_highlight##" . $name . "##end## changed to slot##loot_highlight## #".$slot."##end##";
else
  $this -> addmsg = "##loot_highlight##" . $name . "##end## assigned to slot##loot_highlight## #".$slot."##end##";

$this -> loot[$slot][$name] = 1;
}
else
{
$this -> loot[$slot][$name] = 1;
$this -> addmsg = "##loot_highlight##" . $name . "##end## assiged to slot##loot_highlight## #".$slot."##end##";
}
}
else
$this -> addmsg = "There is currently no roll in slot $slot";
}

$this -> bot -> send_pgroup($this -> addmsg);
}

function loot($msg, $name)
{
$notyet = true;

for ($i=1;$i<= $this->count; $i++)
{
if ($msg == $this->loot[$i][item])
{
$this->loot[$i][num]++;
$num = $this->loot[$i][num];
$notyet = false;
$numslot = $i;
}
}

if ($notyet)
{
$this -> count ++;
$num = 1;
$numslot = $this -> count;
$this -> loot[$numslot][item] = $msg;
$this -> loot[$numslot][num] = 1;
}

$this -> bot -> send_pgroup("##loot_highlight##" . $num . "x " . $msg . "##end## being rolled in slot##loot_highlight## #" . $numslot);

if ($this->count == 1)
{
    unset($this -> leftovers);
}
}


function roll($name)
{
$num = 1;
$lcount=0;

foreach($this -> loot as $slot)
{
$item = $slot[item];
unset($slot[item]);
$numitems = $slot[num];
unset($slot[num]);

for ($k=0;$k<$numitems;$k++)
{
$users = array();
$list = $slot;
$users = array_keys($list);
$count = count($list)-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 = Nobody;
$lcount = count($this -> leftovers)+1;
$this -> leftovers[$lcount] = $item;
}
else
unset($slot[$winner]);


$msg .= "##loot_highlight##Item: ##end##" . $item . "  (Slot##loot_highlight## #" . $num . "##end##)\n";
$msg .= "##loot_highlight##Winner: ##end##" . $winner . "\n\n";
unset ($users);
unset($winner);
unset ($list);
}

unset($this -> loot[$num]);
$num++;
}

$blob = "Item Winners List :: " . $this -> bot -> core("tools") -> make_blob("click to view", $msg);
$this -> bot -> send_pgroup($blob);


$this -> count = 0;

}

function reroll($name)
{
    $lcount= count($this->leftovers);
    if ($lcount==0)
    $this -> bot -> send_pgroup("##loot_highlight##No leftovers from last roll.##end##");
    else
    {
$this -> count = 0;

foreach ($this -> leftovers as $item)
{
$notyet = true;
for ($i=1;$i<= $this->count; $i++)
{
if ($item == $this->loot[$i][item])
{
$this->loot[$i][num]++;
$num = $this->loot[$i][num];
$notyet = false;
$numslot = $i;
}
}

if ($notyet)
{
$this -> count ++;
$num = 1;
$numslot = $this -> count;
$this -> loot[$numslot][item] = $item;
$this -> loot[$numslot][num] = 1;
}
$msg .= "##loot_highlight##" . $num . "x " . $item . "##end## being rolled in slot##loot_highlight## #" . $numslot . "##end##.\n";
}
$blob = "Item Roll List :: " . $this -> bot -> core("tools") -> make_blob("click to view", $msg);
$this -> bot -> send_pgroup($blob);

unset($this->leftovers);
    }

}

function killed($name, $kill)
{
if (!empty($kill))
{
$this -> count = 0;
switch ($kill)
{
case 'apf13':
$this -> klist = array(1 => "<a href='itemref://275916/275916/1'>Biotech Matrix</a> ",
2 => "<a href='itemref://275916/275916/1'>Biotech Matrix</a> ",
3 => "<a href='itemref://275916/275916/1'>Biotech Matrix</a> ",
4 => "<a href='itemref://275909/275909/1'>Gelatinous Lump</a> ",
5 => "<a href='itemref://275909/275909/1'>Gelatinous Lump</a> ",
6 => "<a href='itemref://275909/275909/1'>Gelatinous Lump</a> ",
7 => "<a href='itemref://257960/257960/1'>Action Probability Estimator</a> ",
8 => "<a href='itemref://257962/257962/1'>Dynamic Gas Redistribution Valves</a> ",
9 => "<a href='itemref://257706/257706/1'>Kyr'Ozch Helmet</a> ",
10 => "<a href='itemref://1/1/1'>Bounty Items</a> ",
11 => "<a href='itemref://257968/257968/1'>Hacker ICE-Breaker Source</a> ",
12 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
13 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
14 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
15 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
16 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
17 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ");
Break;
case 'apf28':
$this -> klist = array(1 => "<a href='itemref://275914/275914/1'>Kyr'Ozch Circuitry</a> ",
2 => "<a href='itemref://275914/275914/1'>Kyr'Ozch Circuitry</a> ",
3 => "<a href='itemref://275914/275914/1'>Kyr'Ozch Circuitry</a> ",
4 => "<a href='itemref://275912/275912/1'>Crystalline Matrix</a> ",
5 => "<a href='itemref://275912/275912/1'>Crystalline Matrix</a> ",
6 => "<a href='itemref://275912/275912/1'>Crystalline Matrix</a> ",
7 => "<a href='itemref://257959/257959/1'>Inertial Adjustment Processing Unit</a> ",
8 => "<a href='itemref://257963/257963/1'>Notum Amplification Coil</a> ",
9 => "<a href='itemref://1/1/1'>Bounty Items</a> ",
10 => "<a href='itemref://257706/257706/1'>Kyr'Ozch Helmet</a> ",
11 => "<a href='itemref://257968/257968/1'>Hacker ICE-Breaker Source</a> ",
12 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
13 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
14 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
15 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
16 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ",
17 => "<a href='itemref://258296/258296/1'>Kyr'Ozch Data Core</a> ");
Break;
case 'apf35':
$this -> klist = array(1 => "<a href='itemref://275906/275906/1'>Odd Kyr'Ozch Nanobots</a> ",
2 => "<a href='itemref://275906/275906/1'>Odd Kyr'Ozch Nanobots</a> ",
3 => "<a href='itemref://275906/275906/1'>Odd Kyr'Ozch Nanobots</a> ",
4 => "<a href='itemref://275907/275907/1'>Kyr'Ozch Processing Unit</a> ",
5 => "<a href='itemref://275907/275907/1'>Kyr'Ozch Processing Unit</a> ",
6 => "<a href='itemref://275907/275907/1'>Kyr'Ozch Processing Unit</a> ",
7 => "<a href='itemref://275918/275918/1'>Alpha Program Chip</a> ",
8 => "<a href='itemref://275918/275918/1'>Alpha Program Chip</a> ",
9 => "<a href='itemref://275918/275918/1'>Alpha Program Chip</a> ",
10 => "<a href='itemref://275919/275919/1'>Beta Program Chip</a> ",
11 => "<a href='itemref://275919/275919/1'>Beta Program Chip</a> ",
12 => "<a href='itemref://275919/275919/1'>Beta Program Chip</a> ",
13 => "<a href='itemref://257961/257961/1'>Energy Redistribution Unit</a> ",
14 => "<a href='itemref://257964/257964/1'>Visible Light Remodulation Device</a> ",
15 => "<a href='itemref://1/1/1'>Bounty Items</a> ",
16 => "<a href='itemref://257706/257706/1'>Kyr'Ozch Helmet</a> ",
17 => "<a href='itemref://257968/257968/1'>Hacker ICE-Breaker Source</a> ",
18 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ",
19 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ",
20 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ",
21 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ",
22 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ",
23 => "<a href='itemref://258292/258292/1'>Kyr'Ozch Data Core</a> ");
Break;
Default:
$this -> bot -> send_help($name, "loot");
}

foreach ($this -> klist as $s => $item)
{
$notyet = true;
for ($i=1;$i<= $this->count; $i++)
{
if ($item == $this->loot[$i][item])
{
$this->loot[$i][num]++;
$num = $this->loot[$i][num];
$notyet = false;
$numslot = $i;
}
}

if ($notyet)
{
$this -> count ++;
$num = 1;
$numslot = $this -> count;
$this -> loot[$numslot][item] = $item;
$this -> loot[$numslot][num] = 1;
}
//$msg .= "##loot_highlight##" . $num . "x " . $item . "##end## being rolled in slot##loot_highlight## #" . $numslot . "##end##.\n";
}
//$blob = "Item Roll List :: " . $this -> bot -> core("tools") -> make_blob("click to view", $msg);
//$this -> bot -> send_pgroup($blob);
$this -> rlist();
}
else
{
$this -> bot -> send_tell($name, "Error! Please enter kill table to use after !killed");
}
    }

function rlist()
{
    $num = 0;
unset($msg);

    foreach($this -> loot as $slot)
    {
$num++;
$msg .= "Slot ##loot_highlight###".$num."##end##: (".$this -> bot -> core("tools") -> chatcmd("add ".$num, "Add")."/".$this -> bot -> core("tools") -> chatcmd("rem ".$num, "Remove").")\n";
$msg .= "Item: ##loot_highlight##" . $slot[item]."##end## (##loot_highlight##" . $slot[num] . "x##end##)\n";

if(count($slot) == 1)
$msg .= "";
else
{
$list = array_keys($slot);

foreach($list as $key=>$player)
if (($player != "item") && ($player != "num") && ($slot[$player] == 2))
$msg .= " [##loot_highlight##$player##end##]";

foreach($list as $key=>$player)
if (($player != "item") && ($player != "num") && ($slot[$player] == 1))
$msg .= " [##loot_highlight##$player##end##]";
}
$msg .= "\n\n";
}

$blob = "Item Roll List :: " . $this -> bot -> core("tools") -> make_blob("click to view", $msg);
$this -> bot -> send_pgroup($blob);
}

}
?>
--- End code ---

Khalem:

--- Quote from: Zacix on April 27, 2009, 09:13:29 am ---This code isn't !identify/bio actually. It's a whole rollsystem, but also a small module to make the list automatically for 13/28/35. Needs some work to make it work for BeBot though :)

--- End quote ---

Thats what i get for briefly scanning posts *sigh*

Navigation

[0] Message Index

[*] Previous page

Go to full version