BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Module Requests => Topic started by: MagZu on February 26, 2008, 05:42:16 pm

Title: trickle module
Post by: MagZu on February 26, 2008, 05:42:16 pm
can anyone here help me get this module http://bebot.link/index.php/topic,615.0.html  to work with the verson 0.4.2? this is a such a nice module that i have been wanting to get to work for a long time now

Edit: wops i have verson 0.4.2 not 0.4.3 sorry
Title: Re: trickle module
Post by: Tichy on February 27, 2008, 11:27:17 pm
Nice module... I've just ported it to 0.4.3.
Title: Re: trickle module
Post by: MagZu on February 28, 2008, 05:59:52 am
yay thanks alot!
Title: Re: trickle module
Post by: Blueeagle on February 28, 2008, 10:39:14 am
That module was an ugly mess so I cleaned it up for you all.

Cut it down from 463 lines to 210 lines.

Code: [Select]
<?php

/*
Trickle.php
Version 1.2
Author: Shrike, AKA Briwn (RK1 Engineer)
Cleaned up by Terje AKA Blueeagl3(RK1)
For: Bebot (tested on version 0.4.3-svn)
*/

$trickle = new Trickle($bot);

$commands["gc"]["trickle"] = &$trickle;
$commands["tell"]["trickle"] = &$trickle;
$commands["pgmsg"]["trickle"] = &$trickle;

