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

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

Author Topic: New apf  (Read 11868 times)

0 Members and 1 Guest are viewing this topic.

Offline Nogoal

  • BeBot Apprentice
  • ***
  • Posts: 77
  • Karma: +0/-0
New apf
« on: September 24, 2008, 09:09:27 pm »
Did someone bothered to make a !apf 13/28/35 roll lists?

What I mean is, instead of adding loot 1 by one using !loot blahblah, you only have to type !apf 13 and all items are added to loot list.

Offline Karsta

  • BeBot User
  • **
  • Posts: 28
  • Karma: +0/-0
Re: New apf
« Reply #1 on: October 07, 2008, 11:14:02 pm »
Bump

I would like to get this if anyone will do it

!raidloot 13/35/28 maybe

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #2 on: October 15, 2008, 10:25:13 am »
I wrote a this for my own bot, new loot module + raidloot. It's not compatible with Bebot though, so someone would have to port it. Shouldn't be too much work as it's based on a really old bebot version I've modified a bit.
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Nogoal

  • BeBot Apprentice
  • ***
  • Posts: 77
  • Karma: +0/-0
Re: New apf
« Reply #3 on: October 15, 2008, 03:49:58 pm »
Can you post a link to it or send by mail? Thank you.

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #4 on: October 16, 2008, 12:06:48 am »
Code: [Select]
<?php
require_once("./includes/Item.php");
require_once(
"./includes/ItemInfo.php");
class 
Loot extends ModuleBase {
private static $instance;
protected $values;

protected function __construct(Bot $bot) {
$this->values = array(
"bot"   => $bot,
"lootlist"  => array(),
"rolllist"  => array(),
"singleloot" => true,
"preservewinners"  => false,
"reroll" => array(),
"winners"  => array(),
"pgroup"  => array(),
);
}

public static function Create(Bot $bot) {

if(!isset(self::$instance)) {
$o __CLASS__;
self::$instance = new $o($bot);
}
return self::$instance;
}

public function AddLoot($name$list) {
$num 1;
$string implode(" "$list);
$info = array();

while(count($list)>&& $list[0]!=="") {
if(is_numeric($list[0])) {
$num $list[0];
$string preg_replace("/".$num." /","",$string,1);
}
if(preg_match("/^<a href=\"itemref:\/\/([0-9]+)\/([0-9]+)\/([0-9]+)\">([^<]+)<\/a>/i"$string$info)) {
$regex "/^<a href=\"itemref:\/\/([0-9]+)\/([0-9]+)\/([0-9]+)\">([^<]+)<\/a>/i";
}
else if(preg_match("/^([^0-9]+)/i"$string$info)) {
$regex "/^([^0-9]+)/i";
}
else {
preg_match("/(.+)/i"$string$info);
$regex "/(.+)/i";
}
$item Item::Create($info[0]);
$item->setQuantity($num);
$item->setLooter($name);
ItemInfo::Lookup($this->bot$item);
$this->AddToLootList($item);
$string preg_replace($regex,"",$string,1);
$string ltrim($string);
$list explode(" "$string);
print_r($item);
$num 1;
}
}

private function AddToLootList($item) {
for($i=0;$i<count($this->lootlist);$i++) {
if($this->lootlist[$i]->getName()===$item->getName() &&
$this->lootlist[$i]->getLowid()===$item->getLowid() &&
$this->lootlist[$i]->getHighid()===$item->getHighid() &&
$this->lootlist[$i]->getQl()===$item->getQl()) {
$this->lootlist[$i]->setQuantity($this->lootlist[$i]->getQuantity()+$item->getQuantity());
print_r($this->lootlist);
$this->bot->send_pgroup(Highlight($this->lootlist[$i]->getQuantity())."x".$this->lootlist[$i]->getItemReference()." in slot ".bcadd($i,1));
return;
}
}
$this->lootlist[] = $item;
$this->rolllist[] = array();
var_dump($item);
$this->bot->send_pgroup(Highlight($item->getQuantity())."x".$item->getItemReference()." in slot ".count($this->lootlist));
}

public function RemoveLoot($name$index) {
$index $this->IsValidIndex($index$this->lootlist);
if($index===false)
return;
if($this->lootlist[$index]->getLooter() == $name || $this->bot->admin->InGroup($name"raidleader")) {
$this->bot->send_pgroup(Highlight($name)." deleted " $this->lootlist[$index]->getItemReference()." from slot ".Highlight(bcadd($index,1)));
unset($this->lootlist[$index]);
$this->lootlist array_values($this->lootlist);
unset($this->rolllist[$index]);
$this->rolllist array_values($this->rolllist);
}
}

public function Add($name$index) {
$index $this->IsValidIndex($index$this->lootlist);
if($index===false)
return;

if($this->preservewinners) {
if(array_search($name,$this->winners) !== false) {
$this->bot->send_tell($name"You have already won an item");
return;
}
}

if(class_exists("Wishlist",false) && $this->bot->commands["tell"]["mywish"]->active) {
if($this->bot->commands["tell"]["mywish"]->IsWishlistItem($this->lootlist[$index]->getName())) {
if(!$this->bot->commands["tell"]["mywish"]->IsOnWishlist($this->lootlist[$index]->getName(),$name)) {
$this->bot->send_tell($name,"[" Highlight($this->lootlist[$index]->getItemReference()) . "] is a wishlist item not on your wishlist");
return;
}
if(!$this->bot->commands["tell"]["mywish"]->CanRoll($name,$this->lootlist[$index]->getName())) {
$this->bot->send_tell($name,"You are still in your graceperiod.");
return;
}
}
}

$indexes false;
if($this->singleloot) {
$indexes $this->IsRollingForItem($name);
if($indexes) {
foreach($indexes as $key=>$array) {
unset($this->rolllist[$array[0]][$array[1]]);
$this->rolllist[$array[0]] = array_values($this->rolllist[$array[0]]);
}
}
}
$this->rolllist[$index][] = $name;
$this->bot->send_pgroup(Highlight($name)." joined roll for ".$this->lootlist[$index]->getItemReference()." in slot ".Highlight(bcadd($index,1)));
}

private function IsRollingForItem($name) {
$indexes = array();
foreach($this->rolllist as $index=>$array) {
$exist array_search($name,$array);
if($exist !== false)
$indexes[] = array($index,$exist);
}
if(count($indexes) > 0)
return $indexes;
return false;
}

private function IsValidIndex($index,$array,$decrement=true) {
if(!is_numeric($index))
return false;
if($decrement)
$index--;
if($index || $index >= count($this->lootlist))
return false;
return $index;
}

public function Remove($name$index) {
$index $this->IsValidIndex($index$this->lootlist);
if($index===false)
return;

$nameindex array_search($name$this->rolllist[$index]);
if($nameindex !== false) {
unset($this->rolllist[$index][$nameindex]);
$this->rolllist[$index] = array_values($this->rolllist[$index]);
$this->bot->send_pgroup(Highlight($name)." left roll for ".$this->lootlist[$index]->getItemReference()." in slot ".Highlight(bcadd($index,1)));
}
}

public function LootList() {
$msg Headertext("Loot");

foreach($this->lootlist as $index=>$item) {
$msg .= "<br><br>".$item->getIconReference();
$msg .= "<br>".bcadd($index,1).". Added by: ".$item->getLooter();
$msg .= "<br>"."QL ".$item->getQl()." ".$item->getItemReference()." (".Headertext($item->getQuantity()).")";
$msg .= "<br><a href='chatcmd:///tell " $this->bot->botname " " $this->bot->commpre "add " bcadd($index,1) . "'>Join</a>" "/";
$msg .= "<a href='chatcmd:///tell " $this->bot->botname " " $this->bot->commpre "rem " bcadd($index,1) . "'>Leave</a>";

if(count($this->rolllist[$index])>0) {
$msg .= "<br>Added (".Headertext(count($this->rolllist[$index])).")<br>";
foreach($this->rolllist[$index] as $name) {
$msg .= "|".Highlight($name)."|";
}
}
else {
$msg .= "<br>Nobody included";
}
}
return $msg;
}

public function Roll() {
if(count($this->lootlist) == 0) {
$this->bot->send_pgroup("No items to roll");
return;
}

$winners = array();
$this->reroll = array();
$msg Headertext("Winners");
foreach($this->lootlist as $index=>$item) {
$msg .= "<br><br>".$item->getIconReference();
$msg .= "<br>".bcadd($index,1).". Added by: ".$item->getLooter();
$msg .= "<br>"."QL ".$item->getQl()." ".$item->getItemReference();
$msg .= "<br>Winners: ";

if(count($this->rolllist[$index]) < $item->getQuantity()) {
$tmp = clone $item;
$tmp->setQuantity(bcsub($item->getQuantity(), count($this->rolllist[$index])));
$this->reroll[] = $tmp;
}
if(count($this->rolllist[$index]) == 0) {
$msg .= "Nobody rolled";
continue;
}

$winners[] = array();
for($i=count($this->rolllist[$index]);$i>&& $item->getQuantity() > 0;$i--,$item->setQuantity($item->getQuantity()-1)) {
if(class_exists("Wishlist",false) && $this->bot->commands["tell"]["mywish"]->IsWishlistItem($item->getName())) {
$wishlistarray $this->bot->commands["tell"]["mywish"]->GetRollArray($this->rolllist[$index]);
$winnerindex mt_rand(0,count($wishlistarray)-1);
$winner $wishlistarray[$winnerindex];
$winnerindex array_search($winner,$this->rolllist[$index]);
$this->bot->commands["tell"]["mywish"]->wishlistwinners[] = $winner;
}
else {
$winnerindex mt_rand(0,bcsub($i,1));
$winner $this->rolllist[$index][$winnerindex];
}
$msg .= "|".Highlight($winner)."|";
unset($this->rolllist[$index][$winnerindex]);
$this->rolllist[$index] = array_values($this->rolllist[$index]);
$this->LogLootHistory($item,$winner,$this->rolllist[$index]);
if($this->preservewinners) {
$this->winners[] = $winner;
}
}
}
$this->lootlist = array();
$this->rolllist = array();
$this->bot->send_pgroup($this->make_blob("Winners"$msg));
}

public function LogLootHistory($item$winner$loosers) {
$sql "INSERT INTO loothistory (itemql,itemname,itemlowid,itemhighid,itemiconid,winner,loosers,won) VALUES(";
$sql .= $item->getQl().",";
$sql .= "'".str_replace("'","''",$item->getName())."',";
$sql .= $item->getLowid().",";
$sql .= $item->getHighid().",";
$sql .= $item->getIconid().",";
$sql .= "'".$winner."','";
foreach($loosers as $index=>$name) {
$sql .= $name." ";
}
$sql trim($sql);
$sql .= "',".time().")";
$this->bot->db->query($sql);
}

public function Reroll() {
if(count($this->reroll) == 0) {
$this->bot->send_pgroup("No items to reroll");
return;
}
$this->lootlist $this->reroll;
$this->rolllist = array();
$this->reroll = array();
$this->bot->send_pgroup($this->make_blob("Loot List",$this->LootList()));
}

public function Clear($name) {
$this->lootlist = array();
$this->rolllist = array();
$this->bot->send_pgroup("Lootlist cleared by ".Highlight($name));
}

public function Preserve($name$flag) {
switch(strtolower($flag)) {
case "on":
$this->preservewinners true;
$this->bot->send_pgroup("Preserve winners has been turned ".Highlight("on")." by ".Highlight($name));
break;
case "off":
$this->preservewinners false;
$this->bot->send_pgroup("Preserve winners has been turned ".Highlight("off")." by ".Highlight($name));
break;
}
}

public function History($index) {
if(is_numeric($index) !== true)
$index 0;
$msg Headertext("History");
$prev bcsub($index,10);
$prev $prev <= $prev;
$msg .= "<br><br><a href='chatcmd:///tell <botname> <pre>history ".$prev."'>Previous</a>/";
$next bcadd($index,10);
$next $next <= $next;
$msg .= "<a href='chatcmd:///tell <botname> <pre>history ".$next."'>Next</a>";

$sql "SELECT * FROM loothistory ORDER BY id DESC LIMIT ".$index.",10";
$result $this->bot->db->select($sql);

foreach($result as $index=>$row) {
$msg .= "<br><br><a href='itemref://".$row[3]."/".$row[4]."/".$row[1]."'>".$row[2]."</a>";
$msg .= "<br>Winner: ".Highlight($row[6]);
$msg .= "<br>When: ".Highlight(date("Y-F-d H:i"$row[8]) . " GMT");
}

return $msg;
}

function pgmsg($name$msg) {
$pre $this->bot->commpre;
$msg explode(" ",$msg);

switch(ltrim(strtolower($msg[0]),$pre)) {
case "add":
$this->Add($name$msg[1]);
break;
case "rem":
$this->Remove($name$msg[1]);
break;
case "loot":
array_shift($msg);
print_r($msg);
$this->AddLoot($name$msg);
break;
case "list":
$this->bot->send_pgroup($this->make_blob("Loot List",$this->LootList()));
break;
case "del":
$this->RemoveLoot($name,$msg[1]);
break;
case "roll":
case "result":
if($this->bot->admin->in_group($name,"raidleader")) {
$this->Roll();
}
break;
case "reroll":
if($this->bot->admin->in_group($name,"raidleader")) {
$this->Reroll();
}
break;
case "clear":
if($this->bot->admin->in_group($name,"raidleader")) {
$this->Clear($name);
}
break;
case "preserve":
if($this->bot->admin->in_group($name,"raidleader")) {
$this->Preserve($name$msg[1]);
}
break;
case "clearwinners":
if($this->bot->admin->in_group($name,"raidleader")) {
$this->winners = array();
$this->bot->send_pgroup("Prior winners have been cleared by ".Highlight($name));
}
break;
case "history":
$this->bot->send_pgroup($this->make_blob("History",$this->History($msg[1])));
break;
}
}

function tell($name$msg) {
$this->pgmsg($name$msg);
}
}

