function nooblube_dohook($hookname, $args)
{
    global $session, $badguy;
    switch ($hookname) {
        case "battle-defeat":
            //check to see if they're alive first, 'cause otherwise it'll add favour when they get wiped out on the FailBoat
            if ($session['user']['alive'] == false) {
                break;
            }
            //check to see if they've got any hitpoints, for stuff like the Tattoo Monster and defeating their masters
            if ($session['user']['hitpoints'] > 0) {
                break;
            }
            $maxlevel = get_module_setting("level");
            $currentlevel = $session['user']['level'];
            if ($currentlevel < $maxlevel) {
                if ($session['user']['dragonkills'] == 0) {
                    if ($session['user']['deathpower'] < 100) {
                        $session['user']['deathpower'] = get_module_setting("lube");
                    }
                    $tutormsg = translate_inline("`#What did I tell you about being careful?  Bloody newbies.  Okay, those nice gentlemen coming towards you will pick you up and drag you to my FailBoat, but don't worry about it too much.  Just come and see me below decks and I'll get you put on the next boat back to the Island.  Don't get used to it though, matey - once you hit level ten, you'll have to fight for your freedom like everyone else.");
                    if ($tutormsg) {
                        tutor_talk("%s", $tutormsg);
                    }
                }
            }
            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;
}