class 
Trickle
{
var $bot;
var $skill;
var $help;

function Trickle(&$bot)
{
$this -> bot = &$bot;

$this -> bot -> accesscontrol -> create('tell''trickle''GUEST');
$this -> bot -> accesscontrol -> create('gc''trickle''GUEST');
$this -> bot -> accesscontrol -> create('pgmsg''trickle''GUEST');

$this -> help['command']['trickle [sta <num>] [agi <num>] [int <num>] [sen <num>] [str <num>] [psy <num>]'] = 'Will show the amount of skill you gain by increasing the base abilities.';

//Set up the data
$this->skill['Nano skills']['TS']=array('agi'=>0.2'int'=>0.8);
$this->skill['Nano skills']['MC']=array('sta'=>0.2'int'=>0.8);
$this->skill['Nano skills']['BioMet']=array('psy'=>0.2'int'=>0.80);
$this->skill['Nano skills']['MatMet']=array('psy'=>0.2'int'=>0.80);
$this->skill['Nano skills']['PsyMod']=array('sen'=>0.2'int'=>0.80);
$this->skill['Nano skills']['SI']=array('str'=>0.20'int'=>0.80);
$this->skill['Aiding']['First aid']=array('agi'=>0.30'int'=>0.30'sen'=>0.40);
$this->skill['Aiding']['Treatment']=array('agi'=>0.30'int'=>0.50'sen'=>0.20);
$this->skill['Body']['Body dev']=array('sta'=>1.00);
$this->skill['Body']['Nano pool']=array('psy'=>0.70'sen'=>0.10'int'=>0.10'sta'=>0.10);
$this->skill['Body']['Martial arts']=array('agi'=>0.50'psy'=>0.30'str'=>0.20);
$this->skill['Body']['Brawling']=array('str'=>0.60'sta'=>0.40);
$this->skill['Body']['Riposte']=array('sen'=>0.50'agi'=>0.50);
$this->skill['Body']['Dimach']=array('sen'=>0.8'psy'=>0.20);
$this->skill['Body']['Adventuring']=array('str'=>0.20'agi'=>0.50'sta'=>0.30);
$this->skill['Body']['Swimming']=array('str'=>0.20'agi'=>0.20'sta'=>0.60);
$this->skill['Melee']['1h Blunt']=array('str'=>0.50'agi'=>0.10'sta'=>0.40);
$this->skill['Melee']['2h Blunt']=array('str'=>0.50'sta'=>0.50);
$this->skill['Melee']['1h Edged']=array('str'=>0.30'agi'=>0.40'sta'=>0.30);
$this->skill['Melee']['2h Edged']=array('str'=>0.60'sta'=>0.40);
$this->skill['Melee']['Piercing']=array('str'=>0.20'agi'=>0.50'sta'=>0.30);
$this->skill['Melee']['Melee Energy']=array('int'=>0.50'sta'=>0.50);
$this->skill['Melee']['Parry']=array('str'=>0.50'agi'=>0.20'sen'=>0.30);
$this->skill['Melee']['Sneak attack']=array('sen'=>0.80'psy'=>0.20);
$this->skill['Melee']['Fast attack']=array('agi'=>0.60'sen'=>0.40);
$this->skill['Melee']['Multi melee']=array('str'=>0.30'agi'=>0.60'sta'=>0.10);
$this->skill['Misc weapons']['Sharp objects']=array('str'=> 0.20'agi'=>0.60'sen'=>0.20);
$this->skill['Misc weapons']['Grenade']=array('sen'=>0.40'agi'=>0.40'int'=>0.20);
$this->skill['Misc weapons']['Heavy weapons']=array('str'=>0.40'agi'=>0.60);
$this->skill['Ranged']['Bow']=array('sen'=>.4'agi'=>.4'str'=>.2);
$this->skill['Ranged']['Pistol']=array('sen'=>.4'agi'=>.6);
$this->skill['Ranged']['Assault rifle']=array('sen'=>.2'agi'=>.3'sta'=>.4'str'=>.1);
$this->skill['Ranged']['MG/SMG']=array('sen'=>.1'sta'=>.3'str'=>.3'agi'=>.3);
$this->skill['Ranged']['Shotgun']=array('str'=>.4'agi'=>.6);
$this->skill['Ranged']['Rifle']=array('sen'=>.4'agi'=>.6);
$this->skill['Ranged']['Ranged energy']=array('sen'=>.4'psy'=>.4'int'=>.2);
$this->skill['Ranged']['Fling shot']=array('agi'=>1);
$this->skill['Ranged']['Aimed shot']=array('sen'=>1);
$this->skill['Ranged']['Burst']=array('agi'=>.5'str'=>.3'sta'=>.2);
$this->skill['Ranged']['Full auto']=array('sta'=>.4'str'=>.6);
$this->skill['Ranged']['Bow special']=array('sen'=>.4'agi'=>.5'str'=>.1);
$this->skill['Ranged']['Multi ranged']=array('agi'=>.6'int'=>.4);
$this->skill['Spying']['Concealment']=array('agi'=>.3'sen'=>.7);
$this->skill['Spying']['Break & enter']=array('agi'=>.4'sen'=>.3'psy'=>.3);
$this->skill['Spying']['Trap disarm']=array('sen'=>.6'int'=>.2'agi'=>.2);
$this->skill['Spying']['Perception']=array('int'=>.3'sen'=>.7);
$this->skill['Navigation']['Vehicle air']=array('sen'=>.6'int'=>.2'agi'=>.2);
$this->skill['Navigation']['Vehicle ground']=array('sen'=>.6'int'=>.2'agi'=>.2);
$this->skill['Navigation']['Vehicle water']=array('sen'=>.6'int'=>.2'agi'=>.2);
$this->skill['Navigation']['Map navigation']=array('sen'=>.5'int'=>.4'psy'=>.10);
$this->skill['Trade & Repair']['Mech engi']=array('int'=>.5'agi'=>.5);
$this->skill['Trade & Repair']['Electric engi']=array('int'=>.5'agi'=>.3'sta'=>.2);
$this->skill['Trade & Repair']['Quantum FT']=array('int'=>.5'psy'=>.5);
$this->skill['Trade & Repair']['Weapon smith']=array('int'=>.5'str'=>.5);
$this->skill['Trade & Repair']['Pharma tech']=array('int'=>.8'agi'=>.2);
$this->skill['Trade & Repair']['Nano prog']=array('int'=>1);
$this->skill['Trade & Repair']['Comp lit']=array('int'=>1);
$this->skill['Trade & Repair']['Psychology']=array('int'=>.5'sen'=>.5);
$this->skill['Trade & Repair']['Chemistry']=array('int'=>.5'sta'=>.5);
$this->skill['Trade & Repair']['Tutoring']=array('int'=>.7'sen'=>.2'psy'=>.1);
}

function tell($name$msg)
{
$reply $this -> command_handler($name$msg"tell");
if ($reply !== FALSE)
$this -> bot -> send_tell($name"##normal## $reply ##end##");
}

function gc($name$msg)
{
$reply $this -> command_handler($name$msg"gc");
if ($reply !== FALSE)
$this -> bot -> send_gc("##normal## $reply ##end##");
}

function pgmsg($name$msg)
{
$reply $this -> command_handler($name$msg"pgmsg");
if ($reply !== FALSE)
$this -> bot -> send_pgroup("##normal## $reply ##end##");
}

function parse_com($command$pattern = array('com''sub''args'))
{
$num_pieces=count($pattern);
$num_com=count(explode(' '$command));
$pieces explode(' '$command$num_pieces);
$com array_combine(array_slice($pattern0$num_com), $pieces);
return ($com);
}

function command_handler($source$msg$type)
{
$msg strtolower($msg);
$com $this->parse_com($msg, array('com''stat1''val1''stat2''val2''stat3''val3''stat4''val4''stat5''val5''stat6''val6', ));
if(empty($com['stat1']))
{
return('##error##You need to specify which stats to trickle from.##end##');
}
$stats=array('str''sta''sen''agi''int''psy');
if((!in_array($com['stat1'], $stats))&&(!empty($com['stat1'])))
return("##error##{$com['stat1']} is not a recognized base stat.##end##");
if((!in_array($com['stat2'], $stats))&&(!empty($com['stat2'])))
return("##error##{$com['stat2']} is not a recognized base stat.##end##");
if((!in_array($com['stat3'], $stats))&&(!empty($com['stat3'])))
return("##error##{$com['stat3']} is not a recognized base stat.##end##");
if((!in_array($com['stat4'], $stats))&&(!empty($com['stat4'])))
return("##error##{$com['stat4']} is not a recognized base stat.##end##");
if((!in_array($com['stat5'], $stats))&&(!empty($com['stat5'])))
return("##error##{$com['stat5']} is not a recognized base stat.##end##");
if((!in_array($com['stat6'], $stats))&&(!empty($com['stat6'])))
return("##error##{$com['stat6']} is not a recognized base stat.##end##");

if((!empty($com['stat1']))&&(!empty($com['val1'])))
$stats[$com['stat1']]=$com['val1'];
if((!empty($com['stat2']))&&(!empty($com['val2'])))
$stats[$com['stat2']]=$com['val2'];
if((!empty($com['stat3']))&&(!empty($com['val3'])))
$stats[$com['stat3']]=$com['val3'];
if((!empty($com['stat4']))&&(!empty($com['val4'])))
$stats[$com['stat4']]=$com['val4'];
if((!empty($com['stat5']))&&(!empty($com['val5'])))
$stats[$com['stat5']]=$com['val5'];
if((!empty($com['stat6']))&&(!empty($com['val6'])))
$stats[$com['stat6']]=$com['val6'];

$trickle $this -> Calc_trickle($stats);
return($this->CreateBlob($stats$trickle));
}

function Calc_trickle($upgrade)
{
foreach($this->skill as $group_name=>$group)
{
foreach($group as $item_name=>$item)
{
foreach($item as $stat=>$factor)
{
$increase[$group_name][$item_name]+=($upgrade[$stat]/4)*$factor;
}
}
}
return($increase);
}

function CreateBlob($stats$trickle)
{
$msg "##ao_infoheadline##::: Ability Trickle-down :::##end##\n\n";
$msg2 "";
if ($stats['int'] > 0)
$msg2 .= "##ao_infotext## - Intelligence: ##end##{$stats['int']}\n";
if ($stats['sta'] > 0)
$msg2 .= "##ao_infotext## - Stamina: ##end##{$stats['sta']}\n";
if ($stats['agi'] > 0)
$msg2 .= "##ao_infotext## - Agility: ##end##{$stats['agi']}\n";
if ($stats['sen'] > 0)
$msg2 .= "##ao_infotext## - Sense: ##end##{$stats['sen']}\n";
if ($stats['psy'] > 0)
$msg2 .= "##ao_infotext## - Psychic: ##end##{$stats['psy']}\n";
if ($stats['str'] > 0)
$msg2 .= "##ao_infotext## - Strength: ##end##{$stats['str']}\n";
$msg .= $msg2 "\n";

foreach($trickle as $group_name => $group)
{
$msg.="##ao_infoheadline##$group_name##end##\n";
foreach($group as $skill_name => $skill)
{
$msg.="##ao_infotext##$skill_name:##end## $skill\n";
}
$msg.="\n";
}
return $this -> bot -> make_blob("Ability trickles"$msg);
}

}