$loot Loot::Create($bot);

$bot->commands["tell"]["rem"] = $loot;
$bot->commands["tell"]["add"] = $loot;
$bot->commands["tell"]["loot"] = $loot;
$bot->commands["tell"]["history"] = $loot;
$bot->commands["tell"]["list"] = $loot;
$bot->commands["pgmsg"]["loot"] = $loot;
$bot->commands["pgmsg"]["add"] = $loot;
$bot->commands["pgmsg"]["rem"] = $loot;
$bot->commands["pgmsg"]["list"] = $loot;
$bot->commands["pgmsg"]["del"] = $loot;
$bot->commands["pgmsg"]["roll"] = $loot;
$bot->commands["pgmsg"]["result"] = $loot;
$bot->commands["pgmsg"]["reroll"] = $loot;
$bot->commands["pgmsg"]["clear"] = $loot;
$bot->commands["pgmsg"]["preserve"] = $loot;
$bot->commands["pgmsg"]["clearwinners"] = $loot;
$bot->commands["pgmsg"]["history"] = $loot;
?>

Code: [Select]
<?php

class Item {
private $ql 1;
private $name "";
private $lowid 1;
private $highid 1;
private $iconid 1;
 
private $req "";
private $breedreq "";
private $prefix "";
private $postfix "";
private $looter "";
private $quantity 1;

public static function Create($string) {
$item = new Item();
if(preg_match("/^<a href=\"itemref:\/\/([0-9]+)\/([0-9]+)\/([0-9]+)\">(.*)<\/a>$/i"$string$info)) {
$item->setLowid($info[1]);
$item->setHighid($info[2]);
$item->setQl($info[3]);
$item->setName($info[4]);

}
else {
$item->setName($string);
}
return $item;
}

public function getItemReference() {
return "<a href='itemref://" $this->lowid "/" $this->highid "/" $this->ql "'>" $this->name "</a>";
}

public function getIconReference() {
    
return "<img src='rdb://" $this->iconid "'>";
}

public function getName() {
return $this->name;
}

public function getLowid() {
return $this->lowid;
}

public function getHighid() {
return $this->highid;
}

public function getIconid() {
return $this->iconid;
}

public function getQl() {
return $this->ql;
}

public function getLooter() {
return $this->looter;
}

public function getQuantity() {
return $this->quantity;
}

public function setName($name) {
$this->name $name;
}

public function setLowid($id) {
$this->lowid $id;
}

public function setHighid($id) {
$this->highid $id;
}

public function setIconid($id) {
$this->iconid $id;
}

public function setQl($ql) {
$this->ql $ql;
}

public function setLooter($looter) {
$this->looter $looter;
}

public function setQuantity($quantity) {
$this->quantity $quantity;
}
}
?>
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #5 on: October 16, 2008, 12:07:52 am »
Code: [Select]
<?php
class ItemInfo {
public static function Lookup(Bot $bot,$item) {
$highestid $item->getHighid() < $item->getLowid() ? $item->getLowid() : $item->getHighid();
$lowid $item->getHighid() < $item->getLowid() ? $item->getHighid() : $item->getLowid();
$highid $highestid;
switch($highid) {
case 247103:
$highid 247107;
$lowid 247106;
$name "Pristine Kyr'Ozch Bio-Material";
break;
case 247105:
$highid 247109;
$lowid 247108;
$name "Mutated Kyr'Ozch Bio-Material";
break;
case 247698:
$highid 247674;
$lowid 247673;
$name "Kyr'Ozch Bio-Material - Type 76";
break;
case 247700:
$highid 247676;
$lowid 247675;
$name "Kyr'Ozch Bio-Material - Type 112";
break;
case 247702:
$highid 247678;
$lowid 247677;
$name "Kyr'Ozch Bio-Material - Type 240";
break;
case 247704:
$highid 247680;
$lowid 247679;
$name "Kyr'Ozch Bio-Material - Type 880";
break;
case 247706:
$highid 247682;
$lowid 247681;
$name "Kyr'Ozch Bio-Material - Type 992";
break;
case 247708:
$highid 247684;
$lowid 247683;
$name "Kyr'Ozch Bio-Material - Type 1";
break;
case 247710:
$highid 247686;
$lowid 247685;
$name "Kyr'Ozch Bio-Material - Type 2";
break;
case 247712:
$highid 247688;
$lowid 247687;
$name "Kyr'Ozch Bio-Material - Type 4";
break;
case 247714:
$highid 247690;
$lowid 247689;
$name "Kyr'Ozch Bio-Material - Type 5";
break;
case 247716:
$highid 247692;
$lowid 247691;
$name "Kyr'Ozch Bio-Material - Type 12 ";
break;
case 247718:
$highid 247694;
$lowid 247693;
$name "Kyr'Ozch Bio-Material - Type 3 ";
break;
case 247720:
$highid 247696;
$lowid 247695;
$name "Kyr'Ozch Bio-Material - Type 13";
break;
case 254804:
$highid 254805;
$lowid 247765;
$name "Kyr'Ozch Viral Serum";
break;
default:
$highid $item->getHighid();
$lowid $item->getLowid();
$name $item->getName();
break;
}
$result $bot->db->select("SELECT icon FROM aodb WHERE aoid = '" $highid "'");
if(empty($result)) {
$result 259166;
}
else {
$result $result[0][0];
}
$item->setHighid($highid);
$item->setLowid($lowid);
$item->setIconid($result);
$item->setName($name);
}
}
?>
Code: [Select]
<?php
require_once("./includes/Item.php");
require_once(
"./includes/ItemInfo.php");
class 
RaidLoot extends ModuleBase {
private static $instance;
protected $values;

protected function __construct(Bot $bot) {
$this->values = array(
"bot"   => $bot
);
}

public static function Create(Bot $bot) {

if(!isset(self::$instance)) {
$o __CLASS__;
self::$instance = new $o($bot);
}
return self::$instance;
}

public function pgmsg($name$msg) {
$pre $this->bot->commpre;
$msg explode(" ",$msg);

switch(ltrim(strtolower($msg[0]),$pre)) {
case "raidloot":
$this->CreateLootList($name,$msg[1]);
break;
}
}

public function tell($name,$msg) {
$this->pgmsg($name,$msg);
}

public function CreateLootList($name$type) {
$msg $this->bot->commpre."loot ";
switch(strtolower($type)) {
case "13":
$msg .= "3 <a href=\"itemref://275916/275916/1\">Biotech Matrix</a> ";
$msg .= "3 <a href=\"itemref://275909/275909/1\">Gelatinous Lump</a> ";
$msg .= "1 <a href=\"itemref://257960/257960/1\">Action Probability Estimator</a> ";
$msg .= "1 <a href=\"itemref://257962/257962/1\">Dynamic Gas Redistribution Valves</a> ";
$msg .= "1 <a href=\"itemref://257968/257968/1\">Hacker ICE-Breaker Source</a> ";
$msg .= "5 <a href=\"itemref://258296/258296/1\">Kyr'Ozch Data Core</a> ";
$msg .= "1 <a href=\"itemref://1/1/1\">Bounty Items</a> ";
$msg .= "1 <a href=\"itemref://257706/257706/1\">Kyr'Ozch Helmet</a>";
break;
case "28":
$msg .= "3 <a href=\"itemref://275914/275914/1\">Kyr'Ozch Circuitry</a> ";
$msg .= "3 <a href=\"itemref://275912/275912/1\">Crystalline Matrix</a> ";
$msg .= "1 <a href=\"itemref://257959/257959/1\">Inertial Adjustment Processing Unit</a> ";
$msg .= "1 <a href=\"itemref://257963/257963/1\">Notum Amplification Coil</a> ";
$msg .= "1 <a href=\"itemref://257968/257968/1\">Hacker ICE-Breaker Source</a> ";
$msg .= "4 <a href=\"itemref://258295/258295/1\">Kyr'Ozch Data Core</a> ";
$msg .= "1 <a href=\"itemref://1/1/1\">Bounty Items</a> ";
$msg .= "1 <a href=\"itemref://257706/257706/1\">Kyr'Ozch Helmet</a>";
break;
case "35":
$msg .= "3 <a href=\"itemref://275906/275906/1\">Odd Kyr'Ozch Nanobots</a> ";
$msg .= "3 <a href=\"itemref://275907/275907/1\">Kyr'Ozch Processing Unit</a> ";
$msg .= "3 <a href=\"itemref://275918/275918/1\">Alpha Program Chip</a> ";
$msg .= "3 <a href=\"itemref://275919/275919/1\">Beta Program Chip</a> ";
$msg .= "1 <a href=\"itemref://257961/257961/1\">Energy Redistribution Unit</a> ";
$msg .= "1 <a href=\"itemref://257964/257964/1\">Visible Light Remodulation Device</a> ";
$msg .= "1 <a href=\"itemref://257968/257968/1\">Hacker ICE-Breaker Source</a> ";
$msg .= "3 <a href=\"itemref://258292/258292/1\">Kyr'Ozch Data Core</a> ";
$msg .= "1 <a href=\"itemref://1/1/1\">Bounty Items</a> ";
$msg .= "1 <a href=\"itemref://257706/257706/1\">Kyr'Ozch Helmet</a>";
break;
}
$this->bot->commands["tell"]["loot"]->pgmsg($name,$msg);
}
}

