BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.5.x Custom/Unofficial Modules => Topic started by: Temar on January 15, 2008, 06:21:08 am

Title: Tools Module
Post by: Temar on January 15, 2008, 06:21:08 am
This module Contains Usefull Functions to be used in Other Modules,
i have Moved a Bunch from Bot.php
also Added an Improved version of chatcmd function

If any 1 has any Ideas on Other Usefull Functions that should be Added let me know
Title: Re: Tools Module
Post by: Glarawyn on January 17, 2008, 08:53:20 pm
http://bebot.link/index.php/topic,511.0.html

Heh, lib-custom.php lives.  :P
Title: Re: Tools Module
Post by: Glarawyn on January 18, 2008, 12:29:13 am
Here's one...
Code: [Select]
    /*
        I stole this from Helpbot, and modified it to take a targetlevel
        and a requestor level instead of a percentage.
        I also modified the return value to be just a HTML color code (#XXXXXX)
        Thanks Beaker for this handy function! http://www.kuren.org/ao/helpbot/

        This function returns the color code of the color the hp bar that a
        player of requestorlevel would see for a player of targetlevel.
        ie:
        if requestorlevel is 220 and targetlevel is 5, a grey color code would be returned.
        if requestorlevel is 220 and targetlevel is 200, a greenish color code would be returned.
        if requesterlevel is 200 and targetlevel is 220, a orangish/redish color code would be returned.
        if requestorlevel and targetlevel are equal, a yello color code is returned.
    */
    function con2rgb($targetlevel, $requestorlevel)
    { // Start function con2rgb()
        $percent = $targetlevel/$requestorlevel*100.000001;
        $G = 214.0001-(($percent-100.0001)/100.0001)*4.0001*214.0001;
        if ($G<0)
            $G=0;
        elseif ($G>214)
            $G="D6";
        else
        {
            if ($G<16)
                $G=sprintf("0%X",$G);
            else
                $G=sprintf("%X",$G);
        }

        $R = 214.00001-(100.0001-$percent)*4.0001/100.0001*214.0001;
        if ($R<0)
            $R=0;
        elseif ($R>214)
            $R="D6";
        else
        {
            if ($R<16)
                $R=sprintf("0%X",$R);
            else
                $R=sprintf("%X",$R);
        }
        if ($percent<75.0001)
            return "#909090";
        if ($percent>124.9999)
            return "#D60000";

        return "#".$R.$G."00";
    } // End function con2rgb()
SimplePortal 2.3.7 © 2008-2024, SimplePortal