$session['user']['seenmaster'] = 0; $session['user']['fedmount'] = 0; if ($resurrection != "true") { $session['user']['soulpoints'] = 50 + 5 * $session['user']['level']; $session['user']['gravefights'] = getsetting("gravefightsperday", 10); } $session['user']['boughtroomtoday'] = 0; $session['user']['recentcomments'] = $session['user']['lasthit']; $session['user']['lasthit'] = gmdate("Y-m-d H:i:s"); if ($session['user']['hashorse']) { $msg = $playermount['newday']; require_once "lib/substitute.php"; $msg = substitute_array("`n`&" . $msg . "`0`n"); output($msg); require_once "lib/mountname.php"; list($name, $lcname) = getmountname(); $mff = (int) $playermount['mountforestfights']; $session['user']['turns'] += $mff; $turnstoday .= ", Mount: {$mff}"; if ($mff > 0) { $state = translate_inline("gain"); $color = "`^"; } elseif ($mff < 0) { $state = translate_inline("lose"); $color = "`\$"; } $mff = abs($mff); if ($mff != 0) { output("`n`&Because of %s`&, you %s%s %s`& forest %s for today!`n`0", $lcname, $color, $state, $mff, translate_inline($mff == 1 ? 'fight' : 'fights')); } } else {
function grassyfield_runevent($type) { require_once "lib/buffs.php"; require_once "lib/commentary.php"; addcommentary(); global $session, $playermount; // We assume this event only shows up in the forest currently. $from = "forest.php?"; $session['user']['specialinc'] = "module:grassyfield"; $op = httpget('op'); if ($op == "return") { $session['user']['specialmisc'] = ""; $session['user']['specialinc'] = ""; redirect($from, "Redirected to " . $from . " from Grassy Field module"); } checkday(); output("`n`c`#You Stumble Upon a Grassy Field`c`n`n"); addnav("Return to the forest", $from . "op=return"); require_once "lib/mountname.php"; list($name, $lcname) = getmountname(); if ($session['user']['specialmisc'] != "Nothing to see here, move along.") { if ($session['user']['hashorse'] > 0) { list($max, $cur) = grassyfield_getrounds(); if ($cur > $max * 0.5) { // XXX: this message really should be a module objpref if ($playermount['partrecharge']) { tlschema("mounts"); output($playermount['partrecharge']); tlschema(); } else { output("`&You allow %s`& to frolic and gambol in the field.", $lcname); } } else { // XXX: this message really should be a module objpref if ($playermount['recharge']) { tlschema("mounts"); output($playermount['recharge']); tlschema(); } else { output("`&You allow %s`& to hunt and rest in the field.", $lcname); } } $buff = unserialize($playermount['mountbuff']); if (!isset($buff['schema']) || $buff['schema'] == "") { $buff['schema'] = "mounts"; } apply_buff('mount', $buff); if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) { output("`n`^Your nap leaves you completely healed!"); $session['user']['hitpoints'] = $session['user']['maxhitpoints']; } $args = array('soberval' => 0.8, 'sobermsg' => "`n`&Naps are quite a sobering experience!`n", 'schema' => "module-grassyfield"); modulehook("soberup", $args); $session['user']['turns']--; output("`n`n`^You spend some time - and Stamina - lying around."); } else { output("`&Deciding to take a moment and a load off your poor weary feet you take a quick break from your ventures to take in the beautiful surroundings."); output("`n`n`^Your break leaves you completely healed!"); if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) { $session['user']['hitpoints'] = $session['user']['maxhitpoints']; } } $session['user']['specialmisc'] = "Nothing to see here, move along."; } else { output("`&You relax a while in the fields enjoying the sun and the shade."); } commentdisplay("`n`n`@Talk with the others lounging here.`n", "grassyfield", "Speak lazily", 10); }
function darkhorse_runevent($type, $link) { global $session; $from = $link; $gameret = substr($link, 0, -1); $session['user']['specialinc'] = "module:darkhorse"; require_once "lib/sanitize.php"; $iname = get_module_setting("tavernname"); rawoutput("<span style='color: #787878'>"); output_notl("`c`b%s`b`c", $iname); $op = httpget('op'); switch ($op) { case "": case "search": darkhorse_checkday(); output("A cluster of trees nearby looks familiar..."); output("You're sure you've seen this place before."); output("As you approach the grove, a strange mist creeps in around you; your mind begins to buzz, and you're no longer sure exactly how you got here."); if (darkhorse_tavernmount()) { require_once "lib/mountname.php"; list($name, $lcname) = getmountname(); output("%s`0 seems to have known the way, however.", $name); } output("`n`nThe mist clears, and before you is a log building with smoke trailing from its chimney."); output("A sign over the door says `7\"%s.\"`0", $iname); addnav("Enter the tavern", $from . "op=tavern"); addnav("Leave this place", $from . "op=leaveleave"); break; case "tavern": darkhorse_checkday(); output("You stand near the entrance of the tavern and survey the scene before you."); output("Whereas most taverns are noisy and raucous, this one is quiet and nearly empty."); output("In the corner, an old man plays with some dice."); output("You notice that the tables have been etched on by previous adventurers who have found this place before, and behind the bar, a stick of an old man hobbles around, polishing glasses, as though there were anyone here to use them."); addnav("Talk to the old man", $from . "op=oldman"); addnav("Talk to the bartender", $from . "op=bartender"); // Special case here. go and see if the comment area is blocked and // if so, don't put the link in. $args = modulehook("blockcommentarea", array("section" => "darkhorse")); if (!isset($args['block']) || $args['block'] != 'yes') { addnav("Examine the tables", $from . "op=tables"); } addnav("Exit the tavern", $from . "op=leave"); break; case "tables": require_once "lib/commentary.php"; addcommentary(); commentdisplay("You examine the etchings in the table:`n`n", "darkhorse", "Add your own etching:"); addnav("Return to the Main Room", $from . "op=tavern"); break; case "bartender": darkhorse_bartender($from); break; case "oldman": darkhorse_checkday(); addnav("Old Man"); modulehook("darkhorsegame", array("return" => $gameret)); output("The old man looks up at you, his eyes sunken and hollow."); output("His red eyes make it seem that he may have been crying recently so you ask him what is bothering him."); if ($session['user']['sex'] == SEX_MALE) { output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with her, but she won and took almost all of my money.`0\"`n`n"); } else { output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with him, but he won and took almost all of my money.`0\"`n`n"); } $c = navcount(); if ($c != 0) { output("`0\"`7Say... why not do an old man a favor and let me try to win some of it back from you?"); if ($c > 1) { output(" I can play several games!`0\""); } else { output(" Shall we play a game?`0\""); } } $session['user']['specialmisc'] = ""; addnav("Return to the Main Room", $from . "op=tavern"); break; case "leave": output("You duck out of the tavern, and wander into the thick foliage around you."); output("That strange mist revisits you, making your mind buzz."); output("The mist clears, and you find yourself again where you were before the mist first covered you."); if (!darkhorse_tavernmount()) { output(" How exactly you got to the tavern is not exactly clear."); } $session['user']['specialinc'] = ""; break; case "leaveleave": output("You decide that the tavern holds no appeal for you today."); $session['user']['specialinc'] = ""; break; } rawoutput("</span>"); }
function goldmine_runevent($type) { global $session; // The only type of event we care about are the forest. $from = "forest.php?"; $hashorse = $session['user']['hashorse']; $horsecanenter = 0; $horsecandie = 0; $horsecansave = 0; if ($hashorse) { $horsecanenter = get_module_objpref('mounts', $hashorse, 'entermine'); // See if we automatically tether; if (e_rand(1, 100) <= get_module_setting("alwaystether")) { $horsecanenter = 0; } if ($horsecanenter) { // The mount cannot die or save you if it cannot enter $horsecandie = get_module_objpref('mounts', $hashorse, 'dieinmine'); $horsecansave = get_module_objpref('mounts', $hashorse, 'saveplayer'); } require_once "lib/mountname.php"; list($mountname, $lcmountname) = getmountname(); } $session['user']['specialinc'] = "module:goldmine"; $op = httpget('op'); if ($op == "" || $op == "search") { output("`2You found an old abandoned mine in the depths of the forest."); output("There is some old mining equipment nearby.`n`n"); output("`^As you look around you realize that this is going to be a lot of work."); output("So much so in fact that you will lose a forest fight for the day if you attempt it.`n`n"); output("`^Looking around a bit more, you do notice what looks like evidence of occasional cave-ins in the mine.`n`n"); addnav("Mine for gold and gems", $from . "op=mine"); addnav("Return to the forest", $from . "op=no"); } elseif ($op == "no") { output("`2You decide you don't have time for this slow way to gain gold and gems, and so leave the old mine behind and go on your way...`n"); $session['user']['specialinc'] = ""; } elseif ($op == "mine") { if ($session['user']['turns'] <= 0) { output("`2You are too tired to mine anymore..`n"); $session['user']['specialinc'] = ""; } else { // Horsecanenter is a percent, so, if rand(1-100) > enterpercent, // tether it. Set enter percent to 0 (the default), to always // tether. if (e_rand(1, 100) > $horsecanenter && $hashorse) { $msg = get_module_objpref('mounts', $hashorse, 'tethermsg'); if ($msg) { output($msg); } else { output("`&Seeing that the mine entrance is too small for %s`&, you tether it off to the side of the entrance.`n", $lcmountname); } // The mount it tethered, so it cannot die nor save the player $horsecanenter = 0; $horsecandie = 0; $horsecansave = 0; } output("`2You pick up the mining equipment and start mining for gold and gems...`n`n"); $rand = e_rand(1, 20); switch ($rand) { case 1: case 2: case 3: case 4: case 5: output("`2After a few hours of hard work you have only found worthless stones and one skull...`n`n"); output("`^You lose one forest fight while digging.`n`n"); if ($session['user']['turns'] > 0) { $session['user']['turns']--; } $session['user']['specialinc'] = ""; break; case 6: case 7: case 8: case 9: case 10: $gold = e_rand($session['user']['level'] * 5, $session['user']['level'] * 20); output("`^After a few hours of hard work, you find %s gold!`n`n", $gold); $session['user']['gold'] += $gold; debuglog("found {$gold} gold in the goldmine"); output("`^You lose one forest fight while digging.`n`n"); if ($session['user']['turns'] > 0) { $session['user']['turns']--; } $session['user']['specialinc'] = ""; break; case 11: case 12: case 13: case 14: case 15: $gems = e_rand(1, round($session['user']['level'] / 7) + 1); output("`^After a few hours of hard work, you find `%%s %s`^!`n`n", $gems, translate_inline($gems == 1 ? "gem" : "gems")); $session['user']['gems'] += $gems; debuglog("found {$gems} gems in the goldmine"); output("`^You lose one forest fight while digging.`n`n"); if ($session['user']['turns'] > 0) { $session['user']['turns']--; } $session['user']['specialinc'] = ""; break; case 16: case 17: case 18: $gold = e_rand($session['user']['level'] * 10, $session['user']['level'] * 40); $gems = e_rand(1, round($session['user']['level'] / 3) + 1); output("`^You have found the mother lode!`n`n"); output("`^After a few hours of hard work, you find `%%s %s`^ and %s gold!`n`n", $gems, translate_inline($gems == 1 ? "gem" : "gems"), $gold); $session['user']['gems'] += $gems; $session['user']['gold'] += $gold; debuglog("found {$gold} gold and {$gems} gems in the goldmine"); output("`^You lose one forest fight while digging.`n`n"); if ($session['user']['turns'] > 0) { $session['user']['turns']--; } $session['user']['specialinc'] = ""; break; case 19: case 20: output("`2After a lot of hard work you believe you have spotted a `&huge`2 `%gem`2 and some `6gold`2.`n"); output("`2Anxious to be rich, you rear back and slam the pick home, knowing that the harder you hit, the quicker you will be done....`n"); output("`7Unfortunately, you are quickly done in.`n"); output("Your over-exuberant hit caused a massive cave in.`n"); // Find the chance of dying based on race $vals = modulehook("raceminedeath"); $dead = 0; $racesave = 1; if (isset($vals['racesave']) && $vals['racesave']) { if ($vals['schema']) { tlschema($vals['schema']); } $racemsg = translate_inline($vals['racesave']); if ($vals['schema']) { tlschema(); } } if (isset($vals['chance']) && e_rand(1, 100) < $vals['chance']) { $dead = 1; $racesave = 0; $racemsg = ""; } if ($dead) { // The player has died, see if their horse saves them if (isset($horsecansave) && e_rand(1, 100) <= $horsecansave) { $dead = 0; $horsesave = 1; } } // If we are still dead, see if the horse dies too. $session['user']['specialinc'] = ""; if ($dead) { if (e_rand(1, 100) <= $horsecandie) { $horsedead = 1; } output("You have been crushed under a ton of rock.`n`nPerhaps the next adventurer will recover your body and bury it properly.`n"); if ($horsedead) { $msg = get_module_objpref('mounts', $hashorse, 'deathmsg'); if ($msg) { output($msg); } else { output("%s`7's bones were buried right alongside yours.", $mountname); } global $playermount; $debugmount = $playermount['mountname']; debuglog("lost their mount, a {$debugmount}, in a mine collapse."); $session['user']['hashorse'] = 0; if (isset($session['bufflist']['mount'])) { strip_buff("mount"); } } elseif ($hashorse) { if ($horsecanenter) { output("%s`7 managed to escape being crushed.", $mountname); output("You know that it is trained to return to the village.`n"); } else { output("Fortunately you left %s`7 tethered outside.", $lcmountname); output("You know that it is trained to return to the village.`n"); } } $exp = round($session['user']['experience'] * 0.1, 0); output("At least you learned something about mining from this experience and have gained %s experience.`n`n", $exp); output("`3You may continue to play tomorrow`n"); $session['user']['experience'] += $exp; $session['user']['alive'] = false; $session['user']['hitpoints'] = 0; $gemlost = round(get_module_setting("percentgemloss") / 100 * $session['user']['gems'], 0); $goldlost = round(get_module_setting("percentgoldloss") / 100 * $session['user']['gold'], 0); debuglog("lost {$goldlost} gold and {$gemlost} gems by dying in the goldmine"); output("`^%s gold `&and `%%s %s`& were lost when you were buried!", $goldlost, $gemlost, translate_inline($gemlost == 1 ? "gem" : "gems")); $session['user']['gold'] -= $goldlost; $session['user']['gems'] -= $gemlost; addnav("Daily News", "news.php"); addnews("%s was completely buried after becoming greedy digging in the mines.", $session['user']['name']); } else { if (isset($horsesave) && $horsesave) { $msg = get_module_objpref('mounts', $hashorse, 'savemsg'); if ($msg) { output($msg); } else { output("%s`7 managed to drag you to safety in the nick of time!`n", $mountname); } } elseif ($racesave) { if (isset($racemsg) && $racemsg) { output_notl($racemsg); } else { output("Through sheer luck, you manage to escape the cave-in intact!`n"); } } output("`n`&Your close call scared you so badly that you cannot face any more opponents today.`n"); debuglog("`&has lost all turns for the day due to a close call in the mine."); $session['user']['turns'] = 0; } break; } } } }