$raidloot RaidLoot::Create($bot);

$bot->commands["tell"]["raidloot"] = $raidloot;
$bot->commands["pgmsg"]["raidloot"] = $raidloot;
?>
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #6 on: October 16, 2008, 12:15:05 am »
Some of the lootlists may be a bit inaccurate when it comes to how many cores that drops and stuff. It should work pretty flawlessly (at least it seems to do in my bot :P).
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline plugz

  • BeBot User
  • **
  • Posts: 35
  • Karma: +0/-0
Re: New apf
« Reply #7 on: November 09, 2008, 08:19:25 pm »
Zacix, is your above post the ported verison of this for bebot?

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #8 on: November 10, 2008, 02:08:11 pm »
no....it's the version I use on my bot.
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline plugz

  • BeBot User
  • **
  • Posts: 35
  • Karma: +0/-0
Re: New apf
« Reply #9 on: January 04, 2009, 01:57:24 am »
Nice layout Zacix, now, how to we add it into our bot :P

I normally dev on Budabot for my orgbot, but I'm using bebot for our org raidbot, so my knowledge is limited

I have all 4 saved as php and ready to import into the modules folder, any particulars needed to get them going from there?

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: New apf
« Reply #10 on: April 25, 2009, 10:48:49 pm »
noone made something like this for bebot 0.5/0.6 yet and published? that's a shame...
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: New apf
« Reply #11 on: April 26, 2009, 07:11:47 pm »
This is shipped with BeBot by default. See !identify or !bio
BeBot Founder and Fixer Kingpin

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: New apf
« Reply #12 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 :)
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: New apf
« Reply #13 on: April 27, 2009, 07:20:46 pm »
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: [Select]
<?

$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);
}

}
?>
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: New apf
« Reply #14 on: April 27, 2009, 07:28:23 pm »
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 :)

Thats what i get for briefly scanning posts *sigh*
BeBot Founder and Fixer Kingpin

 

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


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 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: 425
  • 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