function dwshacks_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "dwellings-list-type":
            addnav("Show Only Types");
            addnav(array("%s", translate_inline(ucfirst(get_module_setting("dwnameplural", "dwshacks")))), "runmodule.php?module=dwellings&op=list&showonly=dwshacks&ref={$args['ref']}&sortby={$args['sortby']}&order={$args['order']}");
            break;
        case "dwellings-list-interact":
            if ($args['type'] == "dwshacks" && $args['status'] == 1 && get_module_setting("maxkeys") == 123456789) {
                addnav("", "runmodule.php?module=dwellings&op=enter&dwid={$args['dwid']}");
                $tress = translate_inline("Tresspass");
                rawoutput("<a href='runmodule.php?module=dwellings&op=enter&dwid={$args['dwid']}'>{$tress}</a>");
            }
            break;
        case "dwellings-manage":
            $dwid = $args['dwid'];
            if (get_module_setting("maxkeys") == 123456789 && $args['type'] == "dwshacks") {
                blocknav("runmodule.php?module=dwellings&op=keys&dwid={$dwid}");
            }
            break;
        case "dwellings":
            if (get_module_objpref("city", $args['cityid'], "showdwshacks")) {
                output("  Along the narrow pathway, precariously placed wood planks are nailed and leaning on each other in a fashion that only leaves you to assume they are supposed to be %s.`0", translate_inline(get_module_setting("dwnameplural")));
                if ($args['allowbuy'] == 1 && $session['user']['dragonkills'] >= get_module_setting("dkreq")) {
                    $cityid = $args['cityid'];
                    addnav("Options");
                    addnav(array("Establish a %s", translate_inline(ucfirst(get_module_setting("dwname", "dwshacks")))), "runmodule.php?module=dwellings&op=buy&type=dwshacks&subop=presetup&cityid={$cityid}");
                }
            }
            break;
    }
    return $args;
}
function iitems_hunterslodge_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "superuser":
            if ($session['user']['superuser'] & SU_EDIT_USERS) {
                addnav("Hunter's Lodge Purchase Log", "runmodule.php?module=iitems_hunterslodge&op=superuser");
            }
            break;
        case "village":
            tlschema($args['schemas']['fightnav']);
            addnav($args['fightnav']);
            tlschema();
            blocknav("lodge.php");
            addnav("L?The Hunter's Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
            break;
        case "newday":
            if ($session['user']['referer'] > 0) {
                $sql = "SELECT lastip, uniqueid FROM " . db_prefix("accounts") . " WHERE acctid={$session['user']['referer']}";
                $result = db_query($sql);
                $row = db_fetch_assoc($result);
                if ($row['lastip'] != $session['lastip'] && $row['uniqueid'] != $session['uniqueid']) {
                    $sql = "UPDATE " . db_prefix("accounts") . " SET donation=donation+1 WHERE acctid={$session['user']['referer']}";
                    $result = db_query($sql);
                }
            }
            break;
        case "items-returnlinks":
            $args['lodge'] = "runmodule.php?module=iitems_hunterslodge&op=start";
            break;
    }
    return $args;
}
function maikopan_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "village":
            if (get_module_pref("plotpoint3a", "watcher_quests") && !get_module_pref("plotpoint1") && $session['user']['location'] == "Kittania") {
                output("`0You hear quite a commotion coming from Maiko's cookery school.  A clattering of pots and pans, and a hoarse, screeching voice: \"`i`%Where is it?  WHERE IS IT?!`i`0\"`n`nYou might want to check that out.`n`n");
                addnav($args['fightnav']);
                tlschema();
                blocknav("runmodule.php?module=meatschool&op=start");
                addnav("Maiko's Cookery Academy", "runmodule.php?module=maikopan&step=1");
            } else {
                if (get_module_pref("plotpoint1") && !get_module_pref("plotpoint2")) {
                    blocknav("runmodule.php?module=meatschool&op=start");
                }
            }
            break;
        case "pub_kittania":
            if (get_module_pref("plotpoint1") && !get_module_pref("plotpoint2")) {
                redirect("runmodule.php?module=maikopan&step=2");
            }
            break;
    }
    return $args;
}
function newbfaq_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "commentary_talkform":
            if (!get_module_pref("seenrules")) {
                //debug($args);
                $args['blocktalkform'] = true;
                $args['message'] = "<a href='runmodule.php?module=newbfaq&op=start'>Click here to join in the chinwagging!</a>";
                addnav("", "runmodule.php?module=newbfaq&op=start");
            }
            break;
        case "village":
            if (get_module_pref("reminduser") == 1) {
                addnav("", "runmodule.php?module=newbfaq&op=rem");
                redirect("runmodule.php?module=newbfaq&op=rem");
            } else {
                addnav("Info");
                addnav("Frequently Asked Questions", "runmodule.php?module=newbfaq&op=faq");
                //addnav("The Rules","runmodule.php?module=newbfaq&op=rules");
                blocknav("petition.php?op=faq");
            }
            break;
        case "biostat":
            $id = $args['acctid'];
            $ret = rawurlencode($args['return_link']);
            if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
                addnav("Superuser");
                addnav("Send rules reminder", "runmodule.php?module=newbfaq&op=setrem&id={$id}&ret={$ret}");
            }
            //		break;
    }
    return $args;
}
function scrapbots_scavenge($reps = 1)
{
    global $session;
    //todo: hook in Stamina system, factor in remaining Stamina and experience
    //Get the player's Scrap
    $playerscrap = scrapbots_get_player_scrap();
    for ($i = 0; $i < $reps; $i++) {
        //Actually, let's just put in a random chance that the player will trip and impale themselves on a rusty bit of pointy scrap
        require_once "modules/staminasystem/lib/lib.php";
        $return = process_action("Scavenging for Scrap");
        if ($return['lvlinfo']['levelledup'] == true) {
            output("`n`c`b`0You gained a level in Scavenging for Scrap!  You are now level %s!  This action will cost fewer Stamina points now, so you can Scavenge more each day!`b`c`n", $return['lvlinfo']['newlvl']);
        }
        $stamina = get_stamina();
        $failchance = e_rand(1, 100);
        if ($stamina < 100) {
            output("`4You're getting tired.`0  Clambering around on a big pile of pointy, rusted scrap metal while you're half-asleep carries certain risks.`n");
        }
        if ($failchance > $stamina) {
            output("`\$This fact is driven home to you as you slip on an oily bit of sheet metal and fall head-first into the pile!`nYou `blose`b some hitpoints!`n`0");
            $hploss = e_rand(0, floor($session['user']['maxhitpoints'] / 2));
            $session['user']['hitpoints'] -= $hploss;
            if ($session['user']['hitpoints'] <= 0) {
                output("`\$You begin to feel a bit dizzy from the lack of blood.  Before you know it, you've collapsed, and the friendly local Robots have helped themselves to your cash and summoned the Retraining Personnel!`n");
                $session['user']['alive'] = false;
                $session['user']['gold'] = 0;
                addnav("Whoops.");
                addnav("Daily News", "news.php");
                blocknav("runmodule.php?module=scrapbots&scavenge=1");
                blocknav("runmodule.php?module=scrapbots&scavenge=10");
                blocknav("village.php");
                break;
            }
        }
        //dummy vals for now
        $normalchance = 100;
        $rarechance = 66;
        $veryrarechance = 99;
        $scrapnames = scrapbots_scrapnames();
        $scavengerarity = e_rand(1, 99);
        if ($scavengerarity <= $normalchance) {
            //award normal object
            $award = e_rand(0, 15);
            $playerscrap['data']['normalitems'][$award] += 1;
            output("`0You rummage through the scrap pile and come up with a `5%s`0.`n", $scrapnames['normalitems'][$award]);
        } elseif ($scavengerarity > $normalchance && $scavengerarity <= $rarechance) {
            $award = e_rand(0, 12);
            $playerscrap['data']['rareitems'][$award] += 1;
            output("`0You find a rare item!  A pretty nice `5%s`0.`n", $scrapnames['rareitems'][$award]);
        } elseif ($scavengerarity > $rarechance) {
            //award very rare item
            $award = e_rand(0, 3);
            $playerscrap['data']['veryrareitems'][$award] += 1;
            output("`0You find a very rare item!  This `5%s`0 looks like it's in good nick!`n", $scrapnames['veryrareitems'][$award]);
        }
    }
    set_module_pref("scrap", serialize($playerscrap), "scrapbots");
    return;
}
function dwellingscostsp_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "dwellings-buy-valuecheck":
            $typeid = get_module_setting("typeid", $args['type']);
            $paidsp = abs((int) httppost('paidsp'));
            if ($paidsp < 0) {
                $paidsp = 0;
            }
            $pointsavailable = $session['user']['donation'] - $session['user']['donationspent'];
            if ($pointsavailable < $paidsp) {
                $args['allowpay'] = 0;
                blocknav("runmodule.php?module=dwellings&op=build&type=" . $args['type'] . "&dwid=" . $args['dwid'] . "");
                output("`nYou do not have that many site points.");
            } elseif ($paidsp > get_module_objpref("dwellingtypes", $typeid, "spcost") - get_module_objpref("dwellings", $args['dwid'], "spspent")) {
                $args['allowpay'] = 0;
                blocknav("runmodule.php?module=dwellings&op=build&type=" . $args['type'] . "&dwid=" . $args['dwid'] . "");
                output("`nYou have tried to spend more site points than you need to.");
            }
            break;
        case "dwellings-buy-setup":
            $typeid = get_module_setting("typeid", $args['type']);
            $paidsp = abs((int) httppost('paidsp'));
            if ($paidsp < 0) {
                $paidsp = 0;
            }
            $spent = get_module_objpref("dwellings", $args['dwid'], "spspent") + $paidsp;
            set_module_objpref("dwellings", $args['dwid'], "spspent", $spent);
            $session['user']['donationspent'] += $paidsp;
            if ($spent != get_module_objpref("dwellingtypes", $typeid, "spcost")) {
                $args['finished'] = 0;
            }
            break;
        case "dwellings-pay-costs":
            $typeid = get_module_setting("typeid", $args['type']);
            $costsp = get_module_objpref("dwellingtypes", $typeid, "spcost") - get_module_objpref("dwellings", $args['dwid'], "spspent");
            if ($costsp) {
                output("`#%s Site Points`0`n", $costsp);
            }
            break;
        case "dwellings-pay-input":
            $typeid = get_module_setting("typeid", $args['type']);
            $costsp = get_module_objpref("dwellingtypes", $typeid, "spcost") - get_module_objpref("dwellings", $args['dwid'], "spspent");
            $sp = translate_inline("Site Points");
            if ($costsp) {
                rawoutput("{$sp}: <input id='input' name='paidsp' width=5><br>");
            }
            break;
    }
    return $args;
}
function golinda_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "pointsdesc":
            $args['count']++;
            $format = $args['format'];
            $str = translate("The ability to visit Golinda, the Lodge Healer costs %s points per day.  Golinda's rates are %s%% those of the normal healer.");
            $str = sprintf($str, get_module_setting("points"), get_module_setting("costpercent"));
            output($format, $str, true);
            break;
        case "newday":
            set_module_pref("paidtoday", 0);
            break;
        case "forest":
            if (get_module_pref("paidtoday")) {
                if (get_module_setting("blockhealer")) {
                    blocknav("healer.php", true);
                }
                addnav("Heal");
                addnav("Visit Golinda (already paid)", "runmodule.php?module=golinda&op=enter&from=forest");
            }
            break;
        case "lodge":
            // Reimburse people points spent for old version of Golinda
            $config = unserialize($session['user']['donationconfig']);
            if (!is_array($config)) {
                $config = array();
            }
            if (array_key_exists('healer', $config) && $config['healer']) {
                $points = 150 * round($config['healer'] / 10, 0);
                $points += 20 * round($config['healer'] % 10, 0);
                if ($points > $session['user']['donationspent']) {
                    $points = $session['user']['donationspent'];
                }
                $session['user']['donationspent'] -= $points;
                unset($config['healer']);
                if ($points) {
                    output("`^Due to changes in the way in which Golinda is handled, you have been refunded %s donation points!`n`n", $points);
                }
            }
            $session['user']['donationconfig'] = serialize($config);
            $cost = get_module_setting("points");
            if (get_module_pref("paidtoday")) {
                addnav("Visit Golinda (already paid)", "runmodule.php?module=golinda&op=enter");
            } else {
                addnav(array("Visit Golinda (%s points)", $cost), "runmodule.php?module=golinda&op=enter");
            }
            break;
    }
    return $args;
}
function uniqueforests_dohook($hookname, $args)
{
    global $session;
    require_once "modules/cityprefs/lib.php";
    $cityid = get_cityprefs_cityid("location", $session['user']['location']);
    switch ($hookname) {
        case "collect-events":
            if (get_module_objpref("city", $cityid, "use")) {
                foreach ($args as $index => $event) {
                    $event['rawchance'] = 0;
                    $events[$index] = $event;
                }
                $args = $events;
            }
            break;
        case "village":
            if (get_module_objpref("city", $cityid, "use")) {
                addnav($args['gatenav']);
                $name = get_module_objpref("city", $cityid, "name");
                blocknav("forest.php");
                addnav(array("%s", $name), "forest.php?location=uniqueforests");
            }
            break;
        case "header-forest":
            if (httpget('location') == "uniqueforests" || get_module_objpref("city", $cityid, "use")) {
                if (httpget('op') == "") {
                    global $block_new_output;
                    $block_new_output = true;
                }
                blocknav("runmodule.php", true);
                blocknav("healer.php", true);
                tlschema("module-uniqueforests");
            }
            break;
        case "footer-forest":
            if (httpget('location') == "uniqueforests" || get_module_objpref("city", $cityid, "use")) {
                $name = get_module_objpref("city", $cityid, "name");
                page_header(color_sanitize($name));
            }
            break;
        case "forest-desc":
            if (httpget('location') == "uniqueforests" || get_module_objpref("city", $cityid, "use")) {
                page_header(color_sanitize($name));
                global $block_new_output;
                $block_new_output = false;
                output(get_module_objpref("city", $cityid, "desc"));
                $block_new_output = true;
            }
            break;
    }
    return $args;
}
function buildinghitpoints_determine_navs($info)
{
    foreach ($info['data'] as $key => $vals) {
        if ($vals['hitpoints'] < $vals['maxhitpoints']) {
            blocknav($vals['blocknav']);
            addnav("Repairs");
            addnav(array("Repair %s", $vals['buildingname']), "runmodule.php?module=buildinghitpoints&op=repair&city=" . $info['cid'] . "&building=" . $key);
        } else {
            addnav("Reinforcements");
            addnav(array("Reinforce %s", $vals['buildingname']), "runmodule.php?module=buildinghitpoints&op=repair&city=" . $info['cid'] . "&building=" . $key);
        }
    }
}
function settings_dohook($hook, $args)
{
    switch ($hook) {
        case 'footer-news':
        case 'village':
            if ($hook == 'village') {
                addnav($args['othernav']);
            } else {
                addnav('News');
            }
            addnav('*?Settings*', 'runmodule.php?module=settings');
            blocknav('prefs.php');
            break;
        case 'footer-modules':
            if (httpget('cat') != '' && httpget('module') != '' || is_array(httppost('module'))) {
                $userprefs = db_prefix('module_userprefs');
                $modules = db_prefix('modules');
                $sql = db_query("SELECT DISTINCT m.modulename AS fallback,\n                    mu.modulename, mu.setting, m.formalname\n                    FROM {$modules} AS m\n                    LEFT JOIN {$userprefs} AS mu ON m.modulename = mu.modulename\n                    WHERE (setting LIKE 'user_%' OR m.infokeys LIKE '%|prefs|%')");
                $fill = [];
                $rewrite = json_decode(get_module_setting('rewrite'), true);
                while ($row = db_fetch_assoc($sql)) {
                    if ($row['setting'] != '' && strpos($row['setting'], 'user_') !== false) {
                        $structuredKey = "{$row['modulename']}__{$row['setting']}";
                        if ($rewrite[$structuredKey] != $row['formalname']) {
                            $fill[$structuredKey] = $rewrite[$structuredKey];
                        } else {
                            $fill[$structuredKey] = $row['formalname'];
                        }
                    } else {
                        $possibleKeys = get_module_info($row['fallback'])['prefs'];
                        foreach ($possibleKeys as $key => $val) {
                            if (strpos($key, 'user_') !== false) {
                                $structuredKey = "{$row['fallback']}__{$key}";
                                if ($rewrite[$structuredKey] != $row['formalname'] && $rewrite[$structuredKey] != '') {
                                    $fill[$structuredKey] = $rewrite[$structuredKey];
                                } else {
                                    $fill[$structuredKey] = $row['formalname'];
                                }
                            }
                        }
                    }
                }
                if ($fill != $rewrite) {
                    set_module_setting('rewrite', json_encode($fill));
                    output("`QUpdating the 'Settings' module rewrite conditions...");
                }
            }
            break;
    }
    return $args;
}
function mountrarity_dohook($hookname, $args)
{
    switch ($hookname) {
        case "newday-runonce":
            $sql = "SELECT mountid FROM " . db_prefix("mounts") . " WHERE mountactive=1";
            $result = db_query($sql);
            while ($row = db_fetch_assoc($result)) {
                $id = $row['mountid'];
                $rarity = get_module_objpref("mounts", $id, "rarity");
                if (e_rand(1, 100) > $rarity) {
                    set_module_objpref("mounts", $id, "unavailable", 1);
                } else {
                    // You need to reset the availability if it's not unavailable
                    // otherwise, it never becomes available again!
                    set_module_objpref("mounts", $id, "unavailable", 0);
                }
            }
            break;
        case "mountfeatures":
            $rarity = get_module_objpref("mounts", $args['id'], "rarity");
            $args['features']['Rarity'] = $rarity;
            break;
        case "stables-desc":
            if (get_module_setting("showout")) {
                $sql = "SELECT mountid, mountname FROM " . db_prefix("mounts") . " WHERE mountactive=1";
                $result = db_query($sql);
                output("`nA sign by the door proclaims that the following mounts are out of stock for today:");
                while ($row = db_fetch_assoc($result)) {
                    $out = get_module_objpref("mounts", $row['mountid'], "unavailable");
                    if ($out) {
                        output("`n%s", $row['mountname']);
                    }
                }
            } else {
                output("`nIf you don't see something you like today, perhaps you should check again tomorrow.");
            }
            break;
        case "stables-nav":
            $sql = "SELECT mountid FROM " . db_prefix("mounts") . " WHERE mountactive=1";
            $result = db_query($sql);
            while ($row = db_fetch_assoc($result)) {
                $id = $row['mountid'];
                $out = get_module_objpref("mounts", $id, "unavailable");
                if ($out) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
            }
            break;
    }
    return $args;
}
function mountaccessories_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "boughtmount":
        case "soldmount":
            $accs = get_player_acc_list();
            $hadaccessories = count($accs);
            if ($hadaccessories != 0) {
                output("Merick merrily strips off the accessories adorning your previous mount, and tosses them into a pile in the corner.  \"Ye'll nae be needin' these any more, I dare wager!\"`n`nYou contemplate asking him for the accessories back, or perhaps some money for them - but the slightly manic look in Merick's eye, and the sharpened pitchfork slung across his back, give you second thoughts.`n");
            }
            strip_accessories();
            addnav("Browse Mount Accessories", "runmodule.php?module=mountaccessories&op=browse");
            if ($session['user']['hashorse'] == 0) {
                blocknav("runmodule.php?module=mountaccessories&op=browse");
            }
            break;
        case "newday":
            apply_all_accessories();
            break;
        case "superuser":
            addnav("Edit Mount Accessories", "runmodule.php?module=mountaccessories&op=editdefaultaccessories");
            break;
        case "stables-nav":
            if ($session['user']['hashorse'] > 0) {
                addnav("Browse Mount Accessories", "runmodule.php?module=mountaccessories&op=browse");
            }
            break;
        case "charstats":
            if ($session['user']['hashorse'] > 0) {
                $rawaccs = get_player_acc_list();
                $display = "";
                $number = 0;
                foreach ($rawaccs as $acc => $details) {
                    $number++;
                    $display .= $details['displayname'];
                    $display .= "<br>";
                }
                $stat = "Mount Accessories";
                if ($number == 0) {
                    $display = "None";
                }
                setcharstat("Equipment Info", $stat, $display);
            }
            break;
    }
    return $args;
}
function basictraining_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "village":
            tlschema($args['schemas']['fightnav']);
            addnav($args['fightnav']);
            tlschema();
            addnav("Basic Training", "runmodule.php?module=basictraining&op=start");
            break;
        case "newday":
            if (!get_module_pref("visited")) {
                blocknav("village.php");
                blocknav("news.php");
                addnav("Get on with it", "runmodule.php?module=basictraining&op=start");
            }
    }
    return $args;
}
function additionalkeys_dohook($hookname, $args)
{
    $add = get_module_objpref("dwellings", $args['dwid'], "addkeys");
    $args['maxkeys'] += $add;
    global $session;
    switch ($hookname) {
        case "dwellings-manage":
            $type = $args['type'];
            $dwid = httpget('dwid');
            $typeid = get_module_setting("typeid", $type);
            addnav("Management");
            if (get_module_objpref("dwellingtypes", $typeid, "keys", "additionalkeys") != 0) {
                addnav("Keymaker", "runmodule.php?module=additionalkeys&op=buykeys&dwid={$dwid}&type={$type}");
            } else {
                blocknav("Keymaker", "runmodule.php?module=additionalkeys&op=buykeys&dwid={$dwid}&type={$type}");
            }
            break;
    }
    return $args;
}
function alternativeresurrect_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "ramiusfavors":
            blocknav("graveyard.php?op=resurrection");
            if ($session['user']['deathpower'] >= 100) {
                $deathoverlord = getsetting('deathoverlord', 'Ramius');
                addnav(array("%s Favors", sanitize($deathoverlord)));
                addnav("e?Resurrection (100 favor)", "runmodule.php?module=alternativeresurrect&op=resurrect");
            }
            break;
        case "shades":
            if ($session['user']['bufflist'] != "a:0:{}") {
                set_module_pref("bufflist", $session['user']['bufflist']);
            }
            break;
        case "newday":
            clear_module_pref("bufflist");
            break;
    }
    return $args;
}
            $dks = get_module_setting("dks");
            if (get_module_setting('flirttype')) {
                output("`n`n\"`&Just a friendly reminder. I can only help you if someone has proposed to you.  I recommend you visit the `\$Love `@Shack`&,`@\" `^%s`@ says to you helpfully.", $vicar);
            } elseif ($dks > $session['user']['dragonkills']) {
                output("`n`n\"`&You will not be able to propose to anyone until after you've reached `^%s dragonkill%s`&,`@\" `^%s`@ says to you helpfully.", $dks, translate_inline($dks > 1 ? "s" : ""), $vicar);
            }
        }
        break;
}
addnav("Navigation");
if (get_module_setting("location") == 1) {
    addnav("Return to the Gardens", "gardens.php");
} else {
    villagenav();
}
addnav("Actions");
addnav("Talk to Others", "runmodule.php?module=marriage&op=" . $op . "&op2=talk");
if (get_module_pref("supernomarry") == 1 || get_module_pref("user_wed") == 1) {
    addnav("Proposals Blocked", "runmodule.php?module=marriage&op=general&op2=nopropose");
    blocknav("runmodule.php?module=marriage&op=" . $op . "&op2=proposelist");
    blocknav("runmodule.php?module=marriage&op=" . $op . "&op2=propose");
}
if ($session['user']['marriedto'] == 0) {
    if (get_module_setting('flirttype') == 0 && $session['user']['dragonkills'] >= get_module_setting("dks")) {
        addnav("Propose", "runmodule.php?module=marriage&op=" . $op . "&op2=propose");
    }
    addnav("View Proposals", "runmodule.php?module=marriage&op=" . $op . "&op2=proposelist");
} else {
    addnav("Get a Divorce!", "runmodule.php?module=marriage&op=" . $op . "&op2=divorce");
}
page_footer();
function onslaught_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "village":
            $lv = onslaught_checkbreach();
            if ($lv >= 100) {
                redirect("runmodule.php?module=onslaught&op=start");
            } else {
                switch ($session['user']['location']) {
                    case "NewHome":
                        switch ($lv) {
                            case $lv < 10:
                                output("`0NewHome seems quiet at the moment - by which you mean there are no monsters actively banging on the gates.  The people manning the turret-mounted machine guns are chatting jovially with each other and sharing cigarettes.  For now at least, NewHome is safe.`n`n");
                                break;
                            case $lv < 25:
                                output("`0You glance upwards, towards the Monster Defence Turrets.  Their custodians are idly scanning the horizon.  From time to time, a gunner will nudge his or her fellow guard and point somewhere off in the middle distance.  NewHome remains well-guarded.`n`n");
                                break;
                            case $lv < 50:
                                output("`0The brave men and women atop the Monster Defence Turrets seem more alert than usual - they attentively focus on the surrounding Jungle, keeping watch over their territory.  Every now and then a gun will swivel suddenly and take aim, only for trigger fingers to become relaxed as a slavering beast is confirmed as nothing more than a shadow or a rustle in the breeze.`n`n");
                                break;
                            case $lv < 70:
                                output("`0Shots have recently been fired from the Monster Defence Turrets, and the smell of gunpowder hangs in the air.  The atmosphere is tense, guarded - the people of NewHome glance nervously at their Outpost's buttresses, wondering if people would think them paranoid if they just, y'know, shored them up a little bit.  A few new planks here and there.  Nothing to worry about.  Nothing at all.`n`n");
                                break;
                            case $lv < 80:
                                output("`0Bursts of machine gun fire can occasionally be heard from the Monster Defence Turrets.  Their custodians laugh and cheer as monsters fall - most of their days are slow, tedious, made up of perpetual smoking and the occasional unfortunately misdetected rabbit, and it's nice to get some action once in a while.  The people of NewHome go about their daily business, but their smiles seem strained, as if pasted on.  Some of them are casually inspecting the Outpost walls, taking measurements and carrying hammers.`n`n");
                                break;
                            case $lv < 90:
                                output("`0Things up in the Monster Defence Turrets are getting a little tense.  The joyful laughter from the gunners first slowed then stopped as their unexpected fun gave way to unexpected challenge.  The atmosphere is charged - shops are still open, but you have to knock to be let in.  Hands are gently gripping weapons.  Talk is subdued.  Cold sweat is trickling down spines.  A few citizens are making themselves busy hammering new planks to the Outpost walls to reinforce them.  NewHome is, it would seem, under threat.`n`n");
                                break;
                            case $lv < 95:
                                output("`0The guns in the Monster Defence Turrets haven't stopped firing for the past few minutes.  Conversation is subdued under frequent bursts of fire.  The gunners swear and call down for more ammunition, their hands sweaty, their faces red.  Outside the Outpost, bullets thump into earth and flesh, churning the grass into brown and red ruin.  Inside, citizens run back and forth between the Outpost walls, the turrets, the ammunition stores and the lumber piles, wondering why the hell they didn't reinforce the walls yesterday, or the week before, or the month before that.`n`neBoy's is doing a roaring trade in first aid kits and grenades, and Sheila is staying open for just as long as she can, serving Customers Who Aren't Looters At All, No Sir, with one hand on her favourite shotgun.  As for the other merchants, well...`n`nThe Museum is closed and locked up tight, as is the Hunter's Lodge, the Council Offices, Corporal Punishment's Basic Training, the Bank, the Comms Tent, the Strategy Hut, Mike's Chop Shop...  even greasy old Joe is standing outside his diner, sharpening a large meat cleaver.  NewHome is preparing for the worst.`n`n");
                                blocknav("lodge.php");
                                blocknav("runmodule.php?module=basictraining&op=start");
                                blocknav("runmodule.php?module=counciloffices&councilop=enter");
                                blocknav("runmodule.php?module=newhomemuseum&op=lobby");
                                blocknav("bank.php");
                                blocknav("gypsy.php");
                                blocknav("runmodule.php?module=staminafood&op=start&location=nh");
                                blocknav("runmodule.php?module=strategyhut");
                                blocknav("stables.php");
                                break;
                            case $lv < 100:
                                output("`0All conversation in the Outpost square has ceased.  Screaming and cursing can be heard from overhead, the custodians of the Monster Defence Turrets throwing out all the lead they can.  The angle of their fire has lowered over the past few minutes, and now powerful shoulders crunch at the Outpost's frail wooden walls, serrated claws splinter the defences.  The gunners' hands are numb, their ears ringing, their throats on fire, their barrels glowing red.`n`nAll you can smell is the gunner's smoke.  All you can hear is their fire.  You see people screaming, but you don't hear them.  You see the gunners frantically gesturing for more ammunition, but there isn't enough to go around.  Doors have gone missing from shops and turned up nailed to the Outpost walls.  Still some stragglers stumble into the Outpost from the melee outside, covered in blood and panting, showering all the thanks in the world on the gunners, their preferred deity, or both.`n`nMister Stern sits on the steps of his museum polishing his glasses, a shiny little six-shot revolver lying on the steps beside him.  He puts his glasses back on and picks the gun up, looking it over as though he's not sure what to do with it.  Corporal Punishment sits beside Mister Stern, one arm around the thin man, the other resting on his own pistol.  Over at Sheila's, Mike is hovering indecisively around the door with a single red rose in one hand and a machete in the other.`n`nHeads turn as a single mighty BANG pushes the Northernmost Outpost walls inwards, splintering the buttresses.  A long, black claw is quickly hacked off by a nearby citizen, and lies twitching on the ground.`n`nNewHome prepares for death or glory.`n`n");
                                break;
                        }
                        break;
                    case "Kittania":
                        break;
                    case "New Pittsburgh":
                        break;
                    case "Squat Hole":
                        break;
                    case "Pleasantville":
                        break;
                    case "Cyber City 404":
                        break;
                    case "AceHigh":
                        break;
                    case "Improbable Central":
                        break;
                }
            }
            break;
    }
    return $args;
}
function racegobot_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;
    if (is_module_active("racerobot")) {
        $city = "Cyber City 404";
    } else {
        $city = getsetting("villagename", LOCATION_FIELDS);
    }
    $race = "Gobot";
    switch ($hookname) {
        case "racenames":
            $args[$race] = $race;
            break;
        case "raceminedeath":
            if ($session['user']['race'] == $race) {
                $args['chance'] = get_module_setting("minedeathchance");
            }
            break;
        case "chooserace":
            if ($session['user']['dragonkills'] < 7) {
                break;
            }
            output("`0<a href='newday.php?setrace={$race}{$resline}'>You point downwards, directing the gatekeeper's attention to your knobbly tyres.</a>`n`n ", true);
            addnav("`&Gobot`0", "newday.php?setrace={$race}{$resline}");
            addnav("", "newday.php?setrace={$race}{$resline}");
            break;
        case "setrace":
            if ($session['user']['race'] == $race) {
                output("\"Aha,\" says the gatekeeper, taking out his ledger.  \"Say no more.  Gee...\"`nThe roar of your engine cuts him off, and he looks up.`nHe stares in annoyance at the rapidly-diffusing cloud of dust stretching from his hut to the outpost gate.`n\"Well, that's just bloody rude,\" mutters the gatekeeper.  \"I didn't even get to see its face when I mis-spelled its race.  Ah, well...  Can't insult 'em all, I guess.\"`nHe goes back to his crossword.");
                if (is_module_active("cities")) {
                    set_module_pref("homecity", $city, "cities");
                    if ($session['user']['age'] == 0) {
                        $session['user']['location'] = $city;
                    }
                }
            }
            break;
            //	case "newday-intercept":
            //		if ($session['user']['race']==$race){
            //			if(get_module_pref("reset")==1){
            //				global $session;
            //				$session['user']['specialty'] = "";
            //				set_module_pref("reset",0);
            //				output("`#SYSTEM MESSAGE - FIRMWARE RECONFIGURATION SUBROUTINE INITIALISED.  LIST OF IMPLANTS AVAILABLE FOR EMULATION DISPLAYED BELOW.  AWAITING INPUT.`n`nADVISORY MESSAGE - PROFICIENCY IN USE OF CURRENTLY-EMULATED IMPLANT WILL BE RETAINED.`n`n`0");
            //			}
            //		}
            //		break;
        //	case "newday-intercept":
        //		if ($session['user']['race']==$race){
        //			if(get_module_pref("reset")==1){
        //				global $session;
        //				$session['user']['specialty'] = "";
        //				set_module_pref("reset",0);
        //				output("`#SYSTEM MESSAGE - FIRMWARE RECONFIGURATION SUBROUTINE INITIALISED.  LIST OF IMPLANTS AVAILABLE FOR EMULATION DISPLAYED BELOW.  AWAITING INPUT.`n`nADVISORY MESSAGE - PROFICIENCY IN USE OF CURRENTLY-EMULATED IMPLANT WILL BE RETAINED.`n`n`0");
        //			}
        //		}
        //		break;
        case "newday":
            if ($session['user']['race'] == $race) {
                racegobot_checkcity();
                $bonus = get_module_setting("bonus");
                $one = translate_inline("an");
                $two = translate_inline("two");
                $three = translate_inline("three");
                $word = $bonus == 1 ? $one : $bonus == 2 ? $two : $three;
                $fight = translate_inline("fight");
                $fights = translate_inline("fights");
                $args['turnstoday'] .= ", Race (gobot): {$bonus}";
                $session['user']['turns'] += $bonus;
                output("`n`&Because you are `7untiring`&, you gain `^four extra`& jungle fights for today!`n`0");
                apply_buff("racialbenefit1", array("name" => "`7Ultra-Lightweight Frame`0", "defmod" => "0.5", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                apply_buff("racialbenefit2", array("name" => "`7Lightning Fists`0", "atkmod" => "1.3", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                apply_buff("racialbenefit3", array("name" => "`7Auto-Repair Subroutine`0", "regen" => "ceil(<level>/3);", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "effectmsg" => "`#SYSTEM MESSAGE: {damage} POINTS OF DAMAGE AUTO-REPAIRED`0", "schema" => "module-racegobot"));
                apply_buff("racialbenefit4", array("name" => "`7Cold`0", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "tempstat-charm" => "- floor(<charm>*0.8)", "schema" => "module-racegobot"));
                set_module_pref("reset", 1);
                set_module_pref("uses", 4);
                set_module_pref("status", 2);
                set_module_pref("overdrive", 1);
            }
            break;
        case "fightnav-specialties":
            if ($session['user']['race'] == $race) {
                $uses = get_module_pref("uses");
                $status = get_module_pref("status");
                $overdrive = get_module_pref("overdrive");
                $script = $args['script'];
                if ($uses >= 1) {
                    addnav(array("Power Configuration`0", $uses), "");
                    if ($status == 2) {
                        addnav(array("`4Overclock`7`0", 1), $script . "op=fight&skill={$spec}&l=1", true);
                        addnav(array("`4Underclock`7`0", 1), $script . "op=fight&skill={$spec}&l=2", true);
                    }
                    if ($status == 1) {
                        addnav(array("`4Reset (currently Underclocked)`7`0", 1), $script . "op=fight&skill={$spec}&l=3", true);
                    }
                    if ($status == 3) {
                        addnav(array("`4Reset (currently Overclocked)`7`0", 1), $script . "op=fight&skill={$spec}&l=3", true);
                    }
                }
                if ($overdrive == 1) {
                    addnav(array("`4Engage OverDrive`0", 1), $script . "op=fight&skill={$spec}&l=5", true);
                }
            }
            break;
        case "apply-specialties":
            if ($session['user']['race'] == $race) {
                $skill = httpget('skill');
                $l = httpget('l');
                $dec = 1;
                if ($skill == $spec) {
                    if (get_module_pref("uses") >= 1) {
                        switch ($l) {
                            case 1:
                                apply_buff("racialbenefit3", array("startmsg" => "`#SYSTEM MESSAGE:  OVERCLOCKING IN EFFECT.  REROUTING POWER.  AUTO-REPAIR SUBROUTINE DISABLED`0", "name" => "`7Auto-Repair Subroutine - Disabled`0", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                apply_buff("racialbenefit2", array("startmsg" => "`#SYSTEM MESSAGE:  OVERCLOCKING IN EFFECT.  REROUTING POWER.  COMBAT SUBROUTINE ACCELERATED`0", "name" => "`7Lightning Fists - Enhanced`0", "atkmod" => "1.6", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                set_module_pref("status", '3');
                                break;
                            case 2:
                                apply_buff("racialbenefit3", array("startmsg" => "`#SYSTEM MESSAGE:  UNDERCLOCKING IN EFFECT.  REROUTING POWER.  AUTO-REPAIR SUBROUTINE ACCELERATED`0", "name" => "`7Auto-Repair Subroutine - Enhanced`0", "effectmsg" => "`#SYSTEM MESSAGE: {damage} POINTS OF DAMAGE AUTO-REPAIRED`0", "regen" => "ceil(<level>);", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                apply_buff("racialbenefit2", array("startmsg" => "`#SYSTEM MESSAGE:  UNDERCLOCKING IN EFFECT.  REROUTING POWER.  COMBAT SUBROUTINE DECELERATED`0", "name" => "`7Lightning Fists - Decelerated`0", "atkmod" => "0.8", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                set_module_pref("status", '1');
                                break;
                            case 3:
                                apply_buff("racialbenefit3", array("startmsg" => "`#SYSTEM MESSAGE:  POWER REROUTING DISABLED.  SYSTEM RESTORED TO FACTORY SETTINGS`0", "name" => "`7Auto-Repair Subroutine`0", "effectmsg" => "`#SYSTEM MESSAGE: {damage} POINTS OF DAMAGE AUTO-REPAIRED`0", "regen" => "ceil(<level>/3);", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                apply_buff("racialbenefit2", array("name" => "`7Lightning Fists`0", "atkmod" => "1.3", "allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-racegobot"));
                                set_module_pref("status", '2');
                                break;
                            case 5:
                                apply_buff("overdrive", array("startmsg" => "`#SYSTEM MESSAGE:  BACKUP BATTERY ENGAGED.  OVERDRIVE ENABLED.`0", "name" => "`4OverDrive`0", "regen" => "<level>", "atkmod" => "1.5", "effectmsg" => "`#SYSTEM MESSAGE:  {damage} POINTS OF DAMAGE AUTO-REPAIRED BY OVERDRIVE SEQUENCE`0", "wearoff" => "`#SYSTEM MESSAGE:  BACKUP BATTERY DEPLETED.  OVERDRIVE DISABLED.", "rounds" => 5, "schema" => "module-racegobot"));
                                set_module_pref("overdrive", '0');
                        }
                    }
                }
            }
            break;
        case "validforestloc":
        case "validlocation":
            if (is_module_active("cities")) {
                $args[$city] = "village-{$race}";
            }
            break;
        case "count-travels":
            if ($session['user']['race'] == $race) {
                $args['available'] = $args['available'] + 15;
            }
            break;
        case "village":
            if ($session['user']['race'] == $race) {
                blocknav("runmodule.php?module=bloodbank");
            }
            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");
            }
            break;
    }
    return $args;
}
function mountprereq_dohook($hookname, $args)
{
    global $session;
    global $playermount;
    switch ($hookname) {
        case "boughtmount":
            $id = $session['user']['hashorse'];
            if ($id > 0) {
                $favorcost = get_module_objpref("mounts", $id, "favorcost");
                $donationcost = get_module_objpref("mounts", $id, "donationcost");
                $session['user']['deathpower'] -= $favorcost;
                $session['user']['donationspent'] += $donationcost;
                if ($favorcost != 0) {
                    $claim = $favorcost > 0 ? "claims" : "rewards";
                    $from = $favorcost > 0 ? "from" : "to";
                    if ($favorcost < 0) {
                        $favorcostpos = -$favorcost;
                    } else {
                        $favorcostpos = $favorcost;
                    }
                    output("`n`\$Ramius`6 makes a brief appearance, and %s`\$ %s favor`6 %s you.`n", $claim, $favorcostpos, $from);
                }
                if ($donationcost != 0) {
                    output("`n`6A `&representative`6 from the Lodge walks in from the door, and deducts`7 %s points`6 from your ledger.", $donationcost);
                }
            }
            break;
        case "dragonkill":
            set_module_pref('vieweddk', 0);
            break;
        case "stables-nav":
            $sql = "SELECT mountid FROM " . db_prefix("mounts") . " WHERE mountactive=1";
            $result = db_query($sql);
            while ($row = db_fetch_assoc($result)) {
                $id = $row['mountid'];
                if (is_module_active('alignment') && get_module_objpref("mounts", $id, "boolalign") != 0) {
                    $align = get_module_pref('alignment', 'alignment');
                    $alignlo = get_module_objpref("mounts", $id, "alignlo");
                    $alignhi = get_module_objpref("mounts", $id, "alignlo");
                    if (get_module_objpref("mounts", $id, "boolalign") == 1 && $align > $alignlo) {
                        blocknav("stables.php?op=examine&id={$id}");
                    } elseif (get_module_objpref("mounts", $id, "boolalign") == 2 && $align < $alignlo || $align > $alignhi) {
                        blocknav("stables.php?op=examine&id={$id}");
                    } elseif (get_module_objpref("mounts", $id, "boolalign") == 3 && $align < $alignhi) {
                        blocknav("stables.php?op=examine&id={$id}");
                    }
                }
                $favorreq = get_module_objpref("mounts", $id, "favorreq");
                $favorcost = get_module_objpref("mounts", $id, "favorcost");
                $favor = $session['user']['deathpower'];
                if ($favor < $favorreq || $favor < $favorcost) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
                $charm = $session['user']['charm'];
                $charmreq = get_module_objpref("mounts", $id, "charmreq");
                if ($charm < $charmreq) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
                $donationreq = get_module_objpref("mounts", $id, "donationreq");
                $donationcost = get_module_objpref("mounts", $id, "donationcost");
                $donationavail = $session['user']['donation'] - $session['user']['donationspent'];
                if ($donationavail < $donationreq || $donationavail < $donationcost) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
                $racereq = get_module_objpref("mounts", $id, "racereq");
                if ($racereq != "" && $session['user']['race'] != $racereq) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
                $sexreq = get_module_objpref("mounts", $id, "sexreq");
                if ($sexreq != 2 && $session['user']['sex'] != $sexreq) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
            }
            if (get_module_setting('boolview') == 1) {
                addnav("Other");
                addnav("Bestiary", "runmodule.php?module=mountprereq&op=bestiary");
            }
            break;
    }
    return $args;
}
     if ($args['setting'] == "oc" && $args['module'] == 'marriage') {
         if ($args['new'] == 1 && !is_module_active('oldchurch')) {
             $args['new'] = 0;
             set_module_setting('oc', 0);
             output_notl("`n`c`b`QMarriage Module - Old Church is not installed`0`b`c");
         }
     }
     break;
 case "footer-inn":
     set_module_pref('inShack', 0);
     if (httpget('op')) {
         break;
     }
     if ($session['user']['marriedto'] != 0 && $session['user']['marriedto'] != 4294967295.0 && is_module_active('lovers')) {
         addnav("Things to do");
         blocknav("runmodule.php?module=lovers&op=flirt", true);
         require_once "lib/partner.php";
         $namepartner = get_partner();
         addnav(array("F?Flirt with %s`0", $namepartner), "runmodule.php?module=marriage&op=innflirt");
     }
     break;
 case "footer-oldchurch":
     if (!is_module_active('oldchurch')) {
         set_module_setting('oc', 0);
     }
     $module = httpget('module');
     $op = httpget('op');
     if (get_module_setting('oc') && $module == 'oldchurch' && $op == 'enter') {
         addnav("Marriage Wing", "runmodule.php?module=marriage&op=oldchurch");
     }
     break;
function cities_dohook($hookname, $args)
{
    global $session;
    $city = getsetting("villagename", LOCATION_FIELDS);
    $home = $session['user']['location'] == get_module_pref("homecity");
    $capital = $session['user']['location'] == $city;
    switch ($hookname) {
        case "validatesettings":
            if ($args['dangerchance'] < $args['safechance']) {
                $args['validation_error'] = "Danger chance must be equal to or greater than the safe chance.";
            }
            break;
        case "drinks-check":
            if ($session['user']['location'] == $city) {
                $val = get_module_objpref("drinks", $args['drinkid'], "servedcapital");
                $args['allowdrink'] = $val;
            }
            break;
        case "master-autochallenge":
            global $session;
            if (get_module_pref("homecity") != $session['user']['location']) {
                $info = modulehook("cities-usetravel", array("foresttext" => array("`n`n`^Startled to find your master in %s`^, your heart skips a beat, costing a forest fight from shock.", $session['user']['location']), "traveltext" => array("`n`n`%Surprised at finding your master in %s`%, you feel a little less inclined to be gallivanting around the countryside today.", $session['user']['location'])));
                if ($info['success']) {
                    if ($info['type'] == "travel") {
                        debuglog("Lost a travel because of being truant from master.");
                    } elseif ($info['type'] == "forest") {
                        debuglog("Lost a forest fight because of being truant from master.");
                    } else {
                        debuglog("Lost something, not sure just what, because of being truant from master.");
                    }
                }
            }
            break;
        case "villagetext":
            if ($session['user']['location'] == $city) {
                // The city needs a name still, but at least now it's a bit
                // more descriptive
                // Let's do this a different way so that things which this
                // module (or any other) resets don't get resurrected.
                $args['text'] = array("All around you, the people of Improbable Central move about their business.  No one seems to pay much attention to you as they all seem absorbed in their own lives and problems.  Along various streets you see many different types of shops, each with a sign out front proclaiming the business done therein.  Off to one side, you see a very curious looking rock which attracts your eye with its strange shape and color.  People are constantly entering and leaving via the city gates to a variety of destinations.`n`n");
                $args['schemas']['text'] = "module-cities";
                $args['clock'] = "`n`0The clock on the inn reads `^%s.`0`n";
                $args['schemas']['clock'] = "module-cities";
                // if (is_module_active("calendar")) {
                // $args['calendar']="`n`0You hear a townsperson say that today is `^%1\$s`0, `^%3\$s %2\$s`0, `^%4\$s`0.`n";
                // $args['schemas']['calendar'] = "module-cities";
                // }
                $args['title'] = array("%s, the Capital City", $city);
                $args['schemas']['title'] = "module-cities";
                $args['fightnav'] = "Combat Avenue";
                $args['schemas']['fightnav'] = "module-cities";
                $args['marketnav'] = "Store Street";
                $args['schemas']['marketnav'] = "module-cities";
                $args['tavernnav'] = "Ale Alley";
                $args['schemas']['tavernnav'] = "module-cities";
                $args['newestplayer'] = "";
                $args['schemas']['newestplayer'] = "module-cities";
            }
            if ($home) {
                //in home city.
                blocknav("inn.php");
                blocknav("stables.php");
                blocknav("rock.php");
                // blocknav("hof.php");
                blocknav("mercenarycamp.php");
            } elseif ($capital) {
                //in capital city.
                //blocknav("forest.php");
                blocknav("train.php");
                blocknav("weapons.php");
                blocknav("armor.php");
            } else {
                //in another city.
                blocknav("train.php");
                blocknav("inn.php");
                blocknav("stables.php");
                blocknav("rock.php");
                blocknav("clans.php");
                // blocknav("hof.php");
                blocknav("mercenarycamp.php");
            }
            break;
        case "stablelocs":
            $args[$city] = sprintf_translate("The City of %s", $city);
            break;
        case "camplocs":
            $args[$city] = sprintf_translate("The City of %s", $city);
            break;
    }
    return $args;
}
function dragonplace_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "gypsy":
            // No scry in the tent unless you can hunt down the dragon.
            if ($session['user']['level'] < 15) {
                break;
            }
            $cost = get_module_setting("scrygems");
            $g = translate_inline($cost == 1 ? "gem" : "gems");
            if ($cost > 0) {
                addnav("Dragon's Eye");
                addnav(array("Search (%s %s)", $cost, $g), "runmodule.php?module=dragonplace&op=scry");
                output("`n`nOn a low table, you see a glimmering orb, with a placard nearby stating that the orb is the eye of an ancient dragon.`n");
                output("You vaguely recall a tale about how one could look into a dragon's eye and see what its kin sees!`n`n");
                output("You move toward the table, and the voice of the old crone stops you, \"`!What?? You think that's free?  It'll cost you %s %s to look through that eyeball!`5\"", $cost, $g);
            }
            break;
        case "forest":
            blocknav("forest.php?op=dragon", false);
            // Move the check for the location into the cave code so that
            // the unwary don't get a clue as to whether the dragon is there.
            $max = get_module_setting("maxsearch");
            if ($session['user']['level'] >= 15 && (!$max || get_module_pref("search") < $max)) {
                // Make sure we have a dragon cave
                if (get_module_pref("dragonloc") == getsetting("villagename", LOCATION_FIELDS)) {
                    dragonplace_choose();
                }
                tlschema("forest");
                addnav("Fight");
                addnav("G?`@Seek out the Green Dragon", "runmodule.php?module=dragonplace&op=dragon");
                tlschema();
            }
            break;
        case "newday":
            if ($session['user']['level'] < 15) {
                break;
            }
            $didchoose = 0;
            if (get_module_pref("reset")) {
                dragonplace_choose();
                set_module_pref("reset", 0);
                debuglog("Forcing dragon randomization");
                $didchoose = 1;
            }
            set_module_pref("search", 0);
            // Don't move on resurrection if we shouldn't
            if (!$didchoose && $args['resurrection'] === "true" && !get_module_setting("mvres")) {
                debuglog("Dragon didn't move due to resurrection.");
                break;
            }
            // Check chance of moving.
            if (!$didchoose && e_rand(1, 100) > get_module_setting("chance")) {
                debuglog("Dragon didn't move today.");
                break;
            }
            // If we chose on above because of the reset, no need to do it again.
            if (!$didchoose) {
                dragonplace_choose();
            }
            debuglog("Dragon location was randomized..");
            output("`n`b`^The `@Green Dragon`^ wanders to a new cave...`b`n");
            break;
        case "footer-inn":
            if (httpget('op') == "fleedragon" && get_module_setting('idrag') == 1) {
                $session['user']['seendragon'] = 1;
                set_module_pref("search", get_module_pref("search") + 1);
            }
            break;
        case "dragonkill":
            set_module_pref('gems', 0);
            set_module_pref('gold', 0);
            set_module_pref('hp', 0);
            set_module_pref("search", 0);
            output("`n`@All those empty caves, all that searching, just for the Dragon to return...");
            // Pick a new location now since the dragon might not move on new day.
            set_module_pref("dragonloc", '');
            set_module_pref("dragonloc2", '');
            dragonplace_choose();
            break;
    }
    return $args;
}
function applebob_run()
{
    require_once 'lib/villagenav.php';
    global $session;
    $op = httpget('op');
    $cost = get_module_setting('cost');
    $eatAllowed = get_module_setting('allowed');
    $eatToday = get_module_pref('ate_today');
    page_header("Sichae's Apple Stand");
    output("`&`c`bApple Bobbing Stand`b`c");
    switch ($op) {
        case 'bob':
            increment_module_pref('ate_today', 1);
            $session['user']['gold'] -= $cost;
            debuglog("spent {$cost} gold on an apple.");
            $appleChance = e_rand(1, 10);
            $color = e_rand(1, 4);
            $colors = [1 => '`4red', 2 => '`2green', 3 => '`^yellow', 4 => '`@green'];
            output("`7You hand Sichae your %s gold, and place your hands on the edge of the barrel.", $cost);
            output("Taking a deep breath, you plunge your head forwards into the chilly water, and vainly attempt to grab hold of an apple with your teeth.");
            output("You finally emerge from the water with a %s`7 coloured apple in your mouth, gasping for breath.", $colors[$color]);
            output("Sichae smiles at your success.`n`n");
            output("`&\"Well done, fair warrior!\"`n`n");
            if ($appleChance == 1) {
                output("`7She grins mischievously, `&\"'Tis a rare warrior that plucks the hallowed blue apple!");
                output("There you have my finest achievement.");
                output("Go forth and slay all in your path, enchanted one!\"`n`n");
                output("`7Your jaw slackens in astonishment at the thought of a blue apple, but you manage to catch the fruit in one hand as it falls.");
                output("As you do, its delicious flavor hits you with surprise.");
                output("Your muscles tingle and a warm buzz flows into your very bones.`n`n");
                output("You feel `5mystical!");
                apply_buff('sichae', ['name' => '`!Blue Apple Mystique', 'rounds' => 20, 'defmod' => 1.03, 'roundmsg' => '`!The Blue Apple\'s power tingles in your bones.']);
                apply_buff('sichae', array("name" => "`!Blue Apple Mystique", "rounds" => 20, "defmod" => 1.03, "roundmsg" => "`!The Blue Apple's power tingles in your bones."));
            } else {
                if ($color == 4) {
                    output("`7As she says this though, you realize that something is very odd about this apple.");
                    output("It looks and tastes just like an ordinary green apple, but you begin to feel very strange.`n`n");
                    output("Bizarre creatures appear before your eyes.");
                    output("You realize that someone has poisoned the apple!`n`n");
                    output("All of the imaginary monsters from your nightmares close in on you, and you feel the terrifying urge to flee this place!");
                    apply_buff('sichae', ['name' => '`@Poisoned Appled', 'rounds' => 20, 'defmod' => 0.97, 'roundmsg' => '`@Strange hallucinations taunt you as you fight.']);
                    blocknav("runmodule.php?module=applebob&op=bob");
                }
            }
            addnav(['Try again (%s gold)', $cost], 'runmodule.php?module=applebob&op=bob');
            villagenav();
            break;
        default:
            output("`7You begin to approach the apple stand, peering into the barrels with interest.");
            output("Inside are apples of red, yellow and green.");
            output("Sichae stands with her hands on her hips, and regards you with a mysterious smile.`n`n");
            output("Her silken garments of jade and blue swish in the cool breeze, and her lithe muscles flex as she pads over to where you stand.`n`n");
            output("`&\"Ah! A visitor to the realms! So you think you can do this, do you?");
            output("It shall be amusing to see you try.\"`n`n");
            output("`7She arches her delicate neck back, and laughs a deep and beautiful sound, that immediately makes you relax.");
            output("She motions to the barrel in front of you.");
            output("`&\"%s gold to show me what talent you posess.", $cost);
            output("And one of the apples is special indeed...\"");
            if ($eatToday >= $eatAllowed) {
                output("`7Much as you'd like to play, your stomach protests fitfully.");
            } else {
                if ($session['user']['gold'] < $cost) {
                    output("`7Unfortunately your pockets do not seem to be full enough to play!");
                } else {
                    addnav(['Try your luck (`^%s gold`0)', $cost], 'runmodule.php?module=applebob&bob=bob');
                }
            }
            villagenav();
            break;
    }
    page_footer();
}
function staminacorecombat_dohook($hookname, $args)
{
    global $session;
    static $damagestart = 0;
    switch ($hookname) {
        case "forest":
            blocknav("forest.php?op=search");
            blocknav("forest.php?op=search&type=slum");
            blocknav("forest.php?op=search&type=thrill");
            blocknav("forest.php?op=search&type=suicide");
            addnav("Fight");
            $normalcost = stamina_getdisplaycost("Hunting - Normal");
            $slumcost = stamina_getdisplaycost("Hunting - Easy Fights");
            $thrillcost = stamina_getdisplaycost("Hunting - Big Trouble");
            $suicidecost = stamina_getdisplaycost("Hunting - Suicidal");
            addnav(array("T?Look for Trouble (`Q%s%%`0)", $normalcost), "runmodule.php?module=staminacorecombat&op=search");
            if ($session['user']['level'] > 1) {
                addnav(array("E?Look for an Easy Fight (`Q%s%%`0)", $slumcost), "runmodule.php?module=staminacorecombat&op=slum");
            }
            addnav(array("B?Look for Big Trouble (`Q%s%%`0)", $thrillcost), "runmodule.php?module=staminacorecombat&op=thrill");
            if (getsetting("suicide", 0)) {
                if (getsetting("suicidedk", 10) <= $session['user']['dragonkills']) {
                    addnav(array("*?Search `\$Suicidally`0 (`Q%s%%`0)", $suicidecost), "runmodule.php?module=staminacorecombat&op=suicide");
                }
            }
            break;
        case "battle":
            blocknav("forest.php?op=fight");
            blocknav("forest.php?op=run");
            addnav("Standard Fighting");
            addnav("Fight", "runmodule.php?module=staminacorecombat&op=fight");
            addnav("Run", "runmodule.php?module=staminacorecombat&op=run");
            break;
        case "startofround":
            switch (httpget("levelup")) {
                case "normal":
                    output("`c`b`0You gained a level in Looking for Trouble!  This action costs fewer Stamina points now, so you can find more beasties to aggress!`b`c`n`n");
                    break;
                case "easy":
                    output("`c`b`0You gained a level in Looking for Easy Fights!  This action costs fewer Stamina points now, so you can pick on more small creatures!`b`c`n`n");
                    break;
                case "hard":
                    output("`c`b`0You gained a level in Looking for Big Trouble!  This action costs fewer Stamina points now, so you can throw yourself on the mercy of large creatures more often!`b`c`n`n");
                    break;
                case "suicide":
                    output("`c`b`0You gained a level in Looking for Really Big Trouble!  This action costs fewer Stamina points now, so you can put yourself in mortal danger more often!`b`c`n`n");
                    break;
            }
            if ($session['user']['alive'] == 1) {
                staminacorecombat_applystaminabuff();
            }
            $damagestart = $session['user']['hitpoints'];
            break;
        case "endofround":
            $damagetaken = $damagestart - $session['user']['hitpoints'];
            if (httpget("op") == "fight") {
                $return = process_action("Fighting - Standard");
                if ($return['lvlinfo']['levelledup'] == true) {
                    output("`n`c`b`0You gained a level in Standard Fighting!  You are now level %s!  This action will cost fewer Stamina points now.`b`c`n", $return['lvlinfo']['newlvl']);
                }
            }
            if (httpget("op") == "run") {
                $return = process_action("Running Away");
                if ($return['lvlinfo']['levelledup'] == true) {
                    output("`n`c`b`0You gained a level in Running Away!  You are now level %s!  This action will cost fewer Stamina points now, so you can run away like a cowardly dog more often!`b`c`n", $return['lvlinfo']['newlvl']);
                }
            }
            $reps = $damagetaken / $session['user']['maxhitpoints'] * 10;
            if ($damagetaken > 0) {
                $staminalost = 0;
                for ($i = 0; $i < $reps; $i++) {
                    $return = process_action("Taking It on the Chin");
                    $staminalost += $return['points_used'];
                    if ($return['lvlinfo']['levelledup'] == true) {
                        output("`n`c`b`0You gained a level in Taking It On The Chin!  You are now level %s!  This action will cost fewer Stamina points now, so getting beaten up will tire you out a little less.  Good thing, really!`b`c`n", $return['lvlinfo']['newlvl']);
                    }
                }
                output("Your freshly-inflicted wound knocks %s Stamina points out of you!`n", $staminalost);
            }
            break;
    }
    return $args;
}
<?php

switch ($hookname) {
    case "superuser":
        if ($session['user']['superuser'] & SU_IS_TRANSLATOR) {
            addnav("Actions");
            addnav("Translation Wizard", "runmodule.php?module=translationwizard&op=list");
            if (get_module_setting(blocktrans)) {
                blocknav("untranslated.php");
            }
        }
        break;
    case "header-modules":
        if (get_module_setting("autoscan")) {
            if (httpget('op') == "install") {
                $languageschema = get_module_pref("language", "translationwizard");
                if (!$languageschema) {
                    break;
                }
                require_once "./modules/translationwizard/scanmodules_func.php";
                $content = wizard_scanfile("modules/" . httpget('module') . ".php");
                wizard_insertfile($content, $languageschema);
            } elseif (httpget('op') == "mass" && httppost("install")) {
                $languageschema = get_module_pref("language", "translationwizard");
                if (!$languageschema) {
                    break;
                }
                require_once "./modules/translationwizard/scanmodules_func.php";
                $module = httppost("module");
                if (is_array($module)) {
                    $modules = $module;
    }
    rawoutput("</table>");
}
if ($subop == "giveback") {
    if ($confirm) {
        $sql = "SELECT dwidowner FROM " . db_prefix("dwellingkeys") . " \r\n\t\t\t\t\t\tWHERE keyowner=" . $session['user']['acctid'] . " \r\n\t\t\t\t\t\tAND dwid={$dwid}";
        $result = db_query($sql);
        $row = db_fetch_assoc($result);
        $sql = "UPDATE " . db_prefix("dwellingkeys") . " \r\n\t\t\t\t\t\tSET keyowner=0 \r\n\t\t\t\t\t\tWHERE keyowner=" . $session['user']['acctid'] . " \r\n\t\t\t\t\t\tAND dwid=" . $dwid;
        db_query($sql);
        $msg = "`2%s has returned their key to your %s in %s.";
        $mailmessage = array($msg, $session['user']['name'], $row['type'], $row['location']);
        require_once "lib/systemmail.php";
        systemmail($row['dwidowner'], array("`2Key returned!`2"), $mailmessage);
        output("The key has been returned.");
        blocknav("runmodule.php?module=dwellingseditor&op=enter&dwid={$dwid}");
    } else {
        output("Are you sure you want to give back your key to this dwelling?");
        addnav("Yes,", "runmodule.php?module=dwellingseditor&op=keys&subop=giveback&confirm=1&dwid={$dwid}");
    }
}
if ($subop == "givekey") {
    output("`2Who do you want to give the key to?`n`n");
    $submit = translate_inline("Submit");
    rawoutput("<form action='runmodule.php?module=dwellingseditor&op=keys&subop=givekey2&keyid={$keyid}&dwid={$dwid}' method='POST'>");
    addnav("", "runmodule.php?module=dwellingseditor&op=keys&subop=givekey2&keyid={$keyid}&dwid={$dwid}");
    rawoutput("<input name='name' id='name'> <input type='submit' class='button' value='{$submit}'>");
    rawoutput("</form>");
    rawoutput("<script language='JavaScript'>document.getElementById('name').focus()</script>");
}
if ($subop == "givekey2") {
		
		if($session['user']['acctid']!=$ownerid){
			blocknav("runmodule.php?module=dwellings&op=coffers&dwid=$dwid");
			blocknav("runmodule.php?module=dwellings&op=keys&subop=giveback&dwid=$dwid");
			blocknav("runmodule.php?module=dwellings&op=logout&dwid=$dwid&type=dwinns");
		}
		if(get_module_setting("ownerguest")==1 || $session['user']['acctid']!=$ownerid){
			addnav("Dwelling");
			if(get_module_pref("sleepingindwinn")!=$dwid)
				addnav("Get a room","runmodule.php?module=dwinns&op=room&dwid=$dwid");
			else
				addnav("Go to your room","runmodule.php?module=dwinns&op=room&dwid=$dwid");
			addnav("Sit at a table","runmodule.php?module=dwinns&op=table&dwid=$dwid");
			addnav("Sit at the bar","runmodule.php?module=dwinns&op=bar&dwid=$dwid");
		}
		
		if($session['user']['acctid']==$ownerid){
			blocknav("runmodule.php?module=dwellings&op=logout&dwid=$dwid&type=dwinns");
			addnav("Dwellings Extras");
			addnav("Pay for adds","runmodule.php?module=dwinns&op=village-add&dwid=$dwid");
			addnav("Kitchen","runmodule.php?module=dwinns&op=meals&dwid=$dwid");
			addnav("Brewery","runmodule.php?module=dwinns&op=drinks&dwid=$dwid");
			addnav("Build new rooms","runmodule.php?module=dwinns&op=rooms&dwid=$dwid");
			if($row['stars']<10)
				addnav("Improve the place","runmodule.php?module=dwinns&op=improve&dwid=$dwid");
			addnav("Change room price","runmodule.php?module=dwinns&op=room-price&dwid=$dwid");
			addnav("Check Statistics","runmodule.php?module=dwinns&op=stats&dwid=$dwid");
		}
	}
?>
function pvpimmunity_dohook($hookname, $args)
{
    switch ($hookname) {
        case "notifyuserprefchange":
            if ($args['name'] == "check_willing") {
                set_module_pref("locked", 1);
            }
            break;
        case "process-create":
            // Newly created players don't need to be pvplocked.  they cannot
            // have done a recent pvp.
            $acctid = $args['acctid'];
            set_module_pref("locked", 0, "pvpimmunity", $acctid);
            break;
        case "dragonkill":
            set_module_pref("locked", 0);
            break;
        case "checkuserpref":
            if ($args['name'] == "check_willing") {
                if (get_module_pref("locked")) {
                    $args['pref'] = str_replace(",bool", ",viewonly", $args['pref']);
                }
                $args['allow'] = 1;
            }
            break;
        case "pvpmodifytargets":
            foreach ($args as $index => $target) {
                if (!get_module_pref("check_willing", "pvpimmunity", $target['acctid'])) {
                    $args[$index]['invalid'] = 1;
                }
            }
            break;
        case "village":
            if (!get_module_pref("check_willing")) {
                blocknav("pvp.php", true);
            }
            break;
        case "pvpwarning":
            if (!get_module_pref("locked")) {
                if (!$args['dokill']) {
                    output("`\$WARNING:`7 You are currently set to allow PvP, but are not yet locked in for this dragon kill cycle.");
                    output("Once you attack for the first time during a dragon kill you will be unable to stay safe from others until the next time you kill the dragon.");
                    output("If you, like some, would prefer to completely avoid the player versus player aspect of the game, including the possibility of being killed by players much stronger than you, then you should enable PvP immunity from your Preferences page.`n`n");
                } else {
                    output("`\$WARNING:`7 By attacking another player in PvP you have locked yourself into allowing PvP against you for this dragonkill cycle.");
                    output("You may visit your preferences page to change this after your next dragon kill.`n`n");
                    set_module_pref("locked", 1);
                }
            }
            break;
        case "heidi-end":
            // If the person has declined PVP, they cannot benefit from trading in
            // PVP turns either.
            if (!get_module_pref("check_willing")) {
                // block the blue candle nav
                blocknav("runmodule.php?module=heidi&op=blue");
            }
            $op = httpget("op");
            if ($op == "") {
                if (!get_module_pref("locked")) {
                    // Okay.. they can change their pvp immunity preferences
                    output("`n`n`7Heidi peers into your eyes for a moment, as if searching your soul for violence.");
                    if (get_module_pref("check_willing")) {
                        output("\"`&Be warned, child, should you burn a blue candle, you will be locked into a world of violence for another cycle!`7\"");
                    } else {
                        output("\"`&You have chosen the way of peace, and so long as you walk it, you may not make use of the blue candles. We all have the means to change our destinies, though, so if 'tis your wish, ye can still change the choice you made.`7\"");
                    }
                } else {
                    // They are already locked.  If they cannot use the blue let
                    // them know why.
                    if (!get_module_pref("check_willing")) {
                        output("`n`n`7Heidi peers into your eyes for a moment, as if searching your soul for violence.");
                        output("\"`&You are truly blessed, my child. You have completely forsaken violence against your fellows for this turn of the cycle! And so, the spirits won't impart the blessing of the blue candles to you, but you have a much more gentle soul.`7\"");
                    }
                }
            } elseif ($op == "blue") {
                // Lock them out of changing.
                set_module_pref("locked", 1);
            }
            break;
        case "header-inn":
            if (!get_module_pref("check_willing")) {
                blocknav("inn.php?op=bartender&act=listupstairs");
            }
            break;
    }
    return $args;
}
<?php

blocknav("weapons.php");
blocknav("armor.php");
$shop = get_module_setting("shopname");
addnav($args['marketnav']);
if ($session['user']['location'] == get_module_setting("shoploc") && get_module_setting("shopall") == 0) {
    if (get_module_pref("pass") == 1 && get_module_setting("shopappear") == 1) {
        addnav("{$shop}", $from . "op=shop&what=enter");
    } else {
        if (get_module_setting("shopappear") == 0 && $session['user']['dragonkills'] >= get_module_setting("dkreq")) {
            addnav("{$shop}", $from . "op=shop&what=enter");
        }
    }
} else {
    if (get_module_setting("shopall") == 1) {
        if (get_module_pref("pass") == 1 && get_module_setting("shopappear") == 1) {
            addnav("{$shop}", $from . "op=shop&what=enter");
        } else {
            if (get_module_setting("shopappear") == 0 && $session['user']['dragonkills'] >= get_module_setting("dkreq")) {
                addnav("{$shop}", $from . "op=shop&what=enter");
            }
        }
    }
}
function breakin_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "newday":
            $guilt = get_module_pref("guilt");
            if ($guilt > 1) {
                if (get_module_pref("guiltydk")) {
                    output("`n`3You start to feel bad about something relating to the inn that you cannot quite remember.");
                    output("You are quite sure that, whatever it was,  you don't want to face Cedrik quite yet.");
                } else {
                    output("`n`3You start to feel bad about breaking into the inn recently, and you aren't sure you can face Cedrik quite yet.");
                }
                if ($guilt == 2) {
                    output("Perhaps tomorrow....`n");
                } elseif ($guilt == 3) {
                    output("Perhaps the day after tomorrow....`n");
                }
                $guilt--;
                set_module_pref("guilt", $guilt);
            } elseif ($guilt == 1) {
                set_module_pref("guilt", 0);
                set_module_pref("guiltydk", 0);
            }
            set_module_pref("breaktoday", 0);
            break;
        case "dragonkill":
            if (get_module_pref("guilt") && get_module_setting("guilt")) {
                set_module_pref("guiltydk", 1);
            }
            break;
        case "inn":
            if (get_module_pref("guilt") && get_module_setting("guilt")) {
                if (get_module_pref("guiltydk")) {
                    output("`n`3For some reason you just cannot explain nor remember you are absolutely unable to bear remaining in the inn for another moment!`0`n");
                } else {
                    output("`n`3You remember forcing that door, and the damage you caused to the lock and door frame, and you just can't bear to be in here a minute longer!`0`n");
                }
                blockmodule("dag");
                blockmodule("lottery");
                blockmodule("lovers");
                blockmodule("inncoupons");
                blockmodule("sethsong");
                blocknav("inn.php?op=bartender");
                blocknav("inn.php?op=converse");
                blocknav("inn.php?op=seth");
                blocknav("inn.php?op=seth&subop=hear");
                blocknav("inn.php?op=converse");
                blocknav("inn.php?op=room");
            }
            break;
        case "stables-desc":
            if (getsetting("villagename", LOCATION_FIELDS) == $session['user']['location']) {
                output("`n`n`3As you look around the stables, you spy a door on the building next door, mostly hidden by dense ivy.`0`n");
                $nouse = 0;
                if (get_module_setting("guilt") && get_module_pref("guilt")) {
                    $nouse = 1;
                }
                if (get_module_pref("breaktoday")) {
                    $nouse = 1;
                }
                if (!$session['user']['playerfights']) {
                    $nouse = 1;
                }
                if ($nouse) {
                    output("You briefly consider investigating it, but decide not to press your luck at this moment.`n");
                }
            }
            break;
        case "stables-nav":
            // only in Merick's stables, not in Bertold's and only if they can
            // use it
            if (getsetting("villagename", LOCATION_FIELDS) == $session['user']['location']) {
                $nouse = 0;
                if (get_module_setting("guilt") && get_module_pref("guilt")) {
                    $nouse = 1;
                }
                if (get_module_pref("breaktoday")) {
                    $nouse = 1;
                }
                if (!$session['user']['playerfights']) {
                    $nouse = 1;
                }
                if (!$nouse) {
                    addnav("Examine Door", "runmodule.php?module=breakin");
                }
            }
            break;
        case "village":
            if (!get_module_setting("stocks") || !is_module_active("stocks")) {
                set_module_setting("thisID", 0);
                break;
            }
            $thisID = get_module_setting("thisID");
            if (!$thisID) {
                break;
            }
            $lastStock = get_module_setting("victim", "stocks");
            if ($thisID != $lastStock) {
                set_module_setting("thisID", 0);
                break;
            }
            // No output if we're not in the capital
            if ($session['user']['location'] != getsetting("villagename", LOCATION_FIELDS)) {
                break;
            }
            if ($thisID == $session['user']['acctid']) {
                output("`n`7You are serving time in the stocks for trying to break into the Inn!`0`n");
            } else {
                $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$thisID}'";
                $result = db_query_cached($sql, "stocks");
                $row = db_fetch_assoc($result);
                output("`n`&%s`7 was put into the stocks for trying to break into the Inn!`0`n", $row['name']);
            }
            break;
    }
    return $args;
}