I think I got all the values right, but double checking is always good. :)
Title: Re: trickle module
Post by: Blueeagle on March 03, 2008, 09:27:32 pm
This is now in the development trunk utilising features from BaseModule and Error.

If you want to test it you need to have PHP5 installed.
Title: Re: trickle module
Post by: clashbot on May 28, 2008, 02:35:31 am
I noticed on the 0.5.1 that even if you put in all 6 stats, it only displays 5 of them, i don't know if psy is getting cut out of the formulation or not... it always cuts off the last skill so var6 stat6 is getting nerfed somewhere...

command:

To [Tunderclash]: trickle str 5 sta 5 psy 5 sen 5 agi 5 int 5


output:

::: Ability Trickle-down :::

- Stamina: 5
- Agility: 5
- Sense: 5
- Psychic: 5
- Strength: 5

Nano skills
TS: 0.25
MC: 0.25
BioMet: 0.25
MatMet: 0.25
PsyMod: 0.25
SI: 0.25

Aiding
First aid: 0.875
Treatment: 0.625

Body
Body dev: 1.25
Nano pool: 1.125
Martial arts: 1.25
Brawling: 1.25
Riposte: 1.25
Dimach: 1.25
Adventuring: 1.25
Swimming: 1.25

Melee
1h Blunt: 1.25
2h Blunt: 1.25
1h Edged: 1.25
2h Edged: 1.25
Piercing: 1.25
Melee Energy: 0.625
Parry: 1.25
Sneak attack: 1.25
Fast attack: 1.25
Multi melee: 1.25

