function rationpack_use($args) { $full = get_module_pref("fullness", "staminafood"); if ($full >= 100) { output("You pick up the ration pack, and eye it for a moment. Then, you put it right back where it was. You're `ifar`i too full to eat anything more for now.`n`n"); unset($args['destroyafteruse']); unset($args['usetext']); return $args; } //debug($args); require_once "modules/staminasystem/lib/lib.php"; addstamina(100000); increment_module_pref("fullness", 40, "staminafood"); increment_module_pref("fat", 40, "staminafood"); increment_module_pref("nutrition", 30, "staminafood"); if ($full < 0) { output("You still feel as though you haven't eaten in days.`n`n"); } if ($full >= 0 && $full < 50) { output("You feel a little less hungry.`n`n"); } if ($full >= 50 && $full < 100) { output("You still feel as though you've got room for more!`n`n"); } if ($full >= 100) { output("You're stuffed! You feel as though you can't possibly eat anything more today.`n`n"); } return $args; }
function energydrink_use($args) { require_once "modules/staminasystem/lib/lib.php"; $full = get_module_pref("fullness", "staminafood"); if ($full >= 100) { output("You eye the bottle critically. Then, you put it right back where it was. You're `ifar`i too full to imbibe anything more for now.`n`n"); unset($args['destroyafteruse']); unset($args['usetext']); return $args; } addstamina(50000); increment_module_pref("fullness", 5, "staminafood"); $full = get_module_pref("fullness", "staminafood"); if ($full < 0) { output("You still feel as though you haven't eaten in days.`n`n"); } if ($full >= 0 && $full < 50) { output("You feel a little less hungry.`n`n"); } if ($full >= 50 && $full < 100) { output("You still feel as though you've got room for more!`n`n"); } if ($full >= 100) { output("You're stuffed! You feel as though you can't possibly eat anything more today.`n`n"); } return $args; }
function wcgpoints_newdaystamina_dohook($hookname, $args) { global $session; switch ($hookname) { case "wcgpoints_increased": if ($args['newpoints'] > 1) { set_module_pref("daysleft", 5); output("`0World Community Grid has updated your statistics, and you now have five game days of extra Stamina!`n`n"); } break; case "stamina-newday": if (get_module_pref("daysleft")) { output("`0Because you're helping to combat suffering with World Community Grid, your starting Stamina has been increased by ten per cent!`n`n"); increment_module_pref("daysleft", -1); output("You have %s days of enhanced Stamina left. The counter is reset to five every time World Community Grid updates your statistics, which usually happens once every 24 hours.`n`n", get_module_pref("daysleft")); require_once "modules/staminasystem/lib/lib.php"; addstamina(100000); } break; case "wcg-features-desc": output("`bStamina Boost`b: every time World Community Grid reports that you've earned some Cobblestones, you'll get an extra 10% of Stamina for five Game Days.`n`n"); break; } return $args; }
function pub_newpittsburgh_drinks_dohook($hookname, $args) { global $session; $drinks = array("brainhem" => array("price" => 35, "verbosename" => "Brain Hemorrhage"), "monstermash" => array("price" => 50, "verbosename" => "Monster Mash"), "specialsauce" => array("price" => 65, "verbosename" => "Special Sauce")); switch ($hookname) { case "pub_newpittsburgh_bartender": if ($session['user']['race'] == "Robot") { if ($session['user']['sex']) { $lovelad = "lad"; } else { $lovelad = "love"; } $args['text']['hello'] = "George looks you up and down, eyes sliding over your smooth glass skin. \"`2You're a Robot, aren't you, " . $lovelad . "?`0\"`n`n\"`#That I am. Are you going to tell me that you don't serve my type in here?`0\"`n`n\"`2On the contrary, Chuck, we'd be `ivery`i pleased to cater to our Robot customers, but we just don't have the power, y'see. Setting up one of those fancy lamps just takes more amps than our genny can kick out. You ask most of the pubs on the Island, it's the same way.`0\"`n`n\"`#I see.`0\"`n`n\"`2We've got games, though. And telly. You're more than welcome here, it's just...`0\" he shrugs his shoulders and spreads his hands. \"`2I don't have anything to sell you that you'd want to buy.`0\"`n`n`#Fair enough`0, you suppose."; } else { $args['drinks'] = $drinks; } break; case "pub_newpittsburgh_drink": $drink = httpget("drink"); switch ($drink) { case "brainhem": $session['user']['gold'] -= 35; output("\"`2All right Chuck,`0\" says George, bringing up a jar of pickled brains. They look far too small to be human, even pickled - perhaps the size of rabbit brains. The wrinkled grey things bob peacefully around as George carefully pours a measure of the fluid into a shot glass with the help of a funnel.`n`nThe liquid smells a lot like embalming fluid.`n`nTastes like it, too, albeit with a nice alcoholic glow.`n`n"); output("You feel `2Energetic!`0`n`n"); apply_buff('pub_newpittsburgh_brainhem', array("name" => "`2Brain Hemorrhage Fuzzies", "rounds" => 15, "defmod" => 1.12, "roundmsg" => "Thanks to your Brain Hemorrhage Fuzzies, your defensive movements are more fluid!", "wearoff" => "You feel the effects of the Brain Hemorrhage fade away.", "schema" => "pub_newpittsburgh")); require_once "modules/staminasystem/lib/lib.php"; addstamina(5000); break; case "monstermash": $session['user']['gold'] -= 50; output("George hands you a tall glass filled with artfully-swirled monster grey matter, garnished with a jolly little paper umbrella and a slice of brainstem.`n`n"); if ($session['user']['race'] != "Zombie") { output("You take a sip. It's... honestly, it's awful. It tastes like a mix of chicken and beef fat, raw eggs, and blood. Lots of blood. Not meaning to be impolite you knock the glass back quickly, trying to ignore the cold, semi-solid lumps slowly sliding over your tongue and curling down your throat.`n`n"); output("You feel `4Sick and Grumpy!`0`n`n"); apply_buff('pub_newpittsburgh_monstermash', array("name" => "`2Monster Mash Grumps", "rounds" => 25, "atkmod" => 1.2, "roundmsg" => "`4The awful Zombie drink makes you feel `\$aggressive!", "wearoff" => "`4You feel the effects of the Monster Mash fade away. Thank goodness for that.", "schema" => "pub_newpittsburgh")); require_once "modules/staminasystem/lib/lib.php"; addstamina(5000); } else { output("You down the contents and lick your lips.`n`n"); output("You feel `2Energetic!`0`n`n"); require_once "modules/staminasystem/lib/lib.php"; addstamina(10000); increment_module_pref("nutrition", 5, "staminafood"); apply_buff('pub_newpittsburgh_monstermash', array("name" => "`2Monster Mash", "rounds" => 25, "atkmod" => 1.2, "defmod" => 1.1, "roundmsg" => "`2The Monster Mash burns warmly in your stomach. Both your attack and defence are increased!", "wearoff" => "`2The Monster Mash warmth has faded. Oh well.", "schema" => "pub_newpittsburgh")); } break; case "specialsauce": $session['user']['gold'] -= 65; output("George pours you a short glass full of something from a thick blue bottle. It's the only thing on the menu that doesn't mention brains, though you wonder if the odd blue liquid wasn't distilled from them. It smells vaguely of formaldehyde, but has enough of a tongue-numbing alcoholic kick that you don't regret ordering it.`n`n"); output("You feel `2Warm!`0`n`n"); apply_buff('pub_newpittsburgh_specialsauce', array("name" => "`2Special Sauce Warmth", "rounds" => 30, "defmod" => 1.25, "atkmod" => 1.25, "roundmsg" => "That Zombie drink was awesome! It's like time's slowed down!", "wearoff" => "You feel the effects of the Special Sauce fade away.", "schema" => "pub_newpittsburgh")); break; } break; } return $args; }
function pub_kittania_drinks_dohook($hookname, $args) { global $session; $drinks = array("cider" => array("price" => 25, "verbosename" => "Vegetable Cider"), "tiggerbalm" => array("price" => 40, "verbosename" => "Tigger Balm")); switch ($hookname) { case "pub_kittania_bartender": if ($session['user']['race'] == "Robot") { $args['text']['hello'] = "Miu-Miu blinks. \"`2Oh, I'm sorry love - we don't have anything for our, um...`0\" she struggles for a moment. \"`2Our... organically-challenged - I mean our CPU-enhanced...`0\"`n`n\"`#You can say \"Robot,\" you know. It's not taboo.`0\"`n`n\"`2Right you are, then,`0\" says Miu-Miu, visibly relieved. \"`2But we `ihave`i got plenty of sun, and you're welcome to sit by the window if you want to charge yourself up, I suppose.`0\"`n`n\"`#Thank you. I may take you up on that.`0\"`n`n\"`2Is there anything else I can help you with, love?`0\"`n`n"; } else { $args['drinks'] = $drinks; } break; case "pub_kittania_drink": $drink = httpget("drink"); switch ($drink) { case "cider": $session['user']['gold'] -= 25; output("\"`2All right love,`0\" says Miu-Miu, setting down the glass in front of you. She leans forward and murmurs \"`2D'you want a mouse in that, petal?`0\"`n`n"); if ($session['user']['race'] == "KittyMorph") { output("You grin, canines peeking out. Miu-Miu smiles back before reaching under the counter, bringing up a small white mouse by its tail.`n`nThere were days when the custom would be to play with it for a while before dunking it in the cider, but these are more civilised times. The mouse struggles for precisely one second, then floats serenely with a cross-eyed grin, tiny bubbles rising from its nose. You knock back the cider and mouse before the bubbles reach the surface, as is the custom of your people these days. As the mouse slides down your gullet, you wonder idly if political correctness has gone too far. It's only a bloody `imouse.`i`n`nThere's a tiny jerk inside your stomach. You grin at Miu-Miu. \"`#I love it when they hiccup.`0\"`n`n"); } else { output("You give Miu-Miu a long, thoughtful stare. \"`#`iNo,`i`0\" you say, politely but firmly.`n`n\"`2Fair enough, love, fair enough. Enjoy.`0\"`n`nThe cider tastes vaguely of apples and grass.`n`n"); } output("You feel `2Energetic!`0`n`n"); apply_buff('pub_kittania_cider', array("name" => "`2Warm Cider Fuzzies", "rounds" => 15, "defmod" => 1.1, "roundmsg" => "Thanks to your Warm Cider Fuzzies, your defensive movements are more fluid!", "wearoff" => "You feel the effects of the Vegetable Cider fade away.", "schema" => "pub_kittania")); require_once "modules/staminasystem/lib/lib.php"; addstamina(5000); break; case "tiggerbalm": $session['user']['gold'] -= 40; if ($session['user']['race'] != "KittyMorph") { output("Miu-Miu raises an eyebrow and gives you an appraising look, before shrugging and pouring a shot of thick green liquid. \"`2You look big enough to handle it, so where's the harm, I suppose... but you want to be careful with that stuff,`0\" she says. \"`2Strictly speaking I'm only supposed to sell it to `ino don't knock it back in one`i - oh, never mind.`0\"`n`nA dribble of burning, herbal-tasting green fluid runs down your chin. \"`#Gleeshuck,\"`0 you say, as your left eye slowly rotates towards the ceiling.`n`n"); output("You feel `4Violent!`0`n`n"); apply_buff('pub_kittania_tiggerbalm', array("name" => "`2Tigger Balm Shakes", "rounds" => 25, "atkmod" => 1.4, "defmod" => 0.8, "roundmsg" => "`4The Tigger Balm Shakes make you feel more `\$aggressive!", "wearoff" => "`4You feel the Tigger Balm Shakes fade away. Thank goodness for that.", "schema" => "pub_kittania")); require_once "modules/staminasystem/lib/lib.php"; addstamina(6000); } else { output("You sip gently at the thick, herbal-tasting green fluid. The fluid is cold, but feels pleasantly warm as it goes down.`n`n"); output("You feel `2Energetic!`0`n`n"); require_once "modules/staminasystem/lib/lib.php"; addstamina(7000); apply_buff('pub_kittania_tiggerbalm', array("name" => "`2Tigger Balm Warmth", "rounds" => 25, "atkmod" => 1.2, "defmod" => 1.1, "roundmsg" => "`2The Tigger Balm burns warmly in your stomach. Both your attack and defence are increased!", "wearoff" => "`2The Tigger Balm warmth has faded. Oh well.", "schema" => "pub_kittania")); } break; } break; } return $args; }
function iitems_dwelling_reconstructor_dohook($hookname, $args) { global $session; switch ($hookname) { case "iitems-use-item": if ($args['player']['itemid'] == "dwelling_reconstructor") { require_once "modules/iitems/lib/lib.php"; require_once "modules/staminasystem/lib/lib.php"; iitems_give_item('toolbox_decorating'); iitems_give_item('toolbox_carpentry'); iitems_give_item('toolbox_masonry'); addstamina(1.0E+27); set_module_pref("encounterchance", 0, "worldmapen"); $session['user']['gems'] += 100; output("One octillion Stamina points added. Toolboxes for masonry, carpentry and decorating added. 100 Cigarettes added. World Map encounter rate reduced to zero. Have fun with that.`n`n"); } break; } return $args; }
function iitems_stamina_dohook($hookname, $args) { global $session; switch ($hookname) { case "iitems-use-item": if ($args['master']['stamina_add']) { require_once "modules/staminasystem/lib/lib.php"; addstamina($args['master']['stamina_add']); } else { if ($args['master']['stamina_remove']) { require_once "modules/staminasystem/lib/lib.php"; removestamina($args['master']['stamina_remove']); } } break; case "iitems-superuser": output("`bIItems: Stamina Support`b`n"); output("`bstamina_add`b - add or remove Stamina points.`n`n"); break; } return $args; }
function meatsystem_run() { global $session; require_once "modules/staminasystem/lib/lib.php"; page_header("Meat!"); addnav("Meat Skills"); $from = httpget('from'); switch (httpget('op')) { case "devour": //special ability for Zombies only - Zombies can eat raw meat, so we're giving them the ability to simply devour the carcass where it lies. $carcasses = unserialize(get_module_pref("carcasses")); if (!is_array($carcasses)) { $carcasses = array(); } debug($carcasses); foreach ($carcasses as $carcassnum => $creatureid) { $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " "; $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400); $creature = db_fetch_assoc($result); output("Giving in to your primal urges, you lean down and begin ripping meat from the still-twitching %s with your teeth.`n`n", $creature['creaturename']); $meat1 = get_module_objpref("creatures", $creatureid, "meat1"); $meat2 = get_module_objpref("creatures", $creatureid, "meat2"); $meat3 = get_module_objpref("creatures", $creatureid, "meat3"); for ($i = 0; $i < $meat1; $i++) { increment_module_pref("nutrition", 1, "staminafood"); increment_module_pref("fat", 3, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); addstamina(1000); } for ($i = 0; $i < $meat2; $i++) { increment_module_pref("nutrition", 2, "staminafood"); increment_module_pref("fat", 2, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); addstamina(2000); } for ($i = 0; $i < $meat3; $i++) { increment_module_pref("nutrition", 3, "staminafood"); increment_module_pref("fat", 1, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); addstamina(5000); } output("For the record, and since it's nice to know these things even if you're too busy tearing cartilage and muscle from the bone to really pay attention to them, in this meal you have eaten %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n", $meat1, $meat2, $meat3); $full = get_module_pref("fullness", "staminafood"); if ($full < 0) { output("You still feel as though you haven't eaten in days.`n`n"); } if ($full >= 0 && $full < 50) { output("You feel a little less hungry.`n`n"); } if ($full >= 50 && $full < 100) { output("You still feel as though you've got room for more!`n`n"); } if ($full >= 100) { output("You're stuffed! You feel as though you can't possibly eat anything more today.`n`n"); } unset($carcasses[$carcassnum]); set_module_pref("carcasses", serialize($carcasses)); } break; case "clean": $creatureid = httpget('creatureid'); $carcass = httpget('carcass'); $meat1 = get_module_objpref("creatures", $creatureid, "meat1"); $meat2 = get_module_objpref("creatures", $creatureid, "meat2"); $meat3 = get_module_objpref("creatures", $creatureid, "meat3"); $amber = get_stamina(); $return = process_action("Cleaning the Carcass"); if ($return['lvlinfo']['levelledup'] == true) { output("`n`c`b`0You gained a level in Cleaning Carcasses! You are now level %s! This action will cost fewer Stamina points now, so you can butcher more creatures each day!`b`c`n", $return['lvlinfo']['newlvl']); } $failchance = e_rand(0, 100); if ($failchance > $amber) { //failure - the nice meat gets turned into Crap Meat $meat1 += $meat2; $meat1 += $meat3; output("`4You sit down to clean the carcass. Your exhausted, clumsy incisions make a mockery of the choicest cuts - what is left over can only be described as Crap Meat. %s bite's-worth, to be precise. It looks like it was hacked into chunks by a blind woodsman.", $meat1); //todo for ($i = 0; $i < $meat1; $i++) { give_item("meat_low", false, false, true); } load_inventory(); $carcasses = unserialize(get_module_pref("carcasses")); unset($carcasses[$carcass]); $carcasses = array_values($carcasses); set_module_pref("carcasses", serialize($carcasses)); } else { //success - all meat is sorted output("You spend a few minutes up to your elbows in gore, and getting rather hungry.`n"); if ($meat1 > 0) { output("You tear off enough to make %s rough bite's-worth of what the locals affectionately call Crap Meat. It's mostly wobbling chunks of stinking yellow fat, intermingled with the occasional squirmy tendon.`n", $meat1); } if ($meat2 > 0) { output("You make swift work of the fattier muscle, and before too long you have %s rough bite's-worth of Half-Decent Meat.`n", $meat2); } if ($meat3 > 0) { output("The red, tender slivers of muscle slide easily from the bone, and you wind up with %s rough bite's-worth of Tasty Meat.`n", $meat3); } //todo for ($i = 0; $i < $meat1; $i++) { give_item("meat_low", false, false, true); } for ($i = 0; $i < $meat2; $i++) { give_item("meat_medium", false, false, true); } for ($i = 0; $i < $meat3; $i++) { give_item("meat_high", false, false, true); } load_inventory(); $carcasses = unserialize(get_module_pref("carcasses")); unset($carcasses[$carcass]); $carcasses = array_values($carcasses); set_module_pref("carcasses", serialize($carcasses)); $pmeat1 = has_item("meat_low"); $pmeat2 = has_item("meat_medium"); $pmeat3 = has_item("meat_high"); if (($pmeat1 || $pmeat2 || $pmeat3) && $session['user']['race'] != "Robot") { if (get_module_pref("fullness", "staminafood") < 100) { $cookcost = stamina_getdisplaycost("Cooking"); addnav(array("Cook up some meat (`Q%s%%`0)", $cookcost), "runmodule.php?module=meatsystem&op=cook&from=" . $from); } else { addnav("You're too full to cook, let alone eat", ""); } } } break; case "cook": $pmeat1qty = has_item_quantity("meat_low"); $pmeat2qty = has_item_quantity("meat_medium"); $pmeat3qty = has_item_quantity("meat_high"); output("You whip out your camping stove. It's time to cook!`n`nWhat will you put in the pan? You can fit up to 20 bite's-worth of meat in there. Right now you have %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n`n", $pmeat1qty, $pmeat2qty, $pmeat3qty); rawoutput("<form action='runmodule.php?module=meatsystem&op=cookfinal&from=" . $from . "' method='POST'>"); rawoutput("Put in <input name='meat1' width='2' value='0'> bite's-worth of Crap Meat.<br />"); rawoutput("Put in <input name='meat2' width='2' value='0'> bite's-worth of Half-Decent Meat.<br />"); rawoutput("Put in <input name='meat3' width='2' value='0'> bite's-worth of Tasty Meat.<br />"); rawoutput("<input type='submit' class='button' value='" . translate_inline("Cook!") . "'>"); rawoutput("</form>"); addnav("", "runmodule.php?module=meatsystem&op=cookfinal&from=" . $from); break; case "cookfinal": $pmeat1qty = has_item_quantity("meat_low"); $pmeat2qty = has_item_quantity("meat_medium"); $pmeat3qty = has_item_quantity("meat_high"); $meat1 = httppost("meat1"); $meat2 = httppost("meat2"); $meat3 = httppost("meat3"); //check for the dumbass player cooking meat that they don't have if ($meat1 > $pmeat1qty || $meat2 > $pmeat2qty || $meat3 > $pmeat3qty) { output("You don't `ihave`i that much meat!`n`n"); addnav("Whoops"); addnav("Sorry, I forgot how to count for a second there. Let's try this again.", "runmodule.php?module=meatsystem&op=cook&from=" . $from); break; } //check for the dumbass player inputting a negative number if ($meat1 < 0 || $meat2 < 0 || $meat3 < 0) { page_header("Either taking vegetarianism to whole new levels, or trying to grow meat from an empty pan"); output("You want to cook `inegative`i meat? How very Zen of you.`n`n"); addnav("You sneaky bugger"); addnav("Abandon your efforts to produce the opposite of meat and try again, pretending that you weren't just trying to cheat.", "runmodule.php?module=meatsystem&op=cook&from=" . $from); break; } //check for the dumbass player trying to put too much meat in the pan $totalmeat = $meat1 + $meat2 + $meat3; if ($totalmeat > 20) { output("Your pan can't hold that much meat, pal.`n`n"); addnav("Whoops"); addnav("Try again, without filling the pan up so much", "runmodule.php?module=meatsystem&op=cook&from=" . $from); break; } //check for the dumbass player trying to cook no meat at all $totalmeat = $meat1 + $meat2 + $meat3; if ($totalmeat == 0) { output("You start the process of cooking up your tasty meat. After a few minutes of poking around in your pan, growing hungrier by the second, you realise that you've forgotten something.`n`n"); addnav("Whoops"); addnav("Try again, with meat this time", "runmodule.php?module=meatsystem&op=cook&from=" . $from); break; } //Stamina interaction, including consequences and level-up details. $amber = get_stamina(); $return = process_action("Cooking"); if ($return['lvlinfo']['levelledup'] == true) { output("`n`c`b`0You gained a level in Cooking! You are now level %s! This action will cost fewer Stamina points now, so you can cook more tasty meals each day!`b`c`n", $return['lvlinfo']['newlvl']); } $failchance = e_rand(0, 100); if ($failchance > $amber) { output("`4You put your meat into the pan, and sit down to stir-fry it. The hypnotic motion and white-noise sizzling, combined with your tiredness, sends you staring into space. While your concentration is impaired, the meat bursts into flames. You jerk back into awareness, and look down sadly at the flaming chunks. Bummer."); for ($i = 0; $i < $meat1; $i++) { delete_item(has_item("meat_low")); } for ($i = 0; $i < $meat2; $i++) { delete_item(has_item("meat_medium")); } for ($i = 0; $i < $meat3; $i++) { delete_item(has_item("meat_high")); } break; } //we can now assume that the player is not some sort of cheating reprobate, or trying to cook while dog-tired, and do some cooking! for ($i = 0; $i < $meat1; $i++) { increment_module_pref("nutrition", 1, "staminafood"); increment_module_pref("fat", 3, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); delete_item(has_item("meat_low")); addstamina(1000); } for ($i = 0; $i < $meat2; $i++) { increment_module_pref("nutrition", 2, "staminafood"); increment_module_pref("fat", 2, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); delete_item(has_item("meat_medium")); addstamina(2000); } for ($i = 0; $i < $meat3; $i++) { increment_module_pref("nutrition", 3, "staminafood"); increment_module_pref("fat", 1, "staminafood"); increment_module_pref("fullness", 1, "staminafood"); delete_item(has_item("meat_high")); addstamina(5000); } output("You fry up your lovely meaty loveliness, and sit down to eat. You gain some Stamina!`n`n"); $full = get_module_pref("fullness", "staminafood"); if ($full < 0) { output("You still feel as though you haven't eaten in days.`n`n"); } if ($full >= 0 && $full < 50) { output("You feel a little less hungry.`n`n"); } if ($full >= 50 && $full < 100) { output("You still feel as though you've got room for more!`n`n"); } if ($full >= 100) { output("You're stuffed! You feel as though you can't possibly eat anything more today.`n`n"); } break; } $carcasses = unserialize(get_module_pref("carcasses")); if (!is_array($carcasses)) { $carcasses = array(); } if (count($carcasses) > 0) { output("You look at the spoils of your most recent battle. They lie bloodied and broken on the ground. What will you do with them?"); foreach ($carcasses as $carcassnum => $creatureid) { $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " "; $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400); $creature = db_fetch_assoc($result); $cleancost = stamina_getdisplaycost("Cleaning the Carcass"); addnav(array("Clean the carcass of %s (`Q%s%%`0)", $creature['creaturename'], $cleancost), "runmodule.php?module=meatsystem&op=clean&creatureid=" . $creatureid . "&carcass=" . $carcassnum . "&from=" . $from); } } else { if (httpget('op') != "cook" && httpget('op') != "cookfinal") { output("Now only bloody bones lie strewn around the area.`n`n"); } } addnav("Ah, screw it."); if ($from == "forest") { addnav("Return to the Jungle", "forest.php"); } else { if ($from == "world") { addnav("Return to the World Map", "runmodule.php?module=worldmapen&op=continue"); } } page_footer(); return true; }
function staminafood_run() { global $session; $pmeat1 = has_item_quantity("meat_low"); $pmeat2 = has_item_quantity("meat_medium"); $pmeat3 = has_item_quantity("meat_high"); addnav("Eat"); switch (httpget("op")) { case "sellmeat": switch ($session['user']['location']) { case "NewHome": page_header("Joe's Diner"); if (httpget('q') == 1) { delete_item(has_item("meat_medium")); $session['user']['gold'] += 5; output("With a surly grunt, Joe grabs your meat and slaps down five Requisition tokens.`n`n"); } else { for ($i = 1; $i <= $pmeat2; $i++) { delete_item(has_item("meat_medium")); $session['user']['gold'] += 5; } output("With a surly grunt, Joe grabs your meat and slaps down %s Requisition tokens.`n`n", $pmeat2 * 5); } break; case "New Pittsburgh": page_header("BRAAAAAINS"); if (httpget('q') == 1) { delete_item(has_item("meat_medium")); $session['user']['gold'] += 6; output("With a nod, the waiter takes your meat and hands back six Requisition tokens.`n`n"); } else { for ($i = 1; $i <= $pmeat2; $i++) { delete_item(has_item("meat_medium")); $session['user']['gold'] += 6; } output("With a nod, the waiter takes your meat and hands back %s Requisition tokens.`n`n", $pmeat2 * 6); } break; case "Kittania": page_header("Cool Springs Cafe"); if (httpget('q') == 1) { delete_item(has_item("meat_high")); $session['user']['gold'] += 12; output("With a warm smile, the waitress takes your meat and hands back twelve Requisition tokens.`n`n"); } else { for ($i = 1; $i <= $pmeat3; $i++) { delete_item(has_item("meat_high")); $session['user']['gold'] += 12; } output("With a warm smile, the waitress takes your meat and hands back %s Requisition tokens.`n`n", $pmeat3 * 12); } break; case "Squat Hole": page_header("Kebabs 'N' S***e"); if (httpget('q') == 1) { delete_item(has_item("meat_low")); $session['user']['gold'] += 2; output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back two Requisition tokens.`n`n"); } else { for ($i = 1; $i <= $pmeat1; $i++) { delete_item(has_item("meat_low")); $session['user']['gold'] += 2; } output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back %s Requisition tokens.`n`n", $pmeat1 * 2); } break; } break; case "start": switch (httpget("location")) { case "nh": page_header("Joe's Diner"); output("`0You head into what presents itself as a 1950's-style diner. Plastic red and white gingham patterns cover every available surface. Tomato-shaped ketchup bottles are dotted on tables here and there, dried gunge crusting their nozzles. Behind the bar can be seen Joe, the owner, who is keeping himself busy wiping down the counter tops with a rag, redistributing the half-inch-thick layer of grease into a more uniform level. A sign above the counter reads \"`2WE BUY MEAT. WE PAY 5 REQ PER 120 GRAM'S.`0\"`n`n"); if ($session['user']['race'] != "Robot") { output("The smell of fried onions does its wicked work, and you glance up at the menu.`n`n"); if (get_module_pref("fullness") <= 100) { if ($session['user']['gold'] >= 10) { addnav("Crisps (10 Req)", "runmodule.php?module=staminafood&op=buy&bought=1"); } else { output("After a careful read of the menu, you realise that you can't afford a single thing on it. Bah."); } if ($session['user']['gold'] >= 40) { addnav("Garden Salad (40 Req)", "runmodule.php?module=staminafood&op=buy&bought=2"); } if ($session['user']['gold'] >= 50) { addnav("Plate of Chips (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=3"); addnav("Coffee (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=4"); } if ($session['user']['gold'] >= 150) { addnav("Bangers & Mash (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=5"); } if ($session['user']['gold'] >= 300) { addnav("Cheeseburger (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=6"); } } else { output("You are far too full to eat any more today.`n`n"); } } if ($pmeat2) { output("You remember that Maiko told you that the NewHome diner will only buy middling-quality meat. You have %s pieces of average-quality meat to sell. All of them, quite conveniently - perhaps a little TOO conveniently - weigh exactly a hundred and twenty grams each.`n`n", $pmeat2); addnav("Sell Meat"); addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1"); if ($pmeat2 > 1) { addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all"); } } break; case "ki": page_header("Cool Springs Cafe"); output("You head into what at first appears to be a little hut. As you work down the stairs into the rock underneath Kittania, you realise that this place is so much more.`n`nStrings of fairy lights illuminate the cavern, and soft trickling sounds can be heard against the laughter and conversation of KittyMorphs around you.`n`nYou take a seat and a white-furred KittyMorph approaches, a menu in her hand. \"Welcome to the Cool Springs Cafe,\" she says with a smile. \"We try to tread on Mother Earth as lightly as we can, in here; all of our produce is locally-grown, you'll find a wonderful selection of vegetarian and vegan meals, and the various waters come from the three springs that run through this very cavern. Now, what can I get you?\"`n`nYou peruse the menu, your eyes lingering on the last entry, detailing a rare, dripping, bloody steak. The KittyMorph follows your gaze, and laughs sheepishly. \"Like I said, we `itry`i,\" she giggles, elongated canines peeking out. \"We `iare`i carnivores, you know. Oh, on that note, I should mention that we also buy meat, if you've got any of the good stuff to sell. We pay twelve Requisition per slice.\"`n`n"); if ($session['user']['race'] != "Robot") { if (get_module_pref("fullness") <= 100) { if ($session['user']['gold'] >= 50) { addnav("Hot Chocolate (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=7"); addnav("White Spring Water (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=8"); } else { output("After a careful read of the menu, you realise that you can't afford a single thing on it. Bah."); } if ($session['user']['gold'] >= 100) { addnav("Nut and Berry Salad (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=9"); } if ($session['user']['gold'] >= 175) { addnav("Turquoise Spring Water (175 Req)", "runmodule.php?module=staminafood&op=buy&bought=10"); } if ($session['user']['gold'] >= 250) { addnav("Red Spring Water (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=11"); } if ($session['user']['gold'] >= 500) { addnav("Still-Twitching Steak (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=12"); } } else { output("You are far too full to eat any more today.`n`n"); } } if ($pmeat3) { output("You remember that Maiko told you that the Kittania cafe will only buy the best-quality meat. You have %s pieces of high-quality meat to sell.`n`n", $pmeat3); addnav("Sell Meat"); addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1"); if ($pmeat3 > 1) { addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all"); } } break; case "np": page_header("BRAAAAAINS"); output("You head into the local cafe, imaginatively titled \"BRAAAAAINS\". A waiter comes shuffling over to you, green skin peeling from his face. \"BRAAAAAINS?\" he asks, holding out a menu.`n`nA sign above the counter says \"We are only too happy to buy your surplus meat. We pay 6 Requisition tokens per 120 grams.\"`n`n"); if ($session['user']['race'] != "Robot") { if (get_module_pref("fullness") <= 100) { if ($session['user']['gold'] >= 50) { addnav("Egg and Brains (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=13"); } else { output("After a careful read of the menu, you realise that you can't afford a single thing on it. Bah."); } if ($session['user']['gold'] >= 100) { addnav("Sausage and Brains (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=14"); } if ($session['user']['gold'] >= 150) { addnav("Spam and Brains (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=15"); } if ($session['user']['gold'] >= 200) { addnav("Egg, Brains, Sausage and Brains (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=16"); } if ($session['user']['gold'] >= 250) { addnav("Brains, Spam, Brains, Sausage and Brains (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=17"); } if ($session['user']['gold'] >= 300) { addnav("Brains, Brains, Brains, Brains and Spam (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=18"); } } else { output("You are far too full to eat any more today.`n`n"); } } if ($pmeat2) { output("You remember that Maiko told you that the New Pittsburgh diner will only buy middling-quality meat. You have %s pieces of average-quality meat to sell. All of them, quite conveniently - perhaps a little TOO conveniently - weigh a hundred and twenty grams each.`n`n", $pmeat2); addnav("Sell Meat"); addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1"); if ($pmeat2 > 1) { addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all"); } } break; case "sq": page_header("Kebabs 'N' S***e"); output("You head into the local kebab house. As you're studying the menu, a Midget brushes past you, dragging a six-foot blue plastic bag with the words \"INCINERATE ONLY\" stencilled on the side. He stops, glares up at you, and mutters \"Yer din't see `inuffink.`i\" Then he resumes his journey, dragging the bag into the back of the shop. You're sure you saw a bit of steering wheel poking out.`n`nA sign above the counter reads \"WE BY MEET 2 REK PER BIT\"`n`n"); if ($session['user']['race'] != "Robot") { if (get_module_pref("fullness") <= 100) { if ($session['user']['gold'] >= 20) { addnav("Crisps (20 Req)", "runmodule.php?module=staminafood&op=buy&bought=25"); } else { output("After a careful read of the menu, you realise that you can't afford a single thing on it. Bah."); } if ($session['user']['gold'] >= 50) { addnav("Skinheads on a Raft (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=26"); } if ($session['user']['gold'] >= 75) { addnav("Doner Kebab (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=27"); addnav("Crimson Pitbull (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=28"); } if ($session['user']['gold'] >= 150) { addnav("C**k Nuggets (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=29"); } if ($session['user']['gold'] >= 200) { addnav("Sausage Feast Pizza (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=30"); } } else { output("You are far too full to eat any more today.`n`n"); } } if ($pmeat1) { output("You remember that Maiko told you that the Squat Hole kebab shop only buys the sort of meat that the dog food factory would throw away. You have %s wobbling chunks of Crap Meat to sell.`n`n", $pmeat1); addnav("Sell Meat"); addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1"); if ($pmeat1 > 1) { addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all"); } } break; case "pl": page_header("Mutated Munchies"); if ($session['user']['race'] != "Robot") { output("You head into the local cafe. The stench of vomit and disinfectant hangs in the air. Bravely, you sit down at a table and peruse the menu.`n`n"); if (get_module_pref("fullness") <= 100) { if ($session['user']['gold'] >= 100) { addnav("Wriggly Biscuits (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=19"); } else { output("After a careful read of the menu, you realise that you can't afford a single thing on it. Bah."); } if ($session['user']['gold'] >= 200) { addnav("Phallic Nuts (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=20"); } if ($session['user']['gold'] >= 300) { addnav("Noodly Noodles (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=21"); } if ($session['user']['gold'] >= 400) { addnav("Three-Eyed Fish (400 Req)", "runmodule.php?module=staminafood&op=buy&bought=22"); } if ($session['user']['gold'] >= 500) { addnav("Magical Mystery Meatloaf (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=23"); } if ($session['user']['gold'] >= 750) { addnav("Mutant Steak (750 Req)", "runmodule.php?module=staminafood&op=buy&bought=24"); } } else { output("You are far too full to eat any more today.`n`n"); } } else { output("You are a robot, and this place doesn't buy meat. You have no business here. Out with you!`n`n"); } break; } break; case "buy": page_header("Om nom nom"); require_once "modules/staminasystem/lib/lib.php"; switch (httpget("bought")) { case 1: output("You munch happily on your crisps, reflecting that they're probably not too good for you - but hell, at least they're cheap.`n`nYou gain some Stamina!"); $st = 5000; $nu = 5; $fa = 10; $fu = 5; $co = 10; break; case 2: output("You pick the snails out of your Garden Salad, and tuck in.`n`nYou gain some Stamina!"); $st = 18000; $nu = 15; $fa = 0; $fu = 10; $co = 40; break; case 3: output("You wolf down your plate of chips. They're like little brown paper bags filled with pus, but damn it, you paid good money for these and you're going to eat them come Hell or high water.`n`nYou gain some Stamina!"); $st = 25000; $nu = 20; $fa = 30; $fu = 25; $co = 50; break; case 4: output("The coffee swirls grittily down your throat. You feel like you have more energy!"); apply_stamina_buff('newhomedinercoffee', array("name" => "Caffeine Rush", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "Your Caffeine Rush makes everything a little bit easier!", "wearoffmsg" => "The effects of the caffeine seem to have worn off.")); $co = 50; break; case 5: output("It's not so much Bangers and Mash as Mingers and Mush, but you get stuck in anyway.`n`nYou gain some Stamina!"); $st = 105000; $nu = 40; $fa = 30; $fu = 40; $co = 150; break; case 6: output("You can has cheeseburger! Well, it's not so much \"cheese\" as \"unidentifiable bright orange goo\", but I'm sure you'll live.`n`nYou gain some Stamina!"); $st = 225000; $nu = 60; $fa = 40; $fu = 25; $co = 300; break; case 7: output("You sip your hot chocolate, listening to the babbling brooks. Life ain't so bad.`n`nYou gain some Stamina!"); $st = 25000; $nu = 10; $fa = 10; $fu = 15; $co = 50; break; case 8: output("There's something very odd about the water from the White Spring. You feel light on your feet. It seems to make everything easier, somehow."); apply_stamina_buff('whitespringwater', array("name" => "White Spring Lightness", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the White Spring seem to be making everything a little easier.", "wearoffmsg" => "The White Spring effects seem to have worn off.")); $co = 50; break; case 9: output("You scarf down your salad of nuts and berries, secretly wishing for a nice juicy steak.`n`nYou gain some Stamina!"); $st = 65000; $nu = 25; $fa = 5; $fu = 10; $co = 100; break; case 10: output("The water from the Turquoise Spring is served at room temperature, but somehow tastes very cold. After a few moments, your eyesight improves; you can make out individual facets of a crystal buried in the far wall of the cavern. This should make it a bit easier to hunt down monsters!"); apply_stamina_buff('turquoisespringwater', array("name" => "Turquoise Sight", "class" => "Hunting", "costmod" => 0.5, "expmod" => 1, "rounds" => 3, "roundmsg" => "Thanks to your heightened senses granted by the waters of the Turquoise Spring, hunting for monsters seems a lot easier now.", "wearoffmsg" => "The effects of the Turquoise Spring water have worn off, and your senses return to their usual state.")); $co = 175; break; case 11: output("You down the water from the Red Spring. There's a distinct taste of iron in there. After a few moments, you become anxious - surely there must be something around here that you can engage in combat..."); apply_stamina_buff('redspringwater', array("name" => "Red Haze", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the Red Spring make fighting seem more natural and fluid. You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Red Spring water have worn off, and your senses return to their natural state.")); $co = 250; break; case 12: output("The menu described a still-twitching steak, and boy, it delivered. Steam rises from the plate of raw muscle in front of you. The meat jerks and spasms as it reacts to the sudden flood of oxygen, slapping gently against the plate. Your mouth waters, and you can see some nearby KittyMorphs glancing jealously in your direction. You wolf it down before they get any ideas.`n`nYou gain some Stamina!"); $st = 385000; $nu = 100; $fa = 10; $fu = 80; $co = 500; break; case 13: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 25000; $nu = 10; $fa = 10; $fu = 10; $co = 50; break; case 14: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 65000; $nu = 20; $fa = 20; $fu = 20; $co = 100; break; case 15: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 105000; $nu = 30; $fa = 30; $fu = 30; $co = 150; break; case 16: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 145000; $nu = 40; $fa = 40; $fu = 40; $co = 200; break; case 17: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 185000; $nu = 50; $fa = 50; $fu = 50; $co = 250; break; case 18: output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!"); $st = 225000; $nu = 60; $fa = 60; $fu = 60; $co = 300; break; case 19: output("You chew thoughtfully on your Wriggly Biscuits. They live up to their name quite adequately.`n`nYou gain some Stamina!"); $st = 65000; $nu = 20; $fa = 10; $fu = 10; $co = 100; break; case 20: output("You run your tongue lovingly up, down and around the extremely phallic nuts, savouring their delightfully salty flavour.`n`nYou gain some Stamina!"); $st = 145000; $nu = 40; $fa = 10; $fu = 20; $co = 200; break; case 21: output("The Noodly Noodles jerk and spasm, each bite releasing a sticky yellow goo. Tasty!`n`nYou gain some Stamina!"); $st = 225000; $nu = 40; $fa = 10; $fu = 20; $co = 300; break; case 22: output("You stare down at your three-eyed fish. It stares back up at you, in ways that you can only imagine. After a few moments of depressed contemplation, you tuck in - and hey, it's actually not that bad.`n`nYou gain some Stamina!"); $st = 305000; $nu = 50; $fa = 25; $fu = 40; $co = 400; break; case 23: output("As your fork sinks into your Magical Mystery Meatloaf, a hundred pairs of eyes open on its crispy skin. They close again almost instantly, and you try your hardest to persuade yourself that you were hallucinating from the disinfectant fumes - it beats reality, that's for damn sure.`n`nYou gain some Stamina!"); $st = 385000; $nu = 50; $fa = 25; $fu = 50; $co = 500; break; case 24: output("The Mutant Steak is lean, delicious, nutritious and as big as your head! What a pleasant surprise!`n`nYou gain some Stamina!"); $st = 585000; $nu = 150; $fa = 10; $fu = 80; $co = 750; break; case 25: output("You grimace, and call over to the midget behind the counter. \"These taste like someone tried to make bacon flavour crisps and failed, badly.\"`n`n\"Read the fookin' packet, dick'ead!\"`n`nYou do as he says. Ah. Tumour flavour. Nice.`n`nYou gain some Stamina!"); $st = 10000; $nu = 5; $fa = 10; $fu = 5; $co = 20; break; case 26: output("Skinheads on a Raft turned out to be beans on toast. You're not sure whether to be relieved.`n`nYou gain some Stamina!"); $st = 25000; $nu = 20; $fa = 20; $fu = 15; $co = 50; break; case 27: //Potential for expansion: have the kebab taste better if the player's drunk, have the player find a wedding ring that he can sell for Req, etc. output("You scarf down your doner kebab, stopping occasionally to pick out the occasional toenail or piece of car dashboard. It's pretty fatty, and would taste a lot better if you were drunk, but you make do.`n`nYou gain some Stamina!"); $st = 65000; $nu = 20; $fa = 40; $fu = 20; $co = 75; break; case 28: output("You knock back your Crimson Pitbull, which turned out to be some sort of energy drink.`n`nYou feel aggressive!"); apply_stamina_buff('crimsonpitbull', array("name" => "Bark of the Crimson Pitbull", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The harsh, chemically-sweet taste of the Crimson Pitbull lurks in the back of your throat. You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Crimson Pitbull have worn off, and your senses return to their natural state.")); $co = 75; break; case 29: output("C**k Nuggets turned out to be chicken nuggets, only with a little more fowl language.`n`n...`n`n...sorry.`n`nYou gain some Stamina!"); $st = 145000; $nu = 30; $fa = 60; $fu = 25; $co = 150; break; case 30: output("The Sausage Feast turned out to be less sausage, and more fat, but hey, it's cheap and it tastes halfway decent.`n`nYou gain some Stamina!"); $st = 185000; $nu = 40; $fa = 80; $fu = 50; $co = 200; break; } addstamina($st); increment_module_pref("nutrition", $nu); increment_module_pref("fat", $fa); increment_module_pref("fullness", $fu); $full = get_module_pref("fullness"); if ($full < 0) { output("`n`nYou still feel as though you haven't eaten in days."); } if ($full >= 0 && $full < 50) { output("`n`nYou feel a little less hungry."); } if ($full >= 50 && $full < 100) { output("`n`nYou still feel as though you've got room for more!"); } if ($full >= 100) { output("`n`nYou're stuffed! You feel as though you can't possibly eat anything more today."); } $session['user']['gold'] -= $co; break; } debug(get_module_pref("fat")); debug(get_module_pref("nutrition")); addnav("Exit"); addnav("Return to the Outpost", "village.php"); page_footer(); }
function example_run() { //Yup, we're still gonna need that $session array! global $session; //If we don't declare a page header - IE a title for the page - then the page simply won't load. At all. The player will be left staring at a blank white screen and muttering "What muppet coded this?" Never forget! page_header("Do the Three-Door Shuffle!"); //We need to retrieve, from the database, the pref for whether or not the player's played today. We'll need it soon. Let's assign it to a variable - it'll save typing later on, and make the size of this file smaller. While we're at it, let's get the other pref as well. $playedtoday = get_module_pref("playedtoday"); $playedtotal = get_module_pref("playedtotal"); //httpget lets us grab a part of the page's URL. The first time the player encounters this module, they'll go to "improbableisland.com/runmodule.php?module=example[which is the filename of the module without the .php bit, remember]" - note the conspicuous absence of 'op' in there. As they move through the pages, they'll go to "improbableisland.com/runmodule.php?module=example&op=[something]". It's that [something] that we want to get! We traditionally call the variable 'op' which is short for 'operation,' but you can call it whatever you like. You can even get fancy and use multiple httpget requests for more complex modules with addresses like "improbableisland.com/runmodule.php?module=breaktheserver&action=breakitagain&weapon=axe&target=harddrive&force=allofitbabyyeah", but this module's just about the basics. //Oh, and you remember "switch", right? You met earlier. switch (httpget('op')) { default: //We're talking now about an instance where there is no 'op' in the page's URL. This must mean that the player's on the first page of the module. let's set the scene! //Our first output statement! This is like echo, but it's actually a special function built into Legend of the Green Dragon which will put in our colour codes and make sure we're not doing anything silly. output("`0Some old Joker geezer shows you three doors, and says that there's something nice or nasty behind each one. Whatever, we'll put some proper flavour text in here later. This module would `inever`i have gotten past CavemanJoe with flavour text this lame. God, he's such an asshole. Good thing he won't be reading this.`n`nAnyway, we're using tilde-n for new lines. Just testin' that. And when we want to output something in quotation marks, we have to escape it with a slash, like this:`n`n\"`3Come and look in my doors!`0\" shouts the old geezer. Traditionally characters' colour codes will change only inside their quotation marks, descriptive text will usually be black, and the player's text will usually have colourcode #. So, you've got three doors in front of you; now whatcha gonna do about it? HUH?`n`n"); //Now, let's see how to add in a variable in an output statement... Damn, I'm making this sound a lot more complicated than it actually is. Just read it, it'll be quicker than me trying to explain it. We use %s as placeholders for our variables. output("You've played a total of %s times.`n`n", $playedtotal); //If we want to do more than one variable in an output statement, we basically just use more %s's and more commas: output("I SAID, you've played a total of %s times. That's %s times!`n`n", $playedtotal, $playedtotal); //You remember if statements, right? Of course you do. if ($playedtoday == 0) { //They haven't played today, so let's give them some links to click. addnav("Open the first door!", "runmodule.php?module=example&op=door1"); addnav("Open the second door!", "runmodule.php?module=example&op=door2"); addnav("Open the third door!", "runmodule.php?module=example&op=door3"); } else { //give them an unclickable link that goes nowhere! addnav("I'm not gonna do jack, pal. I've already done this today.", ""); } break; case "door1": //The player went for the first door. Now, let's give the first door a fifty-fifty chance of something nice versus something nasty. //Gimme a random number between one and a hundred, and we'll call it $chance: $chance = e_rand(1, 100); //is the random number less than or equal to fifty? if ($chance <= 50) { //yes, the random number is less than or equal to fifty. Output some flavour text! output("You've won some gold OH MY GOODNESS I MEAN REQUISITION. Proper flavour text for that picky bastard Admin CavemanJoe.`n`n"); //Give the player five gold pieces, because the game doesn't know that we call gold Requisition! That'll help them in their quest to slay the dragon I MEAN THE IMPROBABILITY DRIVE $session['user']['gold'] += 5; } else { //$chance is NOT equal to or less than fifty. In other words, it's 51 or more! output("A midget steals some Requisition or something.`n`n"); //Oh dear - what happens if the player has LESS than 5 Requisition? They'll get a negative number showing in their stats bar! It'll get sorted out back to zero on their next page load, but in the meantime it just looks ugly! So, we'll do another IF statement. This one's fairly self-explanatory: if ($session['user']['gold'] >= 5) { $session['user']['gold'] -= 5; } else { $session['user']['gold'] = 0; } } //What are we forgetting? The player has played today, so we must update their pref so they can't play again! set_module_pref("playedtoday", 1); //Now, we'll increase the number of times they've played by one. increment_module_pref("playedtotal", 1); //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead. //and that's the end of door number one! break; case "door2": //door one was a bit boring. A bit low-stakes. A bit dull. Let's play with the numbers and liven things up a bit. $chance = e_rand(1, 100); if ($chance <= 10) { output("You open the door and a cigarette falls out, followed by two hundred and fifty Requisition tokens! How very Improbable.`n`n"); $session['user']['gems']++; $session['user']['gold'] += 250; //Yes, cigarettes were originally gems in Legend of the Green Dragon! } else { //Since getting a cigarette AND a couple of hundred Req is a pretty awesome prize, we're only giving it a ten per cent chance of appearing. The other ninety times out of a hundred, the Cake or Death guy shows up and gives you some poisoned cake. This code is lifted pretty well straight out of the code for Cake or Death. //The Cake or Death man doesn't exactly KO the player. When you KO a player, you have to mess about with taking away all their navs and making sure they end up on the FailBoat's Daily News page, and it's a bit of a pain in the bum. So I like to just poison the crap out of them instead! :D output("You open the door to find a green-eyed gentleman standing behind it. He hands you a slice of cake, on a paper plate! You thank him, and walk away merrily wolfing down your prize.`n`nYou feel `5Full Of Cake!`0`n`nMoments later, the slow-acting poison starts to take effect. The world begins to melt in front of you. Grey spots dance on the edges of your vision. Behind you, a green-eyed monster offers you another slice of cake, laughing and pointing.`n`nYou curse your luck as the hallucinations begin to kick in."); //We're gonna do an example buff now. I could type about this all night, but you can learn more about buffs at http://wiki.dragonprime.net/index.php?title=Buffs. apply_buff('failcake', array("name" => "`5Full Of FailCake`0", "rounds" => -1, "regen" => -10, "startmsg" => "`5You are walking on pink icing. The sky is made of jam. Your eyes are two cherries. That cake was awesome.`0`n", "roundmsg" => "`5The poisoned cake saps your strength, and you lose ten hitpoints!`0`n", "schema" => "module-cakeordeath")); } //What are we forgetting? The player has played today, so we must update their pref so they can't play again! set_module_pref("playedtoday", 1); //Now, we'll increase the number of times they've played by one. increment_module_pref("playedtotal", 1); //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead. //We're done with Door Two! break; case "door3": //in Door 3 we'll be interacting with my Stamina system. The Stamina system isn't part of Legend of the Green Dragon - in LotGD, and in Improbable Island prior to Season Two, we used Turns instead. I've designed the Stamina system to be very easy to use! Adding and removing Stamina is a piece of cake - just use the functions addstamina(x); or removestamina(x);, where x is the number of Stamina points to add or remove. //since the Stamina system is in itself a (rather large) module and not part of the core, whenever we want to use it we've got to tell the game to find its lib file so it knows what we're talking about when we use its functions. So, let's do that: require_once "modules/staminasystem/lib/lib.php"; //Now we can get on with it, knowing that our functions for interacting with Stamina are already loaded. $chance = e_rand(1, 100); //We'll make this door rather a nice door. Most of the time, anyway. if ($chance <= 90) { output("You open the door and a soft white light envelopes you. You feel mildly energized. You gain some Stamina!`n`n"); addstamina(5000); //See how easy that was? } else { //But every now and then, this door will be an absolute bastard. output("You open the door and a huge round boulder comes rolling out! You lose a whole load of Stamina running away from it, until you gain the common sense to just step out of its way!`n`n"); removestamina(50000); //We don't even need to check if the player has 50,000 Stamina points to take away, because the Stamina system is clever and checks for us! } //What are we forgetting? The player has played today, so we must update their pref so they can't play again! set_module_pref("playedtoday", 1); //Now, we'll increase the number of times they've played by one. increment_module_pref("playedtotal", 1); //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead. //And that's it for door number three! break; } //Now, we're at the end of our possible decisions and outcomes. Because we're out of the switch, we can add in some things that we'll always need, in this module anyway. We'll give the player a link to take them back to the player-created modules area, so that they can get out of this module, and we'll call page_footer so that all of this information is displayed to the player. addnav("Go back where you came from", "runmodule.php?module=labs"); //If we don't call page_footer, none of what we've just coded up will be shown to the player! This is just as important as page_header! page_footer(); //...and we're done! I hope you've enjoyed reading along in this module and learning about programming for Improbable Island and Legend of the Green Dragon! //So, what can you do with what you already know? Well, how about modifying this very file? Here are some things for you to try: //1. (easy) Add a fourth door. That should be pretty easy! But what to put behind it? Maybe it can give different sorts of buffs? The Buffs page in the DragonPedia will help you. Use your imagination! //2. (easyish) Right now, that counter is just a counter, nothing more. Surely we could do something interesting with that! Maybe, after playing the game more than x number of times, a fifth or even sixth door will become available? //3. (harder) Maybe the number of times the game has been played can affect the player's luck? How would you do that? //4. (harder) By adding another pref in the moduleinfo function, we can make this module more complex and exciting. A simple boolean pref could, for example, determine whether a player has an item or not - a key to the seventh door, for example... //Have fun! }
function improbablestuff_run() { global $session; $from = httpget("from"); $use = httpget("use"); page_header("Using Supplies"); if ($use == "smallmedkit") { $session['user']['hitpoints'] += 20; if ($session['user']['hitpoints'] > $session['user']['maxhitpoints']) { $session['user']['hitpoints'] = $session['user']['maxhitpoints']; } output("You take a few moments to patch yourself up using a Small Medkit. Your hitpoints have been restored to %s.", $session[user][hitpoints]); set_module_pref("item1number", get_module_pref("item1number") - 1); } if ($use == "largemedkit") { $session['user']['hitpoints'] += 60; if ($session['user']['hitpoints'] > $session['user']['maxhitpoints']) { $session['user']['hitpoints'] = $session['user']['maxhitpoints']; } output("You take a few moments to patch yourself up using a Large Medkit. Your hitpoints have been restored to %s.", $session[user][hitpoints]); set_module_pref("item2number", get_module_pref("item2number") - 1); } if ($use == "energydrink") { increment_module_pref("nutrition", 5, "staminafood"); require_once "modules/staminasystem/lib/lib.php"; addstamina(25000); set_module_pref("item3number", get_module_pref("item3number") - 1); output("You unscrew the cap on your Energy Drink and gulp it down.`n`nYou gain some Stamina!"); } if ($use == "nicotinegum") { $addiction = get_module_pref("addiction", "smoking"); $betweensmokes = 250 - $addiction; set_module_pref("betweensmokes", $betweensmokes, "smoking"); apply_buff("smoking", array("allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-smoking")); set_module_pref("item4number", get_module_pref("item4number") - 1); output("You chomp down on your Nicotine Gum, and you feel the addiction shakes fade away."); } if ($use == "repellantspray") { $encounter = get_module_pref("encounterchance", "worldmapen"); $buffvalue = get_module_pref("repellantbuff"); $encounter -= 25; $buffvalue -= 10; $buffvalue = $buffvalue / 100; if ($encounter < 0) { $encounter = 0; } apply_buff('is5', array("name" => "`^Repellant Spray", "rounds" => -1, "badguyatkmod" => $buffvalue, "badguydefmod" => $buffvalue, "roundmsg" => "{badguy} can't stand the smell of your Monster Repellant Spray, and doesn't want to get too close!", "wearoff" => "The effects of your Monster Repellant Spray seem to have worn off...`n", "schema" => "module-improbablestuff")); set_module_pref("encounterchance", $encounter, "worldmapen"); set_module_pref("repellantbuff", $buffvalue); set_module_pref("item10number", get_module_pref("item10number") - 1); output("You liberally douse yourself with an entire can of Monster Repellant Spray. For the rest of this game day, your chances of encountering a monster on the Island Map have been reduced by twenty-five per cent, and monsters you do encounter will be reluctant to attack you. Your current encounter rate is %s percent of normal, which can be affected by terrain type and other factors. You can continue soaking your skin and clothes in more cans of the stuff if you like!", $encounter); } if ($use == "potentpill") { apply_buff('is4', array("startmsg" => "`#After swallowing your Power Pill, you feel immediately revitalised! You gain some Stamina and you are now regenerating some hitpoints!`n", "name" => "`^Power Pill", "rounds" => 10, "regen" => "ceil(<maxhitpoints>/10)+1;", "effectmsg" => "The effects of the Power Pill heal you for {damage} points.", "wearoff" => "The Power Pill effects have worn off.`n", "schema" => "module-improbablestuff")); set_module_pref("item5number", get_module_pref("item5number") - 1); output("After swalling your Power Pill, you feel immediately revitalised! You gain some Stamina and will regenerate hitpoints for the next ten rounds of battle!`n"); require_once "modules/staminasystem/lib/lib.php"; addstamina(250000); } if ($use == "rationpack") { require_once "modules/staminasystem/lib/lib.php"; output("You tear open the foil packaging and look inside.`n`nAfter a few moments' contemplation, you let out the heartbroken sigh of every soldier with an empty belly and a full Rat Pack.`n`nThe material inside has been designed to withstand being thrown out of a plane, bounced down a mountain, encased in snow and ice, left out in the sun and/or buried in a swamp for up to three years. It contains all the essential nutrients required for a soldier to live on for several weeks without dying of malnutrition. It even comes with dessert in the form of a chocolate bar - one that, according to rumour, has saved the lives of several contestants. Not for its nutritional value, of which there is none, but for its remarkable bullet-stopping tensile strength.`n`nYou suck thoughtfully on the corner of the material. Before long it begins to react with your saliva, breaking up and yielding to your teeth, and rewarding you some Stamina as you begin the arduous process of digestion.`n`nIt beats starving. Just."); increment_module_pref("item11number", -1); increment_module_pref("fullness", 40, "staminafood"); increment_module_pref("nutrition", 30, "staminafood"); increment_module_pref("fat", 10, "staminafood"); addstamina(100000); $full = get_module_pref("fullness", "staminafood"); if ($full < 0) { output("`n`nYou still feel as though you haven't eaten in days."); } if ($full >= 0 && $full < 50) { output("`n`nYou feel a little less hungry."); } if ($full >= 50 && $full < 100) { output("`n`nYou still feel as though you've got room for more!"); } if ($full >= 100) { output("`n`nYou're stuffed! You feel as though you can't possibly eat anything more today."); } } if ($use == "teleporter") { $to = httpget("to"); if ($to == "") { if (httpget("bomb") == 1) { output("You light the fuse on your Improbability Bomb. Before you have the chance to toss it at your enemy, it writhes and shifts in your hand, turning into a One-Shot Teleporter - with its relocation matrix already enabled! "); } else { output("You press the Big Red Button on your One-Shot Teleporter. "); } output("One obligatory blinding flash of light and pain later, you find yourself floating around in empty black nothingness!`n`nA flashing red light and an annoying BEEPing noise from your device insists that you select a destination, and quickly, before you find yourself stuck here or imploded."); set_module_pref("item6number", get_module_pref("item6number") - 1); $vloc = array(); $vname = getsetting("villagename", LOCATION_FIELDS); $vloc[$vname] = "village"; $vloc = modulehook("validlocation", $vloc); ksort($vloc); reset($vloc); foreach ($vloc as $loc => $val) { addnav(array("Go to %s", $loc), "runmodule.php?module=improbablestuff&use=teleporter&to=" . htmlentities($loc)); } } else { output("You quickly select an outpost from the list. With a sudden jolt, you find yourself standing in the middle of your chosen outpost! You look around for your teleporting device, but realise that it must have only teleported you, not itself. What a piece of junk."); $session['user']['location'] = $to; $session['user']['specialinc'] = ""; addnav("Back to the Outpost", "village.php"); } } if ($use == "kittencard") { //expansion, possibly for S3 - more types of kittens for variable Favour rewards. Ginger ones are her favourite. output("`0You nervously hold out the greetings card. `\$The Watcher`0 looks down at your offering.`n`nShe smiles, taking the card and placing it neatly on her desk with the others. \"`7Aren't you just `iadorable`i?`0\" she says. You're not sure whether she's talking about you or the kitten.`n`nYou gain `\$30`0 Favour with `\$The Watcher!`0`n`n"); $session['user']['deathpower'] += 30; increment_module_pref("item13number", -1); addnav("Yay for kittens!", "graveyard.php?op=question"); } //Send them back where they came from if ($from == "village") { addnav("Back to the Outpost", "village.php"); } if ($from == "forest") { addnav("Back to the Jungle", "forest.php"); } if ($from == "worldnav") { addnav("Back to the World Map", "runmodule.php?module=worldmapen&op=continue"); } page_footer(); return $args; }
// if (isset($charstat_info['Extra Info']) && isset($charstat_info['Extra Info']['Free Travel'])){ // unset($charstat_info['Extra Info']['Free Travel']); // } //Look at the number of Turns we're missing. Default is ten, and we'll add or remove some Stamina depending, as long as we're not in a fight. if (get_module_setting("turns_emulation_base") != 0) { if (!isset($badguy)) { $stamina = e_rand(get_module_setting("turns_emulation_base"), get_module_setting("turns_emulation_ceiling")); while ($session['user']['turns'] < 10) { $session['user']['turns']++; debug("Turns Removed"); removestamina($stamina); } while ($session['user']['turns'] > 10) { $session['user']['turns']--; debug("Turns Added"); addstamina($stamina); } } } if (!isset($charstat_info['Recent Actions'])) { //Put yer thing down, flip it an' reverse it $yarr = array_reverse($charstat_info); $yarr['Recent Actions'] = array(); $charstat_info = array_reverse($yarr); } if (isset($actions_used)) { foreach ($actions_used as $action => $vals) { if (!$actions_used[$action]['lvlinfo']['currentlvlexp']) { $actions_used[$action]['lvlinfo']['currentlvlexp'] = 1; } $pct = ($actions_used[$action]['lvlinfo']['exp'] - $actions_used[$action]['lvlinfo']['currentlvlexp']) / ($actions_used[$action]['lvlinfo']['nextlvlexp'] - $actions_used[$action]['lvlinfo']['currentlvlexp']) * 100;
<?php global $session; $hid = httpget('hid'); $rid = httpget('rid'); require_once "modules/improbablehousing/lib/lib.php"; $house = improbablehousing_gethousedata($hid); page_header("Cheat"); addnav("Cheat!"); addnav("Cheat a new room", "runmodule.php?module=improbablehousing&op=cheat&sub=newroom&hid={$hid}&rid={$rid}"); addnav("Cheat a blank house", "runmodule.php?module=improbablehousing&op=cheat&sub=resethouse&hid={$hid}&rid={$rid}"); addnav("Cheat loads of Stamina", "runmodule.php?module=improbablehousing&op=cheat&sub=stamina&hid={$hid}&rid={$rid}"); switch (httpget('sub')) { case "stamina": output("Adding stamina"); require_once "modules/staminasystem/lib/lib.php"; addstamina(10000000); break; case "newroom": output("You've started a new build job to create a new room. Have at it!`n`n"); $newjob = array("name" => "New Room Construction", "jobs" => array(0 => array("name" => "Add wood", "iitems" => array("wood" => 1, "toolbox_carpentry" => 1), "actions" => array("Carpentry" => 1), "req" => 2, "done" => 0, "desc" => "You set about hammering and sawing. Before too long, the new room is one step closer to completion."), 1 => array("name" => "Add stone", "iitems" => array("stone" => 1, "toolbox_masonry" => 1), "actions" => array("Masonry" => 1), "req" => 2, "done" => 0, "desc" => "You set about chiseling and tinkering. Before too long, the new room is one step closer to completion.")), "completioneffects" => array("newrooms" => array(0 => array("name" => "Extension", "enterfrom" => $rid, "size" => 1, "desc" => "You're standing in a small, undecorated extension room.", "sleepslots" => array(0 => array("name" => "Floor space", "stamina" => 50000), 1 => array("name" => "Floor space", "stamina" => 50000)))), "msg" => "The new room is now complete!")); $house['data']['buildjobs'][] = $newjob; break; case "resethouse": output("House reset to blank."); $house['data'] = array("rooms" => array(0 => array("name" => "Main Room", "size" => 1, "desc" => "You're standing in a small, undecorated room.", "sleepslots" => array(0 => array("name" => "Floor space", "stamina" => 50000), 1 => array("name" => "Floor space", "stamina" => 50000)))), "name" => "One-room dwelling belonging to " . $session['user']['name'], "desc_exterior" => "You see a single-room dwelling belonging to " . $session['user']['name']); break; } improbablehousing_sethousedata($house); improbablehousing_bottomnavs($house); page_footer();
function donationextend_dohook($hookname, $args) { global $session; switch ($hookname) { case "donation": require_once "lib/gamelog.php"; gamelog("Donation registered by donationextend"); $amt = $args['amt']; $id = $args['id']; $kitty = get_module_setting("kitty"); $newkitty = $kitty + $amt; set_module_setting("kitty", $newkitty); //set last player if (!get_module_pref("user_shy", "donationextend", $id)) { $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='{$id}'"; $result = db_query_cached($sql, "donationextend_lastdonator", 300); $row = db_fetch_assoc($result); $name = $row['name'] . "`0"; set_module_setting("lastdonator", $name); } else { set_module_setting("lastdonator", "Anonymous"); } break; case "everyfooter": //debug($args,true); // Set up and decrement the kitty require_once "lib/bars.php"; $last = get_module_setting("lasttick"); $ext1 = get_module_setting("extend1cost"); $player = get_module_setting("lastdonator"); $player = appoencode(stripslashes($player)); $elapsed = time() - $last; $dropped = 0; $droppertenseconds = get_module_setting("extend1cost") / 8640; if ($elapsed > 10) { $dropped = $droppertenseconds; } $oldkitty = get_module_setting("kitty"); $newkitty = $oldkitty - $dropped; if ($newkitty < 0) { $newkitty = 0; } //set up display output $out = ""; $sql = "SELECT count(acctid) AS c FROM " . db_prefix("accounts") . " WHERE locked=0"; $result = db_query_cached($sql, "donationextend_totalplayers", 1800); $row = db_fetch_assoc($result); $totalplayers = $row['c']; if ($newkitty > $ext1) { $ext2 = get_module_setting("extend2cost"); if ($newkitty > $ext2) { $over = $newkitty - $ext2; $bar = simplebar($over, $ext2, 70, 5, "AA00AA", "FFFFFF"); $overdisp = number_format($over / 100, 2); //represent as time left to end of Special Extend period $droppersec = get_module_setting("extend1cost") / 86400; $secsleft = round($over / $droppersec); $expirationtime = time() + $secsleft; require_once "lib/datetime.php"; $expirein = reltime($expirationtime, false); $out .= "<span style='font-size:smaller'><strong>Special Extend active!</strong><br />" . $bar . "Thank you for your support! Special Extend expires in " . $expirein . "<br /><a href='runmodule.php?module=donationextend' target='_blank' onclick=\"" . popup("runmodule.php?module=donationextend") . ";return false;\">(what's a Special Extend?)</span></a>"; } else { $moreneeded = $ext2 - $newkitty; $bar = simplebar($newkitty - $ext1, $ext2 - $ext1, 70, 5, "00FF00", "AA00AA"); $moredisp = number_format($moreneeded / 100, 2); $out .= "<span style='font-size:smaller'><strong>Extended Play active!</strong><br />" . $bar . "\$" . $moredisp . " more for <a href='runmodule.php?module=donationextend' target='_blank' onclick=\"" . popup("runmodule.php?module=donationextend") . ";return false;\">Special Extend</a>!</span>"; } } else { $moreneeded = $ext1 - $newkitty; $moredisp = number_format($moreneeded / 100, 2); $bar = fadebar($newkitty, $ext1, 57); $perplayer = $moreneeded / 100 / $totalplayers; if ($perplayer > 1) { $perplayerdisp = "about " . round($moreneeded / $totalplayers, 4) . " cents per player"; } else { $perplayerdisp = "about \$" . number_format($moreneeded / 100 / $totalplayers, 2) . " per player"; } $out .= $bar; if ($newkitty > 0) { $out .= "<span style='font-size:smaller'>\$" . $moredisp . " more (" . $perplayerdisp . ") for <a href='runmodule.php?module=donationextend' target='_blank' onclick=\"" . popup("runmodule.php?module=donationextend") . ";return false;\">Extended Play</a>!</span>"; } else { if ($session['user']['loggedin']) { $out .= "<span class='colDkRed'><strong>The kitty is empty!</strong></span> Improbable Island is entirely dependant on your donations to survive. When the meter is empty, the Island and its creators are in trouble! Someone please chuck a couple of bucks in the hat!"; } } } global $template; //debug($template); if (strpos($template['footer'], "{paypal_extras}")) { //if (isset($template['{paypal_extras}'])){ //debug("Yes!"); $rep = "paypal_extras"; } else { //debug("No!"); $rep = "paypal"; } //$rep = "paypal_extras"; //insert display output into page if (!array_key_exists($rep, $args) || !is_array($args[$rep])) { $args[$rep] = array(); } array_push($args[$rep], $out); //write values back to database if ($elapsed > 10) { set_module_setting("lasttick", time()); set_module_setting("kitty", $newkitty); } //debug($args,true); addcharstat("Misc"); addcharstat("Misc", "testing testing woohoo!"); break; case "stamina-newday": $kitty = get_module_setting("kitty"); if ($kitty >= get_module_setting("extend1cost")) { require_once "modules/staminasystem/lib/lib.php"; $bonus = get_module_setting("extend1amt"); if ($kitty > get_module_setting("extend2cost")) { $bonus += get_module_setting("extend2amt"); output("`0Because Improbable Island's players have been especially generous, today is a `b`5Special Extended Play`0`b day - you `2gain`0 some Stamina!`n`n"); } else { output("`0Because Improbable Island's server costs and advertising budget have been covered quite nicely by donations, today is an `b`2Extended Play`0`b day - you `2gain`0 some Stamina!`n`n"); } if ($session['user']['donation'] > 0) { $bonus = $bonus * 2; } addstamina($bonus); } break; } return $args; }
function rail_surprise_dohook($hookname, $args) { global $session; switch ($hookname) { case "newday": set_module_pref("staminatoday", 0); set_module_pref("reqstoday", 0); set_module_pref("cigstoday", 0); set_module_pref("peddlertoday", 0); break; case "ironhorse-onboard": switch (e_rand(1, 5)) { case 1: // we can have flavor text output("`2Soft gaslight illuminates the red leather, brass fittings, and rich walnut paneling of the luxurious passenger coach. On the pillars between the windows curious painted scenes are framed in gold-leaf scrollwork.`0`n`n"); break; case 2: // we can give a small benefit output("`2A water-boy passes down the aisle, offering passengers cups of refreshing ice-water. You take a long cooling draught. Ahhh!`0`n`n"); // they can drink as much water as they like, but they only get the stamina benefit once if (!get_module_pref("staminatoday")) { require_once "modules/staminasystem/lib/lib.php"; addstamina(25000); set_module_pref("staminatoday", 1); output("`2Right away, you feel more energetic.`0`n`n"); } break; case 3: // ..or we can get a little more complicated output("`2Other passengers crowded onto the train at the last stop, jostling and laughing, swinging their backpacks up into the overhead luggage racks. Most of the seats are filled now... some choose to stand in the aisle. `0"); if (!get_module_pref("reqstoday")) { $sweets = e_rand(50, 150); if ($session['user']['gold'] + $session['user']['goldinbank'] <= $sweets) { // yes, even though she's senile she *can* sense the difference between a millionaire // with an empty wallet, and someone who's genuinely broke. $sweets = round($sweets * 1.1); output("`2A little old lady mistakes you for her grandson Albert. Despite your token protests, she presses %s requisition into your hands. \"`5For sweets,`2\" she insists.`0`n`n", $sweets); $session['user']['gold'] += $sweets; set_module_pref("reqstoday", 1); } else { if ($session['user']['gold'] > $sweets) { // and something different for the more prosperous who are carrying around cash $sweets = round($sweets * 0.5); output("`2Wait, something's wrong... Hey, your wallet is gone! Thieves! Pickpockets! Bastards!`n`nLuckily they didn't find your `ireal`i wallet. You only lost %s req.`0`n`n", $sweets); $session['user']['gold'] -= $sweets; set_module_pref("reqstoday", 1); } } } break; case 4: output("`2Tucked between the seat cushions you find a tattered yellow copy of the Enquirer. It's a very old issue -- the headline reads `b`6Season Two Announced`2`b, and turning to the Letters column you note a lively exchange about empty bottles, bugs, fish, nightclubs, and small princesses. The front page article mentions a Secret Feature Revealed: Scrapbots! Hrm.`0`n`n"); break; case 5: output("`2The clacking, the swaying, have an almost hypnotic effect. You find yourself wanting to nod off -- but there's no way you're going to get any sleep because some boisterous midgets at the far end of the car have started up a game of darts. One of them pins a crudely drawn paper target to the door at the other end, and with much raucous cursing and laughter they have a quick punch-up to see who goes first. Then the darts start flying, never mind the passengers in between.`0`n`n"); if ($session['user']['hitpoints'] == $session['user']['maxhitpoints']) { $session['user']['hitpoints'] = $session['user']['hitpoints'] - e_rand(1, 3); output("`2Sure enough, soon you feel the sting of a stray dart. \"`#Watch it, you little buggers!`2\" you snarl. \"`#It's not the Raven Inn here, you know!`2\"`0`n`n"); } break; // and so on, like that. Eventually there should be about 20 surprises. } break; case "railpeddler-hascase": if (e_rand(1, 30) == 1) { output("`2Among hurrying crowds in the concourse, a scruffy figure approaches a distant passer-by. At first the contestant shakes his head, then looks more interested. He digs out his tobacco pouch and receives something in exchange for a handful of cigarettes. You smile at the memory, patting your own fine leather card case."); // This section can be used to let the peddler dispense various rumors. } else { if (!get_module_pref("peddlertoday") && e_rand(1, 2) == 1) { output("Behind you a voice calls out, \"`2Best levver, best levver cases! Bloody `bbadass`b cases! Bleedin' ace! Brung in special fer yer, an' cheap at twice the price!`0\"`n`nWhen you turn around... hey, there's the scruffy peddler who sold you your fine leather card case.`n`n"); $hid = $args['hid']; $rid = $args['rid']; addnav("Talk to the peddler"); addnav("Ask about rumors", "runmodule.php?module=rail_surprise&op=rumors&hid={$hid}&rid={$rid}"); } } break; } return $args; }
<?php global $session; $rawpref = get_module_pref("sleepingat", "improbablehousing"); if ($rawpref != "nowhere") { debug("They slept in a house!"); $pref = unserialize($rawpref); require_once "modules/improbablehousing/lib/lib.php"; $hid = $pref['house']; $rid = $pref['room']; $slot = $pref['slot']; $house = improbablehousing_gethousedata($hid); if ($house['data']['rooms'][$rid]['sleepslots'][$slot]['occupier'] == $session['user']['acctid']) { require_once "modules/staminasystem/lib/lib.php"; $stam = $house['data']['rooms'][$rid]['sleepslots'][$slot]['stamina']; debug($stam); addstamina($stam); output("`0You got a good night's sleep - must have been the relative luxury of sleeping in a house. `b`2You gain some Stamina.`0`b`n`n"); } }
function rail_ironhorse_run() { global $session; $op = httpget("op"); $fromhid = httpget("hid"); $fromrid = httpget("rid"); $locs = rail_ironhorse_getlocs(); switch ($op) { case "board": page_header("On the Train!"); // Conductor walks through the train here if (rail_hascard("railpass_active") || rail_hascard("railpassfirst_active")) { // they already have a punched ticket - they're fine if (e_rand(1, 20) == 1) { output("`2The `@Conductor `2lurches through the train again, examining passes, taking bribes, exchanging familiar nods with the regular riders.`0`n`n"); } } else { if (rail_hascard("railpass") && rail_hascard("railpassfirst")) { // they have both - we have to ask them which they want to use output("`0The `@Conductor `0examines your passes. \"`2Why, you seem to have both regular and first class passes here. Which would you prefer to use today?`0\"`n`n"); addnav("Which pass will you use?"); addnav("Just the regular today, thanks", "runmodule.php?module=rail_ironhorse&op=choose&hid={$fromhid}&rid={$fromrid}&pass=reg"); addnav("It's first class for me, baby", "runmodule.php?module=rail_ironhorse&op=choose&hid={$fromhid}&rid={$fromrid}&pass=first"); page_footer(); break; } else { // they have one or the other but not both - we can punch automatically if (rail_hascard("railpass")) { // they have a regular pass output("`2The `@Conductor `2peers myopically at your Rail Pass and fumbles with a ticket punch. Ka-`btchik`b! Now you're free to ride the train as much as you want for the rest of the day!`0`n`n"); rail_ironhorse_activatepass("railpass"); } else { // they have a first class pass output("`2The `@Conductor `2inspects your First Class Rail Pass and deferentially produces a ticket punch. Ka-`btchik`b! Now you can ride `ifirst class`i for the rest of the day! Awesome!`0`n`n"); rail_ironhorse_activatepass("railpassfirst"); } } } $hookargs = array("hid" => $fromhid, "rid" => $fromrid); modulehook("ironhorse-onboard", $hookargs); set_module_pref("hasridden", 1); output("`2The wheels clatter, the car shakes with the astounding speed. Why, you must be going a good twenty-five miles an hour!`0`n`n"); addnav("Get off!"); foreach ($locs as $loc => $locarray) { if ($loc == "WA" || $loc == "DB") { } else { if ($locarray[0] == $fromhid) { addnav(array("`2Back to %s: `0%s", $loc, $locarray[2]), "runmodule.php?module=rail_ironhorse&op=leave&hid={$fromhid}&rid={$fromrid}&loc={$loc}"); } else { addnav(array("`2%s: `0%s", $loc, $locarray[2]), "runmodule.php?module=rail_ironhorse&op=leave&hid={$fromhid}&rid={$fromrid}&loc={$loc}"); } } } if (rail_hascard("railpassfirst_active")) { addnav("First Class"); addnav("Request Stop", "runmodule.php?module=rail_ironhorse&op=request&hid={$fromhid}&rid=fromrid"); } addcommentary(); viewcommentary("Riding the Train", "Shout over the engine's thunder:"); page_footer(); break; case "leave": page_header("You have reached your destination!"); rail_ironhorse_cleanup($fromhid); switch (e_rand(1, 200)) { // where are we leaving to? case 1: $loc = "WA"; break; case 2: $loc = "DB"; break; default: $loc = httpget("loc"); break; } $tohid = $locs[$loc][0]; $torid = $locs[$loc][1]; $house = improbablehousing_gethousedata($locs[$loc][0]); $tohousename = $house['data']['name']; set_module_pref("worldXYZ", $house['location'], "worldmapen"); set_module_pref("lastCity", $locs[$loc][3], "worldmapen"); $session['user']['location'] = "House: " . $tohousename . ", Room " . $torid . ""; output("`0The `@Conductor `0smiles toothily as you prepare to disembark. \"`2Thank-you for travelling with the `bImprobable Island Railway Company`b. Please don't forget to take all your luggage with you, and have an improbable day!`0\"`n`n"); output("`2%s`0`n`n", $locs[$loc][4]); addnav("Get off the train"); addnav(array("`2%s`0 Platform", $locs[$loc][2]), "runmodule.php?module=improbablehousing&op=interior&hid={$tohid}&rid={$torid}"); if (!($loc == "WA") && !($loc == "DB")) { addnav("Wait, I've changed my mind"); addnav("`2Stay `0 on board", "runmodule.php?module=rail_ironhorse&op=board&hid={$tohid}&rid={$torid}"); } else { output("`2You feel stronger after your pleasant train ride, and rather refreshed!`n`n`0"); if ($session['user']['hitpoints'] < $session['user']['maxhitpoints']) { $session['user']['hitpoints'] = $session['user']['maxhitpoints']; } else { $session['user']['hitpoints'] = $session['user']['hitpoints'] * 1.1; require_once "modules/staminasystem/lib/lib.php"; addstamina(25000); } } page_footer(); break; case "request": page_header("First Class has its privileges!"); output("`2As holder of an Improbable Island Railway Company `bFirst Class`b Rail Pass, you have the privilege of asking the train to let you off anywhere on the map. Yes, even in the deepest ocean, should that be your whim! This is, after all, an `iImprobable`i railway system; it can accomplish the seemingly impossible.`n`nSimply tell the `@Conductor `2where on the Island you would like to be dropped off.`0`n`n"); rawoutput("<form action='runmodule.php?module=rail_ironhorse&op=requestfinish&hid=" . $fromhid . "&rid=" . $fromrid . "' method='POST'>"); // Note: Width 2 means a 2-digit number. Set the default location to 13,11 Improbable Central. rawoutput("X = <input name='stopX' width='2' value='13'> , Y = <input name='stopY' width='2' value='11'><br/><br/>"); rawoutput("<input type='submit' class='button' value='" . translate_inline("Stop here!") . "'>"); rawoutput("</form>"); addnav("", "runmodule.php?module=rail_ironhorse&op=requestfinish&hid={$fromhid}&rid={$fromrid}"); addnav("Wait, I've changed my mind"); addnav("`2Stay `0 on board", "runmodule.php?module=rail_ironhorse&op=board&hid={$fromhid}&rid={$fromrid}"); page_footer(); break; case "requestfinish": page_header("First Class has its privileges!"); $x = httppost("stopX"); $y = httppost("stopY"); // strip out any non-numeric characters that got entered by mistake $x = ereg_replace("[^0-9]", "", $x); $y = ereg_replace("[^0-9]", "", $y); // make sure they entered values that are in range for the size of the map. $sizeX = get_module_setting("worldmapsizeX", "worldmapen"); $sizeY = get_module_setting("worldmapsizeY", "worldmapen"); if ($x <= 0 || $x > $sizeX || $y <= 0 || $y > $sizeY) { output("`2Sorry mate, stay on the map. Train service doesn't run outside the Improbability bubble. Nice try though.`0"); addnav("Oops!"); addnav("Let's try that again", "runmodule.php?module=rail_ironhorse&op=request&hid={$fromhid}&rid={$fromrid}"); } else { output("`0The `@Conductor `0smiles, all sleek and fangsome, as you prepare to disembark. \"`2Thank-you for travelling with the `bImprobable Island Railway Company`b. Please don't forget to take all your luggage with you, and have an improbable day!`0\"`n`n"); rail_ironhorse_cleanup($fromhid); $maploc = $x . "," . $y . ",1"; set_module_pref("worldXYZ", $maploc, "worldmapen"); addnav("Thanks!"); addnav("`2Leave `0 the train", "runmodule.php?module=worldmapen&op=continue"); } page_footer(); break; case "choose": $pass = httpget("pass"); if ($pass == "first") { rail_ironhorse_activatepass("railpassfirst"); } else { rail_ironhorse_activatepass("railpass"); } addnav("", "runmodule.php?module=rail_ironhorse&op=board&hid={$fromhid}&rid={$fromrid}"); redirect("runmodule.php?module=rail_ironhorse&op=board&hid={$fromhid}&rid={$fromrid}"); break; case "stationmaster": page_header("The Stationmaster"); $val = rail_collector_valuehand(); // note, we only get here if there's a joker in the hand, so only first class passes if ($val['value'] > 2) { $phrase = "that's quite a hand you have there. Quite a hand! I think in this case we could even stretch to `b" . $val['value'] . "`b First Class Rail Passes."; } else { if ($val['value'] > 1) { $phrase = "excellent. For that hand, we could easily give you `btwo`b First Class Rail Passes."; } else { $phrase = "no question about it, definitely a `bFirst Class Rail Pass`b."; } } output("`2Having heard that this eccentric railroad company will sometimes give out a rail pass in exchange for used playing cards, you show the Stationmaster your grubby little collection. \"`#Interested?`2\" you ask.`n`n\"`^Why yes. Those would be worth... let me see. Oh, %s`2\"`0`n`n", $phrase); addnav("What do you say?"); addnav("It's a deal!", "runmodule.php?module=rail_ironhorse&op=stationmasterdeal&hid={$fromhid}&rid={$fromrid}"); addnav("No thanks, I'll wait", "runmodule.php?module=improbablehousing&op=interior&hid={$fromhid}&rid={$fromrid}"); page_footer(); break; case "stationmasterdeal": page_header("The Stationmaster"); $val = rail_collector_valuehand(); for ($i = 0; $i < $val['value']; $i++) { give_item("railpassfirst"); } $qty = rail_collector_emptyhand(); output("`2The Stationmaster thanks you, and the two of you make the exchange to your mutual satisfaction. What on earth the Company `iwants`i with all those old playing cards... well. You've naturally wondered about that from time to time, but they're not saying.`0`n`n"); addnav("Leave"); addnav("Return to the platform", "runmodule.php?module=improbablehousing&op=interior&hid={$fromhid}&rid={$fromrid}"); page_footer(); break; } }
function rail_luckydip_run() { global $session; $op = httpget('op'); $hid = httpget('hid'); $rid = httpget('rid'); $cost = get_module_setting("cost"); $lcost = get_module_setting("lcost"); $tryallowed = get_module_setting("tryallowed"); $trytoday = get_module_pref("trytoday"); page_header("Roving Lucky Dip"); output("`&`c`bElias and his `2Lucky Dip`b`c`n"); switch ($op) { case "start": if ($trytoday >= $tryallowed) { output("`2Much as you'd like to play again, Elias only gives you a friendly nod and turns to the child beside you.`0`n`n"); addnav("Thank him"); } elseif ($session['user']['gold'] < $cost) { output("`n`2Much as you'd like to play, your wallet doesn't hold enough to pay for the privilege. Still, there's always time to exchange a few words.`0`n`n"); addnav("Smile and"); } else { output("`2You peer at the small colored packages with interest."); output("Elias stands behind the brightly-colored bins.`n`n"); output("`2\"`&Hello traveller! "); output("So you think yourself lucky? "); output("There are many treasures in these boxes!`2\"`n`n"); output("`2He motions to the smaller box, and then to the larger one. "); output("`&\"%s requisition for the small, %s for the large. ", $cost, $lcost); output("Who knows what you will find?`2\"`0`n`n"); addnav("Dip your hand"); addnav(array("Small (%s req)", $cost), "runmodule.php?module=rail_luckydip&op=small&hid={$hid}&rid={$rid}"); if ($session['user']['gold'] >= $lcost) { addnav(array("Large (%s req)", $lcost), "runmodule.php?module=rail_luckydip&op=large&hid={$hid}&rid={$rid}"); } } break; case "small": $binsize = "small"; case "large": if ($trytoday >= $tryallowed) { output("`2Much as you'd like to play again, Elias only gives you a friendly nod and turns to the child beside you.`0`n`n"); addnav("Thank him"); } elseif ($session['user']['gold'] < $cost) { output("`n`2Much as you'd like to play, your wallet doesn't hold enough to pay for the privilege. Still, there's always time to exchange a few words.`0`n`n"); addnav("Smile"); } else { $trytoday++; set_module_pref("trytoday", $trytoday); $gift = e_rand(1, 4); if ($binsize == "small") { $dipchance = e_rand(1, 25); $session['user']['gold'] -= $cost; // debuglog("spent $cost gold on a lucky dip."); output("`7You hand Elias your %s requisition, and reach one arm into the blue and white box. ", $cost); } else { $dipchance = e_rand(1, 50); // Elias has a warped sense of humour $session['user']['gold'] -= $lcost; // debuglog("spent $lcost gold on a lucky dip."); output("`2You hand Elias your %s requisition, and reach one arm into the red and white box. ", $lcost); } output("Dragging a package out, you unwrap it with excitement. "); output("Elias smiles.`n`n"); output("`2\"`&So you see, a treasure! "); if ($dipchance == 1) { output("A treasure indeed! "); output("I hope you shall keep it safe!`2\"`n`n"); if (rail_collector_findcard()) { output("`2In your hands is a `6playing card`2!"); } else { output("`2In your hands is a `6calle shell`2!"); $callecount = get_module_pref("callecount", "calletrader"); $callecount++; set_module_pref("callecount", $callecount, "calletrader"); } output("`7You're rather amazed to find such a treasure in a simple lucky dip!"); } elseif ($gift == 4) { output("I hope you shall keep it safe!\"`n`n"); output("`2In your hands is a `5cigarette`2!"); $session['user']['gems']++; } elseif ($gift == 3) { output("I hope you shall spend it wisely!`2\"`n`n"); output("`2You look down to find `610 requisition`2."); $session['user']['gold'] += 10; } elseif ($gift == 2) { output("You shall have hours of joy playing with such a treasure!`2\"`n`n"); output("`2You look down to find a cheap `6children's toy`2."); output("`2You grin -- and play with it amusedly for a few minutes before handing it to the nearest small child, who is delighted."); } else { output("I hope you enjoy it!\""); output("`n`n`7You look down to find a small iced cookie."); output("`n`n`^You bite into it with joy!"); // Don't let it heal them too far if ($session['user']['hitpoints'] <= $session['user']['maxhitpoints'] * 1.1) { $session['user']['hitpoints'] *= 1.05; output("`@You feel healthy!"); $addstam = e_rand(1, 4); if ($addstam == 1) { require_once "modules/staminasystem/lib/lib.php"; addstamina(25000); output("`@You feel `@vigorous!"); } } } addnav("Try again"); addnav(array("Small (%s req)", $cost), "runmodule.php?module=rail_luckydip&op=small&hid={$hid}&rid={$rid}"); if ($session['user']['gold'] >= $lcost) { addnav(array("Large (%s req)", $lcost), "runmodule.php?module=rail_luckydip&op=large&hid={$hid}&rid={$rid}"); } } break; } // end switch addnav("Leave", "runmodule.php?module=rail_ironhorse&op=board&hid={$hid}&rid={$rid}"); page_footer(); }