function racekittymorph_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "Kittania";
    $race = "Kittymorph";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racekittymorph") {
                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'] == 0) {
                break;
            }
            output("`0You smile, and turn around to show the gatekeeper your tail.  <a href='newday.php?setrace={$race}{$resline}'>\"Um... notice anything unusual?\"</a>`n`n", true);
            addnav("`&Kittymorph`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, looking down at his ledger.  \"`6A kittymorph, then, okay, let's see, here...  Kay, eye, tee, ee, em, oh, are, eff.  Kittymorph.`0\"  He looks up again.  \"`6Um.  You can turn around again, now.`0\"`n`nYou oblige.  \"`#Sorry.`0\"`n`n\"`6Don't worry about it.  Have you always been like this?`0\"`n`n\"`#Since I was a kitten,`0\" you reply.  \"`#I don't know what that crazy woman back there was talking about; she says I fell out of a plane and hit my head.  Rubbish.`0\"`n`n\"`6Of course,`0\" says the gatekeeper, smiling.  \"`6You would have landed on your feet, wouldn't you?`0\"`n`n\"`#That's right.  Although...`0\"  You look down, puzzled.  \"`#Some things just don't add up...`0\" you mutter.`n`n\"`6Well, don't worry,`0\" says the gatekeeper.  \"`6Just head into town and get some nice clothes, and you'll sort everything out, I'm sure.  If you wear clothes, that is.`0\"`n`nYou grin.  \"`#When it suits me.`0\"  You saunter off through the gates.  You don't really know how to walk any other way.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "alternativeresurrect":
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                racekittymorph_checkcity();
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('kittymorph3', array("name" => "KittyMorph Bonus: Travelling Speed", "class" => "Travelling", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph4', array("name" => "KittyMorph Bonus: Cooking and Carcass Cleaning Expertise", "class" => "Meat", "costmod" => 0.7, "expmod" => 1.2, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph1', array("name" => "KittyMorph Penalty: Hunting Indifference", "class" => "Hunting", "costmod" => 1.1, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph2', array("name" => "KittyMorph Penalty: Combat Indifference", "class" => "Combat", "costmod" => 1.1, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('kittymorph5', array("name" => "KittyMorph Penalty: Technical Ineptitude", "class" => "ScrapBots", "costmod" => 1.1, "expmod" => 0.8, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "KittyMorph Bonus: Classy Insults Proficiency", "action" => "Insults - Classy", "costmod" => 0.9, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceconfusing', array("name" => "KittyMorph Bonus: Confusing Insults Proficiency", "action" => "Insults - Confusing", "costmod" => 0.5, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //combat buffs
                apply_buff("racialbenefit1", array("name" => "`7KittyMorph Penalty: Slender`0", "defmod" => "0.8", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racekittymorph"));
                apply_buff("racialbenefit2", array("name" => "`7KittyMorph Bonus: Claws`0", "atkmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racekittymorph"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racekittymorph_checkcity();
                if ($session['user']['armordef'] == 0) {
                    apply_buff("nudekitty", array("name" => "`7KittyMorph Bonus: Nude Fighting`0", "badguyatkmod" => 0.7, "badguydefmod" => 0.7, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "roundmsg" => "Because you are fighting completely starkers, {badguy} is hilariously distracted and cannot attack or defend as effectively!", "expireafterfight" => 1, "schema" => "module-racekittymorph"));
                }
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race) {
                if (!$session['user']['alive']) {
                    debug($args['creatureexp']);
                    $args['creatureexp'] = round($args['creatureexp'] * 1.3);
                    debug($args['creatureexp']);
                }
            }
            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":
            racekittymorph_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of Kittania.  Though officially registered as a city, it only earned that title because there were so many sentient creatures living there.`n`nIn reality, the city is a very basic affair, little more than a pack living together in common conditions.  Kittymorphs are a little too lazy to build much.`n");
                $args['schemas']['text'] = "module-racekittymorph";
                $args['clock'] = "`n`0From the position of the sun in the sky, you reckon it's about `&%s`0.`n";
                $args['schemas']['clock'] = "module-racekittymorph";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`n`0Scrawled in dust on the floor is the current date, `&%s`0, `&%s %s %s`0.`n";
                    $args['schemas']['calendar'] = "module-racekittymorph";
                }
                $args['title'] = array("%s, Home of the Kittymorphs", $city);
                $args['schemas']['title'] = "module-racekittymorph";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racekittymorph";
                $args['talk'] = "`n`&Nearby some kittymorphs talk:`n";
                $args['schemas']['talk'] = "module-racekittymorph";
                $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 wonderful smells around you.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, jaw agape and buck naked, is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racekittymorph";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racekittymorph";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Toothclaw Close";
                $args['marketnav'] = "The Cul-De-Sac of Sparkly Things";
                $args['tavernnav'] = "Distraction Avenue";
                $args['schemas']['gatenav'] = "module-racekittymorph";
                unblocknav("stables.php");
            }
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racekittymorph";
            $args['desc'] = array("`6Just next door to the Clan Halls, a rather basic-looking set of stables has been erected.`n`n", array("As you head inside, you notice an obvious lack of the typical stable smell.  Apparently KittyMorphs, for all their laziness, like to keep things clean.`n`n\"`^Well hello there!  What can I do for you, my good %s?`6\" asks a grey-furred KittyMorph male whose name you're absolutely `icertain`i is not \"Mike.\"", translate_inline($session['user']['sex'] ? 'lady' : 'man', 'stables')));
            $args['schemas']['desc'] = "module-racekittymorph";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racekittymorph";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racekittymorph";
            $args['nosuchbeast'] = "`6\"`^Hmm.  Not heard of that one,`6\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racekittymorph";
            $args['toolittle'] = "`6Mike looks over the handful of currency you offered.  \"`^Aha.  Well, the price for this %s, you see, was actually `&%s `^Requisition  and `%%s`^ cigarettes.  Maybe you miscounted?`6\"";
            $args['schemas']['toolittle'] = "module-racekittymorph";
            $args['replacemount'] = "`6You sadly watch Mike lead your %s`6 away, along with your cigarettes.  However, when he returns, he brings with him a nice new `&%s`6 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racekittymorph";
            $args['newmount'] = "`6You hand over your currency.  Within moments, you become the proud recipient of a lovely new `&%s`6!";
            $args['schemas']['newmount'] = "module-racekittymorph";
            $args['confirmsale'] = "`n`n`6Mike eyes your mount up and down, checking it over carefully.  \"`^Yes, yes, that's a really nice example, right there - are you quite sure you want to part with it?`6\"";
            $args['schemas']['confirmsale'] = "module-racekittymorph";
            $args['mountsold'] = "`6With but a single tear, you hand your %s`6 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racekittymorph";
            $args['offer'] = "`n`n`6Mike offers you `&%s`6 Requisition and `%%s`6 Cigarettes for %s`6.";
            $args['schemas']['offer'] = "module-racekittymorph";
            break;
    }
    return $args;
}
function racejoker_dohook($hookname, $args)
{
    //yeah, the $resline thing is a hack.  Sorry, not sure of a better way
    // to handle this.
    // Pass it as an arg?
    global $session, $resline;
    $city = "AceHigh";
    $race = "Joker";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racejoker") {
                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'] < 12) {
                break;
            }
            output("`0You grin, and pull a six-sided die from your left ear.  <a href='newday.php?setrace={$race}{$resline}'>\"Well, let's see, shall we?\"</a>`n`n", true);
            addnav("`&Joker`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("The gatekeeper's smile doesn't go away.  Instead, it freezes, locks carefully into place - and the gatekeeper begins to pray that he can persuade it to stay there until you go away, or at least until your eyes stop doing that `@green glowy thing`0.  \"`6Yes,`0\" he says, carefully.  \"`6Yes, that would be fine.`0\"`n`nYou roll your die.  It skitters along, making a clattering sound like bone on wood.  The fact that it's still four feet above the ground doesn't seem to faze the gatekeeper, or if it does, he's very good at not letting it show.`n`nIt finally comes to rest, seven spots facing the sun.  You look up and grin, teeth white and gleaming and not entirely friendly.  \"`#It seems I am a Joker!`0\" you exclaim in a breathy growl.`n`nThe gatekeeper nods, and picks up his journal.  \"`6Very good.  As you say.  Jay.  Oh.  Kay.  Are.  Ee.  Joker.  All done.`0\"  He looks up, to see you preparing to roll your die again.  He opens his mouth to ask you what you're doing, and bites his tongue.  Never ask what a Joker is doing; they might tell you.`n`nYou roll your die.  It skitters along the invisible table, bounces against an invisible wall, and comes up at two.`n`n\"`#Shame,`0\" you say.  \"`#You would have been more interesting with some additional eyes.  Still, if the die says two are enough, then who am I to disagree?`0\"`n`nYou give the gatekeeper a grin and a wink, and head into the outpost.`n`nA minute later, he remembers to exhale.  He shudders and puts the kettle on, hoping that it isn't going to turn out to be one of `ithose`i days.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "startofround-prebuffs":
            if ($session['user']['race'] == $race && $session['user']['alive']) {
                $chain = unserialize(get_module_pref("chain"));
                if (!is_array($chain)) {
                    $chain = array();
                }
                $suit = httpget("suit");
                if (!$suit) {
                    $suit = e_rand(1, 4);
                }
                switch ($suit) {
                    case 1:
                        $chain[] = "heart";
                        break;
                    case 2:
                        $chain[] = "diamond";
                        break;
                    case 3:
                        $chain[] = "spade";
                        break;
                    case 4:
                        $chain[] = "club";
                        break;
                }
                $hearts = 0;
                $diamonds = 0;
                $spades = 0;
                $clubs = 0;
                $num = 0;
                output("You draw a card from your rather Improbable deck, and add it to your hand.`n");
                foreach ($chain as $card) {
                    rawoutput("<img src=\"images/" . $card . ".png\">");
                    switch ($card) {
                        case "heart":
                            $hearts++;
                            break;
                        case "diamond":
                            $diamonds++;
                            break;
                        case "spade":
                            $spades++;
                            break;
                        case "club":
                            $clubs++;
                            break;
                    }
                    $num++;
                }
                output_notl("`n");
                if ($hearts == $num || $diamonds == $num || $spades == $num || $clubs == $num) {
                    if ($num > 1) {
                        output("`0With a grin you realise that all your cards match up - Joker tradition now allows you to expand your hand by one card!`n");
                    }
                } else {
                    if ($num > 1) {
                        output("`0The bottom card from your hand vanishes.`n");
                    }
                    array_shift($chain);
                }
                set_module_pref("chain", serialize($chain));
                //calculate and award buffs
                $bhearts = round($session['user']['maxhitpoints'] / 100 * e_rand($hearts * $hearts * $hearts / 100, $hearts * $hearts * $hearts / 5));
                $bdiamonds = e_rand($diamonds, $diamonds * $diamonds);
                $bspades = $spades * $spades * $spades * 0.005 + 1;
                $bclubs = $clubs * $clubs * $clubs * 0.005 + 1;
                if ($bhearts > 1) {
                    apply_buff("Hearts", array("regen" => $bhearts, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => 1, "expireafterfight" => 1, "effectmsg" => "The mysterious power of your Hearts aura causes you to regenerate {damage} hitpoints...`0", "schema" => "module-racejoker"));
                }
                if ($bdiamonds > 0) {
                    if ($bdiamonds == 1) {
                        output("`@The reward hopper mounted to the closest camera is briefly enveloped in crackling green lightning.  You step back and deftly catch the single Requisition token that clatters out of it, before heading straight back into the fight!`0`n");
                    } else {
                        output("`@The reward hopper mounted to the closest camera is briefly enveloped in crackling green lightning.  You step back and deftly catch the `b%s`b Requisition tokens that pour out of it, before heading straight back into the fight!`0`n", $bdiamonds);
                    }
                    $session['user']['gold'] += $bdiamonds;
                }
                if ($bspades > 1) {
                    apply_buff("Spades", array("defmod" => $bspades, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => 1, "startmsg" => "You feel an aura of protection gathering around you!", "expireafterfight" => 1, "roundmsg" => "Thanks to the power of the Spades suit, {badguy} is having trouble hitting you!", "schema" => "module-racejoker"));
                }
                if ($bclubs > 1) {
                    apply_buff("Clubs", array("atkmod" => $bclubs, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => 1, "startmsg" => "You feel a burning energy in your muscles...", "expireafterfight" => 1, "roundmsg" => "Thanks to the power of the Clubs suit, your attacks are more powerful!", "schema" => "module-racejoker"));
                }
            }
            break;
            // case "alternativeresurrect":
        // case "alternativeresurrect":
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                clear_module_pref("chain");
                racejoker_checkcity();
                //new Joker grenade -> improbabombs routine
                $bandolier = 0;
                $blprefs = array("inventorylocation" => "fight");
                $bandolier += has_item_quantity("banggrenade", $blprefs);
                $bandolier += has_item_quantity("whoomphgrenade", $blprefs);
                $bandolier += has_item_quantity("zapgrenade", $blprefs);
                $count = 0;
                $count += delete_all_items_of_type("banggrenade");
                $count += delete_all_items_of_type("whoomphgrenade");
                $count += delete_all_items_of_type("zapgrenade");
                if ($count) {
                    output("`0All of your Grenades have turned into Improbability Bombs overnight.  Well, that's what happens when you store explosives around such high levels of Improbability.`n");
                    $backpack = $count - $bandolier;
                    for ($i = 0; $i < $backpack; $i++) {
                        give_item("improbabilitybomb");
                    }
                    for ($i = 0; $i < $bandolier; $i++) {
                        give_item("improbabilitybomb", $blprefs);
                    }
                }
                //Combat buffs
                $jokerattack = e_rand(1, 20) / 10;
                $jokerdefence = e_rand(1, 20) / 10;
                $jokerregen = 0;
                $jokerregenchance = e_rand(1, 100);
                if ($jokerregenchance > 80) {
                    $jokerregen = 5 - e_rand(1, 10);
                }
                apply_buff("joker", array("name" => "Joker Bonus - Improbability", "atkmod" => $jokerattack, "defmod" => $jokerdefence, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racejoker"));
                if ($jokerregen < 0) {
                    output("`n`&Today is a bad day.  Your internal organs appear to have shifted themselves into a rather unfortunate configuration.  Internal bleeding will cause you to lose some hitpoints with every round of battle.`n`0");
                    apply_buff("jokerregen", array("regen" => $jokerregen, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "effectmsg" => "`3Your internal bleeding causes you to lose {damage} hitpoints.`0", "schema" => "module-racejoker"));
                }
                if ($jokerregen > 0) {
                    output("`n`&Today is a good day.  You appear to have discovered the secret of cellular regeneration.  You will gain hitpoints in every battle.`n`0");
                    apply_buff("jokerregen", array("regen" => $jokerregen, "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "effectmsg" => "`3Your accelerated cellular regeneration causes you to gain {damage} hitpoints.`0", "schema" => "module-racejoker"));
                }
                $c1 = e_rand(10, 200) / 100;
                $c2 = e_rand(10, 200) / 100;
                $c3 = e_rand(10, 200) / 100;
                $c4 = e_rand(10, 200) / 100;
                $c5 = e_rand(10, 200) / 100;
                $e1 = e_rand(10, 200) / 100;
                $e2 = e_rand(10, 200) / 100;
                $e3 = e_rand(10, 200) / 100;
                $e4 = e_rand(10, 200) / 100;
                $e5 = e_rand(10, 200) / 100;
                //Stamina Buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('joker1', array("name" => "Joker Improbability Modifier: Travelling", "class" => "Travelling", "costmod" => $c1, "expmod" => $e1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('joker2', array("name" => "Joker Improbability Modifier: Cooking and Carcass Cleaning", "class" => "Meat", "costmod" => $c2, "expmod" => $e2, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('joker3', array("name" => "Joker Improbability Modifier: Hunting", "class" => "Hunting", "costmod" => $c3, "expmod" => $e3, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('joker4', array("name" => "Joker Improbability Modifier: Combat", "class" => "Combat", "costmod" => $c4, "expmod" => $e4, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('joker5', array("name" => "Joker Improbability Modifier: ScrapBots", "class" => "ScrapBots", "costmod" => $c5, "expmod" => $e5, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
            }
            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":
            racejoker_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of AceHigh.  Though relatively new, this town seems to be prospering.  The houses are built of stone and timber frames, and well-dressed gentlemen and ladies stroll about with impeccable manners.  Every now and then, one of them explodes in an astonishing flash of green light, drawing polite applause from those nearby.`n`n");
                $args['schemas']['text'] = "module-racejoker";
                $args['clock'] = "`0The great clockwork readout at the centre of the city reads `&%s`0.`n`n";
                $args['schemas']['clock'] = "module-racejoker";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`0A smaller contraption next to it reads `&%s`0, `&%s %s %s`0.`n`n";
                    $args['schemas']['calendar'] = "module-racejoker";
                }
                $args['title'] = array("%s, Home of the Jokers", $city);
                $args['schemas']['title'] = "module-racejoker";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racejoker";
                $args['talk'] = "`0Nearby some people converse politely:`n";
                $args['schemas']['talk'] = "module-racejoker";
                $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-racejoker";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racejoker";
                $args['gatenav'] = "Village Gates";
                $args['schemas']['gatenav'] = "module-racejoker";
                unblocknav("stables.php");
            }
            break;
    }
    return $args;
}
function racezombie_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "New Pittsburgh";
    $race = "Zombie";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racezombie") {
                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'] == 0) {
                break;
            }
            output("`0<a href='newday.php?setrace={$race}{$resline}'>\"BRAAAAAAAAAAAAINS.\"</a>`n`n", true);
            addnav("`0Zombie`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("`0The hairy man nods.  \"`6All right, all right, a simple \"I'm a zombie\" would have done.`0\"  He looks down and writes in his ledger.  \"`6Zed, oh, em, bee, why.  Zombie.  There.`0\"`n`nYou give the man a sheepish look.  \"`#I didn't actually mean to say that.  It just slipped out.`0\"`n`nHe smiles.  \"`6That's okay, I know how it is.  So, how did you get here?`0\"`n`n\"`#As far as I know, it was on a jet PLAAAAAAAAINS oh God!`0\"  You clap your hands over your mouth.`n`nThe gatekeeper chuckles.  \"`6Works every time.`0\"`n`nYou scowl at him.  \"`#Get on with the form.`0\"`n`n\"`6So, have you been a zombie all your life?`0\"`n`nYou pause.  \"`#I think so.  I mean...  Growing up, I think I played with the other zombie kids in zombie school, but...  Hmm.  It's amazing that there would have `ibeen`i a zombie school in the first place.`0\"  You give the man a very serious look.  \"`#This really doesn't make much sense at all, does it?`0\"`n`n\"`6Few things do around here, sunshine.  Do yourself a favour and don't think about it too much.  Unless you want your head to explode.`0\"`n`nThe word rushes up your throat like vomit.  \"`#BRAAAAAAAAAINS!`0\"`n`n\"`6Yes, that's right, brains.  Lovely juicy brains, splattering around all over the shop.  Yum!`0\"`n`nYou scowl at the gatekeeper while convulsing again, your mouth operating of its own accord.  \"`#BRAAAAAAAAAINS you know, that's really not funny.`0\"`n`n\"`6I know.  I shouldn't make fun.  It's a tough life for zombies.  You have it very hard, don't you?  Bits falling off all the time?  Uncontrollable larynx and primeval, base reactions if something sets you off?`0\"`n`n\"`#That's not true.`0\"  You shoot the gatekeeper a withering glare.  \"`#You've just been perpetuating the tired old Zombie stereotype.  And I, for one, am sick of the constant prejudice that comes from people like you.`0\"`n`n\"`6All right, all right, I meant no offense.  I was just having a little joke.`0\"`n`nGrudgingly, you remember your manners.  \"`#Apology accepted.  I didn't mean to get angry.  It's just hard, you know?`0\"`n`n\"`6I know,`0\" says the gatekeeper with a twinkle in his eye.  \"`6You don't need to explain.`0\"`n`n\"`#EXPLAAAAAAAAAAAAAAAAAAINS!  Oh, `ifuck you`i.`0\"  You storm off towards the gate.`n`nBehind you, the gatekeeper cries \"`6You know what, I think it might rain!`0\"`n`n\"`#RAAAAAAAAAINS!`0\" says your mouth.  \"`3`iFuck you, old man,`i`0\" says your internal monologue.  \"`3`iFuck you and your tasty, tasty brains.`i`0\"");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "alternativeresurrect":
        case "stamina-newday":
            if ($session['user']['race'] == $race) {
                racezombie_checkcity();
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('Zombie2', array("name" => "Zombie Bonus: Combat Endurance", "class" => "Combat", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie1', array("name" => "Zombie Bonus: Hunting Endurance", "class" => "Hunting", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie8', array("name" => "Zombie Bonus: Carcass Cleaning Skills", "action" => "Cleaning the Carcass", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie0', array("name" => "Zombie Penalty: Slow of Mind", "class" => "Global", "costmod" => 1, "expmod" => 0.8, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie3', array("name" => "Zombie Penalty: Slow-Moving", "class" => "Travelling", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie4', array("name" => "Zombie Penalty: Scavenging Slowness", "action" => "Scavenging for Scrap", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie5', array("name" => "Zombie Penalty: Metalwork Ineptitude", "action" => "Metalworking", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie6', array("name" => "Zombie Penalty: Soldering Ineptitude", "action" => "Soldering", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie7', array("name" => "Zombie Penalty: Programming Ineptitude", "action" => "Programming", "costmod" => 1.4, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('Zombie9', array("name" => "Zombie Penalty: Cooking Ineptitude", "action" => "Cooking", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "Zombie Bonus: Insults Proficiency", "class" => "Insults", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //Combat Buffs
                apply_buff("racialbenefit1", array("name" => "`0Zombie Bonus: No Pain`0", "defmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racezombie"));
                apply_buff("racialbenefit2", array("name" => "`0Zombie Bonus: Leathery Fists`0", "atkmod" => "1.1", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racezombie"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racezombie_checkcity();
                $args['creaturegold'] = round($args['creaturegold'] * 1.2, 0);
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race && $session['user']['alive'] == false) {
                if (!$session['user']['alive']) {
                    $args['creatureexp'] = round($args['creatureexp'] * 0.8);
                }
            }
            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":
            racezombie_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of New Pittsburgh.  This place used to be populated almost entirely by humans, but... well, you know zombies.`n`nThe stench of rotten flesh hangs in the air, and cries of \"BRAAAAAINS\" can be heard every now and then.`n`nYou notice a group of zombies conversing in grunts and moans around an old horse trough, idly picking at the flappy bits of skin on their necks.`n");
                $args['schemas']['text'] = "module-racezombie";
                $args['clock'] = "`n`0From the strength of the overpowering odour, you reason that it is approximately `0%s`0.`n";
                $args['schemas']['clock'] = "module-racezombie";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`n`0Written in blood on a nearby wall is `0%s`0, `0%s %s %s`0.`n";
                    $args['schemas']['calendar'] = "module-racezombie";
                }
                $args['title'] = array("%s, Home of the Zombies", $city);
                $args['schemas']['title'] = "module-racezombie";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racezombie";
                $args['talk'] = "`n`0Nearby some zombies talk:`n";
                $args['schemas']['talk'] = "module-racezombie";
                $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 wonderful smells around you.  The smells of BRAAAAAAINS.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, jaw agape and eyeballs swivelling in their sockets, is `0%s`0.";
                }
                $args['schemas']['newest'] = "module-racezombie";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racezombie";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Brains Avenue";
                $args['marketnav'] = "Shiny Street";
                $args['tavernnav'] = "Hugs Boulevard";
                $args['schemas']['gatenav'] = "module-racezombie";
                unblocknav("stables.php");
            }
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racezombie";
            $args['desc'] = array("`0Just next door to the Clan Halls, a scruffy-looking warehouse has been erected.  It looks pretty similar to the other buildings - blood splattered along every wall, groups of undead monsters shambling around, cries of \"BRAAAAAAAAINS!\" emanating from within - you know, the usual.  You head inside.`n`n", array("As you venture inside the building, a young Zombie woman shuffles towards you on her one good leg.  \"`^Good day to you, %s - my name is Mike, and what may I do for you today?`0\" You reason that \"Mike\" must be short for \"Michelle\" or something - or perhaps this whole franchise thing is going a bit too far.", translate_inline($session['user']['sex'] ? 'madam' : 'sir', 'stables')));
            $args['schemas']['desc'] = "module-racezombie";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racezombie";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racezombie";
            $args['nosuchbeast'] = "`0\"`^I'm sorry, I've never heard of such a thing,`0\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racezombie";
            $args['toolittle'] = "`0Mike looks over the handful of currency you offered.  \"`^Hmm.  Well, you see, the price for this %s was actually `0%s `^Requisition tokens and `%%s`^ cigarettes.  My apologies for any misunderstandings.`0\"";
            $args['schemas']['toolittle'] = "module-racezombie";
            $args['replacemount'] = "`0You sadly watch Mike lead your %s`0 away, along with your cigarettes.  However, when she returns, she brings with her a nice new `0%s`0 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racezombie";
            $args['newmount'] = "`0You hand over your currency.  Within moments, you become the proud recipient of a lovely new `0%s`0!";
            $args['schemas']['newmount'] = "module-racezombie";
            $args['confirmsale'] = "`n`n`0Mike eyes your mount up and down, checking it over carefully.  \"`^My, this is indeed a fine specimen.  Are you quite sure you wish to part with it?`0\"";
            $args['schemas']['confirmsale'] = "module-racezombie";
            $args['mountsold'] = "`0With but a single tear, you hand your %s`0 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racezombie";
            $args['offer'] = "`n`n`0Mike offers you `0%s`0 Requisition and `%%s`0 Cigarettes for %s`0.";
            $args['schemas']['offer'] = "module-racezombie";
            break;
    }
    return $args;
}
function tutor_dohook($hookname, $args)
{
    global $session;
    $age = $session['user']['age'];
    $ignore = get_module_pref("user_ignore");
    // If this person is already well out of tutoring range, just return
    if ($session['user']['dragonkills'] || $ignore || $age >= 11) {
        return $args;
    }
    switch ($hookname) {
        case "newday":
            set_module_pref("seenforest", 0);
            break;
        case "village":
            if ($age < 11) {
                tlschema($args['schemas']['gatenav']);
                addnav($args["gatenav"]);
                tlschema();
                addnav("*?`\$Help Me, I'm Lost!", "runmodule.php?module=tutor&op=helpfiles");
                unblocknav("runmodule.php?module=tutor&op=helpfiles");
            }
            break;
        case "battle":
            $badguy = $args;
            $tutormsg = "";
            if ($badguy['creaturehealth'] > 0 && $badguy['creaturelevel'] > $session['user']['level'] && $badguy['type'] == 'forest') {
                $tutormsg = translate_inline("`#Eibwen`0 looks agitated!  \"`\$Look out!`3 This creature looks like it is a higher level than you!  You might want to `^run away`3! You might not be successful, but keep trying and hope you get away before you're turned into forest fertilizer!`0\"`n");
            }
            if ($tutormsg) {
                tutor_talk("%s", $tutormsg);
            }
        case "everyheader":
            if (!$session['user']['loggedin']) {
                break;
            }
            $adef = $session['user']['armordef'];
            $wdam = $session['user']['weapondmg'];
            $gold = $session['user']['gold'];
            $goldinbank = $session['user']['goldinbank'];
            $goldtotal = $gold + $goldinbank;
            if (!isset($args['script']) || !$args['script']) {
                break;
            }
            switch ($args['script']) {
                case "newday":
                    if ($age > 1) {
                        break;
                    }
                    if ((!$session['user']['race'] || $session['user']['race'] == "Horrible Gelatinous Blob") && httpget("setrace") == "") {
                        if (is_module_active("racetroll")) {
                            $troll = translate_inline("Troll");
                        }
                        if (is_module_active("racedwarf")) {
                            $dwarf = translate_inline("Dwarf");
                        }
                        if (is_module_active("racehuman")) {
                            $human = translate_inline("Human");
                        }
                        if (is_module_active("raceelf")) {
                            $elf = translate_inline("Elf");
                        }
                        if ($troll || $dwarf || $human || $elf) {
                            $tutormsg = translate_inline("`0A tiny `#aqua-colored imp`0 flies up and buzzes beside your head for a moment.`n`n\"`&Wha-wha-wha...`0\" you stammer.`n`n\"`#Oh, hush up you.  You're supposed to listen to me, not talk!`0\" the imp squeaks.`n`n\"`#Now, I'm here to help you get familiar with these realms, so you better listen close to what I've got to say.`0\"`n`nYou nod dumbly for a moment then give this being your attention.`n`n\"`#Now,`0\" it says,\" `#you're only young, and maybe you don't remember where you grew up. If you've never been in here before, choosing one of these is probably easiest!`0\" He jumps about excitedly, waiting for your decision, and waves a list of suggestions in front of you.`n");
                            tutor_talk("%s`c`b`n`b`c", $tutormsg);
                        }
                    } elseif ($session['user']['specialty'] == "" && !httpget("setrace")) {
                        if (is_module_active("specialtylaser")) {
                            $ls = translate_inline("Head-Mounted Laser");
                        }
                        if (is_module_active("specialtytelepathy")) {
                            $tp = translate_inline("Telepathy");
                        }
                        if (is_module_active("specialtytelekinesis")) {
                            $tk = translate_inline("Telekinesis");
                        }
                        if (is_module_active("specialtyspacialawareness")) {
                            $sa = translate_inline("Spacial Awareness");
                        }
                        if ($ls || $tp || $tk || $sa) {
                            $tutormsg = translate_inline("`0The bug flutters about you, no matter how much you try to swat him from view. A moment later his piercing chatter returns.`n`n\"`#Oh, look, more decisions! I suppose you want some career counseling now?`0\"`n`nHe buzzes about, before imparting, \"`#Why not try one of these first, so you won't trip over your own shoelaces?`0\"`n`nHe holds a small scroll before you, embossed with small script, and awaits your decision.`n");
                            tutor_talk("%s`c`b`b`c", $tutormsg);
                        }
                    }
                    break;
                case "village":
                    $tutormsg = "";
                    if ($wdam == 0 && $gold >= 50) {
                        $tutormsg = translate_inline("\"`3You really should get a weapon, to make you stronger. You can buy one at the `^weapon shop`3. I'll meet you there!`0\"`n");
                    } elseif ($wdam == 0 && $goldtotal >= 50) {
                        $tutormsg = translate_inline("\"`3We need to withdraw some gold from `^the bank`3 to buy a weapon, Come with me!`0\"`n");
                    } elseif ($adef == 0 && $gold >= 60) {
                        $tutormsg = translate_inline("\"`3You won't be very safe without any armor! The `^armor shop`3 has a nice selection. Let's go!`0\"`n");
                    } elseif ($adef == 0 && $goldtotal >= 60) {
                        $tutormsg = translate_inline("\"`3We need to withdraw some gold from `^the bank`3, so we can buy some armor!`0\"`n");
                    } elseif (!$session['user']['experience']) {
                        $tutormsg = translate_inline("\"`3The `^forest`3 is worth visiting, too. That's where you gain experience and gold!`0\"`n");
                    } elseif ($session['user']['experience'] > 100 && $session['user']['level'] == 1 && !$session['user']['seenmaster']) {
                        $tutormsg = translate_inline("\"`3Holy smokes!  You're advancing so fast!  You have enough experience to reach level 2.  You should find the `^warrior training`3, and challenge your master!  After you've done that, you'll find you're much more powerful.`0\"`n");
                    }
                    if ($tutormsg) {
                        tutor_talk("%s", $tutormsg);
                    }
                    break;
                case "forest":
                    $tutormsg = "";
                    if ($goldtotal >= 50 && $wdam == 0) {
                        $tutormsg = translate_inline("\"`3Hey, you have enough gold to buy a weapon. It might be a good idea to visit `^the town`3 now and go shopping!`0\"`n");
                    } elseif ($goldtotal >= 60 && $adef == 0) {
                        $tutormsg = translate_inline("\"`3Hey, you have enough gold to buy some armor. It might be a good idea to visit `^the town`3 now and go shopping!`0\"`n");
                    } elseif (!$session['user']['experience'] && !get_module_pref("seenforest")) {
                        $tutormsg = translate_inline("`#Eibwen`& flies in loops around your head. \"`3Not much to say here.  Fight monsters, gain gold, heal when you need to.  Most of all, have fun!`0\"`n`nHe flies off back toward the village.`n`nOver his shoulder, he calls out, \"`3Before I go, please read the FAQs... and the Message of the Day is something you should check each time you log in. Don't be afraid to explore, but don't be afraid to run away either! And just remember, dying is part of life!`0\"`n");
                        set_module_pref("seenforest", 1);
                    }
                    if ($tutormsg) {
                        tutor_talk("%s", $tutormsg);
                    }
                    break;
            }
            break;
    }
    return $args;
}
function racehuman_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "NewHome";
    $race = "Human";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            if ($args['setting'] == "villagename" && $args['module'] == "racehuman") {
                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":
            output("`0You boggle at the question.<a href='newday.php?setrace={$race}{$resline}'>\"Of course I'm human!  What sort of mad place is this?!\"</a>`n`n", true);
            addnav("`&Human`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("`0The hairy man squints at you.  \"`6Sorry, with these Flash grenades going off all the time, you know how it is...`0\"  He reaches underneath his desk, pulls out a pair of glasses and puts them on.  His eyes are magnified four times over.  \"`6Ah, I see now.  Yes, you look human to me.`0\"  He looks down and writes in a little ledger.  \"`6Haitch, you, em, ee, en.  Human.`0\"`n`nYou frown at the Coke-bottle lenses.  \"`#How, exactly, were you doing the crossword?`0\"`n`nThe hairy man leans forward, cups his ear.  \"`6What?`0\"`n`n\"`#Never mind.`0\"`n`n\"`6Not quite blind, no.`0\"`n`nYou shake your head.  \"`#Forget it.`0\"`n`nThe hairy man looks puzzled.  \"`6Regret what?`0\"`n`nYou open your mouth to say something, then close it again and shake your head.`n`nThe gatekeeper shrugs.  \"`6Go on, then.  In you go, and choose your implant.`0\"`n`n\"`#That's it?  \"Are you human,\" that's the whole form?`0\"`n`nThe gatekeeper smiles.  \"`6Paperwork reduction act.`0\"`n`nYou shrug, and walk in to the Outpost.  At least the weather is nice.");
                set_module_pref("homecity", $city, "cities");
                if ($session['user']['age'] == 0) {
                    $session['user']['location'] = $city;
                }
            }
            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":
            racehuman_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of NewHome.  Though called a city, this stronghold of humans is little more than a fortified village.  The city's low defensive walls are surrounded by rolling plains which gradually turn into dense, moist jungle in one direction, and a stretch of beach and ocean in the other.`n`n");
                $args['schemas']['text'] = "module-racehuman";
                $args['clock'] = "`0A nearby loudspeaker announces that the time is currently `&%s`0.`n`n";
                $args['schemas']['clock'] = "module-racehuman";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`0A smaller contraption next to it reads `&%s`0, `&%s %s %s`0.`n`n";
                    $args['schemas']['calendar'] = "module-racehuman";
                }
                $args['title'] = array("%s, City of Humans", $city);
                $args['schemas']['title'] = "module-racehuman";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racehuman";
                $args['talk'] = "`n`&Nearby some contestants talk:`n";
                $args['schemas']['talk'] = "module-racehuman";
                $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 stare openly at the various different types of horrendous-looking creatures standing around you.  But that's okay - they can see that you're new, and they don't mind the staring.";
                } else {
                    $args['newest'] = "`n`0Wandering the outpost, gawping at the strange people around, is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racehuman";
                $args['section'] = "village-{$race}";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Northern Quadrant";
                $args['marketnav'] = "Eastern Quadrant";
                $args['tavernnav'] = "Western Quadrant";
                $args['schemas']['gatenav'] = "module-racehuman";
                unblocknav("stables.php");
            }
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racehuman";
            $args['desc'] = array("`6Just next door to the Clan Halls, a rather strange building has been erected, with a very strange smell wafting from within.  An unusual blend of manure and oil.`n`nInside, you are greeted by an array of unusual-looking beasts and vehicles.`n`n", array("As you venture further into the building, Mike smiles broadly, \"`^Ahh! how can I help you today, %s?`6\" he asks in a booming voice.", translate_inline($session['user']['sex'] ? 'lass' : 'lad', 'stables')));
            $args['schemas']['desc'] = "module-racehuman";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racehuman";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racehuman";
            $args['nosuchbeast'] = "`6\"`^Never heard of it,`6\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racehuman";
            $args['toolittle'] = "`6Mike looks over the handful of currency you offered.  \"`^Obviously you misheard my price.  This %s will cost you `&%s `^Requisition  and `%%s`^ Cigarettes.  No more, no less.`6\"";
            $args['schemas']['toolittle'] = "module-racehuman";
            $args['replacemount'] = "`6You sadly watch Mike lead your %s`6 away, along with your cigarettes.  However, when he returns, he brings with him a nice new `&%s`6 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racehuman";
            $args['newmount'] = "`6You hand over your currency.  Within moments, you become the proud recipient of a lovely new `&%s`6!";
            $args['schemas']['newmount'] = "module-racehuman";
            $args['confirmsale'] = "`n`n`6Mike eyes your mount up and down, checking it over carefully.  \"`^It's a nice one, to be sure.  Are you quite sure you want to part with it?`6\"";
            $args['schemas']['confirmsale'] = "module-racehuman";
            $args['mountsold'] = "`6With but a single tear, you hand your %s`6 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racehuman";
            $args['offer'] = "`n`n`6Mike offers you `&%s`6 Requisition and `%%s`6 Cigarettes for %s`6.";
            $args['schemas']['offer'] = "module-racehuman";
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
    }
    return $args;
}
function racemutant_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "Pleasantville";
    $race = "Mutant";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racemutant") {
                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'] < 5) {
                break;
            }
            output("`0You show the gatekeeper a sad smile.  <a href='newday.php?setrace={$race}{$resline}'>\"That's a very insensitive question.\"</a>`n`n", true);
            addnav("`&Mutant`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("`0The gatekeeper puts on his glasses.  \"`6Oh,`0\" he says, quietly.`n`n\"`#Yes,`0\" you reply.  \"`#Oh.`0\"`n`nYou stare at each other for a moment.  The colour slowly drains from the gatekeeper's face.`n`n\"`6Well,`0\" says the gatekeeper, to break the silence.  \"`6Let's get you signed in, shall we?`0\"  He swallows uncomfortably, and takes out his ledger.  \"`6Em, you, tee, you, enn, tee.  Mu-hluck!`0\"  He swallows again, wiping his mouth on the back of his sleeve.  \"`6Mutant.  Sorry.  Have you been like this all your li... blugh.`0\"  A little blob of vomit plops onto his ledger.  He takes a deep breath.  \"`6Have you been like this all your life?`0\"`n`n\"`#Yes,`0\" you reply.  \"`#Since my dear mother first excreted me from her poor, wretched womb, looked down, screamed \"Dear God what IS that `iTHING`i\" and died immediately from a combination of horror, shame and embarrassment, I have been the hideous abomination that you see before you now.  And you needn't apologise, I'm used to it.`0\"  You shake your head sadly.  \"`#So, so very used to it.`0\"`n`n\"`6Well, that's... hruuuu`iuuuuuuuuu`iuuuurgh!  Oh, sweet Jesus Mary and Joseph!`0\"`n`n\"`#That's okay, let it all out.  Isn't it strange how there's always carrots in there?`0\" you ask.  \"`#You don't have to look up if you don't want to.  I know that the sight of your own expulsions are preferable to my horrendous visage.`0\"`n`n\"`6Blarghle,`0\" says the gatekeeper.`n`n\"`#Like I say, I'm used to it.`0\"  You turn and head toward the gate, leaving a trail of slime behind you.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "stamina-newday":
        case "alternativeresurrect":
            if ($session['user']['race'] == $race) {
                racemutant_checkcity();
                //Stamina Buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('mutant2', array("name" => "Mutant Bonus: Combat Skills", "class" => "Combat", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant4', array("name" => "Mutant Bonus: Scavenging Proficiency", "action" => "Scavenging for Scrap", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant5', array("name" => "Mutant Bonus: Metalwork Skills", "action" => "Metalworking", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant6', array("name" => "Mutant Bonus: Soldering Skills", "action" => "Soldering", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant8', array("name" => "Mutant Bonus: Carcass Cleaning Skills", "action" => "Cleaning the Carcass", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant0', array("name" => "Mutant Penalty: Learning Difficulties", "class" => "Global", "costmod" => 1, "expmod" => 0.5, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('mutant1', array("name" => "Mutant Penalty: Hunting Inexperience", "class" => "Hunting", "costmod" => 1.1, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "Mutant Bonus: Insults Proficiency", "class" => "Insults", "costmod" => 0.5, "expmod" => 1.1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //Combat Buffs
                apply_buff("racialbenefit1", array("name" => "`7Mutant Bonus: Leathery Hide`0", "defmod" => "1.1", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racemutant"));
                apply_buff("racialbenefit2", array("name" => "`7Mutant Bonus: Combat Appendages`0", "atkmod" => "1.1", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racemutant"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racemutant_checkcity();
                $args['creaturegold'] = round($args['creaturegold'] * 0.8, 0);
                $args['creatureexp'] = round($args['creatureexp'] * 0.8, 0);
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race && $session['user']['alive'] == false) {
                $args['creatureexp'] = round($args['creatureexp'] * 0.8);
            }
            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":
            racemutant_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of Pleasantville.  It's all very clean, but there are no reflective surfaces - every window has either been boarded up or slavered with a thick coating of slime to prevent reflections.`n`nLooking around at the state of some of your fellow contestants, you think you can see why.`n`n");
                $args['schemas']['text'] = "module-racemutant";
                $args['clock'] = "`0A clock in the village square reads `&%s`0.`n`n";
                $args['schemas']['clock'] = "module-racemutant";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`0A smaller dial beneath reads `&%s`0, `&%s %s %s`0.`n`n";
                    $args['schemas']['calendar'] = "module-racemutant";
                }
                $args['title'] = array("%s, Home of the Mutants", $city);
                $args['schemas']['title'] = "module-racemutant";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racemutant";
                $args['talk'] = "`&Nearby some mutants drone endlessly about their problems:`n";
                $args['schemas']['talk'] = "module-racemutant";
                $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`0You wander around the village, sliding your noodly appendages over every surface, examining it all in great detail.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, touching everything with hideously freaky noodles, is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racemutant";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racemutant";
                $args['gatenav'] = "Outpost Gates";
                $args['fightnav'] = "Oppression Street";
                $args['marketnav'] = "Capitalism Avenue";
                $args['tavernnav'] = "Despair Lane";
                $args['schemas']['gatenav'] = "module-racemutant";
                unblocknav("stables.php");
            }
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racemutant";
            $args['desc'] = array("`6Just next door to the Clan Halls, a scruffy-looking warehouse has been erected.  You head inside.`n`n", array("As you venture inside the building, you notice a young man tending to a nearby... something.  Something bloody indescribable.  \"`#Hello?`6\" you call.  The young man turns around.  \"`#Agh,`6\" you say, quietly.  Then, you smile sheepishly.  \"`#I mean... hi!`6\"`n`n\"`^Don't worry, I'm used to it.  The name's Mike, and what can I do for you today, my good %s?`6\" You try your hardest not to stare, because you know that if you stare, you'll end up counting under your breath to see how many eyes he has, and that would be rude.", translate_inline($session['user']['sex'] ? 'madam' : 'sir', 'stables')));
            $args['schemas']['desc'] = "module-racemutant";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racemutant";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racemutant";
            $args['nosuchbeast'] = "`6\"`^I'm sorry, I've never heard of such a thing,`6\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racemutant";
            $args['toolittle'] = "`6Mike looks over the handful of currency you offered.  \"`^Hmm.  Well, you see, the price for this %s was actually `&%s `^Requisition tokens and `%%s`^ cigarettes.  My apologies for any misunderstandings.`6\"";
            $args['schemas']['toolittle'] = "module-racemutant";
            $args['replacemount'] = "`6You sadly watch Mike lead your %s`6 away, along with your cigarettes.  However, when he returns, he brings with him a nice new `&%s`6 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racemutant";
            $args['newmount'] = "`6You hand over your currency.  Within moments, you become the proud recipient of a lovely new `&%s`6!";
            $args['schemas']['newmount'] = "module-racemutant";
            $args['confirmsale'] = "`n`n`6Mike eyes your mount up and down, checking it over carefully.  Probably seeing it in ways that you can only imagine.  \"`^My, this is indeed a fine specimen.  Are you quite sure you wish to part with it?`6\"";
            $args['schemas']['confirmsale'] = "module-racemutant";
            $args['mountsold'] = "`6With but a single tear, you hand your %s`6 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racemutant";
            $args['offer'] = "`n`n`6Mike offers you `&%s`6 Requisition and `%%s`6 Cigarettes for %s`6.";
            $args['schemas']['offer'] = "module-racemutant";
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
    }
    return $args;
}
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 racemidget_dohook($hookname, $args)
{
    global $session, $resline;
    $city = "Squat Hole";
    $race = "Midget";
    static $damagestart = 0;
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "changesetting":
            // Ignore anything other than villagename setting changes
            if ($args['setting'] == "villagename" && $args['module'] == "racemidget") {
                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'] < 3) {
                break;
            }
            output("`0You stand on tiptoes, thrust a tiny upraised middle finger at the gatekeeper's face, and say <a href='newday.php?setrace={$race}{$resline}'>\"Does it fookin' LOOK like I'm a yooman, dick'ead?\"</a>`n`n", true);
            addnav("`&Midget`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                set_module_pref("midgetrage", 0);
                output("`0\"`6All right, all right, you don't have to shout,`0\" says the gatekeeper.  He pulls out his ledger.  \"`6Right, then.  Em, eye, jay, eye, tee.  Midget.`0\"`n`n\"`#That's right,`0\" you say, hoping that he doesn't cotton on to the fact that you can't read or write.  \"`#And don't forget it, innit?`0\"`n`n\"`6Have you been like this all your life?`0\"`n`n\"`#What's it to you, pal?!`0\"`n`nThe gatekeeper sighs.  \"`6Nothing, just making conversation.  Off you go, then.`0\"`n`nIncensed, you scream up at the gatekeeper.  \"`#Don't tell ME to f**k off!  I'll go where I fookin' well like!`0\"`n`n\"`6If I remember rightly,`0\" says the gatekeeper, \"`6you came here so that you could enter the outpost, right?  Well, there's nothing stopping you now.`0\"`n`n\"`#Don'tchu fookin' get clever with me, mate!  I'll fookin' deck yer!  Come on then, right here, right now!  I'll fookin' FLOOR yer, dick'ead!`0\"`n`nThe gatekeeper sighs again, steps out through a door in the back of his hut, walks around to the front and kicks you, very hard, in the crotch.  You sail over the wall like a football.`n`n\"`6Have a pleasant stay,`0\" calls the gatekeeper.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
        case "stamina-newday":
        case "alternativeresurrect":
            if ($session['user']['race'] == $race) {
                racemidget_checkcity();
                set_module_pref("midgetrage", 0);
                //Stamina buffs
                require_once "modules/staminasystem/lib/lib.php";
                apply_stamina_buff('midget2', array("name" => "Midget Bonus: Combat Skills", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget1', array("name" => "Midget Bonus: Hunting Skills", "class" => "Hunting", "costmod" => 0.5, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget4', array("name" => "Midget Bonus: Scavenging Proficiency", "action" => "Scavenging for Scrap", "costmod" => 0.5, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget8', array("name" => "Midget Bonus: Carcass Cleaning Skills", "action" => "Cleaning the Carcass", "costmod" => 0.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget0', array("name" => "Midget Penalty: Stupidity", "class" => "Global", "costmod" => 1, "expmod" => 0.25, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget3', array("name" => "Midget Penalty: Stubby Little Legs", "class" => "Travelling", "costmod" => 2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget5', array("name" => "Midget Penalty: Metalwork Incompetence", "action" => "Metalworking", "costmod" => 1.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget6', array("name" => "Midget Penalty: Soldering Incompetence", "action" => "Soldering", "costmod" => 1.8, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget7', array("name" => "Midget Penalty: Programming Ultra-Incompetence", "action" => "Programming", "costmod" => 2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('midget9', array("name" => "Midget Penalty: Cooking Ineptitude", "action" => "Cooking", "costmod" => 1.2, "expmod" => 1, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceclassy', array("name" => "Midget Penalty: Classy Insults Super-Duper Incompetence", "action" => "Insults - Classy", "costmod" => 5, "expmod" => 0.25, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('raceconfusing', array("name" => "Midget Penalty: Confusing Insults Confusion", "action" => "Insults - Confusing", "costmod" => 2, "expmod" => 0.25, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                apply_stamina_buff('racecoarse', array("name" => "Midget Bonus: Coarse Insults Proficiency", "action" => "Insults - Coarse", "costmod" => 0.5, "expmod" => 0.25, "rounds" => -1, "roundmsg" => "", "wearoffmsg" => ""));
                //Combat Buffs
                apply_buff("racialbenefit1", array("name" => "`7Midget Bonus: Freakish Strength`0", "atkmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racemidget"));
                apply_buff("racialbenefit2", array("name" => "`7Midget Bonus: Easily Missed`0", "defmod" => "1.2", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racemidget"));
            }
            break;
        case "creatureencounter":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racemidget_checkcity();
                $args['creaturegold'] = round($args['creaturegold'] * 1.2, 0);
            }
            break;
        case "battle-victory":
            if ($session['user']['race'] == $race) {
                //get those folks who haven't manually chosen a race
                racemidget_checkcity();
                if (!$session['user']['alive']) {
                    debug($args['creatureexp']);
                    $args['creatureexp'] = round($args['creatureexp'] / 2);
                    debug($args['creatureexp']);
                }
            }
            break;
        case "startofround":
            if ($session['user']['race'] == $race) {
                $damagestart = $session['user']['hitpoints'] / $session['user']['maxhitpoints'] * 100;
            }
            break;
        case "endofround":
            if ($session['user']['race'] == $race) {
                $damage = $damagestart - $session['user']['hitpoints'] / $session['user']['maxhitpoints'] * 100;
                if ($damage > 0) {
                    debug("Midget Rage increment: " . $damage);
                    increment_module_pref("midgetrage", $damage);
                }
            }
            break;
        case "fightnav-specialties":
            if ($session['user']['race'] == $race) {
                addnav("Midget Rage");
                $rage = round(get_module_pref("midgetrage"), 2);
                if ($rage > 100) {
                    $script = $args['script'];
                    addnav("Invoke Midget Rage!", $script . "op=fight&skill=midgetrage");
                } else {
                    $notrage = 100 - $rage;
                    addnav("{$rage}%<br /><table style='border: solid 1px #000000' bgcolor='#cc0000' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='{$rage}' bgcolor='#ffff00'></td><td width='{$notrage}'></td></tr></table>", "", true);
                }
            }
            break;
        case "apply-specialties":
            if ($session['user']['race'] == $race) {
                $skill = httpget('skill');
                if ($skill == "midgetrage") {
                    apply_buff("midgetrage", array("startmsg" => "`4Bug-eyed, screaming and foaming at the mouth like a Daily Mail columnist talking about Political Correctness Gone Mad, you fly into a terrifying Midget Rage!", "name" => "`^Midget Rage`0", "rounds" => 5, "atkmod" => 2, "wearoff" => "`4You feel yourself coming down from your Midget Rage.`0", "schema" => "module-racemidget"));
                    set_module_pref("midgetrage", 0);
                }
            }
            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":
            racemidget_checkcity();
            if ($session['user']['location'] == $city) {
                $args['text'] = array("`0You are standing in the heart of Squat Hole.  Man, this place has gone downhill.`n`nRusted-out cars compete for space with empty cider cans, and there's a general atmosphere of meanness about.  Piles of dead skunks and excrement lie steaming and glistening by the side of the road.  All the windows are broken, and the whole place could do with a good scrubbing, but there's no chance for investment around here - there is truth in the rumour that copper wire was invented by two Midgets fighting over a penny.`n`n");
                $args['schemas']['text'] = "module-racemidget";
                $args['clock'] = "`0From the strength of the overpowering odour, you reason that it is approximately `&%s`0.`n`n";
                $args['schemas']['clock'] = "module-racemidget";
                if (is_module_active("calendar")) {
                    $args['calendar'] = "`0Written in blood on a nearby wall is `&%s`0, `&%s %s %s`0.`n`n";
                    $args['schemas']['calendar'] = "module-racemidget";
                }
                $args['title'] = array("%s, Home of the Midgets", $city);
                $args['schemas']['title'] = "module-racemidget";
                $args['sayline'] = "says";
                $args['schemas']['sayline'] = "module-racemidget";
                $args['talk'] = "`0Nearby some midgets stand around smoking hand-rolled cigarettes, using a decomposing chicken carcass as an ashtray.  Occasionally they shout at each other in irritating, squeaky voices:`n`n";
                $args['schemas']['talk'] = "module-racemidget";
                $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 just how ghastly everything is.";
                } else {
                    $args['newest'] = "`n`0Wandering the village, gawping at the state of disarray and looking as though someone had just dumped a boxfull of dead rats on their kitchen table is `&%s`0.";
                }
                $args['schemas']['newest'] = "module-racemidget";
                $args['section'] = "village-{$race}";
                $args['stablename'] = "Mike's Chop Shop";
                $args['schemas']['stablename'] = "module-racemidget";
                $args['gatenav'] = "Manky, Rusted Gates";
                $args['fightnav'] = "Brawlin' Street, like";
                $args['marketnav'] = "Shopliftin' Avenue, innit";
                $args['tavernnav'] = "All That Other S***e Road, ya dick'head";
                $args['schemas']['gatenav'] = "module-racemidget";
                unblocknav("stables.php");
            }
            break;
        case "stabletext":
            if ($session['user']['location'] != $city) {
                break;
            }
            $args['title'] = "Mike's Chop Shop";
            $args['schemas']['title'] = "module-racemidget";
            $args['desc'] = array("`6Just next door to the Clan Halls, a scruffy-looking warehouse has been erected.  The stench from the general area is indescribable - even worse than the pervasive funk that hangs over Squat Hole in general.  You hold your nose, and head inside.`n`n", array("As you venture further into the building, Mike scowls at you.  \"`^Wha' the f**k do `iyou`i want, %s?`6\" he asks in an irritating, squeaky voice.", translate_inline($session['user']['sex'] ? 'bitch' : 'dick\'ead', 'stables')));
            $args['schemas']['desc'] = "module-racemidget";
            $args['lad'] = "friend";
            $args['schemas']['lad'] = "module-racemidget";
            $args['lass'] = "friend";
            $args['schemas']['lass'] = "module-racemidget";
            $args['nosuchbeast'] = "`6\"`^Y'wot?  Wha' tha f**k's tha'?`6\" Mike says apologetically.";
            $args['schemas']['nosuchbeast'] = "module-racemidget";
            $args['toolittle'] = "`6Mike looks over the handful of currency you offered.  \"`^Yer fookin' numpty.  I said, fer this 'ere %s, yer lookin' at `&%s `^Req  and `%%s`^ fags.  Nah f**k off an' come back when ye've got it.`6\"";
            $args['schemas']['toolittle'] = "module-racemidget";
            $args['replacemount'] = "`6You sadly watch Mike lead your %s`6 away, along with your cigarettes.  However, when he returns, he brings with him a nice new `&%s`6 which makes you feel a little better.";
            $args['schemas']['replacemount'] = "module-racemidget";
            $args['newmount'] = "`6You hand over your currency, being careful not to touch the midget.  Within moments, you become the proud recipient of a lovely new `&%s`6!";
            $args['schemas']['newmount'] = "module-racemidget";
            $args['confirmsale'] = "`n`n`6Mike eyes your mount up and down, checking it over carefully.  \"`^Yeah, it's no' bad.  I guess.  Yer sure ye wanna flog it?`6\"";
            $args['schemas']['confirmsale'] = "module-racemidget";
            $args['mountsold'] = "`6With but a single tear, you hand your %s`6 over to Mike.  The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
            $args['schemas']['mountsold'] = "module-racemidget";
            $args['offer'] = "`n`n`6Mike offers you `&%s`6 Requisition and `%%s`6 Cigarettes for %s`6.";
            $args['schemas']['offer'] = "module-racemidget";
            break;
        case "stablelocs":
            tlschema("mounts");
            $args[$city] = sprintf_translate("The Village of %s", $city);
            tlschema();
            break;
    }
    return $args;
}