Misc weapons
Sharp objects: 1.25
Grenade: 1
Heavy weapons: 1.25

Ranged
Bow: 1.25
Pistol: 1.25
Assault rifle: 1.25
MG/SMG: 1.25
Shotgun: 1.25
Rifle: 1.25
Ranged energy: 1
Fling shot: 1.25
Aimed shot: 1.25
Burst: 1.25
Full auto: 1.25
Bow special: 1.25
Multi ranged: 0.75

Spying
Concealment: 1.25
Break & enter: 1.25
Trap disarm: 1
Perception: 0.875

Navigation
Vehicle air: 1
Vehicle ground: 1
Vehicle water: 1
Map navigation: 0.75

Trade & Repair
Mech engi: 0.625
Electric engi: 0.625
Quantum FT: 0.625
Weapon smith: 0.625
Pharma tech: 0.25
Psychology: 0.625
Chemistry: 0.625
Tutoring: 0.375

Title: Re: trickle module
Post by: Blueeagle on May 28, 2008, 03:28:54 am
Now all six stats should be done when specified.
Title: Re: trickle module
Post by: clashbot on May 28, 2008, 03:45:18 am
k...thanks...working like it should now..heheh
Title: Re: trickle module
Post by: Zeephonz on July 02, 2008, 11:47:28 pm
An update to this that would be quite nice, would be to have available base ability buffs added as options...

For example, as well as typing....

!trickle str 27 sta 27

... you could type...

!trickle behe

or

!trickle comp - comp attributes
!trickle es - enhanced senses
!trickle fg - feline grace
!trickle ic - iron circle

... anyways, you get the idea

Title: Re: trickle module
Post by: Blueeagle on July 03, 2008, 02:07:07 am
I did concider that, but the extra parsing made me drop it.

What it would entail is to first scan for all such defined buffs and add the stats to them and then look for any aditional stats with given values.

What would probably be more interesting to do is !trickle <stat> <abillity1> <value1>...<abillityN> <valueN> to return only the one target stat you're interested in w/o making a blob.
Title: Re: trickle module
Post by: Zweiblum on July 23, 2008, 11:47:07 am
works well, many thx.. i love this module :)
Title: Re: trickle module
Post by: Tyrence on March 10, 2011, 02:59:54 am
I ported this module to Budabot a while ago and I noticed my module doesn't have the "Speed" skills in it.

It doesn't look like this module has the "Speed" skills in it either so this is just an fyo for anyone who might want to add those.
SimplePortal 2.3.7 © 2008-2024, SimplePortal