function tips_dohook($hookname, $args)
{
    global $session, $charstat_info;
    switch ($hookname) {
        case "charstats":
            setcharstat("Tips", "<td colspan=2>Have a good look around the Museum - there's more there than meets the eye.", "</td>");
            break;
    }
    return $args;
}
function newdaybar_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "charstats":
            require_once "lib/datetime.php";
            $gt = gametimedetails();
            setcharstat("Time", "Game Time", gmdate("g:i a", $gt['gametime']));
            setcharstat("Time", "New day in:", date("H:i:s", secondstonextgameday()));
            break;
    }
    return $args;
}
function pktrack_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "charstats":
            if (get_module_pref("user_showpk") == 1) {
                if (get_module_setting("wo") == 0) {
                    $title = translate_inline("Vital Info");
                }
                if (get_module_setting("wo") == 1) {
                    $title = translate_inline("Personal Info");
                }
                if (get_module_setting("wo") == 2) {
                    $title = translate_inline("Extra Info");
                }
                $name = translate_inline("Player Kills");
                $count = get_module_pref("count");
                setcharstat($title, $name, $count);
            }
            break;
        case "pvpwin":
            debug($args);
            if ($args['options']['type'] == 'pvp') {
                increment_module_pref("count");
            }
            break;
        case "pvploss":
            if (!get_module_setting("losses")) {
                break;
            }
            debug($args);
            if ($args['options']['type'] == 'pvp') {
                increment_module_pref("count", 1, "pktrack", $args['badguy']['acctid']);
            }
            break;
        case "biostat":
            $char = $args['acctid'];
            $cpk = get_module_pref("count", "pktrack", $char);
            output("`^Player Kills: `@%s`0", $cpk);
            output_notl("`n");
            break;
        case "footer-hof":
            addnav("Warrior Rankings");
            addnav("Player Kills", "runmodule.php?module=pktrack&op=hof");
            break;
    }
    return $args;
}
function mountaccessories_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "boughtmount":
        case "soldmount":
            $accs = get_player_acc_list();
            $hadaccessories = count($accs);
            if ($hadaccessories != 0) {
                output("Merick merrily strips off the accessories adorning your previous mount, and tosses them into a pile in the corner.  \"Ye'll nae be needin' these any more, I dare wager!\"`n`nYou contemplate asking him for the accessories back, or perhaps some money for them - but the slightly manic look in Merick's eye, and the sharpened pitchfork slung across his back, give you second thoughts.`n");
            }
            strip_accessories();
            addnav("Browse Mount Accessories", "runmodule.php?module=mountaccessories&op=browse");
            if ($session['user']['hashorse'] == 0) {
                blocknav("runmodule.php?module=mountaccessories&op=browse");
            }
            break;
        case "newday":
            apply_all_accessories();
            break;
        case "superuser":
            addnav("Edit Mount Accessories", "runmodule.php?module=mountaccessories&op=editdefaultaccessories");
            break;
        case "stables-nav":
            if ($session['user']['hashorse'] > 0) {
                addnav("Browse Mount Accessories", "runmodule.php?module=mountaccessories&op=browse");
            }
            break;
        case "charstats":
            if ($session['user']['hashorse'] > 0) {
                $rawaccs = get_player_acc_list();
                $display = "";
                $number = 0;
                foreach ($rawaccs as $acc => $details) {
                    $number++;
                    $display .= $details['displayname'];
                    $display .= "<br>";
                }
                $stat = "Mount Accessories";
                if ($number == 0) {
                    $display = "None";
                }
                setcharstat("Equipment Info", $stat, $display);
            }
            break;
    }
    return $args;
}
function expbar_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "charstats":
            require_once "lib/experience.php";
            $level = $session['user']['level'];
            $dks = $session['user']['dragonkills'];
            $min = exp_for_next_level($level - 1, $dks);
            $req = exp_for_next_level($level, $dks);
            $exp = round($session['user']['experience'], 0) . check_temp_stat("experience", 1);
            // If the user has dropped below the previous level, make that the
            // min and they need 100%  They will continue to need 100% until
            // they reach 'min' again.
            if ($exp < $min) {
                $min = $exp;
            }
            if ($req - $min > 0) {
                $nonpct = floor(($req - $exp) / ($req - $min) * 100);
            } else {
                $nonpct = 0;
            }
            $pct = 100 - $nonpct;
            if ($pct > 100) {
                $pct = 100;
                $nonpct = 0;
            }
            if ($pct < 0) {
                $pct = 0;
                $nonpct = 100;
            }
            if ($exp >= $req) {
                $color = "blue";
            } else {
                $color = "white";
            }
            $old = getcharstat("Personal Info", "Experience");
            $new = "";
            $shownum = 1;
            $shownext = 1;
            $showbar = 1;
            if (!$shownum && !$showbar) {
                $new = "`b`\$hidden`b";
            }
            if ($shownum) {
                $new .= $old;
            }
            $req = number_format($req);
            if ($shownum && $shownext) {
                $new .= "`0 / `@{$req}`0";
            }
            if ($showbar) {
                if ($shownum) {
                    $new .= "<br />";
                }
                $new .= "<table style='border: solid 1px #000000;' bgcolor='red'  cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='{$pct}%' bgcolor='{$color}'></td><td width='{$nonpct}%'></td></tr></table>";
            }
            setcharstat("Personal Info", "Experience", $new);
            break;
    }
    return $args;
}
$greentotal = round(($daystamina - $redpoint - $amberpoint) / $daystamina * 100);
$ambertotal = round(($daystamina - $redpoint) / $daystamina * 100 - $greentotal);
$redtotal = 100 - $greentotal - $ambertotal;
$greenwidth = $greentotal / 100 * $greenpct;
$amberwidth = $ambertotal / 100 * $amberpct;
$redwidth = $redtotal / 100 * $redpct;
$colorgreen = "#00FF00";
$coloramber = "#FFA200";
$colorred = "#FF0000";
$colordarkgreen = "#003300";
$colordarkamber = "#2F1E00";
$colordarkred = "#330000";
$colorbackground = $colordarkgreen;
if ($greenpct == 0) {
    $colorgreen = $colordarkamber;
    $colorbackground = $colordarkamber;
}
if ($amberpct == 0) {
    $colorgreen = $colordarkred;
    $coloramber = $colordarkred;
    $colorbackground = $colordarkred;
}
$pctgrey = 100 - $greenwidth - $amberwidth - $redwidth;
$new = "";
$new .= "<font color={$colorbackground}>{$pctoftotal}%</font><br><table style='border: solid 1px #000000' bgcolor='{$colorbackground}' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='{$redwidth}%' bgcolor='{$colorred}'></td><td width='{$amberwidth}%' bgcolor='{$coloramber}'></td><td width='{$greenwidth}%' bgcolor='{$colorgreen}'></td><td width='{$pctgrey}%'></td></tr></table>";
// $new .= "<table style='border: solid 1px #000000' bgcolor='#777777' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='$pctoftotal%' bgcolor='$color'></td><td width='$pctused%'></td></tr></table>";
setcharstat("Vital Info", $stat, $new);
//Add the "Show Actions" bit
// addcharstat("Vital Info");
// addcharstat("Stamina Details", "<a href='runmodule.php?module=staminasystem&op=show' target='_blank' onclick=\"".popup("runmodule.php?module=staminasystem&op=show").";return false;\">".translate_inline("Show")."</a>");
addnav("", "runmodule.php?module=staminasystem&op=show");
     // db_query($sql);
     // }
     // }
     // $list=get_module_pref('flirtssent');
     // $list=unserialize($list);
     // require_once("./modules/marriage/marriage_func.php");
     // if (!is_array($list)) break;
     // while (list($who,$amount)=each($list)) {
     // marriage_removeplayer($who,$session['user']['acctid']);
     // }
     break;
 case "charstats":
     if ($session['user']['marriedto'] != 0 && get_module_pref('user_stats')) {
         require_once "lib/partner.php";
         $partner = get_partner(true);
         setcharstat("Personal Info", "Marriage", "`^" . translate_inline("Married to ") . $partner);
     }
     break;
 case "faq-toc":
     $t = translate_inline("`@Frequently Asked Questions on Marriage`0");
     output_notl("&#149;<a href='runmodule.php?module=marriage&op=faq'>{$t}</a><br/>", true);
     addnav("", "runmodule.php?module=marriage&op=faq");
     break;
 case "biostat":
     $char = httpget('char');
     $sql = "SELECT a.acctid as userid, a.marriedto as married, b.name as partnername,a.sex as gender FROM " . db_prefix('accounts') . " as a LEFT JOIN " . db_prefix('accounts') . " as b ON a.marriedto=b.acctid WHERE a.acctid='{$char}'";
     $results = db_query($sql);
     $row = db_fetch_assoc($results);
     if ($row['married'] != 0 && $row['partnername'] != "") {
         if (!get_module_pref('user_bio', "marriage", $row['userid'])) {
             $row['partnername'] = "`iSecret`i";
function racerobot_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "Cyber City 404";
    $race = "Robot";
    switch ($hookname) {
        case "load_inventory":
            if ($session['user']['race'] == $race) {
                foreach ($args as $itemid => $prefs) {
                    if ($prefs['blockrobot']) {
                        $args[$itemid]['blockuse'] = true;
                    }
                }
            }
            break;
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racerobot") {
                if ($session['user']['location'] == $args['old']) {
                    $session['user']['location'] = $args['new'];
                }
                $sql = "UPDATE " . db_prefix("accounts") . " SET location='" . addslashes($args['new']) . "' WHERE location='" . addslashes($args['old']) . "'";
                db_query($sql);
                if (is_module_active("cities")) {
                    $sql = "UPDATE " . db_prefix("module_userprefs") . " SET value='" . addslashes($args['new']) . "' WHERE modulename='cities' AND setting='homecity'" . "AND value='" . addslashes($args['old']) . "'";
                    db_query($sql);
                }
            }
            break;
        case "chooserace":
            if ($session['user']['dragonkills'] < 7) {
                break;
            }
            clear_module_pref("heat");
            clear_module_pref("atk");
            clear_module_pref("def");
            clear_module_pref("heal");
            output("`0<a href='newday.php?setrace={$race}{$resline}'>You grin at the gatekeeper</a>, exposing your sharp, bitey metal teeth.`n`n", true);
            addnav("`&Robot`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("\"`6Oh, I see, right,`0\" says the gatekeeper, and takes out his ledger.  \"`6Are, oh, double-you, bee, oh, tee, tee.  Robot.  I must say, it's nice to see some straightforward logic in this place.`0\"`n`nYou nod.  \"`#Yes,`0\" you reply, \"`#it is.`0\"`n`nThe gatekeeper looks up and says, with a mischievous grin, \"`6So - would you like to play a game of chess?`0\"`n`nYou scowl.  \"`#Do not play games with me, human.  Just because you know how to press my buttons does not mean I will allow you to press them.`0\"`n`n\"`6Sorry,`0\" says the gatekeeper with an even wider smile, \"`6I meant - SUDO play a game of chess.`0\"`n`n\"`#I'd love to,`0\" you reply.`n`nAfter you checkmate the gatekeeper in three moves, he sits back, obviously miffed.`n`n\"`#As I won,`0\" you say, \"`#you must answer my question: what is this \"love\" of which you humans speak?`0\"`n`nThe gatekeeper looks up at you, pouting, arms folded.  \"`6This statement is false.`0\"`n`nYou twitch a little, let out a quiet, sad \"`#beep,`0\" and fall over onto your back.`n`nWhen you regain consciousness, you draw yourself up to your full height and stare the grinning gatekeeper in the face.  \"`#I have processed all the relevant data,`0\" you say, in a low, mechanical growl, \"`#and have come to the conclusion that you, fleshbag, are a bastard.`0\"`n`nThe gatekeeper winks and smiles.  \"`6Don't tell the others.`0\"`n`nYou turn and head towards the gate, muttering under your breath.`n`n\"`6Pi is exactly three, by the way!`0\" he calls after you.  But you're too wily for him, oh yes indeed.  Just two minutes later, you reboot successfully and place him on your \"ignore\" list.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "alternativeresurrect":
            if ($session['user']['race'] == $race) {
                racerobot_checkcity();
                set_module_pref("heat", 0);
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('robot3', array("name" => "Robot Bonus: Fast-Moving and Fast-Learning", "action" => "Global", "costmod" => 0.7, "expmod" => 1.2, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //combat buffs
                apply_buff("robotatk", array("name" => "`7Robot Bonus: Stabbity Claws`0", "atkmod" => "1.3", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                apply_buff("robotdef", array("name" => "`7Robot Penalty: Glass Skin`0", "defmod" => "0.4", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                if (get_module_pref("atk") > 0) {
                    $atk = get_module_pref("atk") / 10 + 1;
                    apply_buff("robotatkoc", array("name" => "`7Overclock: Increased Upper Body Servo Power`0", "atkmod" => $atk, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                }
                if (get_module_pref("def") > 0) {
                    $def = get_module_pref("def") / 10 + 1;
                    apply_buff("robotdefoc", array("name" => "`7Overclock: Increased Lower Body Servo Power`0", "defmod" => $def, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                }
                if (get_module_pref("heal") > 0) {
                    $heal = get_module_pref("heal");
                    apply_buff("robothealoc", array("name" => "`7Overclock: In-Combat Self-Repair Subsystem`0", "regen" => $heal, "effectmsg" => "`#SYSTEM MESSAGE: {damage} POINTS OF DAMAGE AUTO-REPAIRED`0", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                } else {
                    strip_buff("robothealoc");
                }
            }
            break;
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                racerobot_checkcity();
                set_module_pref("heat", 0);
                increment_module_pref("amber", -200000, "staminasystem");
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('robot3', array("name" => "Robot Bonus: Fast-Moving and Fast-Learning", "action" => "Global", "costmod" => 0.7, "expmod" => 1.2, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "Robot Penalty: Insults Incompetence", "class" => "Insults", "costmod" => 2, "expmod" => 0.5, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //combat buffs
                apply_buff("robotatk", array("name" => "`7Robot Bonus: Stabbity Claws`0", "atkmod" => "1.3", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                apply_buff("robotdef", array("name" => "`7Robot Penalty: Glass Skin`0", "defmod" => "0.4", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                if (get_module_pref("atk") > 0) {
                    $atk = get_module_pref("atk") / 10 + 1;
                    apply_buff("robotatkoc", array("name" => "`7Overclock: Increased Upper Body Servo Power`0", "atkmod" => $atk, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                }
                if (get_module_pref("def") > 0) {
                    $def = get_module_pref("def") / 10 + 1;
                    apply_buff("robotdefoc", array("name" => "`7Overclock: Increased Lower Body Servo Power`0", "defmod" => $def, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                }
                if (get_module_pref("heal") > 0) {
                    $heal = get_module_pref("heal");
                    apply_buff("robothealoc", array("name" => "`7Overclock: In-Combat Self-Repair Subsystem`0", "regen" => $heal, "effectmsg" => "`#SYSTEM MESSAGE: {damage} POINTS OF DAMAGE AUTO-REPAIRED`0", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racerobot"));
                } else {
                    strip_buff("robothealoc");
                }
            }
            break;
        case "validforestloc":
        case "validlocation":
            if (is_module_active("cities")) {
                $args[$city] = "village-{$race}";
            }
            break;
        case "moderate":
            if (is_module_active("cities")) {
                tlschema("commentary");
                $args["village-{$race}"] = sprintf_translate("City of %s", $city);
                tlschema();
            }
            break;
        case "villagetext":
            racerobot_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of %s.  Though called a city by outsiders, this stronghold of robots is little more than a glorified scrapyard.  Puddles of rusted, oily water cover the bare, muddy earth, and piles of scrap metal lie here and there.  Some residents are engaged in stilted, mechanical conversation around the well in the village square.`n", $city, $city);
                $args['schemas']['text'] = "module-racerobot";
                $args['clock'] = "`n`0The great clockwork readout at the centre of the city reads `&%s`0.`n";
                $args['schemas']['clock'] = "module-racerobot";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`n`0A smaller contraption next to it reads `&%s`0, `&%s %s %s`0.`n";
                    $args['schemas']['calendar'] = "module-racerobot";
                }
                $args['title'] = array("%s, Home of the Robots", $city);
                $args['schemas']['title'] = "module-racerobot";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racerobot";
                $args['talk'] = "`n`&Nearby some robots talk:`n";
                $args['schemas']['talk'] = "module-racerobot";
                $new = get_module_setting("newest-{$city}", "cities");
                if ($new != 0) {
                    $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$new}'";
                    $result = db_query_cached($sql, "newest-{$city}");
                    $row = db_fetch_assoc($result);
                    $args['newestplayer'] = $row['name'];
                    $args['newestid'] = $new;
                } else {
                    $args['newestplayer'] = $new;
                    $args['newestid'] = "";
                }
                if ($new == $session['user']['acctid']) {
                    $args['newest'] = "`n`0As you wander your new home, you feel your jaw dropping at the wonders around you.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, jaw agape, is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racerobot";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racerobot";
                $args['gatenav'] = "Village Gates";
                $args['schemas']['gatenav'] = "module-racerobot";
                unblocknav("stables.php");
            }
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racerobot";
            $args['desc'] = array("`0Just outside the outskirts of the mighty scrapyard, a training area and riding range has been set up.", "You can see a tall, spindly Robot whose name you assume to be Mike.  He's busily tending to his flock of abominations, using his many custom-built appendages to care for the creatures and machines in his care.  Vehicles, animals, and Genetically-Engineered Beasts of Burden are arrayed in front of you.", array("As you approach, \"Mike\" spins around to meet you, brandishing a screwdriver.  \"`^HOW MAY I HELP YOU MY FINE YOUNG %s?`0\" he asks in a buzzing, 8-bit monotone.", translate_inline($session['user']['sex'] ? 'LASS' : 'LAD', 'stables')));
            $args['schemas']['desc'] = "module-racerobot";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racerobot";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racerobot";
            $args['nosuchbeast'] = "`0\"`^I DO NOT STOCK ANY SUCH BEAST OR MACHINE.  PERHAPS IT WAS A DREAM OF YOURS`0\", Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racerobot";
            $args['finebeast'] = array("`0\"`^THIS ONE WILL ASSIST WITH YOUR OBJECTIVE OF CRUSHING YOUR FOES TO A FINE PASTE BENEATH YOUR MIGHTY METAL FEET,`0\" says Mike.`n`n", "`0\"`^TO THIS ONE, THERE ARE NO SUPERIOR EXAMPLES`0\" Mike boasts.`n`n", "`0\"`^DOES THIS ONE NOT HAVE A FINE SHINE`0\" he asks.`n`n", "`0\"`^THIS ONE I FIND AESTHETICALLY PLEASING, BEING AS ITS ANGLES AND SIZES ARE ALMOST A PERFECT 1:1.6180339887 RATIO`0\" exclaims Mike.`n`n", "`0\"`^THIS ONE WOULD BE A VERY ADVISABLE PURCHASE AT 2.1516 TIMES THE PRICE I AM ASKING,`0\" booms Mike.`n`n");
            $args['schemas']['finebeast'] = "module-racerobot";
            $args['toolittle'] = "`0Mike looks over the gold and gems you offer and turns up his mechanical nose, \"`^THIS IS NOT THE CORRECT AMOUNT.  THE %s WILL COST YOU `&%s `^REQUISITION TOKENS  AND `%%s`^ CIGARETTES.  THE PRICE IS NOT NEGOTIABLE.`0\"";
            $args['schemas']['toolittle'] = "module-racerobot";
            $args['replacemount'] = "`0Patting %s`0 on the rump, you hand the reins as well as the money for your new mount, and Mike hands you the reins of a `&%s`0.";
            $args['schemas']['replacemount'] = "module-racerobot";
            $args['newmount'] = "`0You hand over the money for your new mount, and Mike hands you the reins of a new `&%s`0.";
            $args['schemas']['newmount'] = "module-racerobot";
            $args['nofeed'] = "`0\"`^I AM SORRY %s, BUT I DO NOT STOCK FUEL OR FEED HERE.  YOU MUST LOOK ELSEWHERE.`0\"";
            $args['schemas']['nofeed'] = "module-racerobot";
            $args['nothungry'] = "`&%s`0 picks briefly at the food and then ignores it.  Mike, lacking the imagination to be dishonest, shakes his head and hands you back your money.";
            $args['schemas']['nothungry'] = "module-racerobot";
            $args['halfhungry'] = "`&%s`0 dives into the provided food and gets through about half of it before stopping.  \"`^WELL, %s WAS NOT AS HUNGRY AS YOU THOUGHT.`0\" says Mike as he hands you back all but %s Requisition tokens.";
            $args['schemas']['halfhungry'] = "module-racerobot";
            $args['hungry'] = "`0%s`0 seems to inhale the food provided.  %s`0, the greedy creature that it is, then goes snuffling at Mike's pockets for more food.`nMike shakes his head in amusement and collects `&%s`0 Requisition tokens from you.";
            $args['schemas']['hungry'] = "module-racerobot";
            $args['mountfull'] = "`n`0\"`^IT APPEARS, %s, THAT YOUR %s`^ IS NOW FULL.  YOU WILL RETURN WHEN IT IS EMPTY ONCE MORE.`0\" says Mike with a genial smile.";
            $args['schemas']['mountfull'] = "module-racerobot";
            $args['nofeedgold'] = "`0\"`^THAT IS NOT ENOUGH MONEY TO PAY FOR FOOD HERE`0\"  Mike turns his back on you, and you lead %s away to find other places for feeding.";
            $args['schemas']['nofeedgold'] = "module-racerobot";
            $args['confirmsale'] = "`n`n`0UMike eyes your mount up and down, checking it over carefully.  \"`^ARE YOU QUITE SURE YOU WISH TO RELINQUISH THIS CONVEYANCE?`0\"";
            $args['schemas']['confirmsale'] = "module-racerobot";
            $args['mountsold'] = "`0With but a single tear, you hand over the reins to your %s`0 to Mike's stableboy.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racerobot";
            $args['offer'] = "`n`n`0Mike strokes your creature's flank and offers you `&%s`0 Requisition tokens and `%%s`0 cigarettes for %s`0.";
            $args['schemas']['offer'] = "module-racerobot";
            break;
        case "potion":
            if ($session['user']['race'] == $race) {
                blocknav("healer.php?op=buy&pct=100&return=village.php");
                blocknav("healer.php?op=buy&pct=90&return=village.php");
                blocknav("healer.php?op=buy&pct=80&return=village.php");
                blocknav("healer.php?op=buy&pct=70&return=village.php");
                blocknav("healer.php?op=buy&pct=60&return=village.php");
                blocknav("healer.php?op=buy&pct=50&return=village.php");
                blocknav("healer.php?op=buy&pct=40&return=village.php");
                blocknav("healer.php?op=buy&pct=30&return=village.php");
                blocknav("healer.php?op=buy&pct=20&return=village.php");
                blocknav("healer.php?op=buy&pct=10&return=village.php");
                blocknav("healer.php?op=buy&pct=100");
                blocknav("healer.php?op=buy&pct=90");
                blocknav("healer.php?op=buy&pct=80");
                blocknav("healer.php?op=buy&pct=70");
                blocknav("healer.php?op=buy&pct=60");
                blocknav("healer.php?op=buy&pct=50");
                blocknav("healer.php?op=buy&pct=40");
                blocknav("healer.php?op=buy&pct=30");
                blocknav("healer.php?op=buy&pct=20");
                blocknav("healer.php?op=buy&pct=10");
                output("`n`nThe man stops suddenly and looks you up and down, examining your cracked glass skin and visible wiring harnesses.  \"`6'ere,`3\" he says, \"`6Are you `isure`i you're not a Robot?`3\"`n`nYou're really not sure what to say.");
            }
            break;
        case "village":
            if ($session['user']['race'] == $race) {
                blocknav("runmodule.php?module=bloodbank");
                blocknav("healer.php?op=buy");
                addnav("Robot Talents");
                addnav("Configure Overclocking", "runmodule.php?module=racerobot&op=config&from=village");
                if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) {
                    $scost = 400 * ($session['user']['maxhitpoints'] - $session['user']['hitpoints']);
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Repaired (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=repaired&from=village", true);
                }
                $heat = get_module_pref("heat");
                if ($heat > 0) {
                    $scost = 40 * $heat;
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Cooled (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=cooled&from=village", true);
                }
            }
            break;
        case "forest":
            if ($session['user']['race'] == $race) {
                addnav("Robot Talents");
                addnav("Configure Overclocking", "runmodule.php?module=racerobot&op=config&from=forest");
                if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) {
                    $scost = 400 * ($session['user']['maxhitpoints'] - $session['user']['hitpoints']);
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Repaired (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=repaired&from=forest", true);
                }
                $heat = get_module_pref("heat");
                if ($heat > 0) {
                    $scost = 40 * $heat;
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Cooled (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=cooled&from=forest", true);
                }
            }
            break;
        case "worldnav":
            if ($session['user']['race'] == $race) {
                addnav("Robot Talents");
                addnav("Configure Overclocking", "runmodule.php?module=racerobot&op=config&from=worldnav");
                if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) {
                    $scost = 400 * ($session['user']['maxhitpoints'] - $session['user']['hitpoints']);
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Repaired (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=repaired&from=worldnav", true);
                }
                $heat = get_module_pref("heat");
                if ($heat > 0) {
                    $scost = 40 * $heat;
                    $spct = $scost * 100 / 1000000;
                    addnav(array("Standby until Cooled (`Q%s%%`0)", $spct), "runmodule.php?module=racerobot&op=standby&til=cooled&from=worldnav", true);
                }
            }
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("%s", $city);
            tlschema();
            break;
        case "startofround":
            if ($session['user']['race'] == $race && $session['user']['alive'] == 1) {
                $heat = get_module_pref("heat");
                debug("Heat level: " . $heat);
                $fail = e_rand(100, 1500);
                debug("Fail Threshold: " . $fail);
                if ($heat >= $fail) {
                    $penalty = $session['user']['maxhitpoints'] / 100 * ($heat / 10);
                    debug($penalty);
                    $damage = 0 - $penalty;
                    debug("Robot is Overheating!");
                    apply_buff("robotoverheat", array("regen" => $damage, "effectmsg" => "`4`bYou feel a horrible burning, popping sensation deep within your chest!  Something has gone badly wrong, and one of your internal components is overheating!  You lose {damage} hitpoints!`b", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => 1, "schema" => "module-racerobot"));
                }
                //increase player heat level
                $heat += get_module_pref("atk") * 10;
                $heat += get_module_pref("def") * 10;
                $heat += get_module_pref("heal") * 10;
                set_module_pref("heat", $heat);
                debug("Heat level: " . $heat);
            }
            break;
        case "charstats":
            if ($session['user']['race'] == $race) {
                $heat = get_module_pref("heat");
                $col = "#00FF00";
                if ($heat > 200) {
                    $col = "#FDFF00";
                }
                if ($heat > 400) {
                    $col = "#FFA200";
                }
                if ($heat > 600) {
                    $col = "#FF5A00";
                }
                if ($heat > 800) {
                    $col = "#FF0000";
                }
                $width = $heat / 10;
                if ($width > 100) {
                    $width = 100;
                }
                $nwidth = 100 - $width;
                $bar = "<table style='border: solid 1px #000000' bgcolor='#333333' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='{$width}%' bgcolor='{$col}'></td><td width='{$nwidth}%' bgcolor='\$#333333'></td></tr></table>";
                setcharstat("Vital Info", "Heat Level", $bar);
            }
            break;
    }
    return $args;
}
function friendlist_dohook($hookname, $args)
{
    global $session, $SCRIPT_NAME, $battle;
    switch ($hookname) {
        case "checkuserpref":
            $args['allow'] = false;
            if (get_module_setting('allowStat') && $args['name'] == "check_show") {
                $args['allow'] = true;
            } elseif (get_module_Setting('showType') && get_module_pref('check_show')) {
                if ($args['name'] == "check_login" && get_module_setting('allowType') == 0 || $args['name'] == "check_names" && get_module_setting('allowType') == 1 || $args['name'] == "check_head") {
                    $args['allow'] = true;
                }
            }
            break;
        case "faq-toc":
            $t = translate_inline("`@Frequently Asked Questions on Friend Lists`0");
            output_notl("&#149;<a href='runmodule.php?module=friendlist&op=faq'>{$t}</a><br/>", true);
            addnav("", "runmodule.php?module=friendlist&op=faq");
            break;
        case "mailfunctions":
            output_notl("`c`^[`@");
            $t = translate_inline("Friend List");
            rawoutput("<a href='runmodule.php?module=friendlist&op=list'>{$t}</a>");
            addnav('', 'runmodule.php?module=friendlist&op=list');
            output_notl("`^]`c`n");
            if (httpget('op') == 'send' && !($session['user']['superuser'] & SU_GIVES_YOM_WARNING)) {
                $sql = "SELECT acctid,name FROM " . db_prefix("accounts") . " WHERE login='******'to') . "'";
                $result = db_query($sql);
                if (db_num_rows($result) > 0) {
                    $row = db_fetch_assoc($result);
                    if (in_array($row['acctid'], explode('|', get_module_pref('ignored')))) {
                        popup_header("Ye Olde Poste Office");
                        output_notl("`c`^[`%");
                        $t = translate_inline("Back to your Mail");
                        rawoutput("<a href='mail.php'>{$t}</a>");
                        output_notl("`^]`c`Q`n");
                        $info = translate_inline("%s`Q has ignored you, so you cannot send %s`Q Ye Olde Mail.");
                        $info = str_replace('%s', $row['name'], $info);
                        output_notl($info);
                        popup_footer();
                        die;
                    }
                }
            }
            break;
        case "charstats":
            if (get_module_setting('allowStat') && get_module_pref('check_show')) {
                // I could so other 'if' checks here, but if admin have it turned off, it'd increase load, when it isn't needed anyway
                $friends = rexplode(get_module_pref('friends'));
                $x = 0;
                $last = date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " sec"));
                $addon = "";
                if (get_module_setting("allowType") == 0 && get_module_pref("check_login") == 1 || get_module_setting("allowType") == 1 && get_module_pref("check_names") == 1) {
                    $addon = ",login";
                } elseif (get_module_setting("allowType") == 1 && get_module_pref("check_names") == 2) {
                    $addon = ",name";
                }
                $onlinelist = "";
                $bl = false;
                if ($battle === false || !isset($battle) || empty($battle)) {
                    if (httpget('module') == '' && $session['user']['specialinc'] == '' && $session['user']['specialmisc'] == '') {
                        $bl = true;
                    }
                }
                if (implode(",", $friends) != '') {
                    $sql = "SELECT loggedin,laston{$addon} FROM " . db_prefix("accounts") . " WHERE acctid IN (" . implode(",", $friends) . ") AND locked=0";
                    $result = db_query_cached($sql, "friendliststat-" . $session['user']['acctid'], 60);
                    while ($row = db_fetch_assoc($result)) {
                        $loggedin = $row['loggedin'];
                        if ($row['laston'] < $last) {
                            $loggedin = false;
                        }
                        if ($loggedin) {
                            $x++;
                            if ($addon != "") {
                                if ($onlinelist != "") {
                                    $onlinelist .= ", ";
                                }
                                if (get_module_setting('linkType') == 1) {
                                    $onlinelist .= "<a href='mail.php?op=write&to={$row['login']}' class='colLtGreen' target='_blank' onClick=\"" . popup("mail.php?op=write&to={$row['login']}") . ";return false;\">";
                                } elseif (get_module_setting('linkType') == 2 && $bl) {
                                    $link = "bio.php?char=" . rawurlencode($row['login']) . "&ret=" . URLEncode($_SERVER['REQUEST_URI']);
                                    $onlinelist .= "<a href='{$link}' class='colLtGreen'>";
                                    addnav($link, "");
                                }
                                if ($addon == ",login") {
                                    $onlinelist .= sanitize($row['login']);
                                } else {
                                    $onlinelist .= sanitize($row['name']);
                                }
                                if (get_module_setting('linkType') == 1 || get_module_setting('linkType') == 2 && $bl) {
                                    $onlinelist .= "</a>";
                                }
                            }
                        }
                    }
                }
                $onlinelist .= ".";
                if ($x > 0) {
                    $words = sprintf_translate("`^You have `%%s`^ logged-in friends.", $x);
                } else {
                    $words = translate_inline("`@None of your friends are logged-in.");
                }
                setcharstat(translate_inline(get_module_pref('check_head')), translate_inline("Friend Count"), $words);
                if ($onlinelist != ".") {
                    setcharstat(translate_inline(get_module_pref('check_head')), translate_inline("Friend List"), $onlinelist);
                }
            }
            break;
    }
    return $args;
}
function healthbar_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "charstats":
            if ($session['user']['alive']) {
                $cur = $session['user']['hitpoints'];
                $realmax = $session['user']['maxhitpoints'];
                $stat = "Hitpoints";
                $cur_adjustment = check_temp_stat("hitpoints", 1);
                $max_adjustment = check_temp_stat("maxhitpoints", 1);
            } else {
                $cur = $session['user']['soulpoints'];
                $realmax = $session['user']['level'] * 5 + 50;
                $stat = "Soulpoints";
                $cur_adjustment = check_temp_stat("soulpoints", 1);
                $max_adjustment = "";
            }
            if ($cur > $realmax) {
                $max = $cur;
            } else {
                $max = $realmax;
            }
            $pct = round($cur / $max * 100, 0);
            $nonpct = 100 - $pct;
            if ($pct > 100) {
                $pct = 100;
                $nonpct = 0;
            }
            if ($pct < 0) {
                $pct = 0;
                $nonpct = 100;
            }
            if ($pct > 60) {
                if ($session['user']['alive']) {
                    $color = "#00ff00";
                } else {
                    $color = "#dddddd";
                }
                $ccode = "`@";
            } elseif ($pct > 25) {
                if ($session['user']['alive']) {
                    $color = "#ffff00";
                } else {
                    $color = "#666666";
                }
                $ccode = "`^";
            } else {
                if ($session['user']['alive']) {
                    $color = "#ff0000";
                } else {
                    $color = "#880000";
                }
                $ccode = "`\$";
            }
            $hicode = "`&";
            if (!$session['user']['alive']) {
                $ccode = "`7";
            }
            $showcur = 1;
            $showmax = 1;
            $showbar = 1;
            $new = "";
            if (!$showcur && !$showbar) {
                $new = "`b`\$hidden`b";
            }
            if ($showcur) {
                $new .= $ccode . $cur . $cur_adjustment;
            }
            if ($showcur && $showmax) {
                $new .= "`0/`&{$realmax}`0" . $max_adjustment;
            }
            if ($showbar) {
                if ($showcur) {
                    $new .= "<br />";
                }
                $new .= "<table style='border: solid 1px #000000' bgcolor='#777777' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='{$pct}%' bgcolor='{$color}'></td><td width='{$nonpct}%'></td></tr></table>";
            }
            setcharstat("Vital Info", $stat, $new);
            break;
    }
    return $args;
}