Initial commit

This commit is contained in:
root
2020-08-17 19:16:42 -04:00
commit 61584e0eb2
600 changed files with 50518 additions and 0 deletions

View File

@ -0,0 +1,354 @@
<?php
//Converted to a module by Zach Lawson, with the addition of settings
/*
Version History:
Version 1.0 - Original public release
Version 2.0 - Added a feature that allows the cost of the potions to vary by day
Version 2.1 - Fixed some broken stuff
Version 2.2 - Really fixed it this time
Version 2.3 - fixed random cost.
*/
function cedrikspotions_getmoduleinfo(){
$info = array(
"name"=>"Cedrik's Potion Shop",
"version"=>"2.6",
"author"=>"Eric Stevens<br>Modifications by: Chris Vorndran",
"category"=>"Inn",
"download"=>"core_module",
"settings"=>array(
"Cedrik's Potion Shop - Potion Availability,title",
"ischarm"=>"Is Charm potion available,bool|1",
"ismax"=>"Is Vitality potion available,bool|1",
"istemp"=>"Is Health potion available,bool|1",
"isforget"=>"Is Forgetfulness potion available,bool|1",
"istrans"=>"Is Transmutation potion available,bool|1",
"Cedrik's Potion Shop - Costs,title",
"charmcost"=>"Cost for Charm Potion,range,1,10,1|2",
"maxcost"=>"Cost for Vitality Potion,range,1,10,1|2",
"tempcost"=>"Cost for Health Potion,range,1,10,1|2",
"forgcost"=>"Cost for Forgetfulness Potion,range,1,10,1|2",
"transcost"=>"Cost for Transmutation Potion,range,1,10,1|2",
"random"=>"Is the cost per point of potion random,bool|0",
"minrand"=>"Minimum cost per point of effect,range,1,9,1|2",
"maxrand"=>"Maximum cost per point of effect,range,2,10,1|5",
"randcost"=>"Current random cost,rang,1,10,1|2",
"Note: Each <x> amount of gems spent will give the effect the potion. The actual effects can vary based on configuration.,note",
"Cedrik's Potion Shop - Effects,title",
"transmuteturns"=>"How many turns will the transmutation sickness last?,range,1,20,1|10",
"defmod"=>"How much is the multiplier for Transmutation Sickness (defense)?,floatrange,.1,2,.05|.75",
"atkmod"=>"How much is the multiplier for Transmutation Sickness (attack)?,floatrange,.1,2,.05|.75",
"survive"=>"Will transmutation sickness carry over new days?,bool|1",
"charmgain"=>"How much charm do you get per potion,int|1",
"vitalgain"=>"How many maxhp do you get per potion,int|1",
"tempgain"=>"How many current hp do you get per potion,int|20",
"carrydk"=>"Do MaxHitpoint (vitality) potions carry across DKs?,bool|1",
),
"prefs"=>array(
"Cedrik's Potion Shop User Preferences,title",
"extrahps"=>"How many extra hitpoints has the user bought?,int",
),
);
return $info;
}
function cedrikspotions_install(){
module_addhook("header-inn");
module_addhook("newday-runonce");
module_addhook("hprecalc");
return true;
}
function cedrikspotions_uninstall(){
return true;
}
function cedrikspotions_dohook($hookname,$args){
switch($hookname){
case "header-inn":
$op = httpget("op");
$act = httpget("act");
if($op=="bartender" && $act == "") {
addnav_notl(sanitize(getsetting("barkeep","`tCedrik")));
addnav("Gems","runmodule.php?module=cedrikspotions&op=gems");
}
break;
case "newday-runonce":
if (get_module_setting("random")){
$min = get_module_setting("minrand");
$max = get_module_setting("maxrand");
$randcost = e_rand($min,$max);
set_module_setting("randcost",$randcost);
}
break;
case "hprecalc":
$args['total'] -= get_module_pref("extrahps");
if (!get_module_setting("carrydk")) {
$args['extra'] -= get_module_pref("extrahps");
set_module_pref("extrahps", 0);
}
}
return $args;
}
function cedrikspotions_run(){
global $session;
$wish = httppost('wish');
$op = httpget("op");
$iname = getsetting("innname", LOCATION_INN);
tlschema("inn");
page_header($iname);
rawoutput("<span style='color: #9900FF'>");
output_notl("`c`b");
output($iname);
output_notl("`b`c");
tlschema();
$barkeep = getsetting("barkeep","`tCedrik");
$mincost = 0;
$maxcost = 0;
$cost = 0;
$gemcount = httppost('gemcount');
if ($gemcount == "") {
if(get_module_setting("random")) {
$cost =get_module_setting("randcost");
} else {
if (get_module_setting("ischarm")) {
$cm = get_module_setting("charmcost");
if ($mincost==0 || $cm < $mincost) $mincost = $cm;
if ($maxcost==0 || $cm > $maxcost) $maxcost = $cm;
}
if (get_module_setting("ismax")) {
$cm = get_module_setting("maxcost");
if ($mincost==0 || $cm < $mincost) $mincost = $cm;
if ($maxcost==0 || $cm > $maxcost) $maxcost = $cm;
}
if (get_module_setting("istemp")) {
$cm = get_module_setting("tempcost");
if ($mincost==0 || $cm < $mincost) $mincost = $cm;
if ($maxcost==0 || $cm > $maxcost) $maxcost = $cm;
}
if (get_module_setting("isforget")) {
$cm = get_module_setting("forgcost");
if ($mincost==0 || $cm < $mincost) $mincost = $cm;
if ($maxcost==0 || $cm > $maxcost) $maxcost = $cm;
}
if (get_module_setting("istrans")) {
$cm = get_module_setting("transcost");
if ($mincost==0 || $cm < $mincost) $mincost = $cm;
if ($maxcost==0 || $cm > $maxcost) $maxcost = $cm;
}
if ($mincost == $maxcost) $cost = $mincost;
}
}
if (!get_module_setting("random")){
switch ($wish){
case 1:
$cost = get_module_setting("charmcost");
break;
case 2:
$cost = get_module_setting("maxcost");
break;
case 3:
$cost = get_module_setting("tempcost");
break;
case 4:
$cost = get_module_setting("forgcost");
break;
case 5:
$cost = get_module_setting("transcost");
break;
}
}else{
$cost = get_module_setting("randcost");
}
if($op=="gems"){
if ($gemcount==""){
if (get_module_setting("random") || $mincost == $maxcost) {
output("\"`%You have gems, do ya?`0\" %s`0 asks. \"`%Well, I'll make you a magic elixir for `^ %s %s`%!`0\"",$barkeep,$cost, translate_inline($cost == 1?"gem" : "gems"));
} else {
output("\"`%You have gems, do ya?`0\" %s`0 asks. \"`%Well, I'll make you a magic elixir for between `^%s and %s gems`%, depending on which one you want!`0\"",$barkeep,$mincost, $maxcost);
}
output("`n`nGive him how many gems?");
$give = translate_inline("Give");
$link = appendcount("runmodule.php?module=cedrikspotions&op=gems");
addnav("", $link);
rawoutput("<form action='$link' method='POST'>");
rawoutput("<input name='gemcount' value='0'>");
rawoutput("<input type='submit' class='button' value='$give'>");
output("`nAnd what do you wish for?`n");
if (get_module_setting("ischarm") == 1) {
rawoutput("<input type='radio' name='wish' value='1' checked>");
output("Charm");
if ($mincost != $maxcost) {
$cm = get_module_setting("charmcost");
output("(%s %s for %s charm)", $cm, translate_inline($cm==1?"gem":"gems"), get_module_setting("charmgain"));
}
output_notl("`n");
}
if (get_module_setting("ismax") == 1) {
rawoutput("<input type='radio' name='wish' value='2'>");
output("Vitality");
if ($mincost != $maxcost) {
$cm = get_module_setting("maxcost");
$hm = get_module_setting("vitalgain");
$hptype = "permanent";
if (!get_module_setting("carrydk") ||
(is_module_active("globalhp") &&
!get_module_setting("carrydk", "globalhp")))
$hptype = "temporary";
$hptype = translate_inline($hptype);
output("(%s %s for %s %s max %s)", $cm,
translate_inline($cm==1?"gem":"gems"), $hm,
$hptype,
translate_inline($hm==1?"hitpoint":"hitpoints"));
}
output_notl("`n");
}
if (get_module_setting("istemp") == 1) {
rawoutput("<input type='radio' name='wish' value='3'>");
output("Health");
if ($mincost != $maxcost) {
$cm = get_module_setting("tempcost");
$hm = get_module_setting("tempgain");
output("(%s %s for %s %s)", $cm, translate_inline($cm==1?"gem":"gems"), $hm, translate_inline($hm == 1? "hitpoint":"hitpoints"));
}
output_notl("`n");
}
if (get_module_setting("isforget") == 1) {
rawoutput("<input type='radio' name='wish' value='4'>");
output("Forgetfulness");
if ($mincost != $maxcost) {
$cm = get_module_setting("forgcost");
output_notl("(%s %s)", $cm, translate_inline($cm==1?"gem":"gems"));
}
output_notl("`n");
}
if (get_module_setting("istrans") == 1) {
rawoutput("<input type='radio' name='wish' value='5'>");
output("Transmutation");
if ($mincost != $maxcost) {
$cm = get_module_setting("transcost");
output_notl("(%s %s)", $cm, translate_inline($cm==1?"gem":"gems"));
}
output_notl("`n");
}
rawoutput("</form>");
}else{
$gemcount = abs((int)$gemcount);
if ($gemcount>$session['user']['gems']){
output("%s`0 stares at you blankly.",$barkeep);
output("\"`%You don't have that many gems, `bgo get some more gems!`b`0\" he says.");
}else{
output("`#You place %s %s on the counter.", $gemcount, translate_inline($gemcount==1?"gem":"gems"));
if (($wish == 4 || $wish == 5) && $gemcount > $cost) {
output("%s`0, feeling sorry for you, prevents you from paying for multiple doses of a potion that only needs a single dose.",$barkeep);
$gemcount = $cost;
}
$strength = ($gemcount/$cost);
if(!is_integer($strength)){
output("%s`0, knowing about your fundamental misunderstanding of math, hands some of them back to you.",$barkeep);
$strength = floor($strength);
$gemcount=($strength * $cost);
}
if ($gemcount>0) {
output("You drink the potion %s`0 hands you in exchange for your %s, and.....`n`n",$barkeep, translate_inline($gemcount==1?"gem":"gems"));
$session['user']['gems']-=$gemcount;
switch($wish){
case 1:
$session['user']['charm'] += ($strength *
get_module_setting("charmgain"));
output("`&You feel charming!");
output("`^(You gain %s charm %s.)",
$strength*get_module_setting("charmgain"),
translate_inline($strength *
get_module_setting("charmgain")==1 ?
"point" : "points"));
$potiontype = "charm";
break;
case 2:
$session['user']['maxhitpoints'] +=
($strength*get_module_setting("vitalgain"));
$session['user']['hitpoints'] +=
($strength*get_module_setting("vitalgain"));
output("`&You feel vigorous!");
$hptype = "permanently";
if (!get_module_setting("carrydk") ||
(is_module_active("globalhp") &&
!get_module_setting("carrydk", "globalhp")))
$hptype = "temporarily";
$hptype = translate_inline($hptype);
output("`^(You %s gain %s max %s.)", $hptype,
$strength * get_module_setting("vitalgain"),
translate_inline($strength *
get_module_setting("vitalgain") == 1 ?
"hitpoint" : "hitpoints"));
$potiontype = "vitality";
set_module_pref("extrahps",
get_module_pref("extrahps") +
($strength * get_module_setting("vitalgain")));
break;
case 3:
if ($session['user']['hitpoints'] <
$session['user']['maxhitpoints'])
$session['user']['hitpoints'] =
$session['user']['maxhitpoints'];
$session['user']['hitpoints'] +=
($strength * get_module_setting("tempgain"));
output("`&You feel healthy!");
output("`^(You gain %s temporary %s.)",
$strength * get_module_setting("tempgain"),
translate_inline($strength *
get_module_setting("tempgain") == 1 ?
"hitpoint" : "hitpoints"));
$potiontype = "health";
break;
case 4:
$session['user']['specialty']="";
output("`&You feel completely directionless in life.");
output("You should rest and make some important decisions about your life!");
output("`^(Your specialty has been reset.)");
$potiontype = "forgetfulness";
break;
case 5:
$session['user']['race']=RACE_UNKNOWN;
output("`@You double over retching from the effects of transformation potion as your bones turn to gelatin!`n");
output("`^(Your race has been reset and you will be able to chose a new one tomorrow.)");
strip_buff('racialbenefit');
$potiontype = "transmutation";
if (isset($session['bufflist']['transmute'])) {
$session['bufflist']['transmute']['rounds'] += get_module_setting("transmuteturns");
} else {
apply_buff('transmute',
array("name"=>"`6Transmutation Sickness",
"rounds"=>get_module_setting("transmuteturns"),
"wearoff"=>"You stop puking your guts up. Literally.",
"atkmod"=>get_module_setting("atkmod"),
"defmod"=>get_module_setting("defmod"),
"roundmsg"=>"Bits of skin and bone reshape themselves like wax.",
"survivenewday"=>get_module_setting("survive"),
"newdaymessage"=>"`6Due to the effects of the Transmutation Potion, you still feel `2ill`6.",
"schema"=>"module-cedrikspotions"
)
);
}
break;
}
debuglog("used $gemcount gems on $potiontype potions");
}else{
output("`n`nYou feel as though your gems would be better used elsewhere, not on some smelly potion.");
}
}
}
addnav("I?Return to the Inn","inn.php");
villagenav();
}
rawoutput("</span>");
page_footer();
}
?>

View File

@ -0,0 +1,273 @@
<?php
// translator ready
// addnews ready
// mail ready
//ver 1.1 - added a little newday-runonce routine to return the creatures to
// some default value after a specified number of days
function crazyaudrey_getmoduleinfo(){
$info = array(
"name"=>"Crazy Audrey's Petting Zoo",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
"settings"=>array(
"Crazy Audrey Settings,title",
"cost"=>"Cost to pet,int|5",
"animal"=>"Name of animal (should be singular)|Kitten",
"animals"=>"Plural name of animal|Kittens",
"lanimal"=>"Lowercase name of animal (should be singular)|kitten",
"lanimals"=>"Lowercase plural name of animal|kittens",
"The last ones only need to be different for languages which do not capitalize nouns,note",
"sound"=>"Sound that animal makes|mew",
"buffname"=>"Name of buff from animal|Warm Fuzzies",
"gamedaysremaining"=>"How many game days should the animal remain? (set to -1 for indefinite),int|-1",
"defaultanimal"=>"Name of default animal (should be singular)|Kitten",
"defaultanimals"=>"Plural name of default animal|Kittens",
"defaultsound"=>"Sound that default animal makes|mew",
"defaultbuffname"=>"Name of buff from default animal|Warm Fuzzies",
"profit"=>"How much profit has Audrey made?,int|5",
"villagepercent"=>"How often will you see Crazy Audrey sitting in the village square?,range,0,100,1|20",
),
"prefs"=>array(
"Crazy Audrey User Preferences,title",
"played"=>"Played Baskets Today?,bool|0",
)
);
return $info;
}
function crazyaudrey_install(){
module_addhook("village");
module_addhook("village-desc");
module_addhook("newday");
module_addhook("newday-runonce");
module_addeventhook("forest", "return 100;");
return true;
}
function crazyaudrey_uninstall(){
return true;
}
function crazyaudrey_dohook($hookname,$args){
global $session;
$animals = get_module_setting("animals");
$lcanimals = get_module_setting("lanimals");
switch($hookname){
case "village-desc":
if (e_rand(1, 100) <= get_module_setting("villagepercent")) {
output("`n`%Crazy Audrey is here with her `#%s`%!`n",$lcanimals);
$args['doaudrey'] = 1;
}
case "village":
if (!array_key_exists("doaudrey",$args)) $args['doaudrey'] = false;
if ($args['doaudrey']) {
$cost = get_module_setting("cost");
// And since the capital can change the texts
tlschema($args['schemas']['marketnav']);
addnav($args["marketnav"]);
tlschema();
addnav(array(" ?Pet Crazy Audrey's %s`0 (`^%s gold`0)",$animals,$cost),"runmodule.php?module=crazyaudrey&op=pet");
}
break;
case "newday":
set_module_pref("played",0);
break;
case "newday-runonce":
$daysremaining=get_module_setting("gamedaysremaining");
if ($daysremaining>0){
$daysremaining -= 1;
set_module_setting("gamedaysremaining",$daysremaining);
}
if($daysremaining==0){
//This is intentionally not an elseif
set_module_setting("animal",get_module_setting("defaultanimal"));
set_module_setting("animals",get_module_setting("defaultanimals"));
set_module_setting("sound",get_module_setting("defaultsound"));
set_module_setting("buffname",get_module_setting("defaultbuffname"));
set_module_setting("gamedaysremaining",-1);
}
break;
}
return $args;
}
function crazyaudrey_runevent($type)
{
// We act the same for all event types
crazyaudrey_baskets($type);
}
function crazyaudrey_baskets($type)
{
global $session;
$from = "runmodule.php?module=crazyaudrey&";
if ($type == "forest")
$from = "forest.php?";
if ($type == "forest") {
$session['user']['specialinc'] = "module:crazyaudrey";
}
$animal = get_module_setting("animal");
$lcanimal = get_module_setting("lanimal");
$lcplural = get_module_setting("lanimals");
$sound = get_module_setting("sound");
$op = httpget('op');
if ($op == "" || $op == "search" || $op == "baskets") {
if ($op == "baskets") {
output("`5You reach for the lid of one of Crazy Audrey's baskets when you think she is distracted, when out of nowhere, Crazy Audrey appears, ranting feverishly about colored %s, and pulls the baskets to her.`n`n", $lcplural);
} elseif ($type == "forest") {
output("`5You stumble across a clearing that is oddly quiet.");
output("To one side are three baskets, tightly lidded.");
output("Finding this curious, you cautiously approach them when you hear the faint %s`5 of a %s`5.", $sound, $lcanimal);
output("You reach for the lid of the first basket when out of nowhere, Crazy Audrey appears, ranting feverishly about colored %s`5, and pulls the baskets to her.`n`n", $lcplural);
}
output("Taken somewhat aback, you decide you had best question her about these %s.`n`n", $lcplural);
output("\"`#Tell me, good woman,`5\" you begin...`n`n");
output("\"`%GOOD GOOD good good goodgoodgoodgoodgood...`5\" Audrey begins to repeat.");
output("Unflustered, you persist.`n`n");
output("\"`#What are these %s`# you speak of?`5\"`n`n", $lcplural);
output("Amazingly, Crazy Audrey suddenly grows quiet and begins to speak in a regal accent both melodious and soft.`n`n");
output("\"`%Of these baskets, have I three,`n");
output("Four %s`% inside each there do be.`n`n", $lcplural);
output("Minds of their own, do they have,`n");
output("Should two alike emerge, you'll get this salve.`n`n");
output("Energy it gives, to fight your foes,`n");
output("Merely rub it 'tween your toes.`n`n");
output("Should no two alike show their head,`n");
output("Earlier today, you'll see your bed.`n`n");
output("That then is my proposition,`n");
output("Shall thou take it, or from me run?`5\"`n`n");
output("Will you play her game?");
addnav("Play",$from."op=play");
addnav("Run away from Crazy Audrey",$from."op=run");
}else if($op=="run"){
output("`5You run, very quickly, away from this mad woman.");
}else if($op=="play"){
if ($type == "module-internal") {
set_module_pref("played",1);
}
$colors = array("`^C`&a`Ql`6i`7c`qo","`7T`&i`7g`&e`7r","`QGinger","`&White","`^`bHedgehog!`b");
$colors = translate_inline($colors);
$c1 = e_rand(0,3);
$c2 = e_rand(0,3);
$c3 = e_rand(0,3);
if (e_rand(1,20)==1) {
$c1=4; $c2=4; $c3=4;
}
output("`5You agree to Crazy Audrey's preposterous game and she thumps the first basket on the lid.");
if ($c1 == 4) {
output("A %s`5 peeks its head out.`n`n", $colors[$c1]);
} else {
output("A %s`5 %s`5 peeks its head out.`n`n", $colors[$c1], $lcanimal);
}
if ($c2 == 4) {
output("Crazy Audrey then thumps the second basket on the lid, and a %s`5 peeks its head out.`n`n", $colors[$c2]);
} else {
output("Crazy Audrey then thumps the second basket on the lid, and a %s`5 %s`5 peeks its head out.`n`n", $colors[$c2], $lcanimal);
}
if ($c3 == 4) {
output("She thumps the third basket on the lid, and a %s`5 hops out and bounds up to Crazy Audrey's shoulder.`n`n", $colors[$c3]);
} else {
output("She thumps the third basket on the lid, and a %s`5 %s`5 hops out and bounds up to Crazy Audrey's shoulder.`n`n", $colors[$c3], $lcanimal);
}
if ($c1==$c2 && $c2==$c3){
if ($c1==4){
$where = translate_inline($type=="forest"?"forest":"crowd");
output("\"`%Hedgehogs? HEDGEHOGS?? Hahahahaha, HEDGEHOGS!!!!`5\" shouts Crazy Audrey as she snatches them up in glee and runs cheering into the %s.", $where);
output("You notice that she has dropped a full BAG of those wonderful salves.`n`n");
output("`^You gain FIVE forest fights!");
$session['user']['turns']+=5;
}else{
output("\"`%Argh, you are ALL very bad %s`%!`5\" shouts Crazy Audrey before hugging her shoulder %s`5 and putting it back in the basket.", $lcplural, $lcanimal);
output("\"`%Because my %s`% all were alike, I grant you TWO salves.`5\"`n`n", $lcplural);
output("You rub the salves on your toes.`n`n");
output("`^You gain TWO forest fights!");
$session['user']['turns']+=2;
}
}elseif ($c1==$c2 || $c2==$c3 || $c1==$c3){
output("\"`%Garr, you crazy %s`%, what do you know? Why I ought to paint you all different colors!`5\"", $lcplural);
output("Despite her threatening words, Crazy Audrey pets the %s`5 on her shoulder and places it back in the basket, before giving you your salve, which you rub all over your toes.`n`n", $lcanimal);
output("`^You gain a forest fight!");
$session['user']['turns']++;
}else{
output("\"`%Well done my pretties!`5\" shouts Crazy Audrey.");
output("Just then her shoulder-mounted %s`5 leaps at you.", $lcanimal);
if ($session['user']['turns'] > 0) {
output("In fending it off, you lose some energy.");
$msg = "`^You lose a forest fight!";
$session['user']['turns']--;
} else {
output("In fending it off, you get a nasty scratch along one side of your face.");
$msg = "`^You lose a charm point!";
if ($session['user']['charm'] > 0)
$session['user']['charm']--;
}
output("Finally it hops back in its basket and all is quiet.");
output("Crazy Audrey cackles quietly and looks at you.`n`n");
output($msg);
}
}
if ($op == "run" || $op=="play") {
if ($type == "forest") {
$session['user']['specialinc'] = "";
}
}
}
function crazyaudrey_run(){
global $session;
$op = httpget('op');
if ($op=="pet"){
page_header("Crazy Audrey's Zoo");
$cost = get_module_setting("cost");
$animal = get_module_setting("animal");
$lcanimal = get_module_setting("lanimal");
$plural = get_module_setting("animals");
$lcplural = get_module_setting("lanimals");
$profit = get_module_setting("profit");
output("`5You cautiously approach Crazy Audrey.");
output("Next to her is a sign that reads, \"`#%s gold to pet %s`#,`5\" and a basket filled with `^%s`5 gold!",$cost,$lcplural,$profit);
if ($session['user']['gold']>=$cost){
output("You place your `^%s`5 gold in the basket, and spend a few minutes petting one of the %s`5.", $cost, $lcplural);
output("Soon though, Crazy Audrey chases you off, and you stand at a distance admiring the %s`5.",$lcplural);
$session['user']['gold']-=$cost;
debuglog("spent $cost gold to pet audrey's pets");
$profit += $cost;
set_module_setting("profit",$profit);
$buffname = get_module_setting("buffname");
apply_buff('crazyaudrey',array("name"=>$buffname,"rounds"=>5,"activate"=>"defense","defmod"=>1.05, "schema"=>"module-crazyaudrey"));
output("`5After a few minutes, you once again try to approach in order to look into her baskets.");
if (get_module_pref("played")==0) {
addnav("Look at Crazy Audrey's baskets","runmodule.php?module=crazyaudrey&op=baskets");
} else {
output("`5As you approach closer, Crazy Audrey looks up and screams at you. \"`%Hey!! I recognize you! You've already played with my %s`% today! Get away from here, you pervy %s`% fancier!`5\"", $lcplural, $lcanimal);
output("You quickly step back and admire the %s`5 from a safe distance.", $lcplural);
}
}else{
output("Not having `^%s`5 gold, you wander sadly away.",$cost);
}
}elseif ($op=="baskets" || $op == "play" || $op == "run"){
page_header("Crazy Audrey");
crazyaudrey_baskets("module-internal",
"runmodule.php?module=crazyaudrey");
}
if ($op != "baskets") {
require_once("lib/villagenav.php");
villagenav();
}
page_footer();
}
?>

56
lotgd-web/lotgd/modules/dag.php Executable file
View File

@ -0,0 +1,56 @@
<?php
//addnews ready
// mail ready
// translator ready
require_once("lib/sanitize.php");
require_once("lib/datetime.php");
require_once("lib/http.php");
function dag_getmoduleinfo(){
$info = array(
"name"=>"Dag Durnick Bounties",
"author"=>"Darrel Morrone<br>Updates by Andrew Senger, JT Traub, and Eric Stevens",
"version"=>"1.3",
"category"=>"Inn",
"download"=>"core_module",
"settings"=>array(
"Dag Durnick Bounty Settings,title",
"bountymin"=>"Minimum amount per level of target for bounty,int|50",
"bountymax"=>"Maximum amount per level of target for bounty,int|200",
"bountylevel"=>"Minimum player level for being a bounty target,int|3",
"bountyfee"=>"Percentage of bounty kept by Dag Durnick,int|10",
"maxbounties"=>"How many bounties can a person set per day,int|5"
),
"prefs"=>array(
"Dag Durnick Bounty User Preferences,title",
"bounties"=>"Bounties set today,int|0"
)
);
return $info;
}
function dag_install(){
require_once("modules/dag/install.php");
$args = func_get_args();
return call_user_func_array("dag_install_private",$args);
}
function dag_uninstall(){
output("Dropping bounty table");
$sql = "DROP TABLE IF EXISTS " . db_prefix("bounty");
db_query($sql);
return true;
}
function dag_dohook($hookname, $args){
require_once("modules/dag/dohook.php");
$args = func_get_args();
return call_user_func_array("dag_dohook_private",$args);
}
function dag_run(){
require_once("modules/dag/run.php");
$args = func_get_args();
return call_user_func_array("dag_run_private",$args);
}
?>

View File

@ -0,0 +1,64 @@
<?php
function dag_dohook_private($hookname,$args){
require_once("modules/dag/misc_functions.php");
global $session;
switch($hookname){
case "pvpwin":
$args = dag_pvpwin($args);
break;
case "dragonkill":
// handle bounties -- they go away on defeat of green dragon
$windate = date("Y-m-d H:i:s");
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1,winner=0,windate='$windate' WHERE target={$session['user']['acctid']} AND status=0";
db_query($sql);
break;
case "inn-desc":
if (getsetting("pvp",1)) {
output("`nDag Durnick sits, sulking in the corner with a pipe clamped firmly in his mouth.`n");
}
break;
case "inn":
if (getsetting("pvp",1)) {
addnav("Things to do");
addnav("D?Talk to Dag Durnick","runmodule.php?module=dag");
}
break;
case "delete_character":
// handle bounties -- they go away on character deletion
$windate = date("Y-m-d H:i:s");
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1,winner=0,windate='$windate' WHERE target={$args['acctid']} AND status=0";
db_query($sql);
break;
case "superuser":
if ($session['user']['superuser'] & SU_EDIT_USERS) {
addnav("Module Configurations");
// Stick the admin=true on so that runmodule will let us run
// even if the module is deactivated
addnav("Dag's Bounties", "runmodule.php?module=dag&manage=true&admin=true");
}
break;
case "newday":
set_module_pref("bounties",0);
break;
case "showsettings":
$info = dag_getmoduleinfo();
$parts = array();
$values = array();
while(list($key,$val)= each($info['settings'])) {
if (is_array($val)) {
$x = explode("|", $val[0]);
} else {
$x = explode("|", $val);
}
$y = explode(",", $x[0]);
if ($y[1] == "title") $parts[$key] = $x[0];
else $parts[$key] = $y[0] . ",viewonly";
$values[$key] = get_module_setting($key);
}
$args['settings'] = array_merge($args['settings'], $parts);
$args['values'] = array_merge($args['values'], $values);
break;
}
return $args;
}
?>

View File

@ -0,0 +1,72 @@
<?php
function dag_install_private(){
global $session;
module_addhook("inn-desc");
module_addhook("inn");
module_addhook("superuser");
module_addhook("newday");
module_addhook("pvpwin");
module_addhook("dragonkill");
module_addhook("showsettings");
module_addhook("delete_character");
debug("Creating Bounty Table");
$sql = "SHOW TABLES";
$result = db_query($sql);
$bountytableisthere=false;
while ($row = db_fetch_assoc($result)){
list($key,$val)=each($row);
if ($val==db_prefix("bounty")){
$bountytableisthere=true;
break;
}
}
if ($bountytableisthere){
debug("The bounty table already exists on your server, not overwriting it.`n");
}else{
debug("Creating the bounty table.`n");
$sql="CREATE TABLE " . db_prefix("bounty") . " (
bountyid int(11) unsigned NOT NULL auto_increment,
amount int(11) unsigned NOT NULL default '0',
target int(11) unsigned NOT NULL default '0',
setter int(11) unsigned NOT NULL default '0',
setdate datetime NOT NULL default '0000-00-00 00:00:00',
status int(11) unsigned NOT NULL default '0',
winner int(11) unsigned NOT NULL default '0',
windate datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (bountyid),
INDEX(status),
INDEX(target),
INDEX(status,target)
) Type=INNODB";
db_query($sql);
}
//look to see if we're migrating bounties from the old system.
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
while ($row = db_fetch_assoc($result)){
if ($row['Field']=="bounty"){
$sql = "INSERT INTO " . db_prefix("bounty") . " (amount,target,setdate) SELECT bounty,acctid,'".date("Y-m-d H:i:s")."' FROM " . db_prefix("accounts") . " WHERE " . db_prefix("accounts") . ".bounty > 0";
debug("The bounty column was found in your accounts table, migrating its values to the bounty table.`n");
db_query($sql);
debug("Dropping accounts column from the user table.`n");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP bounty";
db_query($sql);
//drop it from the user's session too.
unset($session['user']['bounty']);
}elseif ($row['Field']=="bounties"){
$sql = "SELECT bounties,acctid FROM " . db_prefix("accounts") . " WHERE bounties>0";
$result1 = db_query($sql);
debug("Migrating bounty counts.`n");
while ($row1 = db_fetch_assoc($result1)){
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) VALUES ('dag','bounties',{$row1['acctid']},{$row1['bounties']})";
db_query($sql);
}//end while
debug("Dropping bounty count from the user table.`n");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP bounties";
db_query($sql);
//drop it from the user's session too.
unset($session['user']['bounties']);
}//end if
}//end while
return true;
}

View File

@ -0,0 +1,546 @@
<?php
function dag_sortbounties($x, $y) {
if ($x['Amount'] == $y['Amount']) {
return 0;
} elseif ($x['Amount'] > $y['Amount']) {
return -1;
} elseif ($x['Amount'] < $y['Amount']) {
return 1;
}
}
function dag_sortbountieslevel($x, $y) {
if ($x['Level'] == $y['Level']) {
return dag_sortbounties($x, $y);
} elseif ($x['Level'] > $y['Level']) {
return -1;
} elseif ($x['Level'] < $y['Level']) {
return 1;
}
}
function dag_manage(){
page_header("Dag's Bounty Lists");
require_once("lib/superusernav.php");
superusernav();
// Add some bounty expiration for closed bounties
$sql = "DELETE FROM " . db_prefix("bounty") . " WHERE status=1 AND windate <'".date("Y-m-d H:i:s",strtotime("-".(getsetting("expirecontent",180)/10)." days"))."'";
db_query($sql);
addnav("Actions");
addnav("A?View All Bounties","runmodule.php?module=dag&manage=true&op=viewbounties&type=1&sort=1&dir=1&admin=true");
addnav("O?View Open Bounties","runmodule.php?module=dag&manage=true&op=viewbounties&type=2&sort=1&dir=1&admin=true");
addnav("C?View Closed Bounties","runmodule.php?module=dag&manage=true&op=viewbounties&type=3&sort=1&dir=1&admin=true");
addnav("R?Refresh List","runmodule.php?module=dag&manage=true&admin=true");
rawoutput("<form action='runmodule.php?module=dag&manage=true&op=viewbounties&type=search&admin=true' method='POST'>");
addnav("","runmodule.php?module=dag&manage=true&op=viewbounties&type=search&admin=true");
output("Setter: ");
rawoutput("<input name='setter' value=\"".htmlentities(stripslashes(httppost('setter')))."\">");
output(" Winner: ");
rawoutput("<input name='getter' value=\"".htmlentities(stripslashes(httppost('getter')))."\">");
output(" Target: ");
rawoutput("<input name='target' value=\"".htmlentities(stripslashes(httppost('target')))."\">");
output_notl("`n");
output("Order by: ");
$id = translate_inline("ID");
$amt = translate_inline("Amount");
$targ = translate_inline("Target");
$set = translate_inline("Setter");
$sdate = translate_inline("Set Date");
$stat = translate_inline("Status");
$win = translate_inline("Winner");
$wdate = translate_inline("Win Date");
$desc = translate_inline("Descending");
$asc = translate_inline("Ascending");
$search = translate_inline("Search");
rawoutput("<select name='s'>
<option value='1'".(httppost('s')=='1'?" selected":"").">$id</option>
<option value='2'".(httppost('s')=='2'?" selected":"").">$amt</option>
<option value='3'".(httppost('s')=='3'?" selected":"").">$targ</option>
<option value='4'".(httppost('s')=='4'?" selected":"").">$set</option>
<option value='5'".(httppost('s')=='5'?" selected":"").">$sdate</option>
<option value='6'".(httppost('s')=='6'?" selected":"").">$stat</option>
<option value='7'".(httppost('s')=='7'?" selected":"").">$win</option>
<option value='8'".(httppost('s')=='8'?" selected":"").">$wdate</option>
</select>");
rawoutput("<input type='radio' name='d' value='1'".(httppost('d')==1?" checked":"")."> $desc");
rawoutput("<input type='radio' name='d' value='2'".(httppost('d')==1?"":" checked")."> $asc");
output_notl("`n");
rawoutput("<input type='submit' class='button' value='$search'>");
rawoutput("</form>");
$op = httpget('op');
if ($op == "") {
// ***ADDED***
// By Andrew Senger
// Adding for new Bounty Code
output_notl("`n`n");
output("`c`bThe Bounty List`b`c`n");
$sql = "SELECT bountyid,amount,target,setter,setdate FROM " . db_prefix("bounty") . " WHERE status=0 ORDER BY bountyid ASC";
$result = db_query($sql);
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
$amt = translate_inline("Amount");
$lev = translate_inline("Level");
$name = translate_inline("Name");
$loc = translate_inline("Location");
$sex = translate_inline("Sex");
$alive = translate_inline("Alive");
$last = translate_inline("Last On");
rawoutput("<tr class='trhead'><td><b>$amt</b></td><td><b>$lev</b></td><td><b>$name</b></td><td><b>$loc</b></td><td><b>$sex</b></td><td><b>$alive</b></td><td><b>$last</b></td>");
$listing = array();
$totlist = 0;
for($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$amount = (int)$row['amount'];
$sql = "SELECT name,alive,sex,level,laston,loggedin,lastip,uniqueid FROM " . db_prefix("accounts") . " WHERE acctid={$row['target']}";
$result2 = db_query($sql);
if (db_num_rows($result2) == 0) {
/* this person has been deleted, clear bounties */
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1 WHERE target={$row['target']}";
db_query($sql);
continue;
}
$row2 = db_fetch_assoc($result2);
$yesno = 0;
for($j=0;$j<=$i;$j++){
if($listing[$j]['Name'] == $row2['name']) {
$listing[$j]['Amount'] = $listing[$j]['Amount'] + $amount;
$yesno = 1;
}
}
if ($yesno==0) {
$listing[] = array('Amount'=>$amount,'Level'=>$row2['level'],'Name'=>$row2['name'],'Location'=>$row2['location'],'Sex'=>$row2['sex'],'Alive'=>$row2['alive'],'LastOn'=>$row2['laston']);
$totlist = $totlist + 1;
}
}
usort($listing, 'dag_sortbounties');
for($i=0;$i<$totlist;$i++) {
rawoutput("<tr class='".($i%2?"trdark":"trlight")."'><td>");
output_notl("`^%s`0", $listing[$i]['Amount']);
rawoutput("</td><td>");
output_notl("`^%s`0", $listing[$i]['Level']);
rawoutput("</td><td>");
output_notl("`^%s`0", $listing[$i]['Name']);
rawoutput("</td><td>");
output($loggedin ? "`#Online`0" : $listing[$i]['Location']);
rawoutput("</td><td>");
output($listing[$i]['Sex']?"`!Female`0":"`!Male`0");
rawoutput("</td><td>");
output($listing[$i]['Alive']?"`1Yes`0":"`4No`0");
rawoutput("</td><td>");
$laston= relativedate($listing[$i]['LastOn']);
if ($loggedin) $laston=translate_inline("Now");
output_notl("%s", $laston);
rawoutput("</td></tr>");
}
rawoutput("</table>");
output("`n`n`c`bAdd Bounty`b`c`n");
rawoutput("<form action='runmodule.php?module=dag&manage=true&op=addbounty&admin=true' method='POST'>");
output("`2Target: ");
rawoutput("<input name='contractname'>");
output_notl("`n");
output("`2Amount to Place: ");
rawoutput("<input name='amount' id='amount' width='5'>");
output_notl("`n`n");
$final = translate_inline("Finalize Contract");
rawoutput("<input type='submit' class='button' value='$final'>");
rawoutput("</form>");
addnav("","runmodule.php?module=dag&manage=true&op=addbounty&admin=true");
}else if ($op == "addbounty") {
if (httpget('subfinal')==1){
$sql = "SELECT acctid,name,login,level,locked,age,dragonkills,pk,experience FROM " . db_prefix("accounts") . " WHERE name='".addslashes(rawurldecode(stripslashes(httppost('contractname'))))."' AND locked=0";
}else{
$contractname = stripslashes(rawurldecode(httppost('contractname')));
$name="%";
for ($x=0;$x<strlen($contractname);$x++){
$name.=substr($contractname,$x,1)."%";
}
$sql = "SELECT acctid,name,login,level,locked,age,dragonkills,pk,experience FROM " . db_prefix("accounts") . " WHERE name LIKE '".addslashes($name)."' AND locked=0";
}
$result = db_query($sql);
if (db_num_rows($result) == 0) {
output("No one by that name!");
} elseif(db_num_rows($result) > 100) {
output("Too many names!");
} elseif(db_num_rows($result) > 1) {
output("Select the correct name:`n");
rawoutput("<form action='runmodule.php?module=dag&manage=true&op=addbounty&subfinal=1&admin=true' method='POST'>");
output("`2Target: ");
rawoutput("<select name='contractname'>");
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
rawoutput("<option value=\"".rawurlencode($row['name'])."\">".full_sanitize($row['name'])."</option>");
}
rawoutput("</select>");
output_notl("`n`n");
$amount = httppost('amount');
output("`2Amount to Place: ");
rawoutput("<input name='amount' id='amount' width='5' value='$amount'>");
output_notl("`n`n");
$final = translate_inline("Finalize Contract");
rawoutput("<input type='submit' class='button' value='$final'>");
rawoutput("</form>");
addnav("","runmodule.php?module=dag&manage=true&op=addbounty&subfinal=1");
} else {
// Now, we have just the one, so check it.
$row = db_fetch_assoc($result);
if ($row['locked']) {
output("Target is a locked user.");
}
$amt = (int)httppost('amount');
if ($amt <= 0) {
output("That bounty value make no sense.");
} else {
// All good!
$sql = "INSERT INTO " . db_prefix("bounty") . " (amount, target, setter, setdate) VALUES ($amt, ".$row['acctid'].", 0, '".date("Y-m-d H:i:s")."')";
db_query($sql);
output("Bounty added!");
}
}
} else if ($op == "viewbounties") {
$type = httpget('type');
$sort = httpget('sort');
$dir = httpget('dir');
output("`c`bThe Bounty List`b`c`n");
if ($type == 1) {
output("`c`bViewing: `3All Bounties`b`c");
}elseif ($type == 2) {
output("`c`bViewing: `3Open Bounties`b`c");
}elseif ($type == 3) {
output("`c`bViewing: `3Closed Bounties`b`c");
}
addnav("Sorting");
if (($sort == 1) && ($dir == 1)) {
addnav("1?By BountyID - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=1&dir=2&admin=true");
output("`c`bSorting By: `3BountyID - Desc`b`c`n`n");
}elseif (($sort == 1) && ($dir == 2)) {
addnav("1?By BountyID - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=1&dir=1&admin=true");
output("`c`bSorting By: `3BountyID - Asc`b`c`n`n");
}else {
addnav("1?By BountyID - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=1&dir=1&admin=true");
}
if (($sort == 2) && ($dir == 1)) {
addnav("2?By Amount - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=2&dir=2&admin=true");
output("`c`bSorting By: `3Amount - Desc`b`c`n`n");
}elseif (($sort == 2) && ($dir == 2)) {
addnav("2?By Amount - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=2&dir=1&admin=true");
output("`c`bSorting By: `3Amount - Asc`b`c`n`n");
}else {
addnav("2?By Amount - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=2&dir=1&admin=true");
}
if (($sort == 3) && ($dir == 1)) {
addnav("3?By Target - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=3&dir=2&admin=true");
output("`c`bSorting By: `3Target - Desc`b`c`n`n");
}elseif (($sort == 3) && ($dir == 2)) {
addnav("3?By Target - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=3&dir=1&admin=true");
output("`c`bSorting By: `3Target - Asc`b`c`n`n");
}else {
addnav("3?By Target - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=3&dir=1&admin=true");
}
if (($sort == 4) && ($dir == 1)) {
addnav("4?By Setter - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=4&dir=2&admin=true");
output("`c`bSorting By: `3Setter - Desc`b`c`n`n");
}elseif (($sort == 4) && ($dir == 2)) {
addnav("4?By Setter - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=4&dir=1&admin=true");
output("`c`bSorting By: `3Setter - Asc`b`c`n`n");
}else {
addnav("4?By Setter - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=4&dir=1&admin=true");
}
if (($sort == 5) && ($dir == 1)) {
addnav("5?By Set Date - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=5&dir=2&admin=true");
output("`c`bSorting By: `3Set Date - Desc`b`c`n`n");
}elseif (($sort == 5) && ($dir == 2)) {
addnav("5?By Set Date - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=5&dir=1&admin=true");
output("`c`bSorting By: `3Set Date - Asc`b`c`n`n");
}else {
addnav("5?By Set Date - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=5&dir=1&admin=true");
}
if ($type == 1) {
if (($sort == 6) && ($dir == 1)) {
addnav("6?By Status - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=6&dir=2&admin=true");
output("`c`bSorting By: `3Status - Desc`b`c`n`n");
}elseif (($sort == 6) && ($dir == 2)) {
addnav("6?By Status - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=6&dir=1&admin=true");
output("`c`bSorting By: `3Status - Asc`b`c`n`n");
}else {
addnav("6?By Status - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=6&dir=1&admin=true");
}
}
if (($type == 1) || ($type == 3)) {
if (($sort == 7) && ($dir == 1)) {
addnav("7?By Winner - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=7&dir=2&admin=true");
output("`c`bSorting By: `3Winner - Desc`b`c`n`n");
}elseif (($sort == 7) && ($dir == 2)) {
addnav("7?By Winner - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=7&dir=1&admin=true");
output("`c`bSorting By: `3Winner - Asc`b`c`n`n");
}else {
addnav("7?By Winner - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=7&dir=1&admin=true");
}
if (($sort == 8) && ($dir == 1)) {
addnav("8?By Win Date - Asc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=8&dir=2&admin=true");
output("`c`bSorting By: `3Win Date - Desc`b`c`n`n");
}elseif (($sort == 8) && ($dir == 2)) {
addnav("8?By Win Date - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=8&dir=1&admin=true");
output("`c`bSorting By: `3Win Date - Asc`b`c`n`n");
}else {
addnav("8?By Win Date - Desc","runmodule.php?module=dag&manage=true&op=viewbounties&type=".$type."&sort=8&dir=1&admin=true");
}
}
addnav("Return to Bounty Home","runmodule.php?module=dag&manage=true&op=bounties&admin=true");
switch ($type) {
case 1:
$t = "";
break;
case 2:
$t = " WHERE status=0";
break;
case 3:
$t = " WHERE status=1";
break;
}
switch ($sort) {
case 1:
$s = " ORDER BY bountyid";
break;
case 2:
$s = " ORDER BY amount";
break;
case 3:
$s = " ORDER BY target";
break;
case 4:
$s = " ORDER BY setter";
break;
case 5:
$s = " ORDER BY setdate";
break;
case 6:
$s = " ORDER BY status";
break;
case 7:
$s = " ORDER BY winner";
break;
case 8:
$s = " ORDER BY windate";
break;
}
switch ($dir) {
case 1:
$d = " DESC";
break;
case 2:
$d = " ASC";
break;
}
//override those options in favor of the search form if it exists
if ($type=='search'){
switch(httppost('s')){
case 1: $s = " ORDER BY bountyid"; break;
case 2: $s = " ORDER BY amount"; break;
case 3: $s = " ORDER BY target"; break;
case 4: $s = " ORDER BY setter"; break;
case 5: $s = " ORDER BY setdate"; break;
case 6: $s = " ORDER BY status"; break;
case 7: $s = " ORDER BY winner"; break;
case 8: $s = " ORDER BY windate"; break;
}
switch(httppost('d')){
case 1: $d = " DESC"; break;
case 2: $d = " ASC"; break;
}
$t = "";
if (httppost('setter')>'') {
if ($t>"") $t.=" AND";
$a = httppost('setter');
$setter = "%";
for ($i=0;$i<strlen($a);$i++){
$setter.=$a[$i]."%";
}
$sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE name LIKE '$setter'";
$result = db_query($sql);
$ids = array();
while ($row = db_fetch_assoc($result)){
array_push($ids,$row['acctid']);
}
if (count($ids)==0) $ids[0]=0;
$t .= " setter IN (".join(",",$ids).")";
}
if (httppost('getter')>'') {
if ($t>"") $t.=" AND";
$a = httppost('getter');
$getter = "%";
for ($i=0;$i<strlen($a);$i++){
$getter.=$a[$i]."%";
}
$sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE name LIKE '$getter'";
$result = db_query($sql);
$ids = array();
while ($row = db_fetch_assoc($result)){
array_push($ids,$row['acctid']);
}
if (count($ids)==0) $ids[0]=0;
$t .= " winner IN (".join(",",$ids).")";
}
if (httppost('target')>'') {
if ($t>"") $t.=" AND";
$a = httppost('target');
$target = "%";
for ($i=0;$i<strlen($a);$i++){
$target.=$a[$i]."%";
}
$sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE name LIKE '$target'";
$result = db_query($sql);
$ids = array();
while ($row = db_fetch_assoc($result)){
array_push($ids,$row['acctid']);
}
if (count($ids)==0) $ids[0]=0;
$t .= " target IN (".join(",",$ids).")";
}
if ($t>"") $t = " WHERE".$t;
}
$sql = "SELECT bountyid,amount,target,setter,setdate,status,winner,windate FROM " . db_prefix("bounty").$t.$s.$d;
$result = db_query($sql);
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
$id = translate_inline("ID");
$amt = translate_inline("Amt");
$targ = translate_inline("Target");
$set = translate_inline("Setter");
$sdate = translate_inline("Set Date/Time");
$stat = translate_inline("Status");
$win = translate_inline("Winner");
$wdate = translate_inline("Win Date/Time");
$ops = translate_inline("Ops");
rawoutput("<tr class='trhead'><td><b>$id</b></td><td><b>$amt</b></td><td><b>$targ</b></td><td><b>$set</b></td><td><b>$sdate</b></td><td><b>$stat</b></td><td><b>$win</b></td><td><b>$wdate</b></td><td>$ops</td></tr>");
for($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
if ($row['target']==0) {
$target['name'] = translate_inline("`2Green Dragon");
} else {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid=".(int)$row['target'];
$result2 = db_query($sql);
if (db_num_rows($result2) == 0) {
$target['name'] = translate_inline("`4Deleted Character");
} else {
$target = db_fetch_assoc($result2);
}
}
if ($row['setter']==0) {
$setter['name'] = translate_inline("`2Green Dragon");
}else {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid=".(int)$row['setter'];
$result3 = db_query($sql);
if (db_num_rows($result3) == 0) {
$setter['name'] = translate_inline("`4Deleted Character");
} else {
$setter = db_fetch_assoc($result3);
}
}
$winner['name'] = "";
if (($row['winner']==0) && $row['status'] == 1) {
$winner['name'] = translate_inline("`2Green Dragon");
} elseif ($row['status'] == 1) {
$sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid=".(int)$row['winner'];
$result4 = db_query($sql);
if (db_num_rows($result4) == 0) {
$winner['name'] = translate_inline("`2Deleted Character");
} else {
$winner = db_fetch_assoc($result4);
}
}
rawoutput("<tr class='".($i%2?"trdark":"trlight")."'><td>");
output_notl("`^%s`0", $row['bountyid']);
rawoutput("</td><td>");
output_notl("`^%s`0", $row['amount']);
rawoutput("</td><td>");
output_notl("`&%s`0", $target['name']);
rawoutput("</td><td>");
output_notl("`^%s`0", $setter['name']);
rawoutput("</td><td>");
output_notl("`^%s`0", $row['setdate']);
rawoutput("</td><td>");
output($row['status']==0?"`^Open`0":"`^Closed`0");
rawoutput("</td><td>");
output_notl("`^%s`0", $winner['name']);
rawoutput("</td><td>");
output_notl("`^%s`0", $row['status']?$row['windate']:"");
rawoutput("</td><td>");
if ($row['status'] == 0) {
$link = "runmodule.php?module=dag&manage=true&op=closebounty&id={$row['bountyid']}&admin=true";
$close = translate_inline("Close");
rawoutput("<a href=\"$link\">$close</a>");
addnav("",$link);
} else {
rawoutput("&nbsp;");
}
rawoutput("</td></tr>");
}
rawoutput("</table>");
} else if ($op == "closebounty") {
$windate = date("Y-m-d H:i:s");
$bountyid = (int)httpget('id');
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1,winner=0,windate=\"$windate\" WHERE bountyid=$bountyid";
db_query($sql);
output("Bounty closed.");
// ***END ADD***
}
page_footer();
}
function dag_pvpwin($args){
global $badguy,$session;
// ***ADDED***
// By Andrew Senger
// Added for Bounty Code
// Bounty Check - Andrew Senger
// Check for Bounty
$sql = "SELECT bountyid,amount,setter FROM " . db_prefix("bounty") . " WHERE status=0 AND setdate<='".date("Y-m-d H:i:s")."' AND target=".$badguy['acctid'];
$result = db_query($sql);
if (db_num_rows($result) > 0) {
$totgoodamt = 0;
$totbadamt = 0;
for($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
if ($row['setter'] == $session['user']['acctid']) {
$totbadamt += $row['amount'];
} else {
$totgoodamt += $row['amount'];
$windate = date("Y-m-d H:i:s");
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1,winner=".$session['user']['acctid'].",windate=\"$windate\" WHERE bountyid=".$row['bountyid'];
db_query($sql);
}
}
if ($totgoodamt > 0) {
output("`@When you turn around, Dag Durnick is standing there.");
output("\"%s`# had a bounty of `^%s`# on th' head`@\", he says as he tosses you a leather purse which clinks with the sounds of your new fortune.`n`n", $badguy['creaturename'], $totgoodamt);
}
if ($totbadamt > 0) {
output("\"`#I'm keeping `^%s`# of the total bounty on this soul's head, as ye' be the one that set it.`@\"", $totbadamt);
}
}
// End Check for Bounty
// Add Bounty Gold
if ($totgoodamt > 0) {
$session['user']['gold']+=$totgoodamt;
debuglog("gained ".$totgoodamt." gold bounty for killing ", $badguy['acctid']);
}
// End Add Bounty Gold
// Add Bounty Kill to News
if ($totgoodamt > 0) {
addnews("`4%s`3 collected `4%s`3 gold bounty by turning in `4%s`3's head!",$session['user']['name'],$totgoodamt,$badguy['creaturename']);
}
// End Add Bounty Kill to News
// End Bounty Check - Andrew
// ***END ADD***
if ($totgoodamt > 0) {
$args['pvpmessageadd'] .= sprintf_translate("`nThey also received `^%s`2 in bounty gold.`n", $totgoodamt);
rawoutput(tlbutton_clear());
}
return $args;
}
?>

View File

@ -0,0 +1,245 @@
<?php
function dag_run_private(){
require_once("modules/dag/misc_functions.php");
global $session;
if (httpget('manage')!="true"){
page_header("Dag Durnick's Table");
output("<span style='color: #9900FF'>",true);
output("`c`bDag Durnick's Table`b`c");
}else{
dag_manage();
}
$op = httpget('op');
addnav("Navigation");
addnav("I?Return to the Inn","inn.php");
if ($op != '')
addnav("Talk to Dag Durnick", "runmodule.php?module=dag");
if ($op=="list"){
output("Dag fishes a small leather bound book out from under his cloak, flips through it to a certain page and holds it up for you to see.");
output("\"`7Deese ain't the most recent figgers, I ain't just had time to get th' other numbers put in.`0\"`n`n");
// ***ADDED***
// By Andrew Senger
// Added for new Bounty Code
output("`c`bThe Bounty List`b`c`n");
$sql = "SELECT bountyid,amount,target,setter,setdate FROM " . db_prefix("bounty") . " WHERE status=0 AND setdate<='".date("Y-m-d H:i:s")."' ORDER BY bountyid ASC";
$result = db_query($sql);
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
$amount = translate_inline("Amount");
$level = translate_inline("Level");
$name = translate_inline("Name");
$loc = translate_inline("Location");
$sex = translate_inline("Sex");
$alive = translate_inline("Alive");
$last = translate_inline("Last On");
rawoutput("<tr class='trhead'><td><b>$amount</b></td><td><b>$level</b></td><td><b>$name</b></td><td><b>$loc</b></td><td><b>$sex</b></td><td><b>$alive</b></td><td><b>$last</b></td>");
$listing = array();
$totlist = 0;
for($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$amount = (int)$row['amount'];
$sql = "SELECT name,alive,sex,level,laston,loggedin,lastip,location FROM " . db_prefix("accounts") . " WHERE acctid={$row['target']}";
$result2 = db_query($sql);
if (db_num_rows($result2) == 0) {
/* this person has been deleted, clear bounties */
$sql = "UPDATE " . db_prefix("bounty") . " SET status=1 WHERE target={$row['target']}";
db_query($sql);
continue;
}
$row2 = db_fetch_assoc($result2);
$yesno = 0;
for($j=0;$j<=$i;$j++){
if(isset($listing[$j]) &&
$listing[$j]['Name'] == $row2['name']) {
$listing[$j]['Amount'] = $listing[$j]['Amount'] + $amount;
$yesno = 1;
}
}
if ($yesno==0) {
$loggedin = (date("U")-strtotime($row2['laston'])<getsetting("LOGINTIMEOUT",900) && $row2['loggedin']);
$listing[] = array('Amount'=>$amount,'Level'=>$row2['level'],'Name'=>$row2['name'],'Location'=>$row2['location'],'Sex'=>$row2['sex'],'Alive'=>$row2['alive'],'LastOn'=>$row2['laston'], 'LoggedIn'=>$loggedin);
$totlist = $totlist + 1;
}
}
$sort = httpget("sort");
if ($sort=="level")
usort($listing, 'dag_sortbountieslevel');
elseif ($sort != "")
usort($listing, 'dag_sortbounties');
else
usort($listing, 'dag_sortbountieslevel');
for($i=0;$i<$totlist;$i++) {
rawoutput("<tr class='".($i%2?"trdark":"trlight")."'><td>");
output_notl("`^%s`0", $listing[$i]['Amount']);
rawoutput("</td><td>");
output_notl("`^%s`0", $listing[$i]['Level']);
rawoutput("</td><td>");
output_notl("`^%s`0", $listing[$i]['Name']);
rawoutput("</td><td>");
output($listing[$i]['LoggedIn']?"`#Online`0":$listing[$i]['Location']);
rawoutput("</td><td>");
output($listing[$i]['Sex']?"`!Female`0":"`!Male`0");
rawoutput("</td><td>");
output($listing[$i]['Alive']?"`1Yes`0":"`4No`0");
rawoutput("</td><td>");
$laston = relativedate($listing[$i]['LastOn']);
output_notl("%s", $laston);
rawoutput("</td></tr>");
}
rawoutput("</table>");
// ***END ADDING***
}else if ($op=="addbounty"){
if (get_module_pref("bounties") >= get_module_setting("maxbounties")) {
output("Dag gives you a piercing look.");
output("`7\"Ye be thinkin' I be an assassin or somewhat? Ye already be placin' more than 'nuff bounties for t'day. Now, be ye gone before I stick a bounty on yer head fer annoyin' me.\"`n`n");
} else {
$fee = get_module_setting("bountyfee");
if ($fee < 0 || $fee > 100) {
$fee = 10;
set_module_setting("bountyfee",$fee);
}
$min = get_module_setting("bountymin");
$max = get_module_setting("bountymax");
output("Dag Durnick glances up at you and adjusts the pipe in his mouth with his teeth.`n");
output("`7\"So, who ye be wantin' to place a hit on? Just so ye be knowing, they got to be legal to be killin', they got to be at least level %s, and they can't be having too much outstandin' bounty nor be getting hit too frequent like, so if they ain't be listed, they can't be contracted on! We don't run no slaughterhouse here, we run a.....business. Also, there be a %s%% listin' fee fer any hit ye be placin'.\"`n`n", get_module_setting("bountylevel"), get_module_setting("bountyfee"));
rawoutput("<form action='runmodule.php?module=dag&op=finalize' method='POST'>");
output("`2Target: ");
rawoutput("<input name='contractname'>");
output_notl("`n");
output("`2Amount to Place: ");
rawoutput("<input name='amount' id='amount' width='5'>");
output_notl("`n`n");
$final = translate_inline("Finalize Contract");
rawoutput("<input type='submit' class='button' value='$final'>");
rawoutput("</form>");
addnav("","runmodule.php?module=dag&op=finalize");
}
}elseif ($op=="finalize") {
if (httpget('subfinal')==1){
$sql = "SELECT acctid,name,login,level,locked,age,dragonkills,pk,experience FROM " . db_prefix("accounts") . " WHERE name='".addslashes(rawurldecode(stripslashes(httppost('contractname'))))."' AND locked=0";
}else{
$contractname = stripslashes(rawurldecode(httppost('contractname')));
$name="%";
for ($x=0;$x<strlen($contractname);$x++){
$name.=substr($contractname,$x,1)."%";
}
$sql = "SELECT acctid,name,login,level,locked,age,dragonkills,pk,experience FROM " . db_prefix("accounts") . " WHERE name LIKE '".addslashes($name)."' AND locked=0";
}
$result = db_query($sql);
if (db_num_rows($result) == 0) {
output("Dag Durnick sneers at you, `7\"There not be anyone I be knowin' of by that name. Maybe ye should come back when ye got a real target in mind?\"");
} elseif(db_num_rows($result) > 100) {
output("Dag Durnick scratches his head in puzzlement, `7\"Ye be describing near half th' town, ye fool? Why don't ye be giving me a better name now?\"");
} elseif(db_num_rows($result) > 1) {
output("Dag Durnick searches through his list for a moment, `7\"There be a couple of 'em that ye could be talkin' about. Which one ye be meaning?\"`n");
rawoutput("<form action='runmodule.php?module=dag&op=finalize&subfinal=1' method='POST'>");
output("`2Target: ");
rawoutput("<select name='contractname'>");
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
rawoutput("<option value=\"".rawurlencode($row['name'])."\">".full_sanitize($row['name'])."</option>");
}
rawoutput("</select>");
output_notl("`n`n");
$amount = httppost('amount');
output("`2Amount to Place: ");
rawoutput("<input name='amount' id='amount' width='5' value='$amount'>");
output_notl("`n`n");
$final = translate_inline("Finalize Contract");
rawoutput("<input type='submit' class='button' value='$final'>");
rawoutput("</form>");
addnav("","runmodule.php?module=dag&op=finalize&subfinal=1");
} else {
// Now, we have just the one, so check it.
$row = db_fetch_assoc($result);
if ($row['locked']) {
output("Dag Durnick sneers at you, `7\"There not be anyone I be knowin' of by that name. Maybe ye should come back when ye got a real target in mind?\"");
} elseif ($row['login'] == $session['user']['login']) {
output("Dag Durnick slaps his knee laughing uproariously, `7\"Ye be wanting to take out a contract on yerself? I ain't be helping no suicider, now!\"");
} elseif ($row['level'] < get_module_setting("bountylevel") ||
($row['age'] < getsetting("pvpimmunity",5) &&
$row['dragonkills'] == 0 && $row['pk'] == 0 &&
$row['experience'] < getsetting("pvpminexp",1500))) {
output("Dag Durnick stares at you angrily, `7\"I told ye that I not be an assassin. That ain't a target worthy of a bounty. Now get outta me sight!\"");
} else {
// All good!
$amt = abs((int)httppost('amount'));
$min = get_module_setting("bountymin") * $row['level'];
$max = get_module_setting("bountymax") * $row['level'];
$fee = get_module_setting("bountyfee");
$cost = round($amt*((100+$fee)/100), 0);
$curbounty = 0;
$sql = "SELECT sum(amount) AS total FROM " . db_prefix("bounty") . " WHERE status=0 AND target={$row['acctid']}";
$result = db_query($sql);
if (db_num_rows($result) > 0) {
$nrow = db_fetch_assoc($result);
$curbounty = $nrow['total'];
}
if ($amt < $min) {
output("Dag Durnick scowls, `7\"Ye think I be workin' for that pittance? Be thinkin' again an come back when ye willing to spend some real coin. That mark be needin' at least %s gold to be worth me time.\"", $min);
} elseif ($session['user']['gold'] < $cost) {
output("Dag Durnick scowls, `7\"Ye don't be havin enough gold to be settin' that contract. Wastin' my time like this, I aught to be puttin' a contract on YE instead!");
} elseif ($amt + $curbounty > $max) {
if ($curbounty) {
output("Dag looks down at the pile of coin and just leaves them there.");
output("`7\"I'll just be passin' on that contract. That's way more'n `^%s`7 be worth and ye know it. I ain't no durned assassin. A bounty o' %s already be on their head, what with the bounties I ain't figgered in to th' book already. I might be willin' t'up it to %s, after me %s%% listin' fee of course\"`n`n",$row['name'], $curbounty, $max, $fee);
} else {
output("Dag looks down at the pile of coin and just leaves them there.");
output("`7\"I'll just be passin' on that contract. That's way more'n `^%s`7 be worth and ye know it. I ain't no durned assassin. I might be willin' t'let y' set one of %s, after me %s%% listin' fee of course\"`n`n", $row['name'], $max, $fee);
}
} else {
output("You slide the coins towards Dag Durnick, who deftly palms them from the table.");
output("`7\"I'll just be takin' me %s%% listin' fee offa the top. The word be put out that ye be wantin' `^%s`7 taken care of. Be patient, and keep yer eyes on the news.\"`n`n", $fee, $row['name']);
set_module_pref("bounties",get_module_pref("bounties")+1);
$session['user']['gold']-=$cost;
// ***ADDED***
// By Andrew Senger
// Adding for new Bounty Code
$setdate = time();
// random set date up to 4 hours in the future.
$setdate += e_rand(0,14400);
$sql = "INSERT INTO ". db_prefix("bounty") . " (amount, target, setter, setdate) VALUES ($amt, ".$row['acctid'].", ".(int)$session['user']['acctid'].", '".date("Y-m-d H:i:s",$setdate)."')";
db_query($sql);
// ***END ADD***
debuglog("spent $cost to place a $amt bounty on {$row['name']}");
}
}
}
}else{
output("You stroll over to Dag Durnick, who doesn't even bother to look up at you.");
output("He takes a long pull on his pipe.`n");
output("`7\"Ye probably be wantin' to know if there's a price on yer head, ain't ye.\"`n`n");
// ***ADDED***
// By Andrew Senger
// Adding for new Bounty Code
$sql = "SELECT sum(amount) as total FROM " . db_prefix("bounty") . " WHERE status=0 AND setdate<='".date("Y-m-d H:i:s")."' AND target=".$session['user']['acctid'];
$result = db_query($sql);
$curbounty = 0;
if (db_num_rows($result) != 0) {
$row = db_fetch_assoc($result);
$curbounty = $row['total'];
}
if ($curbounty == 0) {
output("\"`3Ye don't have no bounty on ya. I suggest ye be keepin' it that way.\"");
} else {
output("\"`3Well, it be lookin like ye have `^%s gold`3 on yer head currently. Ye might wanna be watchin yourself.\"", $curbounty);
}
// ***END ADD***
addnav("Bounties");
addnav("Check the Wanted List","runmodule.php?module=dag&op=list");
addnav("Set a Bounty","runmodule.php?module=dag&op=addbounty");
}
modulehook('dagnav');
if ($op == "list") {
addnav("Sort List");
addnav("View by Bounty",
"runmodule.php?module=dag&op=list&sort=bounty");
addnav("View by Level", "runmodule.php?module=dag&op=list&sort=level");
}
rawoutput("</span>");
page_footer();
}
?>

View File

@ -0,0 +1,320 @@
<?php
// translator ready
// addnews ready
// mail ready
function darkhorse_getmoduleinfo(){
$info = array(
"name"=>"Dark Horse Tavern",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
"settings"=>array(
"Dark Horse Tavern Settings,title",
"tavernname"=>"Name of the tavern|Dark Horse Tavern",
),
"prefs-mounts"=>array(
"Dark Horse Tavern Mount Preferences,title",
"findtavern"=>"Can this mount find the tavern,bool|0",
),
);
return $info;
}
function darkhorse_tavernmount() {
global $playermount;
if (isset($playermount) && is_array($playermount) && array_key_exists("mountid",$playermount)){
$id = $playermount['mountid'];
}else{
$id = 0;
}
// We need the module parameter here because this function can be
// called from the eventchance eval and this module might not be loaded
// at that point.
$tavern = get_module_objpref("mounts", $id, "findtavern", "darkhorse");
return $tavern;
}
function darkhorse_install(){
module_addeventhook("forest",
"require_once(\"modules/darkhorse.php\");
return (darkhorse_tavernmount() ? 0 : 100);");
module_addeventhook("travel",
"require_once(\"modules/darkhorse.php\");
return (darkhorse_tavernmount() ? 0 : 100);");
$sql = "DESCRIBE " . db_prefix("mounts");
$result = db_query($sql);
while($row = db_fetch_assoc($result)) {
if ($row['Field'] == "tavern") {
debug("Migrating tavern for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'darkhorse','mounts','findtavern',mountid,tavern FROM " . db_prefix("mounts");
db_query($sql);
debug("Dropping tavern field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP tavern";
db_query($sql);
}
}
module_addhook("forest");
module_addhook("mountfeatures");
module_addhook("moderate");
return true;
}
function darkhorse_uninstall(){
return true;
}
function darkhorse_dohook($hookname,$args){
switch($hookname) {
case "moderate":
$args['darkhorse'] = get_module_setting("tavernname");
break;
case "mountfeatures":
$tavern = get_module_objpref("mounts", $args['id'], "findtavern");
$args['features']['Darkhorse']=$tavern;
break;
case "forest":
if(darkhorse_tavernmount()) {
// add the nav
addnav("Other");
$iname = get_module_setting("tavernname");
require_once("lib/mountname.php");
list($name, $lcname) = getmountname();
addnav(array("D?Take %s`0 to %s", $lcname, $iname),
"runmodule.php?module=darkhorse&op=enter");
}
break;
}
return $args;
}
function darkhorse_checkday(){
// Reset special-in just in case checkday kicks in.
$session['user']['specialinc']="";
checkday();
// And now set it back.
$session['user']['specialinc']="module:darkhorse";
}
function darkhorse_bartender($from){
global $session;
$what = httpget('what');
if ($what==""){
output("The grizzled old man behind the bar reminds you very much of a strip of beef jerky.`n`n");
$dname = translate_inline($session['user']['sex']?"lasshie":"shon");
output("\"`7Shay, what can I do for you %s?`0\" inquires the toothless fellow.", $dname);
output("\"`7Don't shee the likesh of your short too offen 'round theshe partsh.`0\"");
addnav("Learn about my enemies",$from."op=bartender&what=enemies");
addnav("Learn about colors",$from."op=bartender&what=colors");
}elseif($what=="colors"){
output("The old man leans on the bar.");
output("\"`%Sho you want to know about colorsh, do you?`0\" he asks.`n`n");
output("You are about to answer when you realize the question was rhetorical.`n`n");
output("He continues, \"`%To do colorsh, here'sh what you need to do. Firsht, you ushe a &#0096; mark (found right above the tab key) followed by 1, 2, 3, 4, 5, 6, 7, !, @, #, $, %, ^, &, ), q or Q. Each of thoshe correshpondsh with a color to look like this: `n`1&#0096;1 `2&#0096;2 `3&#0096;3 `4&#0096;4 `5&#0096;5 `6&#0096;6 `7&#0096;7 `n`!&#0096;! `@&#0096;@ `#&#0096;# `\$&#0096;\$ `%&#0096;% `^&#0096;^ `&&#0096;& `n `)&#0096;) `q&#0096;q `Q&#0096;Q `n`% got it?`0\"`n You can practice below:", true);
rawoutput("<form action=\"".$from."op=bartender&what=colors\" method='POST'>");
$testtext = httppost('testtext');
$try = translate_inline("Try");
rawoutput("<input name='testtext' id='testtext'><input type='submit' class='button' value='$try'></form>");
addnav("",$from."op=bartender&what=colors");
rawoutput("<script language='JavaScript'>document.getElementById('testtext').focus();</script>");
if ($testtext) {
output("`0You entered %s`n", prevent_colors(HTMLEntities($testtext, ENT_COMPAT, getsetting("charset", "ISO-8859-1"))),true);
output("It looks like %s`n", $testtext);
}
output("`0`n`nThese colors can be used in your name, and in any conversations you have.");
}else if($what=="enemies"){
$who = httpget('who');
if ($who==""){
output("\"`7Sho, you want to learn about your enemiesh, do you? Who do you want to know about? Well? Shpeak up! It only costs `^100`7 gold per person for information.`0\"");
$subop = httpget('subop');
if ($subop!="search"){
$search = translate_inline("Search");
rawoutput("<form action='".$from."op=bartender&what=enemies&subop=search' method='POST'><input name='name' id='name'><input type='submit' class='button' value='$search'></form>");
addnav("",$from."op=bartender&what=enemies&subop=search");
rawoutput("<script language='JavaScript'>document.getElementById('name').focus();</script>");
}else{
addnav("Search Again",$from."op=bartender&what=enemies");
$search = "%";
$name = httppost('name');
for ($i=0;$i<strlen($name);$i++){
$search.=substr($name,$i,1)."%";
}
$sql = "SELECT name,alive,location,sex,level,laston,loggedin,login FROM " . db_prefix("accounts") . " WHERE (locked=0 AND name LIKE '$search') ORDER BY level DESC";
$result = db_query($sql);
$max = db_num_rows($result);
if ($max > 100) {
output("`n`n\"`7Hey, whatsh you think yoush doin'. That'sh too many namesh to shay. I'll jusht tell you 'bout shome of them.`0`n");
$max = 100;
}
$n = translate_inline("Name");
$lev = translate_inline("Level");
rawoutput("<table border=0 cellpadding=0><tr><td>$n</td><td>$lev</td></tr>");
for ($i=0;$i<$max;$i++){
$row = db_fetch_assoc($result);
rawoutput("<tr><td><a href='".$from."op=bartender&what=enemies&who=".rawurlencode($row['login'])."'>");
output_notl("%s", $row['name']);
rawoutput("</a></td><td>{$row['level']}</td></tr>");
addnav("",$from."op=bartender&what=enemies&who=".rawurlencode($row['login']));
}
rawoutput("</table>");
}
}else{
if ($session['user']['gold']>=100){
$sql = "SELECT name,acctid,alive,location,maxhitpoints,gold,sex,level,weapon,armor,attack,race,defense,charm FROM " . db_prefix("accounts") . " WHERE login='$who'";
$result = db_query($sql);
if (db_num_rows($result)>0){
$row = db_fetch_assoc($result);
$row = modulehook("adjuststats", $row);
$name = str_replace("s", "sh", $row['name']);
$name = str_replace("S", "Sh", $name);
output("\"`7Well... letsh shee what I know about %s`7,`0\" he says...`n`n", $name);
output("`4`bName:`b`6 %s`n", $row['name']);
output("`4`bRace:`b`6 %s`n",
translate_inline($row['race'],"race"));
output("`4`bLevel:`b`6 %s`n", $row['level']);
output("`4`bHitpoints:`b`6 %s`n", $row['maxhitpoints']);
output("`4`bGold:`b`6 %s`n", $row['gold']);
output("`4`bWeapon:`b`6 %s`n", $row['weapon']);
output("`4`bArmor:`b`6 %s`n", $row['armor']);
output("`4`bAttack:`b`6 %s`n", $row['attack']);
output("`4`bDefense:`b`6 %s`n", $row['defense']);
output("`n`^%s7 ish alsho ", $row['name']);
$amt=$session['user']['charm'];
if ($amt == $row['charm']) {
output("ash ugly ash you are.`n");
} else if ($amt-10 > $row['charm']) {
output("`bmuch`b uglier shan you!`n");
} else if ($amt > $row['charm']) {
output("uglier shan you.`n");
} else if ($amt+10 < $row['charm']) {
output("`bmuch`b more beautiful shan you!`n");
} else {
output("more beautiful shan you.`n");
}
$session['user']['gold']-=100;
debuglog("spent 100 gold to learn about an enemy");
}else{
output("\"`7Eh..? I don't know anyone named that.`0\"");
}
}else{
output("\"`7Well... letsh shee what I know about cheapshkates like you,`0\" he says...`n`n");
output("`4`bName:`b`6 Get some money`n");
output("`4`bLevel:`b`6 You're too broke`n");
output("`4`bHitpoints:`b`6 Probably more than you`n");
output("`4`bGold:`b`6 Definately richer than you`n");
output("`4`bWeapon:`b`6 Something good enough to lay the smackdown on you`n");
output("`4`bArmor:`b`6 Probably something more fashionable than you`n");
output("`4`bAttack:`b`6 Eleventy billion`n");
output("`4`bDefense:`b`6 Super Duper`n");
}
}
}
addnav("Return to the Main Room",$from."op=tavern");
}
function darkhorse_runevent($type, $link){
global $session;
$from = $link;
$gameret = substr($link, 0, -1);
$session['user']['specialinc']="module:darkhorse";
require_once("lib/sanitize.php");
$iname = get_module_setting("tavernname");
rawoutput("<span style='color: #787878'>");
output_notl("`c`b%s`b`c",$iname);
$op = httpget('op');
switch($op){
case "":
case "search":
darkhorse_checkday();
output("A cluster of trees nearby looks familiar...");
output("You're sure you've seen this place before.");
output("As you approach the grove, a strange mist creeps in around you; your mind begins to buzz, and you're no longer sure exactly how you got here.");
if(darkhorse_tavernmount()) {
require_once("lib/mountname.php");
list($name, $lcname) = getmountname();
output("%s`0 seems to have known the way, however.", $name);
}
output("`n`nThe mist clears, and before you is a log building with smoke trailing from its chimney.");
output("A sign over the door says `7\"%s.\"`0", $iname);
addnav("Enter the tavern",$from."op=tavern");
addnav("Leave this place",$from."op=leaveleave");
break;
case "tavern":
darkhorse_checkday();
output("You stand near the entrance of the tavern and survey the scene before you.");
output("Whereas most taverns are noisy and raucous, this one is quiet and nearly empty.");
output("In the corner, an old man plays with some dice.");
output("You notice that the tables have been etched on by previous adventurers who have found this place before, and behind the bar, a stick of an old man hobbles around, polishing glasses, as though there were anyone here to use them.");
addnav("Talk to the old man",$from."op=oldman");
addnav("Talk to the bartender",$from."op=bartender");
// Special case here. go and see if the comment area is blocked and
// if so, don't put the link in.
$args = modulehook("blockcommentarea", array("section"=>"darkhorse"));
if (!isset($args['block']) || $args['block'] != 'yes') {
addnav("Examine the tables",$from."op=tables");
}
addnav("Exit the tavern",$from."op=leave");
break;
case "tables":
require_once("lib/commentary.php");
addcommentary();
commentdisplay("You examine the etchings in the table:`n`n",
"darkhorse","Add your own etching:");
addnav("Return to the Main Room",$from."op=tavern");
break;
case "bartender":
darkhorse_bartender($from);
break;
case "oldman":
darkhorse_checkday();
addnav("Old Man");
modulehook("darkhorsegame", array("return"=>$gameret));
output("The old man looks up at you, his eyes sunken and hollow.");
output("His red eyes make it seem that he may have been crying recently so you ask him what is bothering him.");
if ($session['user']['sex'] == SEX_MALE) {
output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with her, but she won and took almost all of my money.`0\"`n`n");
} else {
output("\"`7Aah, I met an adventurer in the woods, and figured I'd play a little game with him, but he won and took almost all of my money.`0\"`n`n");
}
$c = navcount();
if ($c != 0) {
output("`0\"`7Say... why not do an old man a favor and let me try to win some of it back from you?");
if ($c > 1) output(" I can play several games!`0\"");
else output(" Shall we play a game?`0\"");
}
$session['user']['specialmisc']="";
addnav("Return to the Main Room",$from."op=tavern");
break;
case "leave":
output("You duck out of the tavern, and wander into the thick foliage around you.");
output("That strange mist revisits you, making your mind buzz.");
output("The mist clears, and you find yourself again where you were before the mist first covered you.");
if(!darkhorse_tavernmount()) {
output(" How exactly you got to the tavern is not exactly clear.");
}
$session['user']['specialinc']="";
break;
case "leaveleave":
output("You decide that the tavern holds no appeal for you today.");
$session['user']['specialinc']="";
break;
}
rawoutput("</span>");
}
function darkhorse_run(){
$op = httpget('op');
if ($op == "enter") {
httpset("op", "tavern");
page_header(get_module_setting("tavernname"));
darkhorse_runevent("forest", "forest.php?");
// Clear the specialinc, just in case.
$session['user']['specialinc']="";
page_footer();
}
}
?>

View File

@ -0,0 +1,77 @@
<?php
// translator ready
// addnews ready
// mail ready
require_once("lib/e_rand.php");
require_once("lib/showform.php");
require_once("lib/http.php");
require_once("lib/buffs.php");
/*
* Date: Mar 07, 2004
* Version: 1.0
* Author: JT Traub
* Email: jtraub@dragoncat.net
* Purpose: Provide basic drinks and drunkeness handling.
* Subsumes some of the functionality from the drinks module by
* John J. Collins (collinsj@yahoo.com)
*
* Date: Mar 09, 2004
* Version: 1.1
* Purpose: Remove the 'activate' field
*/
function drinks_getmoduleinfo(){
$info = array(
"name"=>"Exotic Drinks",
"author"=>"John J. Collins<br>Heavily modified by JT Traub",
"category"=>"Inn",
"download"=>"core_module",
"settings"=>array(
"Drink Module Settings,title",
"hardlimit"=>"How many hard drinks can a user buy in a day?,int|3",
"maxdrunk"=>array("How drunk before %s`0 won't serve you?,range,0,100,1|66", getsetting("barkeep", "`)Cedrik")),
),
"prefs"=>array(
"Drink Module User Preferences,title",
"drunkeness"=>"Drunkeness,range,0,100,1|0",
"harddrinks"=>"How many hard drinks has the user bought today?,int|0",
"canedit"=>"Has access to the drinks editor,bool|0",
"noslur"=>"Don't slur speach when drunk,bool|0",
),
"version"=>"1.1"
);
return $info;
}
function drinks_install(){
require_once("modules/drinks/install.php");
$args = func_get_args();
return call_user_func_array("drinks_install_private",$args);
}
function drinks_uninstall() {
debug("Dropping table drinks");
$sql = "DROP TABLE IF EXISTS " . db_prefix("drinks");
db_query($sql);
debug("Dropping objprefs related to drinks");
$sql = "DELETE FROM " . db_prefix("module_objprefs") .
" WHERE objtype='drinks'";
db_query($sql);
return true;
}
function drinks_dohook(){
require_once("modules/drinks/dohook.php");
$args = func_get_args();
return call_user_func_array("drinks_dohook_private",$args);
}
function drinks_run(){
require_once("modules/drinks/run.php");
$args = func_get_args();
return call_user_func_array("drinks_run_private",$args);
}
?>

View File

@ -0,0 +1,113 @@
<?php
function drinks_dohook_private($hookname,$args) {
global $session;
switch($hookname) {
case "dragonkill":
set_module_pref("drunkeness",0);
break;
case "ale":
require_once("modules/drinks/misc_functions.php");
$texts = drinks_gettexts();
$drinktext = modulehook("drinks-text",$texts);
$drunk = get_module_pref("drunkeness");
$drunklist = array(
-1=>"stone cold sober",
0=>"quite sober",
1=>"barely buzzed",
2=>"pleasantly buzzed",
3=>"almost drunk",
4=>"barely drunk",
5=>"solidly drunk",
6=>"sloshed",
7=>"hammered",
8=>"really hammered",
9=>"almost unconscious",
10=>"about to pass out");
$drunklist = translate_inline($drunklist);
$drunk = round($drunk/10-.5, 0);
if ($drunk > 10) $drunk = 10;
$hard = "";
if (get_module_pref('harddrinks')>=get_module_setting('hardlimit')) {
tlschema($drinktexts['schemas']['toomany']);
output_notl("`n`n");
$remark = translate_inline($drinktexts['toomany']);
$remark = str_replace("{lover}",$partner."`0", $remark);
$remark = str_replace("{barkeep}", $drinktext['barkeep']."`0", $remark);
output_notl("%s`n", $remark);
output($drinktexts['toomany']);
output_notl("`n");
$hard = "AND harddrink=0";
}
output("`n`n`7You now feel %s.`n`n", $drunklist[$drunk]);
$sql = "SELECT * FROM " . db_prefix("drinks") . " WHERE active=1 $hard ORDER BY costperlevel";
$result = db_query($sql);
while ($row = db_fetch_assoc($result)) {
$row['allowdrink'] = 1;
$row = modulehook("drinks-check", $row);
if ($row['allowdrink']) {
$drinkcost = $row['costperlevel']*$session['user']['level'];
// No hotkeys on drinks. Too easy for them to interfere
// with and modify stock navs randomly.
addnav(array(" ?%s (`^%s`0 gold)", $row['name'], $drinkcost),
"runmodule.php?module=drinks&act=buy&id={$row['drinkid']}");
}
}
break;
case "newday":
set_module_pref("harddrinks", 0);
$drunk = get_module_pref("drunkeness");
if ($drunk > 66) {
output("`n`&Waking up in the gutter after your last little 'adventure with alcohol', you `\$lose 1`& turn crawling back to your normal lodging.`n");
$args['turnstoday'] .= ", Hangover: -1";
$session['user']['turns']--;
// Sanity check
if ($session['user']['turns'] < 0) $session['user']['turns'] = 0;
}
set_module_pref("drunkeness",0);
break;
case "header-graveyard":
set_module_pref("drunkeness",0);
break;
case "soberup":
$soberval = $args['soberval'];
$sobermsg = $args['sobermsg'];
$drunk = get_module_pref("drunkeness");
if ($drunk > 0) {
$drunk = round($drunk * $soberval, 0);
set_module_pref("drunkeness", $drunk);
if ($sobermsg) {
if ($args['schema']) tlschema($args['schema']);
output($sobermsg);
if ($args['schema']) tlschema();
}
}
break;
case "commentary":
if (($session['user']['superuser'] & SU_IS_GAMEMASTER) && substr($args['commentline'], 0, 5) == "/game") break;
require_once("modules/drinks/drunkenize.php");
$drunk = get_module_pref("drunkeness");
if ($drunk > 50) {
$args['commenttalk'] = "drunkenly {$args['commenttalk']}";
}
$commentline = $args['commentline'];
if (substr($commentline, 0, 1) != ":" &&
substr($commentline, 0, 2) != "::" &&
substr($commentline, 0, 3) != "/me" &&
$drunk > 0) {
$args['commentline'] = drinks_drunkenize($commentline, $drunk);
}
break;
case "superuser":
if (($session['user']['superuser'] & SU_EDIT_USERS) || get_module_pref("canedit")) {
addnav("Module Configurations");
// Stick the admin=true on so that when we call runmodule it'll
// work to let us edit drinks even when the module is deactivated.
addnav("Drinks Editor","runmodule.php?module=drinks&act=editor&admin=true");
}
break;
}//end select
return $args;
}//end function
?>

View File

@ -0,0 +1,44 @@
<?php
function drinks_drunkenize($commentary,$level){
if (get_module_pref("noslur")) return $commentary;
$straight = $commentary;
$replacements=0;
while ($replacements/strlen($straight) < ($level)/500 ){
$slurs = array("a"=>"aa","e"=>"ee","f"=>"ff","h"=>"hh","i"=>"iy","l"=>"ll","m"=>"mm","n"=>"nn","o"=>"oo","r"=>"rr","s"=>"sss","u"=>"oo","v"=>"vv","w"=>"ww","y"=>"yy","z"=>"zz");
if (e_rand(0,9)) {
$letter = array_rand($slurs);
$x = strpos(strtolower($commentary),$letter);
if ($x!==false &&
substr($commentary,$x,5)!="*hic*" &&
substr($commentary,max($x-1,0),5)!="*hic*" &&
substr($commentary,max($x-2,0),5)!="*hic*" &&
substr($commentary,max($x-3,0),5)!="*hic*" &&
substr($commentary,max($x-4,0),5)!="*hic*") {
if (substr($commentary,$x,1)<>strtolower($letter))
$slurs[$letter] = strtoupper($slurs[$letter]);
else
$slurs[$letter] = strtolower($slurs[$letter]);
$commentary = substr($commentary,0,$x).
$slurs[$letter].substr($commentary,$x+1);
$replacements++;
}
}else{
$x = e_rand(0,strlen($commentary));
// Skip the ` followed by a letter
if (substr($commentary,$x-1,1)=="`") {$x += 1; }
if (substr($commentary,$x,5)=="*hic*") {$x+=5; }
if (substr($commentary,max($x-1,0),5)=="*hic*") {$x+=4; }
if (substr($commentary,max($x-2,0),5)=="*hic*") {$x+=3; }
if (substr($commentary,max($x-3,0),5)=="*hic*") {$x+=2; }
if (substr($commentary,max($x-4,0),5)=="*hic*") {$x+=1; }
$commentary = substr($commentary,0,$x).
"*hic*".substr($commentary,$x);
$replacements++;
}//end if
}//end while
//get rid of spare *'s in *hic**hic*
while (strpos($commentary,"*hic**hic*"))
$commentary = str_replace("*hic**hic*","*hic*hic*",$commentary);
return $commentary;
}
?>

View File

@ -0,0 +1,83 @@
<?php
function drinks_install_private(){
if (db_table_exists(db_prefix("drinks"))) {
debug("Drinks table already exists");
}else{
debug("Creating drinks table");
$sqls = array(
"CREATE TABLE " . db_prefix("drinks") . " (
drinkid smallint(6) NOT NULL auto_increment,
name varchar(25) NOT NULL default '',
active tinyint(4) NOT NULL default '0',
costperlevel int(11) NOT NULL default '0',
hpchance tinyint(4) NOT NULL default '0',
turnchance tinyint(4) NOT NULL default '0',
alwayshp tinyint(4) NOT NULL default '0',
alwaysturn tinyint(4) NOT NULL default '0',
drunkeness tinyint(4) NOT NULL default '0',
harddrink tinyint(4) NOT NULL default '0',
hpmin int(11) NOT NULL default '0',
hpmax int(11) NOT NULL default '0',
hppercent int(11) NOT NULL default '0',
turnmin int(11) NOT NULL default '0',
turnmax int(11) NOT NULL default '0',
remarks text NOT NULL default '',
buffname varchar(50) NOT NULL default '',
buffrounds tinyint(4) NOT NULL default '0',
buffroundmsg varchar(75) NOT NULL default '',
buffwearoff varchar(75) NOT NULL default '',
buffatkmod text NOT NULL,
buffdefmod text NOT NULL,
buffdmgmod text NOT NULL,
buffdmgshield text NOT NULL,
buffeffectfailmsg varchar(255) NOT NULL default '',
buffeffectnodmgmsg varchar(255) NOT NULL default '',
buffeffectmsg varchar(255) NOT NULL default '',
PRIMARY KEY (drinkid)) TYPE=MyISAM",
"INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Ale', 1, 10, 2, 1, 0, 0, 33, 0, 0, 0, 10, 1, 1, 'Cedrik pulls out a glass, and pours a foamy ale from a tapped barrel behind him. He slides it down the bar, and you catch it with your warrior-like reflexes.`n`nTurning around, you take a big chug of the hearty draught, and give {lover} an ale-foam mustache smile.`n`n', '`#Buzz', 10, 'You\\'ve got a nice buzz going.', 'Your buzz fades.', '1.25', '0', '0', '0', '', '', '')",
"INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Habanero Martini', 1, 15, 0, 0, 1, 1, 50, 1, -5, 15, 0.0, -1, 1, 'Cedrik pulls out a bottle labeled with 3 X\\'s and a chile pepper and pours a miniscule shot into your glass. You toss it back and grimace as smoke floods out of your ears.', '`\$Hot Hands', 12, 'You feel like your hands are about to burn off.', 'Finally, your hands are no longer burning.', '1.1', '.9', '1.5', '0', '', '', '')",
"INSERT INTO " . db_prefix("drinks") . " VALUES (0, 'Mule Daniels', 1, 25, 2, 3, 0, 0, 50, 1, -10, -1, 0.0, 1, 3, 'Cedrik drags a large pony-keg out from behind the bar and pours a slug into a cast iron cup which rattles as the thick liquid is poured into it. You toss it back in a gulp and make a face like a mule kicked you hard in the gut. From across the room, you hear {lover} laugh at you.', '`#Mulekick', 15, 'You hear a donkey braying in the distance', 'That donkey finally shuts up.', '0', '0', '1.3', '1.3', 'Your head rings as the donkey kicks you instead.', 'That mule would have kicked {badguy} to the moon, but it missed!', '{badguy} sees`$ {damage}`) stars as the mule kicks him over the moon.')"
);
while (list($key,$sql)=each($sqls)){
db_query($sql);
}
}
// See if we're migrating from an old version of the drinks code with a
// buffactivate field
$sql = "DESCRIBE ". db_prefix("drinks");
$result = db_query($sql);
while($row = db_fetch_assoc($result)) {
if ($row['Field']=="buffactivate"){
debug("Dropping buffactivate from the drinks table.");
$sql = "ALTER TABLE " . db_prefix("drinks") . " DROP buffactivate";
db_query($sql);
} // end if
if ($row['Field']=="hppercent" && $row['Type']=="float") {
debug("Altering {$row['Field']} from float to int in the drinks table.");
$sql = "UPDATE " . db_prefix("drinks") . " SET hppercent=hppercent*100";
db_query($sql);
$sql = "ALTER TABLE " . db_prefix("drinks") . " CHANGE {$row['Field']} {$row['Field']} int(11) NOT NULL DEFAULT 0";
db_query($sql);
}
if (($row['Field']=="buffatkmod" || $row['Field']=="buffdefmod" ||
$row['Field']=="buffdmgmod" || $row['Field']=="buffdmgshield") &&
($row['Type'] == "float")) {
debug("Altering {$row['Field']} from float to text in the drinks table.");
$sql = "ALTER TABLE " . db_prefix("drinks") . " CHANGE {$row['Field']} {$row['Field']} text NOT NULL";
db_query($sql);
}
} // end while
// Install the hooks.
module_addhook("ale");
module_addhook("newday");
module_addhook("superuser");
module_addhook("header-graveyard");
module_addhook("commentary");
module_addhook("soberup");
module_addhook("dragonkill");
return true;
}
?>

View File

@ -0,0 +1,247 @@
<?php
function drinks_gettexts() {
global $session;
$iname = getsetting("innname", LOCATION_INN);
$drinktext = array(
"title"=>"$iname",
"barkeep"=>getsetting("barkeep", "`tCedrik"),
"return"=>"",
"demand"=>"Pounding your fist on the bar, you demand another drink",
"toodrunk"=>" but {barkeep} continues to clean the glass he was working on. \"`%You've had enough ".($session['user']['sex']?"lass":"lad").",`0\" he declares.",
"toomany"=>"{barkeep} eyes you critically. \"`%Ya've had enough of the hard stuff, my friend. No more of that for you today.`0\"",
"drinksubs"=>array(),
);
$schemas = array(
'title'=>"module-drinks",
'barkeep'=>"module-drinks",
'return'=>"module-drinks",
'demand'=>"module-drinks",
'toodrunk'=>"module-drinks",
'toomany'=>"module-drinks",
'drinksubs'=>"module-drinks",
);
$drinktext['schemas'] = $schemas;
return $drinktext;
}
// Support functions
function drinks_editor(){
global $mostrecentmodule;
if (!get_module_pref("canedit")) check_su_access(SU_EDIT_USERS);
page_header("Drink Editor");
require_once("lib/superusernav.php");
superusernav();
addnav("Drink Editor");
addnav("Add a drink","runmodule.php?module=drinks&act=editor&op=add&admin=true");
$op = httpget('op');
$drinkid = httpget('drinkid');
$header = "";
if ($op != "") {
addnav("Drink Editor Main","runmodule.php?module=drinks&act=editor&admin=true");
if ($op == 'add') {
$header = translate_inline("Adding a new drink");
} else if ($op == 'edit') {
$header = translate_inline("Editing a drink");
}
} else {
$header = translate_inline("Current drinks");
}
output_notl("`&<h3>$header`0</h3>", true);
$drinksarray=array(
"Drink,title",
"drinkid"=>"Drink ID,hidden",
"name"=>"Drink Name",
"costperlevel"=>"Cost per level,int",
"hpchance"=>"Chance of modifying HP (see below),range,0,10,1",
"turnchance"=>"Chance of modifying turns (see below),range,0,10,1",
"alwayshp"=>"Always modify hitpoints,bool",
"alwaysturn"=>"Always modify turns,bool",
"drunkeness"=>"Drunkeness,range,1,100,1",
"harddrink"=>"Is drink hard alchohol?,bool",
"hpmin"=>"Min HP to add (see below),range,-20,20,1",
"hpmax"=>"Max HP to add (see below),range,-20,20,1",
"hppercent"=>"Modify HP by some percent (see below),range,-25,25,5",
"turnmin"=>"Min turns to add (see below),range,-5,5,1",
"turnmax"=>"Max turns to add (see below),range,-5,5,1",
"remarks"=>"Remarks",
"buffname"=>"Name of the buff",
"buffrounds"=>"Rounds buff lasts,range,1,20,1",
"buffroundmsg"=>"Message each round of buff",
"buffwearoff"=>"Message when buff wears off",
"buffatkmod"=>"Attack modifier of buff",
"buffdefmod"=>"Defense modifier of buff",
"buffdmgmod"=>"Damage modifier of buff",
"buffdmgshield"=>"Damage shield modifier of buff",
"buffeffectfailmsg"=>"Effect failure message (see below)",
"buffeffectnodmgmsg"=>"No damage message (see below)",
"buffeffectmsg"=>"Effect message (see below)",
);
if($op=="del"){
$sql = "DELETE FROM " . db_prefix("drinks") . " WHERE drinkid='$drinkid'";
module_delete_objprefs('drinks', $drinkid);
db_query($sql);
$op = "";
httpset('op', "");
}
if($op=="save"){
$subop = httpget("subop");
if ($subop=="") {
$drinkid = httppost("drinkid");
list($sql, $keys, $vals) = postparse($drinksarray);
if ($drinkid > 0) {
$sql = "UPDATE " . db_prefix("drinks") . " SET $sql WHERE drinkid='$drinkid'";
} else {
$sql = "INSERT INTO " . db_prefix("drinks") . " ($keys) VALUES ($vals)";
}
db_query($sql);
if (db_affected_rows()> 0) {
output("`^Drink saved!");
} else {
$str = db_error();
if ($str == "") {
output("`^Drink not saved: no changes detected.");
} else {
output("`^Drink not saved: `\$%s`0", $sql);
}
}
} elseif ($subop == "module") {
$drinkid = httpget("drinkid");
// Save module settings
$module = httpget("editmodule");
// This should obey the same rules as the configuration editor
// So disabling
//$sql = "DELETE FROM " . db_prefix("module_objprefs") . " WHERE objtype='drinks' AND objid='$drinkid' AND modulename='$module'";
//db_query($sql);
$post = httpallpost();
reset($post);
while(list($key, $val)=each($post)) {
set_module_objpref("drinks", $drinkid,$key, $val, $module);
}
output("`^Saved.");
}
if ($drinkid) {
$op = "edit";
httpset("drinkid", $drinkid, true);
} else {
$op = "";
}
httpset('op', $op);
}
if ($op == "activate") {
$sql = "UPDATE " . db_prefix("drinks") . " SET active=1 WHERE drinkid='$drinkid'";
db_query($sql);
$op = "";
httpset('op', "");
}
if ($op == "deactivate") {
$sql = "UPDATE " . db_prefix("drinks") . " SET active=0 WHERE drinkid='$drinkid'";
db_query($sql);
$op = "";
httpset('op', "");
}
if ($op==""){
$op = translate_inline("Ops");
$id = translate_inline("Id");
$nm = translate_inline("Name");
$dkn = translate_inline("Drunkeness");
$hard = translate_inline("Hard Alchohol?");
$edit = translate_inline("Edit");
$deac = translate_inline("Deactivate");
$act = translate_inline("Activate");
$conf = translate_inline("Are you sure you wish to delete this drink?");
$del = translate_inline("Del");
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
rawoutput("<tr class='trhead'>");
rawoutput("<td>$op</td><td>$id</td><td>$nm</td><td>$dkn</td><td>$hard</td>");
rawoutput("</tr>");
$sql = "SELECT drinkid,active,name,drunkeness,harddrink FROM " . db_prefix("drinks") . " ORDER BY drinkid";
$result= db_query($sql);
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$id = $row['drinkid'];
rawoutput("<tr class='".($i%2?"trlight":"trdark")."'>");
rawoutput("<td nowrap>[ <a href='runmodule.php?module=drinks&act=editor&op=edit&drinkid=$id&admin=true'>$edit</a>");
addnav("","runmodule.php?module=drinks&act=editor&op=edit&drinkid=$id&admin=true");
if ($row['active']) {
rawoutput(" | <a href='runmodule.php?module=drinks&act=editor&op=deactivate&drinkid=$id&admin=true'>$deac</a>");
addnav("","runmodule.php?module=drinks&act=editor&op=deactivate&drinkid=$id&admin=true");
} else {
rawoutput(" | <a href='runmodule.php?module=drinks&act=editor&op=activate&drinkid=$id&admin=true'>$act</a>");
addnav("","runmodule.php?module=drinks&act=editor&op=activate&drinkid=$id&admin=true");
}
rawoutput(" | <a href='runmodule.php?module=drinks&act=editor&op=del&drinkid=$id&admin=true' onClick='return confirm(\"$conf\");'>$del</a> ]</td>");
addnav("","runmodule.php?module=drinks&act=editor&op=del&drinkid=$id&admin=true");
output_notl("<td>`^%s</td>`0", $id, true);
output_notl("<td>`&%s`0</td>", $row['name'], true);
output_notl("<td>`^%s`0</td>", $row['drunkeness'], true);
$hard = translate_inline("`^No");
if ($row['harddrink']) $hard = translate_inline("`\$Yes");
output_notl("<td>%s`0</td>", $hard, true);
rawoutput("</tr>");
}
rawoutput("</table>");
}
$subop= httpget("subop");
if($op=="edit"){
addnav("Drink properties", "runmodule.php?module=drinks&act=editor&op=edit&drinkid=$drinkid&admin=true");
module_editor_navs("prefs-drinks", "runmodule.php?module=drinks&act=editor&drinkid=$drinkid&op=edit&subop=module&editmodule=");
if ($subop=="module") {
$module = httpget("editmodule");
$oldmodule = $mostrecentmodule;
rawoutput("<form action='runmodule.php?module=drinks&act=editor&op=save&subop=module&editmodule=$module&drinkid=$drinkid&admin=true' method='POST'>");
module_objpref_edit('drinks', $module, $drinkid);
$mostrecentmodule = $oldmodule;
rawoutput("</form>");
addnav("", "runmodule.php?module=drinks&act=editor&op=save&subop=module&editmodule=$module&drinkid=$drinkid&admin=true");
} elseif ($subop=="") {
$sql = "SELECT * FROM " . db_prefix("drinks") . " WHERE drinkid='".httpget('drinkid')."'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
}
}elseif ($op=="add"){
/* We're adding a new drink, make an empty row */
$row = array();
$row['drinkid'] = 0;
}
if (($op == "edit" || $op == "add") && $subop=="") {
rawoutput("<form action='runmodule.php?module=drinks&act=editor&op=save&admin=true' method='POST'>");
addnav("","runmodule.php?module=drinks&act=editor&op=save&admin=true");
showform($drinksarray,$row);
rawoutput("</form>");
output("`\$NOTE:`7 Make sure that you know what you are doing when modifying or adding drinks.`n");
output("Just because the drinks have a lot of options, doesn't mean you have to use all of them`n`n");
output("`2Drink ID: `7This field is used internally and should be unique.`n");
output("`2Name: `7The name of the drink the user will see.`n");
output("`2Cost per level: `7This value times the users level is the drink cost.`n");
output("`2Chance of modifying HP: `7If set, this is the number of chances out of the total of this and the turn chance for HP getting modified.`n");
output("`2Chance of modifying turns: `7If set, this is the number of chances out of the total of this and the HP chance for turns getting modified.`n");
output("`2Always modify HP: `7If set, hitpoints will be modified. Should not be set alongside HP chance above.`n");
output("`2Always modify turns: `7If set, turns will be modified. Should not be set alongside turn chance above.`n");
output("`2Drunkeness: `7How drunk will this make the player.`n");
output("`2Hard Drink: `7Users are only allowed a certain number of hard drinks per day regardless of drunkeness.`n");
output("`2Min HP to add: `7If we are modifying hitpoints, and if HP percent isn't set, use this and the HP max value to pick a random amount of HP to add. Can be negative.`n");
output("`2Max HP to add: `7If we are modifying hitpoints and if HP percent isn't set, use this and the HP min value to pick a random amount of HP to add. Can be negative.`n");
output("`2HP percent: `7If we are modifying hitpoints and if this is set, the users hitpoints are modified by this percentage. Can be negative.`n");
output("`2Min turns to add: `7If we are modifying turns, use this and the turn max value to pick a random amount of turns to add. Can be negative.`n");
output("`2Max turns to add: `7If we are modifying turns, use this and the turn min value to pick a random amount of turns to add. Can be negative.`n");
output("`2Remarks: `7Text displayed to the user when they order the drink.`n");
output("`2Buff name: `7What is this buff called.`n");
output("`2Buff rounds: `7How many rounds this buff lasts.`n");
output("`2Buff round message: `7What message should show as each round occurs.`n");
output("`2Buff wearoff: `7What message is shown when this buff wears off.`n");
output("`2Buff attack modifier: `7Multiplier to modify attack points by? 1.0 is no modification, 2.0 doubles their attack points.`n");
output("`2Buff defense modifier: `7Multiplier to modify defense points by? 1.0 is no modification, 2.0 doubles their defense points.`n");
output("`2Buff damage modifier: `7Multiplier to modify damage by? 1.0 is no modification, 2.0 doubles their damage points. This is `\$VERY POTENT`7!`n");
output("`2Buff damage shield modifier: `7When you are hit, deals damage to your opponent based on damage done to you. 1.0 deals identical damage, 2.0 deals double damage back to the opponent.`n");
output("`2Effect failure message: Message if this buff fails. (Only used with damage shield)`n");
output("`2Effect no damage message: Message if no damage is done. (Only used with damage shield)`n");
output("`2Effect message: What shows when this buff has an effect. (Only used with damage shield)`n`n");
}
page_footer();
}
?>

View File

@ -0,0 +1,155 @@
<?php
function drinks_run_private(){
require_once("modules/drinks/misc_functions.php");
require_once("lib/partner.php");
global $session;
$partner = get_partner();
$act = httpget('act');
if ($act=="editor"){
drinks_editor();
}elseif ($act=="buy"){
$texts = drinks_gettexts();
$drinktext = modulehook("drinks-text",$texts);
tlschema($drinktext['schemas']['title']);
page_header($drinktext['title']);
rawoutput("<span style='color: #9900FF'>");
output_notl("`c`b");
output($drinktext['title']);
output_notl("`b`c");
tlschema();
$drunk = get_module_pref("drunkeness");
$end = ".";
if ($drunk > get_module_setting("maxdrunk"))
$end = ",";
tlschema($drinktext['schemas']['demand']);
$remark = translate_inline($drinktext['demand']);
$remark = str_replace("{lover}",$partner."`0", $remark);
$remark = str_replace("{barkeep}", $drinktext['barkeep']."`0", $remark);
tlschema();
output_notl("%s$end", $remark);
$drunk = get_module_pref("drunkeness");
if ($drunk > get_module_setting("maxdrunk")) {
tlschema($drinktext['schemas']['toodrunk']);
$remark = translate_inline($drinktext['toodrunk']);
tlschema();
$remark = str_replace("{lover}",$partner."`0", $remark);
$remark = str_replace("{barkeep}", $drinktext['barkeep']."`0", $remark);
output($remark);
tlschema();
} else {
$sql = "SELECT * FROM " . db_prefix("drinks") . " WHERE drinkid='".httpget('id')."'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
$drinkcost = $session['user']['level'] * $row['costperlevel'];
if ($session['user']['gold'] >= $drinkcost) {
$drunk = get_module_pref("drunkeness");
$drunk += $row['drunkeness'];
set_module_pref("drunkeness", $drunk);
$session['user']['gold'] -= $drinkcost;
debuglog("spent $drinkcost on {$row['name']}");
$remark = str_replace("{lover}",$partner."`0", $row['remarks']);
$remark = str_replace("{barkeep}", $drinktext['barkeep']."`0", $remark);
if (count($drinktext['drinksubs']) > 0) {
$keys = array_keys($drinktext['drinksubs']);
$vals = array_values($drinktext['drinksubs']);
$remark = preg_replace($keys, $vals, $remark);
}
output($remark);
output_notl("`n`n");
if ($row['harddrink']) {
$drinks = get_module_pref("harddrinks");
set_module_pref("harddrinks", $drinks+1);
}
$givehp = 0;
$giveturn = 0;
if ($row['hpchance']>0 || $row['turnchance']>0) {
$tot = $row['hpchance'] + $row['turnchance'];
$c = e_rand(1, $tot);
if ($c <= $row['hpchance'] && $row['hpchance']>0)
$givehp = 1;
else
$giveturn = 1;
}
if ($row['alwayshp']) $givehp = 1;
if ($row['alwaysturn']) $giveturn = 1;
if ($giveturn) {
$turns = e_rand($row['turnmin'], $row['turnmax']);
$oldturns = $session['user']['turns'];
$session['user']['turns'] += $turns;
// sanity check
if ($session['user']['turns'] < 0)
$session['user']['turns'] = 0;
if ($oldturns < $session['user']['turns']) {
output("`&You feel vigorous!`n");
} else if ($oldturns > $session['user']['turns']) {
output("`&You feel lethargic!`n");
}
}
if ($givehp) {
$oldhp = $session['user']['hitpoints'];
// Check for percent increase first
if ($row['hppercent'] != 0.0) {
$hp = round($session['user']['maxhitpoints'] *
($row['hppercent']/100), 0);
} else {
$hp = e_rand($row['hpmin'], $row['hpmax']);
}
$session['user']['hitpoints'] += $hp;
// Sanity check
if ($session['user']['hitpoints'] < 1)
$session['user']['hitpoints'] = 1;
if ($oldhp < $session['user']['hitpoints']) {
output("`&You feel healthy!`n");
} else if ($oldhp > $session['user']['hitpoints']) {
output("`&You feel sick!`n");
}
}
$buff = array();
$buff['name'] = $row['buffname'];
$buff['rounds'] = $row['buffrounds'];
if ($row['buffwearoff'])
$buff['wearoff'] = $row['buffwearoff'];
if ($row['buffatkmod'])
$buff['atkmod'] = $row['buffatkmod'];
if ($row['buffdefmod'])
$buff['defmod'] = $row['buffdefmod'];
if ($row['buffdmgmod'])
$buff['dmgmod'] = $row['buffdmgmod'];
if ($row['buffdmgshield'])
$buff['damageshield'] = $row['buffdmgshield'];
if ($row['buffroundmsg'])
$buff['roundmsg'] = $row['buffroundmsg'];
if ($row['buffeffectmsg'])
$buff['effectmsg'] = $row['buffeffectmsg'];
if ($row['buffeffectnodmgmsg'])
$buff['effectnodmgmsg'] = $row['buffeffectnodmgmsg'];
if ($row['buffeffectfailmsg'])
$buff['effectfailmsg'] = $row['buffeffectfailmsg'];
$buff['schema'] = "module-drinks";
apply_buff('buzz',$buff);
} else {
output("You don't have enough money. How can you buy %s if you don't have any money!?!", $row['name']);
}
}
rawoutput("</span>");
if ($drinktext['return']>""){
tlschema($drinktext['schemas']['return']);
addnav($drinktext['return'],$drinktext['returnlink']);
tlschema();
}else{
tlschema($drinktext['schemas']['return']);
addnav("I?Return to the Inn","inn.php");
addnav(array("Go back to talking to %s`0", getsetting("barkeep", "`tCedrik")),"inn.php?op=bartender");
tlschema();
}
require_once("lib/villagenav.php");
villagenav();
page_footer();
}
}
?>

130
lotgd-web/lotgd/modules/fairy.php Executable file
View File

@ -0,0 +1,130 @@
<?php
// mail ready
// addnews ready
// translator ready
function fairy_getmoduleinfo(){
$info = array(
"name"=>"Forest Fairy",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
"settings"=>array(
"Fairy Forest Event Settings,title",
"carrydk"=>"Do max hitpoints gained carry across DKs?,bool|1",
"hptoaward"=>"How many HP are given by the fairy?,range,1,5,1|1",
"fftoaward"=>"How many FFs are given by the fairy?,range,1,5,1|1",
),
"prefs"=>array(
"Fairy Forest Event User Preferences,title",
"extrahps"=>"How many extra hitpoints has the user gained?,int",
),
);
return $info;
}
function fairy_install(){
module_addeventhook("forest", "return 100;");
module_addhook("hprecalc");
return true;
}
function fairy_uninstall(){
return true;
}
function fairy_dohook($hookname,$args){
switch($hookname){
case "hprecalc":
$args['total'] -= get_module_pref("extrahps");
if (!get_module_setting("carrydk")) {
$args['extra'] -= get_module_pref("extrahps");
set_module_pref("extrahps", 0);
}
break;
}
return $args;
}
function fairy_runevent($type)
{
require_once("lib/increment_specialty.php");
global $session;
// We assume this event only shows up in the forest currently.
$from = "forest.php?";
$session['user']['specialinc'] = "module:fairy";
$op = httpget('op');
if ($op=="" || $op=="search"){
output("`%You encounter a fairy in the forest.");
output("\"`^Give me a gem!`%\" she demands.");
output("What do you do?");
addnav("Give her a gem", $from."op=give");
addnav("Don't give her a gem", $from."op=dont");
}elseif ($op=="give"){
$session['user']['specialinc'] = "";
if ($session['user']['gems']>0){
output("`%You give the fairy one of your hard-earned gems.");
output("She looks at it, squeals with delight, and promises a gift in return.");
output("She hovers over your head, sprinkles golden fairy dust down on you before flitting away.");
output("You discover that ...`n`n`^");
$session['user']['gems']--;
debuglog("gave 1 gem to a fairy");
switch(e_rand(1,7)){
case 1:
$extra = get_module_setting("fftoaward");
if ($extra == 1) output("You receive an extra forest fight!");
else output("You receive %s extra forest fights!", $extra);
$session['user']['turns'] += $extra;
break;
case 2:
case 3:
output("You feel perceptive and notice `%TWO gems`^ nearby!");
$session['user']['gems']+=2;
debuglog("found 2 gem from a fairy");
break;
case 4:
case 5:
$hptype = "permanently";
if (!get_module_setting("carrydk") ||
(is_module_active("globalhp") &&
!get_module_setting("carrydk", "globalhp")))
$hptype = "temporarily";
$hptype = translate_inline($hptype);
$extra = get_module_setting("hptoaward");
output("Your maximum hitpoints are `b%s`b increased by %d!",
$hptype, $extra);
$session['user']['maxhitpoints'] += $extra;
$session['user']['hitpoints'] += $extra;
set_module_pref("extrahps",
get_module_pref("extrahps")+$extra);
break;
case 6:
case 7:
increment_specialty("`^");
break;
}
}else{
output("`%You promise to give the fairy a gem, however, when you open your purse, you discover that you have none.");
output("The tiny fairy floats before you, tapping her foot on the air as you try to explain why it is that you lied to her.`n`n");
output("Having had enough of your mumblings, she sprinkles some angry red fairy dust on you.");
output("Your vision blacks out, and when you wake again, you cannot tell where you are.");
output("You spend enough time searching for the way back to the village that you lose time for a forest fight.");
$session['user']['turns']--;
}
output("`0");
}else{
if ($session['user']['gems']) {
output("`%Not wanting to part with one of your precious precious gems, you swat the tiny creature to the ground and walk away.`0");
} else {
output("`%Not having any gems to part with, you swat the tiny creature to the ground and walk away.`0");
}
$session['user']['specialinc'] = "";
}
}
function fairy_run(){
}
?>

View File

@ -0,0 +1,40 @@
<?php
// translator ready
// mail ready
// addnews ready
function findgem_getmoduleinfo(){
$info = array(
"name"=>"Find Gems",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
);
return $info;
}
function findgem_install(){
module_addeventhook("forest", "return 100;");
module_addeventhook("travel", "return 20;");
return true;
}
function findgem_uninstall(){
return true;
}
function findgem_dohook($hookname,$args){
return $args;
}
function findgem_runevent($type,$link)
{
global $session;
output("`^Fortune smiles on you and you find a `%gem`^!`0");
$session['user']['gems']++;
debuglog("found a gem in the dirt");
}
function findgem_run(){
}
?>

View File

@ -0,0 +1,48 @@
<?php
// translator ready
// mail ready
// addnews ready
function findgold_getmoduleinfo(){
$info = array(
"name"=>"Find Gold",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
"settings"=>array(
"Find Gold Event Settings,title",
"mingold"=>"Minimum gold to find (multiplied by level),range,0,50,1|10",
"maxgold"=>"Maximum gold to find (multiplied by level),range,20,150,1|50"
),
);
return $info;
}
function findgold_install(){
module_addeventhook("forest", "return 100;");
module_addeventhook("travel", "return 20;");
return true;
}
function findgold_uninstall(){
return true;
}
function findgold_dohook($hookname,$args){
return $args;
}
function findgold_runevent($type,$link)
{
global $session;
$min = $session['user']['level']*get_module_setting("mingold");
$max = $session['user']['level']*get_module_setting("maxgold");
$gold = e_rand($min, $max);
output("`^Fortune smiles on you and you find %s gold!`0", $gold);
$session['user']['gold']+=$gold;
debuglog("found $gold gold in the dirt");
}
function findgold_run(){
}
?>

View File

@ -0,0 +1,87 @@
<?php
// mail ready
// addnews ready
// translator ready
function foilwench_getmoduleinfo(){
$info = array(
"name"=>"Foilwench",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
);
return $info;
}
function foilwench_install(){
module_addeventhook("forest", "return 100;");
return true;
}
function foilwench_uninstall(){
return true;
}
function foilwench_dohook($hookname,$args){
return $args;
}
function foilwench_runevent($type)
{
require_once("lib/increment_specialty.php");
global $session;
// We assume this event only shows up in the forest currently.
$from = "forest.php?";
$session['user']['specialinc'] = "module:foilwench";
$colors = array(""=>"`7");
$colors = modulehook("specialtycolor", $colors);
$c = $colors[$session['user']['specialty']];
if (!$c) $c = "`7";
if ($session['user']['specialty'] == "") {
output("You have no direction in the world, you should rest and make some important decisions about your life.");
$session['user']['specialinc']="";
return;
}
$skills = modulehook("specialtynames");
$op = httpget('op');
if ($op=="give"){
if ($session['user']['gems']>0){
output("%sYou give `@Foil`&wench%s a gem, and she hands you a slip of parchment with instructions on how to advance in your specialty.`n`n", $c, $c);
output("You study it intensely, shred it up, and eat it lest infidels get ahold of the information.`n`n");
output("`@Foil`&wench%s sighs... \"`&You didn't have to eat it... Oh well, now be gone from here!%s\"`3", $c, $c);
increment_specialty("`3");
$session['user']['gems']--;
debuglog("gave 1 gem to Foilwench");
}else{
output("%sYou hand over your imaginary gem.", $c);
output("`@Foil`&wench%s stares blankly back at you.", $c);
output("\"`&Come back when you have a `breal`b gem you simpleton.%s\"`n`n", $c);
output("\"`#Simpleton?%s\" you ask.`n`n", $c);
output("With that, `@Foil`&wench%s throws you out.`0", $c);
}
$session['user']['specialinc']="";
}elseif($op=="dont"){
output("%sYou inform `@Foil`&wench%s that if she would like to get rich, she will have to do so on her efforts, and stomp away.", $c, $c);
$session['user']['specialinc']="";
}elseif($session['user']['specialty']!=""){
output("%sYou are seeking prey in the forest when you stumble across a strange hut.", $c);
output("Ducking inside, you are met by the grizzled face of a battle-hardened old woman.");
output("\"`&Greetings %s`&, I am `@Foil`&wench, master of all.%s\"`n`n", $session['user']['name'], $c);
output("\"`#Master of all?%s\" you inquire.`n`n", $c);
output("\"`&Yes, master of all. All the skills are mine to control, and to teach.%s\"`n`n", $c);
output("\"`#Yours to teach?%s\" you query.`n`n", $c);
output("The old woman sighs, \"`&Yes, mine to teach. I will teach you how to advance in %s on two conditions.%s\"`n`n", $skills[$session['user']['specialty']], $c);
output("\"`#Two conditions?%s\" you repeat inquisitively.`n`n", $c);
output("\"`&Yes. First, you must give me a gem, and second you must stop repeating what I say in the form of a question!%s\"`n`n", $c);
output("\"`#A gem!%s\" you state definitively.`n`n", $c);
output("\"`&Well... I guess that wasn't a question. So how about that gem?%s\"", $c);
addnav("Give her a gem", $from."op=give");
addnav("Don't give her a gem",$from."op=dont");
}
}
function foilwench_run(){
}
?>

View File

@ -0,0 +1,118 @@
<?php
// addnews ready
// mail ready
// translator ready
function game_dice_getmoduleinfo(){
$info = array(
"name"=>"Dice Game for DarkHorse",
"author"=>"Eric Stevens",
"version"=>"1.1",
"category"=>"Darkhorse Game",
"download"=>"core_module",
);
return $info;
}
function game_dice_install(){
global $session;
debug("Adding Hooks");
module_addhook("darkhorsegame");
return true;
}
function game_dice_uninstall(){
output("Uninstalling this module.`n");
return true;
}
function game_dice_dohook($hookname, $args){
if ($hookname=="darkhorsegame"){
$ret = urlencode($args['return']);
addnav("D?Play Dice Game",
"runmodule.php?module=game_dice&ret=$ret");
}
return $args;
}
function game_dice_run(){
global $session;
$ret = urlencode(httpget("ret"));
page_header("A Game of Dice");
if ($session['user']['gold']>0){
$bet = abs((int)httpget('bet') + (int)httppost('bet'));
if ($bet<=0){
addnav("Never mind", appendlink(urldecode($ret), "op=oldman"));
output("`3\"`!You get to roll a die, and choose to keep or pass on the roll. If you pass, you get up to two more chances to roll, for a total of three rolls. Once you keep your roll (or on the third roll), I will do the same. In the end, if my die is higher than yours, I win, if yours is higher, you win, and if they are a tie, neither of us wins, and we each keep our bet.`3\"`n`n");
output("`3\"`!How much would you bet young %s?`3\"", translate_inline($session['user']['sex']?"lady":"man"));
rawoutput("<form action='runmodule.php?module=game_dice&ret=$ret' method='POST'>");
rawoutput("<input name='bet' id='bet'>");
$b = translate_inline("Bet");
rawoutput("<input type='submit' class='button' value='$b'>");
rawoutput("</form>");
rawoutput("<script language='JavaScript'>document.getElementById('bet').focus();</script>");
addnav("","runmodule.php?module=game_dice&ret=$ret");
}else if($bet>$session['user']['gold']){
output("`3The old man reaches out with his stick and pokes your coin purse.");
output("\"`!I don't believe you have `^%s`! gold!`3\" he declares.`n`n", $bet);
output("Desperate to really show him good, you open up your purse and spill out its contents: `^%s`3 gold.`n`n", $session['user']['gold']);
output("Embarrassed, you think you'll head back to the tavern.");
addnav("Return to the Main Room",appendlink(urldecode($ret), "op=tavern"));
} else {
$what = httpget('what');
if ($what!="keep"){
$session['user']['specialmisc']=e_rand(1,6);
$try=(int)httpget('try');
$try++;
switch ($try) {
case 1: $die = "first"; break;
case 2: $die = "second"; break;
default: $die = "third"; break;
}
$die = translate_inline($die);
output("You roll your %s die, and it comes up as `b%s`b`n`n", $die, $session['user']['specialmisc']);
output("`3You have bet `^%s`3.", $bet);
output("What do you do?");
addnav("Keep","runmodule.php?module=game_dice&what=keep&bet=$bet&ret=$ret");
if ($try<3)
addnav("Pass","runmodule.php?module=game_dice&what=pass&try=$try&bet=$bet&ret=$ret");
}else{
output("Your final roll was `b%s`b, the old man will now try to beat it:`n`n", $session['user']['specialmisc']);
$r = e_rand(1,6);
output("The old man rolls a %s...`n", $r);
if ($r>$session['user']['specialmisc'] || $r==6){
output("\"`7I think I'll stick with that roll!`0\" he says.`n");
}else{
$r = e_rand(1,6);
output("The old man rolls again and gets a %s...`n", $r);
if ($r>=$session['user']['specialmisc']){
output("\"`7I think I'll stick with that roll!`0\" he says.`n");
}else{
$r = e_rand(1,6);
output("The old man rolls his final roll and gets a %s...`n", $r);
}
}
if ($r>$session['user']['specialmisc']){
output("`n\"`7Yeehaw, I knew the likes of you would never stand up to the likes of me!`0\" exclaims the old man as you hand him your `^%s`0 gold.", $bet);
$session['user']['gold']-=$bet;
debuglog("lost $bet gold at dice");
}elseif ($r==$session['user']['specialmisc']){
output("`n\"`7Yah... well, looks as though we tied.`0\" he says.");
}else{
output("`n\"`7Aaarrgh!!! How could the likes of you beat me?!?!?`0\" shouts the old man as he gives you the gold he owes.");
$session['user']['gold']+=$bet;
debuglog("won $bet gold at dice");
}
addnav("Play again?","runmodule.php?module=game_dice&ret=$ret");
addnav("Other Games",appendlink(urldecode($ret), "op=oldman"));
addnav("Return to the Main Room", appendlink(urldecode($ret), "op=tavern"));
}
}
}else{
output("`3The old man reaches out with his stick and pokes your coin purse. \"`!Empty?!?! How can you bet with no money??`3\" he shouts.");
output("With that, he turns back to his dice, apparently having already forgotten his anger.");
addnav("Return to the Main Room", appendlink(urldecode($ret), "op=tavern"));
}
page_footer();
}
?>

View File

@ -0,0 +1,193 @@
<?php
/*Five Sixes tavern game
version 1.7
- Added periods at the end of News announcements
version 1.6
- Fixed newday reset
version 1.5
- Added win function for rolling 3 sixes
- Included winner list for 4 and 3 sixes on the entry page
*/
function game_fivesix_getmoduleinfo(){
$info = array(
"name"=>"Five Sixes Dice Game",
"author"=>"`4Talisman",
"version"=>"1.7",
"category"=>"Darkhorse Game",
"download"=>"core_module",
"settings"=>array(
"Five Sixes Dice Game,title",
"cost"=>"Cost to play,int|5",
"dailyuses"=>"Plays per day (0=unlimited),int|10",
"jackpot"=>"Gold in the pot,int|100",
"maxjackpot"=>"Maximum Payout,int|5000",
"lastwin5"=>"Last jackpot winner|Nobody...yet",
"lastpot5"=>"Last Jackpot Won,int|0",
"lastwin4"=>"Last winner of 4 sixes|Nobody...yet",
"lastpot4"=>"Last Jackpot Won,int|0",
"lastwin3"=>"Last winner of 3 sixes|Nobody...yet",
"lastpot3"=>"Last Jackpot Won,int|0",
),
"prefs"=>array(
"Five Sixes Dice, title",
"playstoday"=>"Times played today,int|0",
)
);
return $info;
}
function game_fivesix_install(){
global $session;
module_addhook("darkhorsegame");
module_addhook("newday");
return true;
}
function game_fivesix_uninstall(){
return true;
}
function game_fivesix_dohook($hookname, $args){
global $session;
switch($hookname){
case "newday":
set_module_pref("playstoday",0);
break;
case "darkhorsegame":
$ret = urlencode($args['return']);
addnav("Play Sixes Dice Game",
"runmodule.php?module=game_fivesix&ret=$ret&what=play");
}
return $args;
}
function game_fivesix_run(){
global $session;
$ret = urlencode(httpget("ret"));
page_header("A Game of Dice");
$prize=get_module_setting("jackpot");
$cost=get_module_setting("cost");
$what = httpget('what');
if ($what=="play"){
output("`n`@So you'd like to try your hand to rolling five sixes, would you?`n");
output("The game is quite simple, really - you roll five dice.");
output("If all five display sixes, you win the jackpot.`n`n");
output("`^It only costs you %s gold to play, and the current jackpot is %s gold pieces.`n`n", $cost, $prize);
$lastpot5=get_module_setting("lastpot5");
if ($lastpot5>=1){
$lastwin5=get_module_setting("lastwin5");
output("`@The last jackpot, worth %s gold was won by %s.`n`n",$lastpot5,$lastwin5);
}else{
output("`@The jackpot has never been won - you could be the first!`n`n");
}
$lastpot4=get_module_setting("lastpot4");
if ($lastpot4>=1) {
output("%s`@, in a peerless display, won `^%s `@gold for rolling 4 sixes.`n`n", get_module_setting("lastwin4"), get_module_setting("lastpot4"));
}
$lastpot3=get_module_setting("lastpot3");
if ($lastpot3>=1) {
output("If you need a loan, you might talk to %s`@, who won `^%s`@ gold for getting just three sixes.`n`n", get_module_setting("lastwin3"), get_module_setting("lastpot3"));
}
addnav("Play the Games");
addnav("D?Roll the Dice","runmodule.php?module=game_fivesix&what=roll&ret=$ret");
} elseif ($what=="roll"){
$visits = get_module_pref("playstoday");
$max = get_module_setting("dailyuses");
if (($visits < $max) || ($max==0)){
$cost=get_module_setting("cost");
if ($session['user']['gold'] < $cost){
output("`3The old man watches as nothing but moths and dust emerge from your coin purse.`n");
output("He shakes his head at you then turns back to his ale as though you weren't there.");
addnav("Return to the Main Room",appendlink(urldecode($ret), "op=tavern"));
}else{
debuglog("spent $cost gold on five-sixes game");
$session['user']['gold']-=$cost;
$visits++;
set_module_pref("playstoday",$visits);
$prize+=$cost;
$maxpot=get_module_setting("maxjackpot");
if ($prize > $maxpot) {
output("`n`@The old man slips your donation into his own change purse, muttering something about the pot being big enough already.`n`n");
$prize = $maxpot;
}
set_module_setting("jackpot",$prize);
$almost=0;
$one=e_rand(1,6);
if ($one==6) $almost++;
$two=e_rand(1,6);
if ($two==6) $almost++;
$three=e_rand(1,6);
if ($three==6) $almost++;
$four=e_rand(1,6);
if ($four==6) $almost++;
$five=e_rand(1,6);
if ($five==6) $almost++;
output("`n`@You gather the dice in an old leather cup, shake them, and hold your breath as you spill them onto the table.`n");
output("Upon inspecting them, you see their values are `^%s %s %s %s `@and `^%s`@.`n`n",$one,$two,$three,$four,$five);
if ($almost==5){
output("\"Congratulations!\", the old man exclaims.");
output("\"Tis rare for anybody to win this prize\"`n");
output("`^The old man hands you your winnings of %s gold",$prize);
$session['user']['gold']+=$prize;
debuglog("won $prize gold at sixes game.");
addnews("%s won %s gold after rolling 5 sixes in the %s.",$session['user']['name'],$prize, get_module_setting("tavernname","darkhorse"));
set_module_setting("jackpot",100);
set_module_setting("lastpot5",$prize);
$lastwin5=$session['user']['name'];
set_module_setting("lastwin5",$lastwin5);
}elseif ($almost==4){
$win=round($prize * .1);
$prize=$prize - $win;
set_module_setting("jackpot", $prize);
$session['user']['gold']+=$win;
debuglog("won $win gold at sixes game.");
set_module_setting("lastpot4",$win);
$lastwin4=$session['user']['name'];
set_module_setting("lastwin4",$lastwin4);
addnews("%s won %s gold after rolling 4 sixes in the %s.",$session['user']['name'],$win, get_module_setting("tavernname", "darkhorse"));
output("`@The old man leans over the table to peer at your dice and looks thoughtful for a moment.`n");
output("\"Well now...four out of five sixes is darned close, my friend. I think your effort deserves %s gold in reward.\"`n`n",$win);
output("`^The old man hands you %s gold.", $win);
}elseif ($almost==3){
$win=round($prize * .05);
$prize=$prize - $win;
set_module_setting("jackpot", $prize);
$session['user']['gold']+=$win;
set_module_setting("lastpot3",$win);
$lastwin3=$session['user']['name'];
set_module_setting("lastwin3",$lastwin3);
debuglog("won $win gold at sixes game.");
addnews("%s won %s gold after rolling 3 sixes in the %s.",$session['user']['name'],$win,get_module_setting("tavernname", "darkhorse"));
output("`@The old man leans over the table to peer at your dice and cackles as he notes your results.`n");
output("\"Well now...three out of five sixes isn't a bad effort, my friend. I'll give ye %s gold for that try.\"`n`n",$win);
output("`^The old man hands you %s gold.", $win);
}else{
output("The old man cackles. You rolled %s %s...but that's not enough!`n`n", $almost, translate_inline($almost == 1? "six": "sixes"));
output("Disappointed, you walk away.");
}
}
}else{
output("`@The old man looks up at you and shakes his head slowly.`n");
output("`%\"I think you've had enough for today. Why don't you come back tomorrow?\"");
}
addnav("Play the Games");
addnav("Play again?","runmodule.php?module=game_fivesix&ret=$ret&what=play");
}
addnav("Other Games",appendlink(urldecode($ret), "op=oldman"));
addnav("Return to the Main Room",appendlink(urldecode($ret), "op=tavern"));
page_footer();
}
?>

View File

@ -0,0 +1,132 @@
<?php
// addnews ready
// mail ready
// translator ready
function game_stones_getmoduleinfo(){
$info = array(
"name"=>"Stones Game for DarkHorse",
"author"=>"Eric Stevens",
"version"=>"1.1",
"category"=>"Darkhorse Game",
"download"=>"core_module",
);
return $info;
}
function game_stones_install(){
global $session;
debug("Adding Hooks");
module_addhook("darkhorsegame");
return true;
}
function game_stones_uninstall(){
output("Uninstalling this module.`n");
return true;
}
function game_stones_dohook($hookname, $args){
if ($hookname=="darkhorsegame"){
$ret = urlencode($args['return']);
addnav("S?Play Stones Game",
"runmodule.php?module=game_stones&ret=$ret");
}
return $args;
}
function game_stones_run(){
global $session;
$ret = urlencode(httpget("ret"));
page_header("A Game of Stones");
$stones = unserialize($session['user']['specialmisc']);
if (!is_array($stones)) $stones = array();
$side = httpget('side');
if ($side=="likepair") $stones['side']="likepair";
if ($side=="unlikepair") $stones['side']="unlikepair";
$bet = httppost('bet');
if ($bet != "")
$stones['bet'] = min($session['user']['gold'], abs((int)$bet));
if (!isset($stones['side']) || $stones['side']==""){
output("`3The old man explains his game, \"`7I have a bag with 6 red stones, and 10 blue stones in it. You can choose between 'like pair' or 'unlike pair.' I will then draw out pairs of stones two at a time. If they are the same color as each other, they go to which ever of us is 'like pair,' and otherwise they go to which ever of us is 'unlike pair.' Whoever has the most stones at the end will win. If we have the same number, then it is a draw, and no one wins.`3\"");
addnav("Never Mind", appendlink(urldecode($ret), "op=oldman"));
addnav("Like Pair",
"runmodule.php?module=game_stones&side=likepair&ret=$ret");
addnav("Unlike Pair",
"runmodule.php?module=game_stones&side=unlikepair&ret=$ret");
$stones['red']=6;
$stones['blue']=10;
$stones['player']=0;
$stones['oldman']=0;
}elseif (!isset($stones['bet']) || $stones['bet']==0){
$s1 = translate_inline($stones['side']=="likepair"?"Like":"Unlike");
$s2 = translate_inline($stones['side']=="likepair"?"unlike":"like");
output("`3\"`7%s pair for you, and %s pair for me it is then! How much do you bet?`3\"", $s1, $s2);
rawoutput("<form action='runmodule.php?module=game_stones&ret=$ret' method='POST'>");
rawoutput("<input name='bet' id='bet'>");
$b = translate_inline("Bet");
rawoutput("<input type='submit' class='button' value='$b'>");
rawoutput("</form>");
rawoutput("<script language='JavaScript'>document.getElementById('bet').focus();</script>");
addnav("","runmodule.php?module=game_stones&ret=$ret");
addnav("Never Mind", appendlink(urldecode($ret), "op=oldman"));
}elseif ($stones['red']+$stones['blue'] > 0 &&
$stones['oldman']<=8 && $stones['player']<=8){
$s1="";
$s2="";
$rstone = translate_inline("`\$red`3");
$bstone = translate_inline("`!blue`3");
while ($s1=="" || $s2==""){
$s1 = e_rand(1,($stones['red']+$stones['blue']));
if ($s1<=$stones['red']) {
$s1=$rstone;
$stones['red']--;
}else{
$s1=$bstone;
$stones['blue']--;
}
if ($s2=="") {
$s2=$s1;
$s1="";
}
}
output("`3The old man reaches into his bag and withdraws two stones.");
output("They are %s and %s. Your bet is `^%s`3.`n`n", $s1, $s2, $stones['bet']);
if ($stones['side']=="likepair" && $s1==$s2) {
$winner="your";
$stones['player']+=2;
} elseif ($stones['side']!="likepair" && $s1!=$s2) {
$winner="your";
$stones['player']+=2;
} else {
$stones['oldman']+=2;
$winner = "his";
}
$winner = translate_inline($winner);
output("Since you are %s pairs, the old man places the stones in %s pile.`n`n", translate_inline($stones['side']=="likepair"?"like":"unlike"), $winner);
output("You currently have `^%s`3 stones in your pile, and the old man has `^%s`3 stones in his.`n`n", $stones['player'], $stones['oldman']);
output("There are %s %s stones and %s %s stones in the bag yet.", $stones['red'], $rstone, $stones['blue'], $bstone);
addnav("Continue","runmodule.php?module=game_stones&ret=$ret");
}else{
if ($stones['player']>$stones['oldman']){
output("`3Having defeated the old man at his game, you claim your `^%s`3 gold.", $stones['bet']);
$session['user']['gold']+=$stones['bet'];
debuglog("won {$stones['bet']} gold in the stones game");
}elseif ($stones['player']<$stones['oldman']){
output("`3Having defeated you at his game, the old man claims your `^%s`3 gold.", $stones['bet']);
$session['user']['gold']-=$stones['bet'];
debuglog("lost {$stones['bet']} gold in the stones game");
}else{
output("`3Having tied the old man, you call it a draw.");
}
$stones=array();
addnav("Play again?","runmodule.php?module=game_stones&ret=$ret");
addnav("Other Games",appendlink(urldecode($ret), "op=oldman"));
addnav("Return to Main Room", appendlink(urldecode($ret), "op=tavern"));
}
$session['user']['specialmisc']=serialize($stones);
page_footer();
}
?>

View File

@ -0,0 +1,125 @@
<?php
//addnews ready
// mail ready
// translator ready
function glowingstream_getmoduleinfo(){
$info = array(
"name"=>"Glowing Stream",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Forest Specials",
"download"=>"core_module",
);
return $info;
}
debug("glowingstream");
function glowingstream_install(){
module_addeventhook("forest", "return 100;");
module_addeventhook("travel", "return 100;");
return true;
}
function glowingstream_uninstall(){
return true;
}
function glowingstream_dohook($hookname,$args){
return $args;
}
function glowingstream_runevent($type,$link)
{
global $session;
// We only care about the forest here currently.
$from = $link;
$session['user']['specialinc']="module:glowingstream";
$op = httpget('op');
if ($op=="" || $op=="search"){
output("`#You discover a small stream of faintly glowing water that babbles over round pure white stones.");
output("You can sense a magical power in the water.");
output("Drinking this water may yield untold powers, or it may result in crippling disability.");
output("Do you wish to take a drink?");
addnav("Drink", $from . "op=drink");
addnav("Don't Drink", $from . "op=nodrink");
}elseif ($op=="drink"){
$session['user']['specialinc']="";
$rand = e_rand(1,10);
output("`#Knowing that the water could yield deadly results, you decide to take your chances.");
output("Kneeling down at the edge of the stream, you take a long hard draught from the cold stream.");
output("You feel a warmth growing out from your chest...`n");
switch ($rand){
case 1:
output("`iIt is followed by a dreadful clammy cold`i.");
output("You stagger and claw at your breast as you feel what you imagine to be the hand of the reaper placing its unbreakable grip on your heart.`n`n");
output("You collapse by the edge of the stream, only just now noticing that the stones you observed before were actually the bleached skulls of other adventurers as unfortunate as you.`n`n");
output("Darkness creeps in around the edges of your vision as you lay staring up through the trees.");
output("Your breath comes shallower and less and less frequently as warm sunshine splashes on your face, in sharp contrast to the void taking residence in your heart.`n`n");
output("`^You have died due to the foul power of the stream.`n");
output("As the woodland creatures know the danger of this place, none are here to scavenge from your corpse, thus you may keep your gold.`n");
output("The life lesson learned here balances any experience you would have lost.`n");
output("You may continue playing again tomorrow.");
$session['user']['alive']=false;
$session['user']['hitpoints']=0;
addnav("Daily News","news.php");
addnews("%s encountered strange powers in the forest, and was not seen again.",$session['user']['name']);
break;
case 2:
output("`iIt is followed by a dreadful clammy cold`i.");
output("You stagger and claw at your breast as you feel what you imagine to be the hand of the reaper placing its unbreakable grip on your heart.`n`n");
output("You collapse by the edge of the stream, only just now noticing that the stones you observed before were actually the bleached skulls of other adventurers as unfortunate as you.`n`n");
output("Darkness creeps in around the edges of your vision as you lay staring up through the trees.");
output("Your breath comes shallower and less and less frequently as warm sunshine splashes on your face, in sharp contrast to the void taking residence in your heart.`n`n");
output("As you exhale your last breath, you distantly hear a tiny giggle.");
output("You find the strength to open your eyes, and find yourself staring at a tiny fairy who, flying just above your face is inadvertently sprinkling its fairy dust all over you, granting you the power to crawl once again to your feet.");
output("The lurch to your feet startles the tiny creature, and before you have a chance to thank it, it flits off.`n`n");
output("`^You narrowly avoid death, you lose a forest fight, and most of your hitpoints.");
if ($session['user']['turns']>0) $session['user']['turns']--;
if ($session['user']['hitpoints'] >
($session['user']['maxhitpoints']*.1))
$session['user']['hitpoints'] =
round($session['user']['maxhitpoints']*.1,0);
if ($session['user']['hitpoints'] < 1)
$session['user']['hitpoints'] = 1;
break;
case 3:
output("You feel INVIGORATED!`n`n");
output("`^Your hitpoints have been restored to full, and you feel the energy for another turn in the forest.");
if ($session['user']['hitpoints'] <
$session['user']['maxhitpoints'])
$session['user']['hitpoints'] =
$session['user']['maxhitpoints'];
$session['user']['turns']++;
break;
case 4:
output("You feel PERCEPTIVE!`n`n");
output("You notice something glittering under one of the pebbles that line the stream.`n`n");
output("`^You find a `%GEM`^!");
$session['user']['gems']++;
debuglog("found 1 gem by the stream");
break;
case 5:
case 6:
case 7:
output("You feel ENERGETIC!`n`n");
output("`^You receive an extra forest fight!");
$session['user']['turns']++;
break;
default:
output("You feel HEALTHY!`n`n");
output("`^Your hitpoints have been restored to full.");
if ($session['user']['hitpoints'] <
$session['user']['maxhitpoints'])
$session['user']['hitpoints'] =
$session['user']['maxhitpoints'];
}
output("`0");
}else{
$session['user']['specialinc']="";
output("`#Fearing the dreadful power in the water, you decide to let it be, and return to the forest.`0");
}
}
function glowingstream_run(){
}
?>

View File

@ -0,0 +1,282 @@
<?php
// translator ready
//addnews ready
// mail ready
function goldmine_getmoduleinfo(){
$info = array(
"name"=>"Gold Mine",
"version"=>"1.0",
"author"=>"Ville Valtokari",
"category"=>"Forest Specials",
"download"=>"core_module",
"settings"=>array(
"Goldmine Event Settings,title",
"alwaystether"=>"Chance the player will tether their mount automatically,range,0,100,1|10",
"percentgemloss"=>"Percentage of gems lost on death in mine,range,0,100,1|0",
"percentgoldloss"=>"Percentage of gold lost on death in mine,range,0,100,1|0",
),
"prefs-mounts"=>array(
"Goldmine Mount Preferences,title",
"entermine"=>"Chance of entering mine,range,0,100,1|0",
"dieinmine"=>"Chance of dying in the mine,range,0,100,1|0",
"saveplayer"=>"Chance of saving player in mine,range,0,100,1|0",
"tethermsg"=>"Message when mount is tethered|",
"deathmsg"=>"Message when mount dies|",
"savemsg"=>"Message when mount saves player|",
),
);
return $info;
}
function goldmine_install(){
module_addeventhook("forest", "return 100;");
$sql = "DESCRIBE " . db_prefix("mounts");
$result = db_query($sql);
while($row = db_fetch_assoc($result)) {
if ($row['Field'] == "mine_canenter") {
debug("Migrating mine_canenter for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','entermine',mountid,mine_canenter FROM " . db_prefix("mounts") . " WHERE mine_canenter>0";
db_query($sql);
debug("Dropping mine_canenter field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_canenter";
db_query($sql);
}
if ($row['Field'] == "mine_candie") {
debug("Migrating mine_candie for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','dieinmine',mountid,mine_candie FROM " . db_prefix("mounts") . " WHERE mine_candie>0";
db_query($sql);
debug("Dropping mine_candie field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_candie";
db_query($sql);
}
if ($row['Field'] == "mine_cansave") {
debug("Migrating mine_cansave for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','saveplayer',mountid,mine_cansave FROM " . db_prefix("mounts") . " WHERE mine_cansave>0";
db_query($sql);
debug("Dropping mine_cansave field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_cansave";
db_query($sql);
}
if ($row['Field'] == "mine_tethermsg") {
debug("Migrating mine_tethermsg for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','tethermsg',mountid,mine_tethermsg FROM " . db_prefix("mounts") . " WHERE mine_tethermsg!=''";
db_query($sql);
debug("Dropping mine_tethermsg field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_tethermsg";
db_query($sql);
}
if ($row['Field'] == "mine_deathmsg") {
debug("Migrating mine_deathmsg for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','deathmsg',mountid,mine_deathmsg FROM " . db_prefix("mounts") . " WHERE mine_deathmsg!=''";
db_query($sql);
debug("Dropping mine_deathmsg field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_deathmsg";
db_query($sql);
}
if ($row['Field'] == "mine_savemsg") {
debug("Migrating mine_savemsg for all mounts");
$sql = "INSERT INTO " . db_prefix("module_objprefs") . " (modulename,objtype,setting,objid,value) SELECT 'goldmine','mounts','savemsg',mountid,mine_savemsg FROM " . db_prefix("mounts") . " WHERE mine_savemsg!=''";
db_query($sql);
debug("Dropping mine_savemsg field from mounts table");
$sql = "ALTER TABLE " . db_prefix("mounts") . " DROP mine_savemsg";
db_query($sql);
}
}
return true;
}
function goldmine_uninstall(){
return true;
}
function goldmine_dohook($hookname,$args){
return $args;
}
function goldmine_runevent($type)
{
global $session;
// The only type of event we care about are the forest.
$from = "forest.php?";
$hashorse = $session['user']['hashorse'];
$horsecanenter = 0;
$horsecandie = 0;
$horsecansave = 0;
if ($hashorse) {
$horsecanenter = get_module_objpref('mounts', $hashorse, 'entermine');
// See if we automatically tether;
if (e_rand(1, 100) <= get_module_setting("alwaystether"))
$horsecanenter = 0;
if ($horsecanenter) {
// The mount cannot die or save you if it cannot enter
$horsecandie = get_module_objpref('mounts', $hashorse, 'dieinmine');
$horsecansave = get_module_objpref('mounts', $hashorse, 'saveplayer');
}
require_once("lib/mountname.php");
list($mountname, $lcmountname) = getmountname();
}
$session['user']['specialinc']="module:goldmine";
$op = httpget('op');
if ($op == "" || $op == "search") {
output("`2You found an old abandoned mine in the depths of the forest.");
output("There is some old mining equipment nearby.`n`n");
output("`^As you look around you realize that this is going to be a lot of work.");
output("So much so in fact that you will lose a forest fight for the day if you attempt it.`n`n");
output("`^Looking around a bit more, you do notice what looks like evidence of occasional cave-ins in the mine.`n`n");
addnav("Mine for gold and gems", $from . "op=mine");
addnav("Return to the forest", $from . "op=no");
} elseif ($op == "no") {
output("`2You decide you don't have time for this slow way to gain gold and gems, and so leave the old mine behind and go on your way...`n");
$session['user']['specialinc']="";
} elseif ($op=="mine") {
if ($session['user']['turns']<=0) {
output("`2You are too tired to mine anymore..`n");
$session['user']['specialinc']="";
} else {
// Horsecanenter is a percent, so, if rand(1-100) > enterpercent,
// tether it. Set enter percent to 0 (the default), to always
// tether.
if (e_rand(1, 100) > $horsecanenter && $hashorse) {
$msg = get_module_objpref('mounts',$hashorse, 'tethermsg');
if ($msg) output ($msg);
else {
output("`&Seeing that the mine entrance is too small for %s`&, you tether it off to the side of the entrance.`n", $lcmountname);
}
// The mount it tethered, so it cannot die nor save the player
$horsecanenter = 0;
$horsecandie = 0;
$horsecansave = 0;
}
output("`2You pick up the mining equipment and start mining for gold and gems...`n`n");
$rand = e_rand(1,20);
switch ($rand){
case 1:case 2:case 3:case 4: case 5:
output("`2After a few hours of hard work you have only found worthless stones and one skull...`n`n");
output("`^You lose one forest fight while digging.`n`n");
if ($session['user']['turns']>0) $session['user']['turns']--;
$session['user']['specialinc']="";
break;
case 6: case 7: case 8:case 9: case 10:
$gold = e_rand($session['user']['level']*5, $session['user']['level']*20);
output("`^After a few hours of hard work, you find %s gold!`n`n", $gold);
$session['user']['gold'] += $gold;
debuglog("found $gold gold in the goldmine");
output("`^You lose one forest fight while digging.`n`n");
if ($session['user']['turns']>0) $session['user']['turns']--;
$session['user']['specialinc']="";
break;
case 11: case 12: case 13: case 14: case 15:
$gems = e_rand(1, round($session['user']['level']/7)+1);
output("`^After a few hours of hard work, you find `%%s %s`^!`n`n", $gems, translate_inline($gems == 1 ? "gem" : "gems"));
$session['user']['gems'] += $gems;
debuglog("found $gems gems in the goldmine");
output("`^You lose one forest fight while digging.`n`n");
if ($session['user']['turns']>0) $session['user']['turns']--;
$session['user']['specialinc']="";
break;
case 16: case 17: case 18:
$gold = e_rand($session['user']['level']*10, $session['user']['level']*40);
$gems = e_rand(1, round($session['user']['level']/3)+1);
output("`^You have found the mother lode!`n`n");
output("`^After a few hours of hard work, you find `%%s %s`^ and %s gold!`n`n", $gems, translate_inline($gems==1?"gem":"gems"), $gold);
$session['user']['gems'] += $gems;
$session['user']['gold'] += $gold;
debuglog("found $gold gold and $gems gems in the goldmine");
output("`^You lose one forest fight while digging.`n`n");
if ($session['user']['turns']>0) $session['user']['turns']--;
$session['user']['specialinc']="";
break;
case 19: case 20:
output("`2After a lot of hard work you believe you have spotted a `&huge`2 `%gem`2 and some `6gold`2.`n");
output("`2Anxious to be rich, you rear back and slam the pick home, knowing that the harder you hit, the quicker you will be done....`n");
output("`7Unfortunately, you are quickly done in.`n");
output("Your over-exuberant hit caused a massive cave in.`n");
// Find the chance of dying based on race
$vals = modulehook("raceminedeath");
$dead = 0;
$racesave = 1;
if (isset($vals['racesave']) && $vals['racesave']) {
if ($vals['schema']) tlschema($vals['schema']);
$racemsg = translate_inline($vals['racesave']);
if ($vals['schema']) tlschema();
}
if (isset($vals['chance']) && (e_rand(1, 100) < $vals['chance'])) {
$dead = 1;
$racesave = 0;
$racemsg = "";
}
if ($dead) {
// The player has died, see if their horse saves them
if (isset($horsecansave) && (e_rand(1,100) <= $horsecansave)) {
$dead = 0;
$horsesave = 1;
}
}
// If we are still dead, see if the horse dies too.
$session['user']['specialinc']="";
if ($dead) {
if (e_rand(1,100) <= $horsecandie) $horsedead = 1;
output("You have been crushed under a ton of rock.`n`nPerhaps the next adventurer will recover your body and bury it properly.`n");
if ($horsedead) {
$msg = get_module_objpref('mounts', $hashorse, 'deathmsg');
if ($msg) output ($msg);
else {
output("%s`7's bones were buried right alongside yours.", $mountname);
}
global $playermount;
$debugmount = $playermount['mountname'];
debuglog("lost their mount, a $debugmount, in a mine collapse.");
$session['user']['hashorse'] = 0;
if(isset($session['bufflist']['mount']))
strip_buff("mount");
} elseif ($hashorse) {
if ($horsecanenter) {
output("%s`7 managed to escape being crushed.", $mountname);
output("You know that it is trained to return to the village.`n");
} else {
output("Fortunately you left %s`7 tethered outside.", $lcmountname);
output("You know that it is trained to return to the village.`n");
}
}
$exp=round($session['user']['experience']*0.1, 0);
output("At least you learned something about mining from this experience and have gained %s experience.`n`n", $exp);
output("`3You may continue to play tomorrow`n");
$session['user']['experience']+=$exp;
$session['user']['alive']=false;
$session['user']['hitpoints']=0;
$gemlost = round(get_module_setting("percentgemloss")/100 * $session['user']['gems'], 0);
$goldlost = round(get_module_setting("percentgoldloss")/100 * $session['user']['gold'], 0);
debuglog("lost $goldlost gold and $gemlost gems by dying in the goldmine");
output("`^%s gold `&and `%%s %s`& were lost when you were buried!", $goldlost, $gemlost, translate_inline($gemlost == 1?"gem":"gems"));
$session['user']['gold'] -= $goldlost;
$session['user']['gems'] -= $gemlost;
addnav("Daily News","news.php");
addnews("%s was completely buried after becoming greedy digging in the mines.",$session['user']['name']);
} else {
if (isset($horsesave) && $horsesave) {
$msg = get_module_objpref('mounts', $hashorse, 'savemsg');
if ($msg) output ($msg);
else {
output("%s`7 managed to drag you to safety in the nick of time!`n", $mountname);
}
} elseif ($racesave) {
if (isset($racemsg) && $racemsg) output_notl($racemsg);
else {
output("Through sheer luck, you manage to escape the cave-in intact!`n");
}
}
output("`n`&Your close call scared you so badly that you cannot face any more opponents today.`n");
debuglog("`&has lost all turns for the day due to a close call in the mine.");
$session['user']['turns']=0;
}
break;
}
}
}
}
function goldmine_run(){
}
?>

View File

@ -0,0 +1,151 @@
<?php
//addnews ready
// translator ready
// mail ready
require_once("lib/buffs.php");
require_once("lib/partner.php");
//should we move charm here?
//should we move marriedto here?
function lovers_getmoduleinfo(){
$info = array(
"name"=>"Violet and Seth Lovers",
"author"=>"Eric Stevens",
"version"=>"1.0",
"category"=>"Inn",
"download"=>"core_module",
"prefs"=>array(
"Lover Module User Preferences,title",
"seenlover"=>"Visited Lover Today?,bool|0"
)
);
return $info;
}
function lovers_install(){
module_addhook("newday");
module_addhook("inn");
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
while ($row = db_fetch_assoc($result)){
if ($row['Field']=="seenlover"){
$sql = "SELECT seenlover,acctid FROM " . db_prefix("accounts") . " WHERE seenlover>0";
$result1 = db_query($sql);
debug("Migrating seenlover.`n");
while ($row1 = db_fetch_assoc($result1)){
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) VALUES ('lovers','seenlover',{$row1['acctid']},{$row1['seenlover']})";
db_query($sql);
}//end while
debug("Dropping seenlover column from the user table.`n");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP seenlover";
db_query($sql);
//drop it from the user's session too.
unset($session['user']['seenlover']);
}//end if
}//end while
return true;
}
function lovers_uninstall(){
return true;
}
function lovers_dohook($hookname, $args){
global $session;
$partner = get_partner();
switch($hookname){
case "newday":
set_module_pref("seenlover",0);
if ($session['user']['marriedto'] == 4294967295){
$dk = $session['user']['dragonkills'];
// 0.7 seemed to be a perfect balance of no loss of charm.
// 1.0 was too much.
$dk = max(1, round(.85 * sqrt($dk), 0));
$charmloss= e_rand(1,$dk);
$session['user']['charm'] -= $charmloss;
output("`n`%You're married, so there's no reason to keep up that perfect image, and you let yourself go a little today ( You lose `\$%s charmpoint(s)`%).`n",$charmloss);
if ($session['user']['charm']<=0){
output("`bWhen you wake up, you find a note next to you, reading`n`5Dear %s`5,`n",$session['user']['name']);
output("Despite many great kisses, I find that I'm simply no longer attracted to you the way I used to be.`n`n");
output("Call me fickle, call me flakey, but I need to move on.");
output("There are other warriors in the land, and I think some of them are really hot.");
output("So it's not you, it's me, etcetera etcetera.`n`n");
output("No hard feelings, Love,`n%s`b`n",$partner);
addnews("`\$%s`\$ has left %s`\$ to pursue \"other interests.\"`0",$partner, $session['user']['name']);
$session['user']['marriedto']=0;
$session['user']['charm']=0;
}
}
break;
case "inn":
addnav("Things to do");
if ($session['user']['sex']==SEX_MALE){
addnav(array("F?Flirt with %s", $partner),
"runmodule.php?module=lovers&op=flirt");
addnav(array("Chat with %s",translate_inline(getsetting("bard", "`^Seth"))),
"runmodule.php?module=lovers&op=chat");
}else{
addnav(array("F?Flirt with %s", $partner),
"runmodule.php?module=lovers&op=flirt");
addnav(array("Gossip with %s",translate_inline(getsetting("barmaid", "`%Violet"))),
"runmodule.php?module=lovers&op=chat");
}
break;
}
return $args;
}
function lovers_run(){
global $session;
require_once("lib/villagenav.php");
$iname = getsetting("innname", LOCATION_INN);
page_header($iname);
rawoutput("<span style='color: #9900FF'>");
output_notl("`c`b");
output($iname);
output_notl("`b`c");
switch(httpget('op')){
case "flirt":
if ($session['user']['sex']==SEX_MALE) {
require_once("modules/lovers/lovers_violet.php");
lovers_violet();
} else {
require_once("modules/lovers/lovers_seth.php");
lovers_seth();
}
break;
case "chat":
if ($session['user']['sex']==SEX_MALE) {
require_once("modules/lovers/lovers_chat_seth.php");
lovers_chat_seth();
} else {
require_once("modules/lovers/lovers_chat_violet.php");
lovers_chat_violet();
}
break;
}
addnav("Return");
addnav("I?Return to the Inn","inn.php");
villagenav();
rawoutput("</span>");
page_footer();
}
function lovers_getbuff(){
global $session;
$partner = get_partner();
$buff = array(
"name"=>"`!Lover's Protection",
"rounds"=>60,
"wearoff"=>
array("`!You miss %s`!.`0",$partner),
"defmod"=>1.2,
"roundmsg"=>"Your lover inspires you to keep safe!",
"schema"=>"module-lovers",
);
return $buff;
}
?>

View File

@ -0,0 +1,44 @@
<?php
function lovers_chat_seth(){
global $session;
if (httpget("act")==""){
output("You make your way over to where %s`0 is sitting, ale in hand.", getsetting("bard", "`^Seth"));
output("Sitting down, and waiting for %s`0 to finish a song, you light your pipe.", getsetting("bard", "`^Seth"));
addnav("Ask about your manliness","runmodule.php?module=lovers&op=chat&act=armor");
addnav("Discuss Sports","runmodule.php?module=lovers&op=chat&act=sports");
}elseif(httpget("act")=="sports"){
output("You and %s`0 spend some time talking about the recent dwarf tossing competition.", getsetting("bard", "`^Seth"));
output("Not wanting to linger around another man for too long, so no one \"wonders\", you decide you should find something else to do.");
}else{
$charm = $session['user']['charm']+e_rand(-1,1);
output("%s`0 looks you up and down very seriously.", getsetting("bard", "`^Seth"));
output("Only a friend can be truly honest, and that is why you asked him.");
switch($charm){
case -3: case -2: case -1: case 0:
$msg = translate_inline("You make me glad I'm not gay!");
break;
case 1: case 2: case 3:
$msg = translate_inline("I've seen some handsome men in my day, but I'm afraid you aren't one of them.");
break;
case 4: case 5: case 6:
$msg = translate_inline("I've seen worse my friend, but only trailing a horse.");
break;
case 7: case 8: case 9:
$msg = translate_inline("You're of fairly average appearance my friend.");
break;
case 10: case 11: case 12:
$msg = translate_inline("You certainly are something to look at, just don't get too big of a head about it, eh?");
break;
case 13: case 14: case 15:
$msg = translate_inline("You're quite a bit better than average!");
break;
case 16: case 17: case 18:
$msg = translate_inline("Few women would be able to resist you!");
break;
default:
$msg = translate_inline("I hate you, why, you are simply the most handsome man ever!");
}
output("Finally he reaches a conclusion and states, \"%s`0\"", $msg);
}
}
?>

View File

@ -0,0 +1,47 @@
<?php
function lovers_chat_violet(){
global $session;
if (httpget('act')==""){
addnav("Gossip","runmodule.php?module=lovers&op=chat&act=gossip");
addnav(array("Ask if your %s makes you look fat", $session['user']['armor']),"runmodule.php?module=lovers&op=chat&act=fat");
output("You go over to %s`0 and help her with the drinks she is carrying.", getsetting("barmaid", "`%Violet"));
output("Once they are passed out, she takes a cloth and wipes the sweat off of her brow, thanking you much.");
output("Of course you didn't mind, as she is one of your oldest and truest friends!");
}else if(httpget('act')=="gossip"){
output("You and %s`0 gossip quietly for a few minutes about not much at all.", getsetting("barmaid", "`%Violet"));
output("She offers you a pickle.");
output("You accept, knowing that it's in her nature to do so as a former pickle wench.");
output("After a few minutes, %s`0 begins to cast burning looks your way, and you decide you had best let %s`0 get back to work.",getsetting('barkeep','`tCedrik'), getsetting("barmaid", "`%Violet"));
}else if(httpget('act')=="fat"){
$charm = $session['user']['charm']+e_rand(-1,1);
output("%s`0 looks you up and down very seriously.", getsetting("barmaid", "`%Violet"));
output("Only a friend can be truly honest, and that is why you asked her.");
switch($charm){
case -3: case -2: case -1: case 0:
$msg = translate_inline("Your outfit doesn't leave much to the imagination, but some things are best not thought about at all! Get some less revealing clothes as a public service!");
break;
case 1: case 2: case 3:
$msg = translate_inline("I've seen some lovely ladies in my day, but I'm afraid you aren't one of them.");
break;
case 4: case 5: case 6:
$msg = translate_inline("I've seen worse my friend, but only trailing a horse.");
break;
case 7: case 8: case 9:
$msg = translate_inline("You're of fairly average appearance my friend.");
break;
case 10: case 11: case 12:
$msg = translate_inline("You certainly are something to look at, just don't get too big of a head about it, eh?");
break;
case 13: case 14: case 15:
$msg = translate_inline("You're quite a bit better than average!");
break;
case 16: case 17: case 18:
$msg = translate_inline("Few women could count themselves to be in competition with you!");
break;
default:
$msg = translate_inline("I hate you, why, you are simply the most beautiful woman ever!");
}
output("Finally she reaches a conclusion and states, \"%s`0\"", $msg);
}
}
?>

View File

@ -0,0 +1,144 @@
<?php
function lovers_seth(){
global $session;
$seenlover = get_module_pref("seenlover");
$partner = get_partner();
if ($seenlover==0){
//haven't seen lover
if ($session['user']['marriedto']==INT_MAX){
//married
$seenlover=1;
if (e_rand(1,4)==1){
switch(e_rand(1,4)){
case 1:
$msg = translate_inline("being too busy tuning his lute,");
break;
case 2:
$msg = translate_inline("\"that time of month,\"");
break;
case 3:
$msg = translate_inline("\"a little cold... *cough cough* see?\"");
break;
case 4:
$msg = translate_inline("wanting you to fetch him a beer,");
break;
}
output("You head over to snuggle up to %s`0 and kiss him about the face and neck, but he grumbles something about %s and with a comment like that, you storm away from him!",$partner,$msg);
$session['user']['charm']--;
output("`n`n`^You LOSE a charm point!");
}else{
output("You and %s`0 take some time to yourselves, and you leave the inn, positively glowing!",$partner);
apply_buff('lover',lovers_getbuff());
$session['user']['charm']++;
output("`n`n`^You gain a charm point!");
}
}else{
//not married.
if (httpget("flirt")==""){
//haven't flirted yet
addnav("Flirt");
addnav("Wink","runmodule.php?module=lovers&op=flirt&flirt=1");
addnav("Flutter Eyelashes","runmodule.php?module=lovers&op=flirt&flirt=2");
addnav("Drop Hanky","runmodule.php?module=lovers&op=flirt&flirt=3");
addnav("Ask him to buy you a drink","runmodule.php?module=lovers&op=flirt&flirt=4");
addnav("Kiss him soundly","runmodule.php?module=lovers&op=flirt&flirt=5");
addnav("Completely seduce him","runmodule.php?module=lovers&op=flirt&flirt=6");
addnav("Marry him","runmodule.php?module=lovers&op=flirt&flirt=7");
}else{
//flirting now
$c = $session['user']['charm'];
$seenlover=1;
switch(httpget('flirt')){
case 1:
if (e_rand($c,2)>=2){
output("%s`0 grins a big toothy grin.",$partner);
output("My, isn't the dimple in his chin cute??");
if ($c<4) $c++;
}else{
output("%s`0 raises an eyebrow at you, and asks if you have something in your eye.",$partner);
}
break;
case 2:
if (e_rand($c,4)>=4){
output("%s`0 smiles at you and says, \"`^My, what pretty eyes you have.`0\"",$partner);
if ($c<7) $c++;
}else{
output("%s`0 smiles, and waves... to the person standing behind you.",$partner);
}
break;
case 3:
if (e_rand($c,7)>=7){
output("%s`0 bends over and retrieves your hanky, while you admire his firm posterior.",$partner);
if ($c<11) $c++;
}else{
output("%s`0 bends over and retrieves your hanky, wipes his nose with it, and gives it back.",$partner);
}
break;
case 4:
if (e_rand($c,11)>=11){
output("%s`0 places his arm around your waist, and escorts you to the bar where he buys you one of the Inn's fine swills.",$partner);
if ($c<14) $c++;
}else{
output("%s`0 apologizes, \"`^I'm sorry m'lady, I have no money to spare,`0\" as he turns out his moth-riddled pocket.",$partner);
if ($c>0 && $c<10) $c--;
}
break;
case 5:
if (e_rand($c,14)>=14){
output("You walk up to %s`0, grab him by the shirt, pull him to his feet, and plant a firm, long kiss right on his handsome lips.",$partner);
output("He collapses after, hair a bit disheveled, and short on breath.");
if ($c<18) $c++;
}else{
output("You duck down to kiss %s`0 on the lips, but just as you do so, he bends over to tie his shoe.",$partner);
if ($c>0 && $c<13) $c--;
}
break;
case 6:
if (e_rand($c,18)>=18){
output("Standing at the base of the stairs, you make a come-hither gesture at %s`0.",$partner);
output("He follows you like a puppydog.");
if ($session['user']['turns']>0){
output("You feel exhausted!");
$session['user']['turns']-=2;
if ($session['user']['turns']<0)
$session['user']['turns']=0;
}
addnews("`@%s`@ and %s`@ were seen heading up the stairs in the inn together.`0",$session['user']['name'],$partner);
if ($c<25) $c++;
}else{
output("\"`^I'm sorry m'lady, but I have a show in 5 minutes`0\"");
if ($c>0) $c--;
}
break;
case 7:
output("Walking up to %s`0, you simply demand that he marry you.`n`n",$partner);
output("He looks at you for a few seconds.`n`n");
if ($c>=22){
output("\"`^Of course my love!`0\" he says.");
output("The next weeks are a blur as you plan the most wonderous wedding, paid for entirely by %s`0, and head on off to the deep forest for your honeymoon.",$partner);
addnews("`&%s`& and %s`& are joined today in joyous matrimony!!!",$session['user']['name'],$partner);
$session['user']['marriedto']=INT_MAX;
apply_buff('lover',lovers_getbuff());
}else{
output("%s`0 says, \"`^I'm sorry, apparently I've given you the wrong impression, I think we should just be friends.`0\"", $partner);
output("Depressed, you have no more desire to fight in the forest today.");
$session['user']['turns']=0;
debuglog("lost all turns after being rejected for marriage.");
}
break;
}//end switch
if ($c > $session['user']['charm'])
output("`n`n`^You gain a charm point!");
if ($c < $session['user']['charm'])
output("`n`n`\$You LOSE a charm point!");
$session['user']['charm']=$c;
}//end if
}//end if
}else{
//have seen lover
output("You think you had better not push your luck with %s`0 today.",$partner);
}
set_module_pref("seenlover",$seenlover);
}
?>

View File

@ -0,0 +1,150 @@
<?php
function lovers_violet(){
global $session;
$seenlover = get_module_pref("seenlover");
$partner = get_partner();
if ($seenlover==0){
if ($session['user']['marriedto']==INT_MAX){
if (e_rand(1, 4)==1){
switch(e_rand(1,4)){
case 1:
$msg = translate_inline("being too busy serving these pigs,");
break;
case 2:
$msg = translate_inline("\"that time of month,\"");
break;
case 3:
$msg = translate_inline("\"a little cold... *cough cough* see?\"");
break;
case 4:
$msg = translate_inline("men all being pigs,");
break;
}
output("You head over to cuddle %s`0 and kiss her about the face and neck, but she grumbles something about %s and with a comment like that, you storm away from her!`n`n",$partner,$msg);
$session['user']['charm']--;
output("`^You LOSE a charm point!");
}else{
output("You and %s`0 take some time to yourselves, and you leave the inn, positively glowing!",$partner);
apply_buff('lover',lovers_getbuff());
$session['user']['charm']++;
output("`n`n`^You gain a charm point!");
}
$seenlover = 1;
}elseif (httpget('flirt')==""){
output("You stare dreamily across the room at %s`0, who leans across a table to serve a patron a drink.",$partner);
output("In doing so, she shows perhaps a bit more skin than is necessary, but you don't feel the need to object.");
addnav("Flirt");
addnav("Wink","runmodule.php?module=lovers&op=flirt&flirt=1");
addnav("Kiss her hand","runmodule.php?module=lovers&op=flirt&flirt=2");
addnav("Peck her on the lips","runmodule.php?module=lovers&op=flirt&flirt=3");
addnav("Sit her on your lap","runmodule.php?module=lovers&op=flirt&flirt=4");
addnav("Grab her backside","runmodule.php?module=lovers&op=flirt&flirt=5");
addnav("Carry her upstairs","runmodule.php?module=lovers&op=flirt&flirt=6");
addnav("Marry her","runmodule.php?module=lovers&op=flirt&flirt=7");
}else{
$c = $session['user']['charm'];
$seenlover = 1;
switch(httpget('flirt')){
case 1:
if (e_rand($c,2)>=2){
output("You wink at %s`0, and she gives you a warm smile in return.",$partner);
if ($c<4) $c++;
}else{
output("You wink at %s`0, but she pretends not to notice.",$partner);
}
break;
case 2:
output("You stroll confidently across the room toward %s`0.",$partner);
if (e_rand($c,4)>=4){
output("Taking hold of her hand, you kiss it gently, your lips remaining for only a few seconds.");
output("%s`0 blushes and tucks a strand of hair behind her ear as you walk away, then presses the back side of her hand longingly against her cheek while watching your retreat.",$partner);
if ($c<7) $c++;
}else{
output("You reach out to grab her hand, but %s`0 takes her hand back and asks if perhaps you'd like a drink.",$partner);
}
break;
case 3:
output("Standing with your back against a wooden column, you wait for %s`0 to wander your way when you call her name.",$partner);
if (e_rand($c,7)>=7){
output("She approaches, a hint of a smile on her face.");
output("You grab her chin, lift it slightly, and place a firm but quick kiss on her plump lips.");
if ($c<11) $c++;
}else{
output("She smiles and apologizes, insisting that she is simply too busy to take a moment from her work.");
}
break;
case 4:
output("Sitting at a table, you wait for %s`0 to come your way.",$partner);
if (e_rand($c,11)>=11){
output("When she does so, you reach up and grab her firmly by the waist, pulling her down on to your lap.");
output("She laughs and throws her arms around your neck in a warm hug before thumping you on the chest, standing up, and insisting that she really must get back to work.");
if ($c<14) $c++;
}else{
output("When she does so, you reach up to grab her by the waist, but she deftly dodges, careful not to spill the drink that she's carrying.");
if ($c>0 && $c<10) $c--;
}
break;
case 5:
output("Waiting for %s`0 to brush by you, you firmly palm her backside.",$partner);
if (e_rand($c,14)>=14){
output("She turns and gives you a warm, knowing smile.");
if ($c<18) $c++;
}else{
output("She turns and slaps you across the face. Hard.");
output("Perhaps you should go a little slower.");
if ($c>0 && $c<13) $c--;
}
break;
case 6:
if (e_rand($c,18)>=18){
output("Like a whirlwind, you sweep through the inn, grabbing %s`0, who throws her arms around your neck, and whisk her upstairs to her room there.",$partner);
output("Not more than 10 minutes later you stroll down the stairs, smoking a pipe, and grinning from ear to ear.");
if ($session['user']['turns']>0){
output("You feel exhausted! ");
$session['user']['turns']-=2;
if ($session['user']['turns']<0) $session['user']['turns']=0;
}
addnews("`@%s`@ and %s`@ were seen heading up the stairs in the inn together.`0",$session['user']['name'],$partner);
if ($c<25) $c++;
}else{
output("Like a whirlwind, you sweep through the inn, and grab for %s`0.",$partner);
output("She turns and slaps your face!");
output("\"`%What sort of girl do you think I am, anyhow?`0\" she demands! ");
if ($c>0) $c--;
}
break;
case 7:
output("%s`0 is working feverishly to serve patrons of the inn.",$partner);
output("You stroll up to her and take the mugs out of her hand, placing them on a nearby table.");
output("Amidst her protests you kneel down on one knee, taking her hand in yours.");
output("She quiets as you stare up at her and utter the question that you never thought you'd utter.");
output("She stares at you and you immediately know the answer by the look on her face.`n`n");
if ($c>=22){
output("It is a look of exceeding happiness.");
output("\"`%Yes!`0\" she says, \"`%Yes, yes yes!!!`0\"");
output("Her final confirmations are buried in a flurry of kisses about your face and neck.`n`n");
output("The next days are a blur; you and %s`0 are married in the abbey down the street, in a gorgeous ceremony with many frilly girly things.",$partner);
addnews("`&%s`& and %s`& are joined today in joyous matrimony!!!",$session['user']['name'],$partner);
$session['user']['marriedto']=INT_MAX;
apply_buff('lover',lovers_getbuff());
}else{
output("It is a look of sadness.");
output("\"`%No`0,\" she says, \"`%I'm not yet ready to settle down`0.\"`n`n");
output("Disheartened, you no longer possess the will to pursue any more forest adventures today.");
$session['user']['turns']=0;
debuglog("lost all turns after being rejected for marriage.");
}
}
if ($c > $session['user']['charm'])
output("`n`n`^You gain a charm point!");
if ($c < $session['user']['charm'])
output("`n`n`\$You LOSE a charm point!");
$session['user']['charm']=$c;
}
}else{
output("You think you had better not push your luck with %s`0 today.",$partner);
}
set_module_pref("seenlover",$seenlover);
}
?>

View File

@ -0,0 +1,241 @@
<?php
//addnews ready
// mail ready
// translator ready
/**
* Version: 0.6
* Date: July 31, 2003
* Author: John J. Collins
* Email: collinsj@yahoo.com
*
* Purpose: Provide a fun module to Legend of the Green Dragon
* Program Flow: The player can choose to use the Private or Public Toilet.
* It costs Gold to use the Private Toilet. The Public Toilet is free. After
* using one of the toilet's, the play can was their hands or return. If
* they choose to wash their hands, there is a chance that they can get
* their gold back. If they don't choose to wash their hands, there is a
* chance that they will lose some gold. If they loose gold there is an
* entry added to the daily news.
*/
/**
* Modifications:
* Date: Mar 3, 2004
* Author: Eric Stevens aka MightyE
* Email: logd -at- mightye -dot- org
*
* Mods: Reflowed to sit in moduling system.
*/
require_once("lib/http.php");
function outhouse_getmoduleinfo(){
$info = array(
"name"=>"Gnomish Outhouse",
"author"=>"John Collins",
"version"=>"2.0",
"category"=>"Forest",
"download"=>"core_module",
"prefs"=>array(
"Gnomish Outhouse User Preferences,title",
"usedouthouse"=>"Used Outhouse Today,bool|0"
),
"settings"=>array(
"Gnomish Outhouse Settings,title",
"cost"=>"Cost to use the private outhouse,range,1,20,1|5",
"goldinhand"=>"How much gold must user have in hand before they can lose money,range,0,10,1|1",
"giveback"=>"How much gold to give back if the player is rewarded for washing their hands,range,0,20,1|3",
"takeback"=>"How much gold to take if the user is punished for not washing their hands,range,0,20,1|1",
"goodmusthit"=>"Percent of time you get your money back if you wash,range,0,100,1|60",
"badmusthit"=>"Percent of time you lose money if you don't wash,range,0,100,1|50",
"givegempercent"=>"Percent chance of getting a gem if you wash,range,0,100,1|25",
"giveturnchance"=>"Percent chance of a free forest fight if you wash,range,0,100,1|0"
)
);
return $info;
}
function outhouse_install(){
global $session;
debug("Adding Hooks");
module_addhook("forest");
module_addhook("newday");
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
while ($row = db_fetch_assoc($result)){
if ($row['Field']=="usedouthouse"){
$sql = "SELECT usedouthouse,acctid FROM " . db_prefix("accounts") . " WHERE usedouthouse>0";
$result1 = db_query($sql);
debug("Migrating outhouse usage.`n");
while ($row1 = db_fetch_assoc($result1)){
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) VALUES ('outhouse','usedouthouse',{$row1['acctid']},{$row1['usedouthouse']})";
db_query($sql);
}//end while
debug("Dropping usedouthouse column from the user table.`n");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP usedouthouse";
db_query($sql);
//drop it from the user's session too.
unset($session['user']['usedouthouse']);
}//end if
}//end while
return true;
}
function outhouse_uninstall(){
output("Uninstalling this module.`n");
return true;
}
function outhouse_dohook($hookname, $args){
if ($hookname=="forest"){
addnav("O?The Outhouse","runmodule.php?module=outhouse");
}elseif ($hookname=="newday"){
set_module_pref("usedouthouse",0);
}
return $args;
}
function outhouse_run(){
global $session;
$cost = get_module_setting("cost");
$goldinhand = get_module_setting("goldinhand");
$giveback = get_module_setting("giveback");
$takeback = get_module_setting("takeback");
$goodmusthit = get_module_setting("goodmusthit");
$badmusthit = get_module_setting("badmusthit");
$givegempercent = get_module_setting("givegempercent");
$giveturnchance= get_module_setting("giveturnchance");
$returnto = get_module_setting("returnto");
// Does the player have enough gold to use the Private Toilet?
if ($session['user']['gold'] >= $cost)
$canpay = true;
$op = httpget('op');
if ($op == "pay"){
if (!$canpay) {
page_header("Private Toilet");
output("`7You reach into your pocket and find that your gold has vanished!");
output("Dejected, you return to the forest.");
require_once("lib/forest.php");
forest(true);
page_footer();
}
page_header("Private Toilet");
//$session['user']['usedouthouse'] = 1;
set_module_pref("usedouthouse",1);
output("`7You pay your %s gold to the Toilet Gnome for the privilege of using the paid outhouse.`n", $cost);
output("This is the cleanest outhouse in the land!`n");
output("The Toilet Paper Gnome tells you if you need anything, just ask.`n");
if ($session['user']['sex']) {
output("She politely turns her back to you and finishes cleaning the wash stand.`n");
} else {
output("He politely turns his back to you and finishes cleaning the wash stand.`n");
}
$session['user']['gold'] -= $cost;
debuglog("spent $cost gold to use the outhouse");
addnav("Wash your hands", "runmodule.php?module=outhouse&op=washpay");
addnav("Leave", "runmodule.php?module=outhouse&op=nowash");
}elseif ($op == "free"){
page_header("Public Toilet!");
set_module_pref("usedouthouse",1);
output("`2The smell is so strong your eyes tear up and your nose hair curls!`n");
output("After blowing his nose with it, the Toilet Paper Gnome gives you 1 sheet of single-ply TP to use.`n");
output("After looking at the stuff covering his hands, you think you might not want to use it.`n`n");
output("While %s over the big hole in the middle of the room with the TP Gnome observing you closely, you almost slip in.`n", translate_inline($session['user']['sex']?"squatting":"standing"));
output("You go ahead and take care of business as fast as you can; you can only hold your breath so long.`n");
addnav("Wash your hands", "runmodule.php?module=outhouse&op=washfree");
addnav("Leave", "runmodule.php?module=outhouse&op=nowash");
}elseif ($op == "washpay"|| $op == "washfree"){
page_header("Wash Stand");
output("`2Washing your hands is always a good thing. You tidy up, straighten your %s in your reflection in the water, and head on your way.`0`n", $session['user']['armor']);
$goodhabits = e_rand(1, 100);
if ($goodhabits <= $goodmusthit && $op=="washpay"){
output("`^The Wash Room Fairy blesses you!`n");
output("`7You receive `^%s`7 gold for being sanitary and clean!`0`n", $giveback);
$session['user']['gold'] += $giveback;
debuglog("got $giveback gold in the outhouse for washing");
$givegemtemp = e_rand(1, 100);
if ($givegemtemp <= $givegempercent){
$session['user']['gems']++;
debuglog("gained 1 gem in the outhouse");
output("`&Aren't you the lucky one to find a `%gem`& there by the doorway!`0`n");
}
$giveturntemp = e_rand(1, 100);
if ($giveturntemp <= $giveturnchance) {
$session['user']['turns']++;
output("`&You gained a turn!`0`n");
}
}elseif ($goodhabits <= $goodmusthit && $op == "washfree"){
if (e_rand(1, 3)==1) {
output("`&You notice a small bag containing `^%s`7 gold that someone left by the washstand.`0", $giveback);
$session['user']['gold'] += $giveback;
debuglog("got $giveback gold in the outhouse for washing");
}
}
$args = array(
'soberval'=>0.9,
'sobermsg'=>"`&Leaving the outhouse, you feel a little more sober.`n",
'schema'=>"module-outhouse",
);
modulehook("soberup", $args);
require_once("lib/forest.php");
forest(true);
}elseif (($op == "nowash")){
page_header("Stinky Hands");
output("`2Your hands are soiled and real stinky!`n");
output("Didn't your mother teach you any better?`n");
$takeaway = e_rand(1, 100);
if ($takeaway >= $badmusthit){
if ($session['user']['gold'] >= $goldinhand){
$session['user']['gold'] -= $takeback;
debuglog("lost $takeback gold in the outhouse for not washing");
output("`nThe Toilet Paper Gnome has thrown you to the slimy, filthy floor and extracted `\$%s gold`2 %s from you due to your slovenliness!`n", $takeback, translate_inline($takeback ==1?"piece":"pieces"));
}
output("Aren't you glad an embarrassing moment like this isn't in the news?`n");
if ($session['user']['sex']) {
$msg = "`2Always cool, %s`2 was seen walking around with a long string of toilet paper stuck to her foot.`n";
} else {
$msg = "`2Always cool, %s`2 was seen walking around with a long string of toilet paper stuck to his foot.`n";
}
addnews($msg, $session['user']['name']);
}
require_once("lib/forest.php");
forest(true);
}else{
page_header("The Outhouses");
output("`2The nearby village has two outhouses, which it keeps way out here in the forest because of the warding effect of their smell on creatures.`n`n");
if (get_module_pref("usedouthouse")==0){
output("In typical caste style, there is a privileged outhouse, and an underprivileged outhouse.");
output("The choice is yours!`0`n`n");
addnav("Toilets");
if ($canpay){
addnav(array("Private Toilet: (%s gold)", $cost),
"runmodule.php?module=outhouse&op=pay");
}else{
output("`2The Private Toilet costs `^%s`2 gold.", $cost);
output("Looks like you are going to have to hold it or use the Public Toilet!");
}
addnav("Public Toilet: (free)", "runmodule.php?module=outhouse&op=free");
addnav("Hold it", "forest.php");
}else{
switch(e_rand(1,3)){
case 1:
output("The Outhouses are closed for repairs.`n");
output("You will have to hold it till tomorrow!");
break;
case 2:
output("As you draw close to the Outhouses, you realize that you simply don't think you can bear the smell of another visit to the Outhouses today.");
break;
case 3:
output("You really don't have anything left to relieve today!");
break;
}
output("`n`n`7You return to the forest.`0");
require_once("lib/forest.php");
forest(true);
}
}
page_footer();
}
?>

View File

@ -0,0 +1,341 @@
<?php
// translator ready
// addnews ready
// mail ready
function racedwarf_getmoduleinfo(){
$info = array(
"name"=>"Race - Dwarf",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Races",
"download"=>"core_module",
"settings"=>array(
"Dwarven Race Settings,title",
"villagename"=>"Name for the dwarven village|Qexelcrag",
"minedeathchance"=>"Chance for Dwarves to die in the mine,range,0,100,1|5",
),
"prefs-drinks"=>array(
"Dwarven Race Drink Preferences,title",
"servedkeg"=>"Is this drink served in the dwarven inn?,bool|0",
),
);
return $info;
}
function racedwarf_install(){
module_addhook("chooserace");
module_addhook("setrace");
module_addhook("creatureencounter");
module_addhook("villagetext");
module_addhook("travel");
module_addhook("village");
module_addhook("validlocation");
module_addhook("validforestloc");
module_addhook("moderate");
module_addhook("drinks-text");
module_addhook("changesetting");
module_addhook("drinks-check");
module_addhook("raceminedeath");
module_addhook("racenames");
module_addhook("camplocs");
module_addhook("mercenarycamptext");
$sql = "SELECT companionid FROM ".db_prefix("companions")." WHERE name = 'Grizzly Bear'";
$result = db_query($sql);
if (db_num_rows($result) == 0) {
$sql = "INSERT INTO " . db_prefix("companions") . " (`companionid`, `name`, `category`, `description`, `attack`, `attackperlevel`, `defense`, `defenseperlevel`, `maxhitpoints`, `maxhitpointsperlevel`, `abilities`, `cannotdie`, `cannotbehealed`, `companionlocation`, `companionactive`, `companioncostdks`, `companioncostgems`, `companioncostgold`, `jointext`, `dyingtext`, `allowinshades`, `allowinpvp`, `allowintrain`) VALUES (0, 'Grizzly Bear', 'Wild Beasts', 'You look at the beast knowing that this Grizzly Bear will provide an effective block against attack with its long curved claws and massive body of silver-tipped fur.', 1, 2, 5, 2, 25, 25, 'a:4:{s:5:\"fight\";s:1:\"0\";s:4:\"heal\";s:1:\"0\";s:5:\"magic\";s:1:\"0\";s:6:\"defend\";s:1:\"1\";}', 0, 0, '".get_module_setting("villagename", "racedwarf")."', 1, 0, 4, 600, 'You hear a low, deep belly growl coming from a shadowed corner of the Bestiarium. Curious you walk over to investigate your purchase. As you approach a large form shuffles on all four legs towards the front of its hewn rock enclosure.`n`nThe hunched shoulders of the largest bear you have ever seen ripple as its front haunches push against the ground causing it to stand on its hind legs. It makes another low growl before dropping back on all four legs to follow you on your adventure.', 'The grizzly gets scared by the multitude of blows and hits he has to take and flees into the forest.', 1, 0, 0)";
db_query($sql);
debug("Inserted new companion: Grizzly Bear");
}
return true;
}
function racedwarf_uninstall(){
global $session;
$vname = get_module_setting("villagename", "racedwarf");;
$gname = get_module_setting("villagename");
$sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'";
db_query($sql);
if ($session['user']['location'] == $gname)
$session['user']['location'] = $vname;
// Force anyone who was a Dwarf to rechoose race
$sql = "UPDATE " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='Dwarf'";
db_query($sql);
if ($session['user']['race'] == 'Dwarf')
$session['user']['race'] = RACE_UNKNOWN;
$sql = "UPDATE ". db_prefix("companions") ." SET location='all' WHERE location ='$vname'";
db_query($sql);
return true;
}
function racedwarf_dohook($hookname,$args){
//yeah, the $resline thing is a hack. Sorry, not sure of a better way
//to handle this.
// It could be passed as a hook arg?
global $session,$resline;
$city = get_module_setting("villagename");
$race = "Dwarf";
switch($hookname){
case "racenames":
$args[$race] = $race;
break;
case "raceminedeath":
if ($session['user']['race'] == $race) {
$args['chance'] = get_module_setting("minedeathchance");
$args['racesave'] = "Fortunately your dwarven skill let you escape unscathed.`n";
$args['schema'] = "module-racedwarf";
}
break;
case "changesetting":
// Ignore anything other than villagename setting changes for myself
if ($args['setting'] == "villagename" && $args['module']=="racedwarf") {
if ($session['user']['location'] == $args['old'])
$session['user']['location'] = $args['new'];
$sql = "UPDATE " . db_prefix("accounts") .
" SET location='" . addslashes($args['new']) .
"' WHERE location='" . addslashes($args['old']) . "'";
db_query($sql);
$sql = "UPDATE ".db_prefix("companions")." SET location='".$args['new']." WHERE location='".$args['old']."'";
db_query($sql);
if (is_module_active("cities")) {
$sql = "UPDATE " . db_prefix("module_userprefs") .
" SET value='" . addslashes($args['new']) .
"' WHERE modulename='cities' AND setting='homecity'" .
"AND value='" . addslashes($args['old']) . "'";
db_query($sql);
}
}
break;
case "chooserace":
output("<a href='newday.php?setrace=$race$resline'>Deep in the subterranean strongholds of %s</a>, home to the noble and fierce `#Dwarven`0 people whose desire for privacy and treasure bears no resemblance to their tiny stature.`n`n", $city, true);
addnav("`#Dwarf`0","newday.php?setrace=$race$resline");
addnav("","newday.php?setrace=$race$resline");
break;
case "setrace":
if ($session['user']['race']==$race){
output("`#As a dwarf, you are more easily able to identify the value of certain goods.`n");
output("`^You gain extra gold from forest fights!");
if (is_module_active("cities")) {
if ($session['user']['dragonkills']==0 &&
$session['user']['age']==0){
//new farmthing, set them to wandering around this city.
set_module_setting("newest-$city",
$session['user']['acctid'],"cities");
}
set_module_pref("homecity",$city,"cities");
if ($session['user']['age'] == 0)
$session['user']['location']=$city;
}
}
break;
case "validforestloc":
case "validlocation":
if (is_module_active("cities"))
$args[$city] = "village-$race";
break;
case "moderate":
if (is_module_active("cities")) {
tlschema("commentary");
$args["village-$race"]=sprintf_translate("City of %s", $city);
tlschema();
}
break;
case "creatureencounter":
if ($session['user']['race']==$race){
//get those folks who haven't manually chosen a race
racedwarf_checkcity();
$args['creaturegold']=round($args['creaturegold']*1.2,0);
}
break;
case "travel":
$capital = getsetting("villagename", LOCATION_FIELDS);
$hotkey = substr($city, 0, 1);
$ccity = urlencode($city);
tlschema("module-cities");
if ($session['user']['location']==$capital){
addnav("Safer Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity");
}elseif ($session['user']['location']!=$city){
addnav("More Dangerous Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&d=1");
}
if ($session['user']['superuser'] & SU_EDIT_USERS){
addnav("Superuser");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&su=1");
}
tlschema();
break;
case "villagetext":
racedwarf_checkcity();
if ($session['user']['location'] == $city){
// Do this differently
$args['text']=array("`#`c`bCavernous %s, home of the dwarves`b`c`n`3Deep in the heart of Mount %s lie the ancient caverns that the Dwarves have called home for centuries. Colossal columns, covered with deeply carved geometric shapes, stretch up into the darkness, supporting the massive weight of the mountain above. All around you, stout dwarves discuss legendary treasures and drink heartily from mighty steins, which they readily fill from tremendous barrels nearby.`n", $city, $city);
$args['schemas']['text'] = "module-racedwarf";
$args['clock']="`n`3A cleverly crafted crystal prism allows a beam of light to fall through a crack in the great ceiling.`nIt illuminates age old markings carved into the cavern floor, telling you that on the surface it is `#%s`3.`n";
$args['schemas']['clock'] = "module-racedwarf";
if (is_module_active("calendar")) {
$args['calendar'] = "`n`3A second prism marks out the date on the calendar as `#Year %4\$s`3, `#%3\$s %2\$s`3.`nYet a third shows the day of the week as `#%1\$s`3.`nSo finely wrought are these displays that you marvel at the cunning and skill involved.`n";
$args['schemas']['calendar'] = "module-racedwarf";
}
$args['title']= array("The Caverns of %s", $city);
$args['schemas']['title'] = "module-racedwarf";
$args['sayline']="brags";
$args['schemas']['sayline'] = "module-racedwarf";
$args['talk']="`n`#Nearby some villagers brag:`n";
$args['schemas']['talk'] = "module-racedwarf";
$new = get_module_setting("newest-$city", "cities");
if ($new != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") .
" WHERE acctid='$new'";
$result = db_query_cached($sql, "newest-$city");
$row = db_fetch_assoc($result);
$args['newestplayer'] = $row['name'];
$args['newestid']=$new;
} else {
$args['newestplayer'] = $new;
$args['newestid']="";
}
if ($new == $session['user']['acctid']) {
$args['newest']="`n`3Being rather new to this life, you pound an empty stein against an ale keg in an attempt to get some of the fabulous ale therein.";
} else {
$args['newest']="`n`3Pounding an empty stein against a yet unopened barrel of ale, wondering how to get to the sweet nectar inside is `#%s`3.";
}
$args['schemas']['newest'] = "module-racedwarf";
$args['gatenav']="Village Gates";
$args['schemas']['gatenav'] = "module-racedwarf";
$args['fightnav']="Th' Arena";
$args['schemas']['fightnav'] = "module-racedwarf";
$args['marketnav']="Ancient Treasures";
$args['schemas']['marketnav'] = "module-racedwarf";
$args['tavernnav']="Ale Square";
$args['schemas']['tavernnav'] = "module-racedwarf";
$args['mercenarycamp']="A Bestiarium";
$args['schemas']['mercenarycamp'] = "module-racedwarf";
$args['section']="village-$race";
unblocknav("mercenarycamp.php");
}
break;
case "village":
if ($session['user']['location'] == $city) {
tlschema($args['schemas']['tavernnav']);
addnav($args['tavernnav']);
tlschema();
addnav("K?Great Kegs of Ale","runmodule.php?module=racedwarf&op=ale");
}
break;
case "drinks-text":
if ($session['user']['location'] != $city) break;
$args["title"]="Great Kegs of Ale";
$args['schemas']['title'] = "module-racedwarf";
$args["return"]="B?Return to the Bar";
$args['schemas']['return'] = "module-racedwarf";
$args['returnlink']="runmodule.php?module=racedwarf&op=ale";
$args["demand"]="Pounding your fist on the bar, you demand another drink";
$args['schemas']['demand'] = "module-racedwarf";
$args['barkeep'] = "`\$G`4argoyle";
$args['schemas']['barkeep'] = "module-racedwarf";
$args["toodrunk"]=" but `0{barkeep}`0 the bartender continues to clean the stein he was working on and growls, \"`qNo more of my drinks for you!`0\"";
$args['schemas']['toodrunk'] = "module-racedwarf";
$args["toomany"]="`\$G`4argoyle`0 the bartender furrows his balding head. \"`qYou're too weak to handle any more of `QMY`q brew. Begone!`0\"";
$args['schemas']['toomany'] = "module-racedwarf";
$args['drinksubs']=array(
"/Cedrik/"=>$args['barkeep']."`0",
"/ Violet /"=>translate_inline(" a stranger "),
"/ Seth /"=>translate_inline(" a stranger "),
"/ `.Violet`. /"=>translate_inline(" a stranger "),
"/ `.Seth`. /"=>translate_inline(" a stranger "),
);
break;
case "drinks-check":
if ($session['user']['location'] == $city) {
$val = get_module_objpref("drinks", $args['drinkid'], "servedkeg");
$args['allowdrink'] = $val;
}
break;
case "camplocs":
$args[$city] = sprintf_translate("The Village of %s", $city);
break;
case "mercenarycamptext":
if ($session['user']['location'] == $city) {
$args['title'] = "A Bestiarium";
$args['schemas']['title'] = "module-racedwarf";
$args['desc'] = array(
"`5You are making your way to the Bestiarium deep in the bowels of the dwarven mountain stronghold.",
"The sounds of a massive struggle echo off the hewn rock walls of the cavernous passageway.",
"Scuffling is punctuated with the sounds of snarling and the impact of a heavy body slamming into another.`n`n",
"As you round the corner you find yourself at the edge of an arena.",
"Around the walls are carved out stalls which contain beasts of various shapes, sizes and abilities.`n`n",
"In the arena, a `&white wolf `5whose size equals that of a mountain pony is lunging towards a massive `~black bear`5.",
"`~The bear`5 on his hind legs stands as tall as an oak.",
"It raises a paw as `&the wolf `5leaps towards him, then with a movement so quick you nearly miss it, `&the wolf `5is batted away to fall on its side.",
"Apparently enraged, `&the wolf`5 leaps snarling to its feet to prepare to lunge again.`n`n",
"At that moment a stocky dwarf standing at the edge of the arena raises his finger and thumb to his mouth.",
"A piercing whistle cuts through the air.",
"`~The black bear `5lowers himself to all fours and shakes his body, then yawns.",
"`&The white wolf `5pauses, then lays down with his tongue hanging in a pant.",
"Its yellow eyes never leaving you as you walk towards the dwarf.`n`n",
"\"`tGreetings, Dwalin!`5\" you call out as you approach.",
"\"`tI am in need of a beast to accompany me on my adventures.",
"What do you have available this day?`5\"`n`n"
);
$args['schemas']['desc'] = "module-racedwarf";
$args['buynav'] = "Buy a Beast";
$args['schemas']['buynav'] = "module-racedwarf";
$args['healnav'] = "";
$args['schemas']['healnav'] = "";
$args['healtext'] = "";
$args['schemas']['healtext'] = "";
$args['healnotenough'] = "";
$args['schemas']['healnotenough'] = "";
$args['healpaid'] = "";
$args['schemas']['healpaid'] = "";
// We don not want the healer in this camp.
blocknav("mercenarycamp.php?op=heal", true);
}
break;
}
return $args;
}
function racedwarf_checkcity(){
global $session;
$race="Dwarf";
$city= get_module_setting("villagename");
if ($session['user']['race']==$race && is_module_active("cities")){
//if they're this race and their home city isn't right, set it up.
if (get_module_pref("homecity","cities")!=$city){ //home city is wrong
set_module_pref("homecity",$city,"cities");
}
}
return true;
}
function racedwarf_run(){
$op = httpget("op");
switch($op){
case "ale":
require_once("lib/villagenav.php");
page_header("Great Kegs of Ale");
output("`3You make your way over to the great kegs of ale lined up near by, looking to score a hearty draught from their mighty reserves.");
output("A mighty dwarven barkeep named `\$G`4argoyle`3 stands at least 4 feet tall, and is serving out the drinks to the boisterous crowd.");
addnav("Drinks");
modulehook("ale");
addnav("Other");
villagenav();
page_footer();
break;
}
}
?>

View File

@ -0,0 +1,271 @@
<?php
// translator ready
// addnews ready
// mail ready
function raceelf_getmoduleinfo(){
$info = array(
"name"=>"Race - Elf",
"version"=>"1.0",
"author"=>"Eric Stevens",
"category"=>"Races",
"download"=>"core_module",
"settings"=>array(
"Elven Race Settings,title",
"villagename"=>"Name for the elven village|Glorfindal",
"minedeathchance"=>"Chance for Elves to die in the mine,range,0,100,1|90",
),
);
return $info;
}
function raceelf_install(){
module_addhook("chooserace");
module_addhook("setrace");
module_addhook("newday");
module_addhook("villagetext");
module_addhook("travel");
module_addhook("validlocation");
module_addhook("validforestloc");
module_addhook("moderate");
module_addhook("changesetting");
module_addhook("raceminedeath");
module_addhook("pvpadjust");
module_addhook("adjuststats");
module_addhook("racenames");
module_addhook("weaponstext");
return true;
}
function raceelf_uninstall(){
global $session;
$vname = getsetting("villagename", LOCATION_FIELDS);
$gname = get_module_setting("villagename");
$sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'";
db_query($sql);
if ($session['user']['location'] == $gname)
$session['user']['location'] = $vname;
// Force anyone who was a Elf to rechoose race
$sql = "UPDATE " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='Elf'";
db_query($sql);
if ($session['user']['race'] == 'Elf')
$session['user']['race'] = RACE_UNKNOWN;
return true;
}
function raceelf_dohook($hookname,$args){
//yeah, the $resline thing is a hack. Sorry, not sure of a better way
//to handle this.
// Pass it in via args?
global $session,$resline;
$city = get_module_setting("villagename");
$race = "Elf";
switch($hookname){
case "racenames":
$args[$race] = $race;
break;
case "pvpadjust":
if ($args['race'] == $race) {
$args['creaturedefense']+=(1+floor($args['creaturelevel']/5));
}
break;
case"adjuststats":
if ($args['race'] == $race) {
$args['defense'] += (1+floor($args['level']/5));
}
break;
case "raceminedeath":
if ($session['user']['race'] == $race) {
$args['chance'] = get_module_setting("minedeathchance");
}
break;
case "changesetting":
// Ignore anything other than villagename setting changes
if ($args['setting'] == "villagename" && $args['module']=="raceelf") {
if ($session['user']['location'] == $args['old'])
$session['user']['location'] = $args['new'];
$sql = "UPDATE " . db_prefix("accounts") .
" SET location='" . addslashes($args['new']) .
"' WHERE location='" . addslashes($args['old']) . "'";
db_query($sql);
if (is_module_active("cities")) {
$sql = "UPDATE " . db_prefix("module_userprefs") .
" SET value='" . addslashes($args['new']) .
"' WHERE modulename='cities' AND setting='homecity'" .
"AND value='" . addslashes($args['old']) . "'";
db_query($sql);
}
}
break;
case "chooserace":
output("<a href='newday.php?setrace=$race$resline'>High among the trees</a> of the %s forest, in frail looking elaborate `^Elvish`0 structures that look as though they might collapse under the slightest strain, yet have existed for centuries.`n`n", $city, true);
addnav("`^Elf`0","newday.php?setrace=$race$resline");
addnav("","newday.php?setrace=$race$resline");
break;
case "setrace":
if ($session['user']['race']==$race){
output("`^As an elf, you are keenly aware of your surroundings at all times; very little ever catches you by surprise.`n");
output("You gain extra defense!");
if (is_module_active("cities")) {
if ($session['user']['dragonkills']==0 &&
$session['user']['age']==0){
//new farmthing, set them to wandering around this city.
set_module_setting("newest-$city",
$session['user']['acctid'],"cities");
}
set_module_pref("homecity",$city,"cities");
if ($session['user']['age'] == 0)
$session['user']['location']=$city;
}
}
break;
case "newday":
if ($session['user']['race']==$race){
raceelf_checkcity();
apply_buff("racialbenefit",array(
"name"=>"`@Elvish Awareness`0",
"defmod"=>"(<defense>?(1+((1+floor(<level>/5))/<defense>)):0)",
"allowinpvp"=>1,
"allowintrain"=>1,
"rounds"=>-1,
"schema"=>"module-raceelf",
)
);
}
break;
case "validforestloc":
case "validlocation":
if (is_module_active("cities"))
$args[$city]="village-$race";
break;
case "moderate":
if (is_module_active("cities")) {
tlschema("commentary");
$args["village-$race"]=sprintf_translate("City of %s", $city);
tlschema();
}
break;
case "travel":
$capital = getsetting("villagename", LOCATION_FIELDS);
$hotkey = substr($city, 0, 1);
$ccity=urlencode($city);
tlschema("module-cities");
if ($session['user']['location']==$capital){
addnav("Safer Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity");
}elseif ($session['user']['location']!=$city){
addnav("More Dangerous Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&d=1");
}
if ($session['user']['superuser'] & SU_EDIT_USERS){
addnav("Superuser");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&su=1");
}
tlschema();
break;
case "villagetext":
raceelf_checkcity();
if ($session['user']['location'] == $city){
$args['text']=array("`^`c`b%s, Ancestral Home of the Elves`b`c`n`6You stand on the forest floor. %s rises about you, appearing to be one with the forest. Ancient, frail-looking buildings appear to grow from the forest floor, the tree limbs, and on the very treetops. The magnificent trees clutch delicately to these homes of elves. Bright motes of light swirl around you as you move about.`n", $city, $city);
$args['schemas']['text'] = "module-raceelf";
$args['clock']="`n`6Capturing one of the tiny lights, you peer delicately into your hands.`nThe fairy within tells you that it is `^%s`6 before disappearing in a tiny sparkle.`n";
$args['schemas']['clock'] = "module-raceelf";
if (is_module_active("calendar")) {
$args['calendar']="`n`6Another fairy whispers in your ear, \"`^Today is `&%3\$s %2\$s`^, `&%4\$s`^. It is `&%1\$s`^.`6\"`n";
$args['schemas']['calendar'] = "modules-raceelf";
}
$args['title']= array("%s City", $city);
$args['schemas']['title'] = "module-raceelf";
$args['sayline']="converses";
$args['schemas']['sayline'] = "module-raceelf";
$args['talk']="`n`^Nearby some villagers converse:`n";
$args['schemas']['talk'] = "module-raceelf";
$new = get_module_setting("newest-$city", "cities");
if ($new != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") .
" WHERE acctid='$new'";
$result = db_query_cached($sql, "newest-$city");
$row = db_fetch_assoc($result);
$args['newestplayer'] = $row['name'];
$args['newestid']=$new;
} else {
$args['newestplayer'] = $new;
$args['newestid']="";
}
if ($new == $session['user']['acctid']) {
$args['newest']="`n`6You stare around in wonder at the excessively tall buildings and feel just a bit queasy at the prospect of looking down from those heights.";
} else {
$args['newest']="`n`6Looking at the buildings high above, and looking a little queasy at the prospect of such heights is `^%s`6.";
}
$args['schemas']['newest'] = "module-raceelf";
$args['gatenav']="Village Gates";
$args['schemas']['gatenav'] = "module-raceelf";
$args['fightnav']="Honor Avenue";
$args['schemas']['fightnav'] = "module-raceelf";
$args['marketnav']="Mercantile";
$args['schemas']['marketnav'] = "module-raceelf";
$args['tavernnav']="Towering Halls";
$args['schemas']['tavernnav'] = "module-raceelf";
$args['section']="village-$race";
$args['schemas']['weaponshop'] = "module-raceelf";
$args['weaponshop'] = "Gadriel's Weapons";
}
break;
case "weaponstext":
$tradeinvalue = round(($session['user']['weaponvalue']*.75),0);
if ($session['user']['location'] == $city) {
$args['schemas']['title'] = "module-raceelf";
$args['title']="Gadriel's Weapons";
$args['schemas']['desc'] = "module-raceelf";
$args['schemas']['tradein'] = "module-raceelf";
if ($session['user']['race'] == $race) {
$args['desc'] = array(
"`7The Elven Ranger pads gracefully towards you as you enter, examining you from head to foot, an expression of piqued interest upon his fine elven features.",
"The tiny elf has magnificent blond hair reaching almost to his knees, and he spends a long moment memorizing your every facial feature.",
"His assessment finally concluded, a gleam settles in his eyes, and a small smile graces his expression.`n`n",
"`5\"You will be richly rewarded for respecting the acquired skill of your own blood,`7\" he says. `5\"Before you lie the greatest feats of workmanship known in all the lands, the grace and power that only the Elves can create. To wield an Elven weapon is an honor unsurpassed.`7\"",
array("`7You warm to his pride in your shared Elven blood, and proudly display your %s.`n`n",$session['user']['weapon']),
);
$args['tradein'] = array(
array("`5Gadriel`7 looks at you and says, \"`5I'll give you `^%s`5 trade-in value for your `~%s`5.", $tradeinvalue, $session['user']['weapon']),
array("Tell me which instrument of battle you wish to own.\""),
);
}else{
$args['desc'] = array(
"`7The Elven Ranger pads gracefully towards you as you enter, examining you from head to foot, an expression of piqued interest upon his fine elven features.",
"The tiny elf has magnificent blond hair reaching almost to his knees, and he spends a long moment memorizing your every facial feature.",
"Gleaming eyes narrow as his assessment is concluded, and his face becomes a hardened mask which sets your teeth on edge. Despite his tiny stature, you feel intimidated, and he revels in your discomfort.`n`n",
"`7Speaking at last, his words are measured and calculated. `5\"You have shown surprising intelligence,`7\" he barks coldly, `5\"for having sought the finest workmanship in all the lands. No other being can hope to posess the grace and pure power of we Elves. No other weapons have one tenth the nobility and quality of what you see here. And no creature shall wield them as well as an Elf would, though you may try as you might.`7\"",
array("`7You attempt bravado in the face of such arrogance, and thrust forward your %s for inspection.`n`n",$session['user']['weapon']),
);
$args['tradein'] = array(
array("`5Gadriel`7 takes your `5%s`7 and examines it again quitely. After some seconds he gives it back to you with a cold look in his eyes.", $session['user']['weapon']),
array("`5\"`^%s`5 gold is all I can give you for this.\"`7, he says.`n`n", $tradeinvalue),
);
}
$args['schemas']['payweapon'] = "module-raceelf";
$args['payweapon'] = "Gadriel takes your `5%s`7 and puts it on a rack behind him. Then, with a flourish, he pick up a new `5%s`7, deftly demonstrating its use, before handing it to you with gallantry and grace.";
}
break;
}
return $args;
}
function raceelf_checkcity(){
global $session;
$race="Elf";
$city=get_module_setting("villagename");
if ($session['user']['race']==$race && is_module_active("cities")){
//if they're this race and their home city isn't right, set it up.
if (get_module_pref("homecity","cities")!=$city){ //home city is wrong
set_module_pref("homecity",$city,"cities");
}
}
return true;
}
function raceelf_run(){
}
?>

View File

@ -0,0 +1,285 @@
<?php
// translator ready
// addnews ready
// mail ready
function racehuman_getmoduleinfo(){
$info = array(
"name"=>"Race - Human",
"version"=>"1.0",
"author"=>"Eric Stevens",
"category"=>"Races",
"download"=>"core_module",
"settings"=>array(
"Human Race Settings,title",
"villagename"=>"Name for the human village|Romar",
"minedeathchance"=>"Chance for Humans to die in the mine,range,0,100,1|90",
"bonus"=>"How many extra forest fights for humans?,range,1,3,1|2",
),
);
return $info;
}
function racehuman_install(){
module_addhook("chooserace");
module_addhook("setrace");
module_addhook("newday");
module_addhook("villagetext");
module_addhook("stabletext");
module_addhook("travel");
module_addhook("validlocation");
module_addhook("validforestloc");
module_addhook("moderate");
module_addhook("changesetting");
module_addhook("raceminedeath");
module_addhook("stablelocs");
module_addhook("racenames");
return true;
}
function racehuman_uninstall(){
global $session;
$vname = getsetting("villagename", LOCATION_FIELDS);
$gname = get_module_setting("villagename");
$sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'";
db_query($sql);
if ($session['user']['location'] == $gname)
$session['user']['location'] = $vname;
// Force anyone who was a Human to rechoose race
$sql = "UPDATE " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='Human'";
db_query($sql);
if ($session['user']['race'] == 'Human')
$session['user']['race'] = RACE_UNKNOWN;
return true;
}
function racehuman_dohook($hookname,$args){
//yeah, the $resline thing is a hack. Sorry, not sure of a better way
// to handle this.
// Pass it as an arg?
global $session,$resline;
$city = get_module_setting("villagename");
$race = "Human";
switch($hookname){
case "racenames":
$args[$race] = $race;
break;
case "raceminedeath":
if ($session['user']['race'] == $race) {
$args['chance'] = get_module_setting("minedeathchance");
}
break;
case "changesetting":
// Ignore anything other than villagename setting changes
if ($args['setting'] == "villagename" && $args['module']=="racehuman") {
if ($session['user']['location'] == $args['old'])
$session['user']['location'] = $args['new'];
$sql = "UPDATE " . db_prefix("accounts") .
" SET location='" . addslashes($args['new']) .
"' WHERE location='" . addslashes($args['old']) . "'";
db_query($sql);
if (is_module_active("cities")) {
$sql = "UPDATE " . db_prefix("module_userprefs") .
" SET value='" . addslashes($args['new']) .
"' WHERE modulename='cities' AND setting='homecity'" .
"AND value='" . addslashes($args['old']) . "'";
db_query($sql);
}
}
break;
case "chooserace":
output("`0<a href='newday.php?setrace=$race$resline'>On the plains in the city of %s</a>, the city of `&men`0; always following your father and looking up to his every move, until he sought out the `@Green Dragon`0, never to be seen again.`n`n", $city, true);
addnav("`&Human`0","newday.php?setrace=$race$resline");
addnav("","newday.php?setrace=$race$resline");
break;
case "setrace":
if ($session['user']['race']==$race){
$bonus = get_module_setting("bonus");
$one = translate_inline("an");
$two = translate_inline("two");
$three = translate_inline("three");
$word = $bonus==1?$one:$bonus==2?$two:$three;
$fight = translate_inline("fight");
$fights = translate_inline("fights");
output("`&As a human, your size and strength permit you the ability to effortlessly wield weapons, tiring much less quickly than other races.`n`^You gain %s extra forest %s each day!", $word, $bonus==1?$fight:$fights);
if (is_module_active("cities")) {
if ($session['user']['dragonkills']==0 &&
$session['user']['age']==0){
//new farmthing, set them to wandering around this city.
set_module_setting("newest-$city",
$session['user']['acctid'],"cities");
}
set_module_pref("homecity",$city,"cities");
if ($session['user']['age'] == 0)
$session['user']['location']=$city;
}
}
break;
case "newday":
if ($session['user']['race']==$race){
racehuman_checkcity();
$bonus = get_module_setting("bonus");
$one = translate_inline("an");
$two = translate_inline("two");
$three = translate_inline("three");
$word = $bonus==1?$one:$bonus==2?$two:$three;
$fight = translate_inline("fight");
$fights = translate_inline("fights");
$args['turnstoday'] .= ", Race (human): $bonus";
$session['user']['turns']+=$bonus;
$fight = translate_inline("fight");
$fights = translate_inline("fights");
output("`n`&Because you are human, you gain `^%s extra`& forest fights for today!`n`0", $word, $bonus==1?$fight:$fights);
}
break;
case "validforestloc":
case "validlocation":
if (is_module_active("cities"))
$args[$city]="village-$race";
break;
case "moderate":
if (is_module_active("cities")) {
tlschema("commentary");
$args["village-$race"]=sprintf_translate("City of %s", $city);
tlschema();
}
break;
case "travel":
$capital = getsetting("villagename", LOCATION_FIELDS);
$hotkey = substr($city, 0, 1);
$ccity = urlencode($city);
tlschema("module-cities");
if ($session['user']['location']==$capital){
addnav("Safer Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity");
}elseif ($session['user']['location']!=$city){
addnav("More Dangerous Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&d=1");
}
if ($session['user']['superuser'] & SU_EDIT_USERS){
addnav("Superuser");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&su=1");
}
tlschema();
break;
case "villagetext":
racehuman_checkcity();
if ($session['user']['location'] == $city){
$args['text']=array("`&`c`b%s, City of Men`b`c`n`7You are standing in the heart of %s. Though called a city, this stronghold of humans is little more than a fortified village. The city's low defensive walls are surrounded by rolling plains which gradually turn into thick forest in the distance. Some residents are engaged in conversation around the well in the village square.`n", $city, $city);
$args['schemas']['text'] = "module-racehuman";
$args['clock']="`n`7The great sundial at the heart of the city reads `&%s`7.`n";
$args['schemas']['clock'] = "module-racehuman";
if (is_module_active("calendar")) {
$args['calendar'] = "`n`7A smaller contraption next to it reads `&%s`7, `&%s %s %s`7.`n";
$args['schemas']['calendar'] = "module-racehuman";
}
$args['title']=array("%s, City of Men", $city);
$args['schemas']['title'] = "module-racehuman";
$args['sayline']="says";
$args['schemas']['sayline'] = "module-racehuman";
$args['talk']="`n`&Nearby some villagers talk:`n";
$args['schemas']['talk'] = "module-racehuman";
$new = get_module_setting("newest-$city", "cities");
if ($new != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") .
" WHERE acctid='$new'";
$result = db_query_cached($sql, "newest-$city");
$row = db_fetch_assoc($result);
$args['newestplayer'] = $row['name'];
$args['newestid']=$new;
} else {
$args['newestplayer'] = $new;
$args['newestid']="";
}
if ($new == $session['user']['acctid']) {
$args['newest']="`n`7As you wander your new home, you feel your jaw dropping at the wonders around you.";
} else {
$args['newest']="`n`7Wandering the village, jaw agape, is `&%s`7.";
}
$args['schemas']['newest'] = "module-racehuman";
$args['section']="village-$race";
$args['stablename']="Bertold's Bestiary";
$args['schemas']['stablename'] = "module-racehuman";
$args['gatenav']="Village Gates";
$args['schemas']['gatenav'] = "module-racehuman";
unblocknav("stables.php");
}
break;
case "stabletext":
if ($session['user']['location'] != $city) break;
$args['title'] = "Bertold's Bestiary";
$args['schemas']['title'] = "module-racehuman";
$args['desc'] = array(
"`6Just outside the outskirts of the village, a training area and riding range has been set up.",
"Many people from all across the land mingle as Bertold, a strapping man with a wind-weathered face, extols the virtues of each of the creatures in his care.",
array("As you approach, Bertold smiles broadly, \"`^Ahh! how can I help you today, my %s?`6\" he asks in a booming voice.", translate_inline($session['user']['sex']?'lass':'lad', 'stables'))
);
$args['schemas']['desc'] = "module-racehuman";
$args['lad']="friend";
$args['schemas']['lad'] = "module-racehuman";
$args['lass']="friend";
$args['schemas']['lass'] = "module-racehuman";
$args['nosuchbeast']="`6\"`^I'm sorry, I don't stock any such animal.`6\", Bertold say apologetically.";
$args['schemas']['nosuchbeast'] = "module-racehuman";
$args['finebeast']=array(
"`6\"`^Yes, yes, that's one of my finest beasts!`6\" says Bertold.`n`n",
"`6\"`^Not even Merick has a finer specimen than this!`6\" Bertold boasts.`n`n",
"`6\"`^Doesn't this one have fine musculature?`6\" he asks.`n`n",
"`6\"`^You'll not find a better trained creature in all the land!`6\" exclaims Bertold.`n`n",
"`6\"`^And a bargain this one'd be at twice the price!`6\" booms Bertold.`n`n",
);
$args['schemas']['finebeast'] = "module-racehuman";
$args['toolittle']="`6Bertold looks over the gold and gems you offer and turns up his nose, \"`^Obviously you misheard my price. This %s will cost you `&%s `^gold and `%%s`^ gems and not a penny less.`6\"";
$args['schemas']['toolittle'] = "module-racehuman";
$args['replacemount']="`6Patting %s`6 on the rump, you hand the reins as well as the money for your new creature, and Bertold hands you the reins of a `&%s`6.";
$args['schemas']['replacemount'] = "module-racehuman";
$args['newmount']="`6You hand over the money for your new creature, and Bertold hands you the reins of a new `&%s`6.";
$args['schemas']['newmount'] = "module-racehuman";
$args['nofeed']="`6\"`^I'm terribly sorry %s, but I don't stock feed here. I'm not a common stable after all! Perhaps you should look elsewhere to feed your creature.`6\"";
$args['schemas']['nofeed'] = "module-racehuman";
$args['nothungry']="`&%s`6 picks briefly at the food and then ignores it. Bertold, being honest, shakes his head and hands you back your gold.";
$args['schemas']['nothungry'] = "module-racehuman";
$args['halfhungry']="`&%s`6 dives into the provided food and gets through about half of it before stopping. \"`^Well, %s wasn't as hungry as you thought.`6\" says Bertold as he hands you back all but %s gold.";
$args['schemas']['halfhungry'] = "module-racehuman";
$args['hungry']="`6%s`6 seems to inhale the food provided. %s`6, the greedy creature that it is, then goes snuffling at Bertold's pockets for more food.`nBertold shakes his head in amusement and collects `&%s`6 gold from you.";
$args['schemas']['hungry'] = "module-racehuman";
$args['mountfull']="`n`6\"`^Well, %s, your %s`^ is full up now. Come back tomorrow if it hungers again, and I'll be happy to sell you more.`6\" says Bertold with a genial smile.";
$args['schemas']['mountfull'] = "module-racehuman";
$args['nofeedgold']="`6\"`^I'm sorry, but that is just not enough money to pay for food here.`6\" Bertold turns his back on you, and you lead %s away to find other places for feeding.";
$args['schemas']['nofeedgold'] = "module-racehuman";
$args['confirmsale']="`n`n`6Bertold eyes your mount up and down, checking it over carefully. \"`^Are you quite sure you wish to part with this creature?`6\"";
$args['schemas']['confirmsale'] = "module-racehuman";
$args['mountsold']="`6With but a single tear, you hand over the reins to your %s`6 to Bertold's stableboy. The tear dries quickly, and the %s in hand helps you quickly overcome your sorrow.";
$args['schemas']['mountsold'] = "module-racehuman";
$args['offer']="`n`n`6Bertold strokes your creature's flank and offers you `&%s`6 gold and `%%s`6 gems for %s`6.";
$args['schemas']['offer'] = "module-racehuman";
break;
case "stablelocs":
tlschema("mounts");
$args[$city]=sprintf_translate("The Village of %s", $city);
tlschema();
break;
}
return $args;
}
function racehuman_checkcity(){
global $session;
$race="Human";
$city=get_module_setting("villagename");
if ($session['user']['race']==$race && is_module_active("cities")){
//if they're this race and their home city isn't right, set it up.
if (get_module_pref("homecity","cities")!=$city){ //home city is wrong
set_module_pref("homecity",$city,"cities");
}
}
return true;
}
function racehuman_run(){
}
?>

View File

@ -0,0 +1,235 @@
<?php
// translator ready
// addnews ready
// mail ready
function racetroll_getmoduleinfo(){
$info = array(
"name"=>"Race - Troll",
"version"=>"1.0",
"author"=>"Eric Stevens",
"category"=>"Races",
"download"=>"core_module",
"settings"=>array(
"Trollish Race Settings,title",
"villagename"=>"Name for the troll village|Glukmoore",
"minedeathchance"=>"Chance for Trolls to die in the mine,range,0,100,1|90",
),
);
return $info;
}
function racetroll_install(){
module_addhook("chooserace");
module_addhook("setrace");
module_addhook("newday");
module_addhook("villagetext");
module_addhook("travel");
module_addhook("validlocation");
module_addhook("validforestloc");
module_addhook("moderate");
module_addhook("changesetting");
module_addhook("raceminedeath");
module_addhook("pvpadjust");
module_addhook("adjuststats");
module_addhook("racenames");
return true;
}
function racetroll_uninstall(){
global $session;
$vname = getsetting("villagename", LOCATION_FIELDS);
$gname = get_module_setting("villagename");
$sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'";
db_query($sql);
if ($session['user']['location'] == $gname)
$session['user']['location'] = $vname;
// Force anyone who was a Troll to rechoose race
$sql = "UPDATE " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='Troll'";
db_query($sql);
if ($session['user']['race'] == 'Troll')
$session['user']['race'] = RACE_UNKNOWN;
return true;
}
function racetroll_dohook($hookname,$args){
//yeah, the $resline thing is a hack. Sorry, not sure of a better way
// to handle this.
// Pass it in via args?
global $session,$resline;
$city = get_module_setting("villagename");
$race = "Troll";
switch($hookname){
case "racenames":
$args[$race] = $race;
break;
case "pvpadjust":
if ($args['race'] == $race) {
$args['creatureattack']+=(1+floor($args['creaturelevel']/5));
}
break;
case "adjuststats":
if ($args['race'] == $race) {
$args['attack']+=(1+floor($args['level']/5));
}
break;
case "raceminedeath":
if ($session['user']['race'] == $race) {
$args['chance'] = get_module_setting("minedeathchance");
}
break;
case "changesetting":
// Ignore anything other than villagename setting changes
if ($args['setting'] == "villagename" && $args['module']=="racetroll") {
if ($session['user']['location'] == $args['old'])
$session['user']['location'] = $args['new'];
$sql = "UPDATE " . db_prefix("accounts") .
" SET location='" . addslashes($args['new']) .
"' WHERE location='" . addslashes($args['old']) . "'";
db_query($sql);
if (is_module_active("cities")) {
$sql = "UPDATE " . db_prefix("module_userprefs") .
" SET value='" . addslashes($args['new']) .
"' WHERE modulename='cities' AND setting='homecity'" .
"AND value='" . addslashes($args['old']) . "'";
db_query($sql);
}
}
break;
case "chooserace":
output("<a href='newday.php?setrace=$race$resline'>In the swamps of %s</a>`2 as a `@Troll`2, fending for yourself from the very moment you crept out of your leathery egg, slaying your yet unhatched siblings, and feasting on their bones.`n`n",$city, true);
addnav("`@Troll`0","newday.php?setrace=$race$resline");
addnav("","newday.php?setrace=$race$resline");
break;
case "setrace":
if ($session['user']['race']==$race){
output("`@As a troll, and having always fended for yourself, the ways of battle are not foreign to you.`n");
output("`^You gain extra attack!");
if (is_module_active("cities")) {
if ($session['user']['dragonkills']==0 &&
$session['user']['age']==0){
//new farmthing, set them to wandering around this city.
set_module_setting("newest-$city",
$session['user']['acctid'],"cities");
}
set_module_pref("homecity",$city,"cities");
if ($session['user']['age'] == 0)
$session['user']['location']=$city;
}
}
break;
case "validforestloc":
case "validlocation":
if (is_module_active("cities"))
$args[$city] = "village-$race";
break;
case "moderate":
if (is_module_active("cities")) {
tlschema("commentary");
$args["village-$race"]=sprintf_translate("City of %s", $city);
tlschema();
}
break;
case "newday":
if ($session['user']['race']==$race){
racetroll_checkcity();
apply_buff("racialbenefit",array(
"name"=>"`@Trollish Strength`0",
"atkmod"=>"(<attack>?(1+((1+floor(<level>/5))/<attack>)):0)",
"allowinpvp"=>1,
"allowintrain"=>1,
"rounds"=>-1,
"schema"=>"module-racetroll",
)
);
}
break;
case "travel":
$capital = getsetting("villagename", LOCATION_FIELDS);
$hotkey = substr($city, 0, 1);
$ccity = urlencode($city);
tlschema("module-cities");
if ($session['user']['location']==$capital){
addnav("Safer Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity");
}elseif ($session['user']['location']!=$city){
addnav("More Dangerous Travel");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&d=1");
}
if ($session['user']['superuser'] & SU_EDIT_USERS){
addnav("Superuser");
addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&su=1");
}
tlschema();
break;
case "villagetext":
racetroll_checkcity();
if ($session['user']['location'] == $city){
$args['text']=array("`@`b`c%s, Home of the Trolls`c`b`n`2You are standing in a pile of mud, in the heart of a vast swamp. Around you are the fetid skin-covered hovels that trolls call home. Well actually, they call them 'ughrrnk', but that's a bit hard on the throats of non-trolls. Nearby some local peasants squabble over the rapidly decaying remains of the morning's hunt. Perched atop one of the huts, a badly scarred troll smears indescribable filth over his home's surface in an ill fated attempt to water proof it.`n", $city);
$args['schemas']['text'] = "module-racetroll";
$args['clock']="`n`2Based on what's left of the morning's kill, you can tell that it is `@%s`2.`n";
$args['schemas']['clock'] = "module-racetroll";
if (is_module_active("calendar")) {
$args['calendar'] = "`n`2Bellows and noises around you let you know that it is `@%1\$s`2, `@%3\$s %2\$s`2, `@%4\$s`2.`n";
$args['schemas']['calendar'] = "module-racetroll";
}
$args['title']=array("The Swamps of %s", $city);
$args['schemas']['title'] = "module-racetroll";
$args['sayline']="squabbles";
$args['schemas']['sayline'] = "module-racetroll";
$args['talk']="`n`@Nearby some villagers squabble:`n";
$args['schemas']['talk'] = "module-racetroll";
$new = get_module_setting("newest-$city", "cities");
if ($new != 0) {
$sql = "SELECT name FROM " . db_prefix("accounts") .
" WHERE acctid='$new'";
$result = db_query_cached($sql, "newest-$city");
$row = db_fetch_assoc($result);
$args['newestplayer'] = $row['name'];
$args['newestid']=$new;
} else {
$args['newestplayer'] = $new;
$args['newestid']="";
}
if ($new == $session['user']['acctid']) {
$args['newest']="`n`2You wander the village, picking your teeth with the tiny rib of one of your siblings. Flicking off a bit of shell that was still stuck to your skin, you watch as it skips several times across the muddy surface of the swamp before a small lizard jumps on it and begins to consume its nutrients.";
} else {
$args['newest']="`n`2Picking their teeth with a sliver of bone is `@%s`2, still covered with bits of shell from the hatchery.";
}
$args['schemas']['newest'] = "module-racetroll";
$args['gatenav']="Village Gates";
$args['schemas']['gatenav'] = "module-racetroll";
$args['fightnav']="Barshem Gud";
$args['schemas']['fightnav'] = "module-racetroll";
$args['marketnav']="Da Gud Stuff";
$args['schemas']['marketnav'] = "module-racetroll";
$args['tavernnav']="Eatz n' Such";
$args['schemas']['tavernnav'] = "module-racetroll";
$args['infonav']="Da Infoz";
$args['schemas']['infonav'] = "module-racetroll";
$args['section']="village-$race";
}
break;
}
return $args;
}
function racetroll_checkcity(){
global $session;
$race="Troll";
$city=get_module_setting("villagename");
if ($session['user']['race']==$race && is_module_active("cities")){
//if they're this race and their home city isn't right, set it up.
if (get_module_pref("homecity","cities")!=$city){ //home city is wrong
set_module_pref("homecity",$city,"cities");
}
}
return true;
}
function racetroll_run(){
}
?>

View File

@ -0,0 +1,316 @@
<?php
//Seth's songs as a module
//Converted by Zach Lawson with some minor modification
/*
Version History:
Version 1.0 - First public release
Version 1.1 - Fixed a small bug that caused 2 "Return to the Inn" navs to
show up
*/
require_once("lib/villagenav.php");
require_once("lib/http.php");
function sethsong_getmoduleinfo(){
$info = array(
"name"=>"Seth the Bard's Songs",
"version"=>"1.1",
"author"=>"Eric Stevens",
"category"=>"Inn",
"download"=>"core_module",
"settings"=>array(
"Seth the Bard's Songs,title",
"bhploss"=>"Percent of hitpoints that can be lost when Seth burps,range,2,100,2|10",
"shploss"=>"Percent of hitpoints that can be lost when a string breaks,range,2,100,2|20",
"hpgain"=>"Percent of max hitpoints that can be gained,range,2,100,2|20",
//I realize adding 100% of max hitpoints or killing them when they go to Seth is a little outrageous, but might as well give admins the option
"maxgems"=>"Most gems that can be found,int|1",
"mingems"=>"Fewest gems that can be found,int|1",
"Set these equal to each other for a fixed amount,note",
"mingold"=>"Minimum amount gold you can find,int|10",
"maxgold"=>"Maximum amount gold you can find,int|50",
"goldloss"=>"Amount of gold that can be lost,int|5",
"Warning: If a player's gold is less than this amount they loose nothin!,note",
"visits"=>"How many times per day can a player listen to Seth,int|1",
),
"prefs"=>array(
"Seth the Bard's Songs,title",
"been"=>"How many times have they listened Seth today,int|0",
),
);
return $info;
}
function sethsong_install(){
// Convert the seenbard field.
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
while ($row = db_fetch_assoc($result)){
if ($row['Field']=="seenbard"){
$sql = "SELECT seenbard,acctid FROM " . db_prefix("accounts") . " WHERE seenbard>0";
$result1 = db_query($sql);
debug("Migrating seenbard.`n");
while ($row1 = db_fetch_assoc($result1)){
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) VALUES ('seth','been',{$row1['acctid']},{$row1['seenbard']})";
db_query($sql);
}//end while
debug("Dropping seenbard column from the user table.`n");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP seenbard";
db_query($sql);
//drop it from the user's session too.
unset($session['user']['seenbard']);
}//end if
}//end while
module_addhook("inn");
module_addhook("newday");
return true;
}
function sethsong_uninstall(){
return true;
}
function sethsong_dohook($hookname,$args){
switch($hookname){
case "inn":
$op = httpget("op");
if ($op == "" || $op == "strolldown" || $op == "fleedragon") {
addnav("Things to do");
addnav(array("L?Listen to %s`0 the Bard", getsetting("bard", "`^Seth")),"runmodule.php?module=sethsong");
}
break;
case "newday":
set_module_pref("been",0);
break;
}
return $args;
}
function sethsong_run(){
$op=httpget('op');
$visits=get_module_setting("visits");
$been=get_module_pref("been");
$iname = getsetting("innname", LOCATION_INN);
tlschema("inn");
page_header($iname);
rawoutput("<span style='color: #9900FF'>");
output_notl("`c`b");
output($iname);
output_notl("`b`c");
tlschema();
// Short circuit out if we've heard enough
if ($been >= $visits) {
output("%s`0 clears his throat and drinks some water.", getsetting("bard", "`^Seth"));
output("\"I'm sorry, my throat is just too dry.\"");
} else {
sethsong_sing();
}
addnav("Where to?");
addnav("I?Return to the Inn","inn.php");
villagenav();
rawoutput("</span>");
page_footer();
}
function sethsong_sing()
{
global $session;
$mostgold=get_module_setting("maxgold");
$leastgold=get_module_setting("mingold");
$lgain=get_module_setting("hpgain");
$bloss=get_module_setting("bhploss");
$sloss=get_module_setting("shploss");
$gold=get_module_setting("goldloss");
$mostgems=get_module_setting("maxgems");
$leastgems=get_module_setting("mingems");
$visits=get_module_setting("visits");
$been=get_module_pref("been");
$been++;
set_module_pref("been",$been);
$rnd = e_rand(0,18);
output("%s`0 clears his throat and begins:`n`n`^", getsetting("bard", "`^Seth"));
switch ($rnd){
case 0:
output("`@Green Dragon`^ is green,`n`@Green Dragon`^ is fierce.`n");
output("I fancy for a`n`@Green Dragon`^ to pierce.`n`n");
output("`0You gain TWO forest fights for today!");
$session['user']['turns'] += 2;
break;
case 1:
// Since masters are now editable, pick a random one.
$sql = "SELECT creaturename FROM " . db_prefix("masters") . " ORDER BY RAND(".e_rand().") LIMIT 1";
$res = db_query($sql);
if (db_num_rows($res)) {
$row = db_fetch_assoc($res);
$name = $row['creaturename'];
} else {
$name = "MightyE";
}
output("%s, I scoff at thee and tickleth your toes.`n", $name);
output("For they smell most foul and seethe a stench far greater than you know!`n`n");
output("`0You feel jovial, and gain an extra forest fight.");
$session['user']['turns']++;
break;
case 2:
output("Membrane Man, Membrane Man.`n");
output("Membrane man hates %s`^ man.`n", $session['user']['name']);
output("They have a fight, Membrane wins.`n");
output("Membrane Man.`n`n");
output("`0You're not quite sure what to make of this.");
output("You merely back away, and think you'll visit %s`0 when he's feeling better.", getsetting("bard", "`^Seth"));
output("Having rested a while though, you think you could face another forest creature.");
$session['user']['turns']++;
break;
case 3:
output("Gather 'round and I'll tell you a tale`nmost terrible and dark`nof %s`^ and his unclean beer`nand how he hates this bard!`n`n", getsetting('barkeep', '`tCedrik'));
output("`0You realize he's right, %s`0's beer really is nasty.", getsetting('barkeep', '`tCedrik'));
output("That's why most patrons prefer his ale.");
output("Though you don't really gain anything from the tale from %s`0, you do happen to notice a few gold on the ground!", getsetting("bard", "`^Seth"));
$gain = e_rand($leastgold,$mostgold);
$session['user']['gold']+=$gain;
debuglog("found $gain gold near Seth");
break;
case 4:
output("So a pirate goes into a bar with a steering wheel in his pants.`n");
output("The bartender says, \"You know you have a steering wheel in your pants?\"`n");
output("The pirate replies, \"Yaaarr, 'tis drivin' me nuts!\"`n`n");
output("`0With a good hearty chuckle in your soul, you advance on the world, ready for anything!");
$session['user']['hitpoints']=round(max($session['user']['maxhitpoints'],$session['user']['hitpoints'])*(($lgain/100)+1),0);
break;
case 5:
output("Listen close and hear me well: every second we draw even closer to death. *wink*`n`n");
output("`0Depressed, you head for home... and lose a forest fight!");
$session['user']['turns']--;
if ($session['user']['turns']<0)
$session['user']['turns']=0;
break;
case 6:
output("I love MightyE, MightyE weaponry, I love MightyE, MightyE weaponry, I love MightyE, MightyE weaponry, nothing kills as good as MightyE... WEAPONRY!`n`n");
output("`0You think %s`0 is quite correct.`n", getsetting("bard", "`^Seth"));
output("You want to go out and kill something.");
output("You leave and think about bees and fish for some reason.");
$session['user']['turns']++;
break;
case 7:
output("%s`0 seems to sit up and prepare himself for something impressive.",getsetting("bard","`^Seth"));
output("He then burps loudly in your face.");
output("\"`^Was that entertaining enough?`0\"`n`n");
output("`0The smell is overwhelming.");
output("You feel a little ill and lose some hitpoints.");
$session['user']['hitpoints']-=round($session['user']['maxhitpoints'] * ($bloss/100),0);
if ($session['user']['hitpoints']<=0)
$session['user']['hitpoints']=1;
break;
case 8:
output("`0\"`^What is the sound of one hand clapping?`0\" asks %s`0.", getsetting("bard", "`^Seth"));
if ($session['user']['gold'] >=$gold ) {
output("While you ponder this conundrum, %s`0 \"liberates\" a small entertainment fee from your purse.`n`n", getsetting("bard", "`^Seth"));
output("You lose %s gold!",$gold);
$session['user']['gold']-=$gold;
debuglog("lost $gold gold to Seth");
} else {
output("While you ponder this conundrum, %s`0 attempts to \"liberate\" a small entertainment fee from your purse, but doesn't find enough to bother with.", getsetting("bard", "`^Seth"));
}
break;
case 9:
$gems=e_rand($leastgems,$mostgems);
output("What do you call a fish with no eyes?`n`n");
output("A fsshh.`n`n");
output("`0You groan as %s`0 laughs heartily.", getsetting("bard", "`^Seth"));
if($gems==0){
output("Shaking your head, you turn to go back to the inn.");
}
if($gems==1){
output("Shaking your head, you notice a gem in the dust.");
$session['user']['gems']++;
}else{
output("Shaking your head, you notice %s gems in the dust.",$gems);
$session['user']['gems']+=$gems;
}
debuglog("got $gems gem\\(s\\) from Seth");
break;
case 10:
output("%s`0 plays a soft but haunting melody.`n`n", getsetting("bard", "`^Seth"));
output("You feel relaxed, and your wounds seem to fade away.");
if ($session['user']['hitpoints'] < $session['user']['maxhitpoints'])
$session['user']['hitpoints'] = $session['user']['maxhitpoints'];
break;
case 11:
output("%s`0 plays a melancholy dirge for you.`n`n", getsetting("bard", "`^Seth"));
output("You feel lower in spirits, you may not be able to face as many villains today.");
$session['user']['turns']--;
if ($session['user']['turns']<0)
$session['user']['turns']=0;
break;
case 12:
output("The ants go marching one by one, hoorah, hoorah.`n");
output("The ants go marching one by one, hoorah, hoorah!`n");
output("The ants go marching one by one and the littlest one stops to suck his thumb, and they all go marching down, to the ground, to get out of the rain...`n");
output("bum bum bum`n");
output("The ants go marching two by two, hoorah, hoorah!....`n`n");
output("%s`0 continues to sing, but not wishing to learn how high he can count, you quietly leave.`n`n", getsetting("bard", "`^Seth"));
output("Having rested a while, you feel refreshed.");
if($session['user']['hitpoints'] < $session['user']['maxhitpoints'])
$session['user']['hitpoints'] = $session['user']['maxhitpoints'];
break;
case 13:
output("There once was a lady from Venus, her body was shaped like a ...`n`n");
if ($session['user']['sex']==SEX_FEMALE){
output("%s`0 is cut short by a curt slap across his face!", getsetting("bard", "`^Seth"));
output("Feeling rowdy, you gain a forest fight.");
}else{
output("%s`0 is cut short as you burst out in laughter, not even having to hear the end of the rhyme.", getsetting("bard", "`^Seth"));
output("Feeling inspired, you gain a forest fight.");
}
$session['user']['turns']++;
break;
case 14:
output("%s`0 plays a rousing call-to-battle that wakes the warrior spirit inside of you.`n`n", getsetting("bard", "`^Seth"));
output("`0You gain a forest fight!");
$session['user']['turns']++;
break;
case 15:
output("%s`0 seems preoccupied with your... eyes.`n`n", getsetting("bard", "`^Seth"));
if ($session['user']['sex']==SEX_FEMALE){
output("`0You receive one charm point!");
$session['user']['charm']++;
}else{
output("`0Furious, you stomp out of the bar!");
output("You gain a forest fight in your fury.");
$session['user']['turns']++;
}
break;
case 16:
output("%s`0 begins to play, but a lute string snaps, striking you square in the eye.`n`n", getsetting("bard", "`^Seth"));
output("`0\"`^Whoops, careful, you'll shoot your eye out kid!`0\"`n`n");
output("You lose some hitpoints!");
$session['user']['hitpoints']-=round($session['user']['maxhitpoints']*($sloss/100),0);
if ($session['user']['hitpoints']<1)
$session['user']['hitpoints']=1;
break;
case 17:
output("%s`0 begins to play, but a rowdy patron stumbles past, spilling beer on you.", getsetting("bard", "`^Seth"));
output("You miss the performance as you wipe the swill from your %s.", $session['user']['armor']);
break;
case 18:
output("%s`0 stares at you thoughtfully, obviously rapidly composing an epic poem...`n`n", getsetting("bard", "`^Seth"));
output("`^U-G-L-Y, You ain't got no alibi -- you ugly, yeah yeah, you ugly!`n`n");
$session['user']['charm']--;
if ($session['user']['charm']<0){
output("`0If you had any charm, you'd have been offended, instead, %s`0 breaks a lute string.", getsetting("bard", "`^Seth"));
}else{
output("`n`n`0Depressed, you lose a charm point.");
}
break;
}
}
?>

View File

@ -0,0 +1,252 @@
<?php
//addnews ready
// mail ready
// translator ready
function specialtydarkarts_getmoduleinfo(){
$info = array(
"name" => "Specialty - Dark Arts",
"author" => "Eric Stevens",
"version" => "1.1",
"download" => "core_module",
"category" => "Specialties",
"prefs" => array(
"Specialty - Dark Arts User Prefs,title",
"skill"=>"Skill points in Dark Arts,int|0",
"uses"=>"Uses of Dark Arts allowed,int|0",
),
);
return $info;
}
function specialtydarkarts_install(){
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
$specialty="DA";
while($row = db_fetch_assoc($result)) {
// Convert the user over
if ($row['Field'] == "darkarts") {
debug("Migrating darkarts field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtydarkarts', 'skill', acctid, darkarts FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping darkarts field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP darkarts";
db_query($sql);
} elseif ($row['Field']=="darkartuses") {
debug("Migrating darkarts uses field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtydarkarts', 'uses', acctid, darkartuses FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping darkartuses field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP darkartuses";
db_query($sql);
}
}
debug("Migrating Darkarts Specialty");
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='$specialty' WHERE specialty='1'";
db_query($sql);
module_addhook("choose-specialty");
module_addhook("set-specialty");
module_addhook("fightnav-specialties");
module_addhook("apply-specialties");
module_addhook("newday");
module_addhook("incrementspecialty");
module_addhook("specialtynames");
module_addhook("specialtymodules");
module_addhook("specialtycolor");
module_addhook("dragonkill");
return true;
}
function specialtydarkarts_uninstall(){
// Reset the specialty of anyone who had this specialty so they get to
// rechoose at new day
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='' WHERE specialty='DA'";
db_query($sql);
return true;
}
function specialtydarkarts_dohook($hookname,$args){
global $session,$resline;
$spec = "DA";
$name = "Dark Arts";
$ccode = "`$";
switch ($hookname) {
case "dragonkill":
set_module_pref("uses", 0);
set_module_pref("skill", 0);
break;
case "choose-specialty":
if ($session['user']['specialty'] == "" ||
$session['user']['specialty'] == '0') {
addnav("$ccode$name`0","newday.php?setspecialty=$spec$resline");
$t1 = translate_inline("Killing a lot of woodland creatures");
$t2 = appoencode(translate_inline("$ccode$name`0"));
rawoutput("<a href='newday.php?setspecialty=$spec$resline'>$t1 ($t2)</a><br>");
addnav("","newday.php?setspecialty=$spec$resline");
}
break;
case "set-specialty":
if($session['user']['specialty'] == $spec) {
page_header($name);
output("`5Growing up, you recall killing many small woodland creatures, insisting that they were plotting against you.");
output("Your parents, concerned that you had taken to killing the creatures barehanded, bought you your very first pointy twig.");
output("It wasn't until your teenage years that you began performing dark rituals with the creatures, disappearing into the forest for days on end, no one quite knowing where those sounds came from.");
}
break;
case "specialtycolor":
$args[$spec] = $ccode;
break;
case "specialtynames":
$args[$spec] = translate_inline($name);
break;
case "specialtymodules":
$args[$spec] = "specialtydarkarts";
break;
case "incrementspecialty":
if($session['user']['specialty'] == $spec) {
$new = get_module_pref("skill") + 1;
set_module_pref("skill", $new);
$c = $args['color'];
$name = translate_inline($name);
output("`n%sYou gain a level in `&%s%s to `#%s%s!",
$c, $name, $c, $new, $c);
$x = $new % 3;
if ($x == 0){
output("`n`^You gain an extra use point!`n");
set_module_pref("uses", get_module_pref("uses") + 1);
}else{
if (3-$x == 1) {
output("`n`^Only 1 more skill level until you gain an extra use point!`n");
} else {
output("`n`^Only %s more skill levels until you gain an extra use point!`n", (3-$x));
}
}
output_notl("`0");
}
break;
case "newday":
$bonus = getsetting("specialtybonus", 1);
if($session['user']['specialty'] == $spec) {
$name = translate_inline($name);
if ($bonus == 1) {
output("`n`2For being interested in %s%s`2, you receive `^1`2 extra `&%s%s`2 use for today.`n",$ccode, $name, $ccode, $name);
} else {
output("`n`2For being interested in %s%s`2, you receive `^%s`2 extra `&%s%s`2 uses for today.`n",$ccode, $name,$bonus, $ccode,$name);
}
}
$amt = (int)(get_module_pref("skill") / 3);
if ($session['user']['specialty'] == $spec) $amt = $amt + $bonus;
set_module_pref("uses", $amt);
break;
case "fightnav-specialties":
$uses = get_module_pref("uses");
$script = $args['script'];
if ($uses > 0) {
addnav(array("$ccode$name (%s points)`0", $uses),"");
addnav(array("$ccode &#149; Skeleton Crew`7 (%s)`0", 1),
$script."op=fight&skill=$spec&l=1", true);
}
if ($uses > 1) {
addnav(array("$ccode &#149; Voodoo`7 (%s)`0", 2),
$script."op=fight&skill=$spec&l=2",true);
}
if ($uses > 2) {
addnav(array("$ccode &#149; Curse Spirit`7 (%s)`0", 3),
$script."op=fight&skill=$spec&l=3",true);
}
if ($uses > 4) {
addnav(array("$ccode &#149; Wither Soul`7 (%s)`0", 5),
$script."op=fight&skill=$spec&l=5",true);
}
break;
case "apply-specialties":
$skill = httpget('skill');
$l = httpget('l');
if ($skill==$spec){
if (get_module_pref("uses") >= $l){
switch($l){
case 1:
if (getsetting("enablecompanions", true)) {
apply_companion('skeleton_warrior', array(
"name"=>"`4Skeleton Warrior",
"hitpoints"=>round($session['user']['level']*3.33,0)+10,
"maxhitpoints"=>round($session['user']['level']*3.33,0)+10,
"attack"=>round((($session['user']['level']/4)+2))*round((($session['user']['level']/3)+2))+1.5,
"defense"=>floor((($session['user']['level']/3)+0))*ceil(($session['user']['level']/6)+2)+2.5,
"dyingtext"=>"`\$Your skeleton warrior crumbles to dust.`n",
"abilities"=>array(
"fight"=>true,
),
"ignorelimit"=>true, // Does not count towards companion limit...
), true);
// Because of this last "true" the companion can be added any time.
// Even, if the player controls already more companions than normally allowed!
} else {
apply_buff('da1',array(
"startmsg"=>"`\$You call on the spirits of the dead, and skeletal hands claw at {badguy} from beyond the grave.",
"name"=>"`\$Skeleton Crew",
"rounds"=>5,
"wearoff"=>"Your skeleton minions crumble to dust.",
"minioncount"=>round($session['user']['level']/3)+1,
"maxbadguydamage"=>round($session['user']['level']/2,0)+1,
"effectmsg"=>"`)An undead minion hits {badguy}`) for `^{damage}`) damage.",
"effectnodmgmsg"=>"`)An undead minion tries to hit {badguy}`) but `\$MISSES`)!",
"schema"=>"module-specialtydarkarts"
));
}
break;
case 2:
apply_buff('da2',array(
"startmsg"=>"`\$You pull out a tiny doll that looks like {badguy}.",
"effectmsg"=>"You thrust a pin into the {badguy} doll hurting it for `^{damage}`) points!",
"rounds"=>1,
"minioncount"=>1,
"maxbadguydamage"=>round($session['user']['attack']*3,0),
"minbadguydamage"=>round($session['user']['attack']*1.5,0),
"schema"=>"module-specialtydarkarts"
));
break;
case 3:
apply_buff('da3',array(
"startmsg"=>"`\$You place a curse on {badguy}'s ancestors.",
"name"=>"`\$Curse Spirit",
"rounds"=>5,
"wearoff"=>"Your curse has faded.",
"badguydmgmod"=>0.5,
"roundmsg"=>"{badguy} staggers under the weight of your curse, and deals only half damage.",
"schema"=>"module-specialtydarkarts"
));
break;
case 5:
apply_buff('da5',array(
"startmsg"=>"`\$You hold out your hand and {badguy} begins to bleed from its ears.",
"name"=>"`\$Wither Soul",
"rounds"=>5,
"wearoff"=>"Your victim's soul has been restored.",
"badguyatkmod"=>0,
"badguydefmod"=>0,
"roundmsg"=>"{badguy} claws at its eyes, trying to release its own soul, and cannot attack or defend.",
"schema"=>"module-specialtydarkarts"
));
break;
}
set_module_pref("uses", get_module_pref("uses") - $l);
}else{
apply_buff('da0', array(
"startmsg"=>"Exhausted, you try your darkest magic, a bad joke. {badguy} looks at you for a minute, thinking, and finally gets the joke. Laughing, it swings at you again.",
"rounds"=>1,
"schema"=>"module-specialtydarkarts"
));
}
}
break;
}
return $args;
}
function specialtydarkarts_run(){
}
?>

View File

@ -0,0 +1,244 @@
<?php
//addnews ready
// mail ready
// translator ready
function specialtymysticpower_getmoduleinfo(){
$info = array(
"name" => "Specialty - Mystical Powers",
"author" => "Eric Stevens",
"version" => "1.0",
"download" => "core_module",
"category" => "Specialties",
"prefs" => array(
"Specialty - Mystical Powers User Prefs,title",
"skill"=>"Skill points in Mystical Powers,int|0",
"uses"=>"Uses of Mystical Powers allowed,int|0",
),
);
return $info;
}
function specialtymysticpower_install(){
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
$specialty="MP";
while($row = db_fetch_assoc($result)) {
// Convert the user over
if ($row['Field'] == "magic") {
debug("Migrating mystic powers field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtymysticpower', 'skill', acctid, magic FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping magic field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP magic";
db_query($sql);
} elseif ($row['Field']=="magicuses") {
debug("Migrating mystic powers uses field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtymysticpower', 'uses', acctid, magicuses FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping magicuses field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP magicuses";
db_query($sql);
}
}
debug("Migrating Mystic Powers Specialty");
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='$specialty' WHERE specialty='2'";
db_query($sql);
module_addhook("choose-specialty");
module_addhook("set-specialty");
module_addhook("fightnav-specialties");
module_addhook("apply-specialties");
module_addhook("newday");
module_addhook("incrementspecialty");
module_addhook("specialtynames");
module_addhook("specialtymodules");
module_addhook("specialtycolor");
module_addhook("dragonkill");
return true;
}
function specialtymysticpower_uninstall(){
// Reset the specialty of anyone who had this specialty so they get to
// rechoose at new day
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='' WHERE specialty='MP'";
db_query($sql);
return true;
}
function specialtymysticpower_dohook($hookname,$args){
global $session,$resline;
$spec = "MP";
$name = "Mystical Powers";
$ccode = "`%";
$ccode2 = "`%%"; // We need this to handle the damned sprintf escaping.
switch ($hookname) {
case "dragonkill":
set_module_pref("uses", 0);
set_module_pref("skill", 0);
break;
case "choose-specialty":
if ($session['user']['specialty'] == "" ||
$session['user']['specialty'] == '0') {
addnav("$ccode$name`0","newday.php?setspecialty=".$spec."$resline");
$t1 = translate_inline("Dabbling in mystical forces");
$t2 = appoencode(translate_inline("$ccode$name`0"));
rawoutput("<a href='newday.php?setspecialty=$spec$resline'>$t1 ($t2)</a><br>");
addnav("","newday.php?setspecialty=$spec$resline");
}
break;
case "set-specialty":
if($session['user']['specialty'] == $spec) {
page_header($name);
output("`3Growing up, you remember knowing there was more to the world than the physical, and what you could place your hands on.");
output("You realized that your mind itself, with training, could be turned into a weapon.");
output("Over time, you began to control the thoughts of small creatures, commanding them to do your bidding, and also to begin to tap into the mystical force known as mana, which could be shaped into the elemental forms of fire, water, ice, earth, and wind.");
output("To your delight, it could also be used as a weapon against your foes.");
}
break;
case "specialtycolor":
$args[$spec] = $ccode;
break;
case "specialtynames":
$args[$spec] = translate_inline($name);
break;
case "specialtymodules":
$args[$spec] = "specialtymysticpower";
break;
case "incrementspecialty":
if($session['user']['specialty'] == $spec) {
$new = get_module_pref("skill") + 1;
set_module_pref("skill", $new);
$name = translate_inline($name);
$c = $args['color'];
output("`n%sYou gain a level in `&%s%s to `#%s%s!",
$c, $name, $c, $new, $c);
$x = $new % 3;
if ($x == 0){
output("`n`^You gain an extra use point!`n");
set_module_pref("uses", get_module_pref("uses") + 1);
}else{
if (3-$x == 1) {
output("`n`^Only 1 more skill level until you gain an extra use point!`n");
} else {
output("`n`^Only %s more skill levels until you gain an extra use point!`n", (3-$x));
}
}
output_notl("`0");
}
break;
case "newday":
$bonus = getsetting("specialtybonus", 1);
if($session['user']['specialty'] == $spec) {
$name = translate_inline($name);
if ($bonus == 1) {
output("`n`2For being interested in %s%s`2, you receive `^1`2 extra `&%s%s`2 use for today.`n",$ccode,$name,$ccode,$name);
} else {
output("`n`2For being interested in %s%s`2, you receive `^%s`2 extra `&%s%s`2 uses for today.`n",$ccode,$name,$bonus,$ccode,$name);
}
}
$amt = (int)(get_module_pref("skill") / 3);
if ($session['user']['specialty'] == $spec) $amt = $amt + $bonus;
set_module_pref("uses", $amt);
break;
case "fightnav-specialties":
$uses = get_module_pref("uses");
$script = $args['script'];
if ($uses > 0) {
addnav(array("$ccode2$name (%s points)`0", $uses), "");
addnav(array("e?$ccode2 &#149; Regeneration`7 (%s)`0", 1),
$script."op=fight&skill=$spec&l=1", true);
}
if ($uses > 1) {
addnav(array("$ccode2 &#149; Earth Fist`7 (%s)`0", 2),
$script."op=fight&skill=$spec&l=2",true);
}
if ($uses > 2) {
addnav(array("$ccode2 &#149; Siphon Life`7 (%s)`0", 3),
$script."op=fight&skill=$spec&l=3",true);
}
if ($uses > 4) {
addnav(array("g?$ccode2 &#149; Lightning Aura`7 (%s)`0", 5),
$script."op=fight&skill=$spec&l=5",true);
}
break;
case "apply-specialties":
$skill = httpget('skill');
$l = httpget('l');
if ($skill==$spec){
if (get_module_pref("uses") >= $l){
switch($l){
case 1:
apply_buff('mp1', array(
"startmsg"=>"`^You begin to regenerate!",
"name"=>"`%Regeneration",
"rounds"=>5,
"wearoff"=>"You have stopped regenerating.",
"regen"=>$session['user']['level'],
"effectmsg"=>"You regenerate for {damage} health.",
"effectnodmgmsg"=>"You have no wounds to regenerate.",
"aura"=>true,
"auramsg"=>"`5Your {companion}`5 regenerates for `^{damage} health`5 due to your healing aura.",
"schema"=>"module-specialtymysticpower"
));
break;
case 2:
apply_buff('mp2', array(
"startmsg"=>"`^{badguy}`% is clutched by a fist of earth and slammed to the ground!",
"name"=>"`%Earth Fist",
"rounds"=>5,
"wearoff"=>"The earthen fist crumbles to dust.",
"minioncount"=>1,
"effectmsg"=>"A huge fist of earth pummels {badguy} for `^{damage}`) points.",
"minbadguydamage"=>1,
"maxbadguydamage"=>$session['user']['level']*3,
"areadamage"=>true,
"schema"=>"module-specialtymysticpower"
));
break;
case 3:
apply_buff('mp3', array(
"startmsg"=>"`^Your weapon glows with an unearthly presence.",
"name"=>"`%Siphon Life",
"rounds"=>5,
"wearoff"=>"Your weapon's aura fades.",
"lifetap"=>1, //ratio of damage healed to damage dealt
"effectmsg"=>"You are healed for {damage} health.",
"effectnodmgmsg"=>"You feel a tingle as your weapon tries to heal your already healthy body.",
"effectfailmsg"=>"Your weapon wails as you deal no damage to your opponent.",
"schema"=>"module-specialtymysticpower"
));
break;
case 5:
apply_buff('mp5', array(
"startmsg"=>"`^Your skin sparkles as you assume an aura of lightning.",
"name"=>"`%Lightning Aura",
"rounds"=>5,
"wearoff"=>"With a fizzle, your skin returns to normal.",
"damageshield"=>2, // ratio of damage reflected to damage received
"effectmsg"=>"{badguy} recoils as lightning arcs out from your skin, hitting for `^{damage}`) damage.",
"effectnodmgmsg"=>"{badguy} is slightly singed by your lightning, but otherwise unharmed.",
"effectfailmsg"=>"{badguy} is slightly singed by your lightning, but otherwise unharmed.",
"schema"=>"module-specialtymysticpower"
));
break;
}
set_module_pref("uses", get_module_pref("uses") - $l);
}else{
apply_buff('mp0', array(
"startmsg"=>"You furrow your brow and call on the powers of the elements. A tiny flame appears. {badguy} lights a cigarette from it, giving you a word of thanks before swinging at you again.",
"rounds"=>1,
"schema"=>"module-specialtymysticpower"
));
}
}
break;
}
return $args;
}
function specialtymysticpower_run(){
}
?>

View File

@ -0,0 +1,232 @@
<?php
//addnews ready
// mail ready
// translator ready
function specialtythiefskills_getmoduleinfo(){
$info = array(
"name" => "Specialty - Thieving Skills",
"author" => "Eric Stevens",
"version" => "1.0",
"download" => "core_module",
"category" => "Specialties",
"prefs" => array(
"Specialty - Thieving Skills User Prefs,title",
"skill"=>"Skill points in Thieving Skills,int|0",
"uses"=>"Uses of Thieving Skills allowed,int|0",
),
);
return $info;
}
function specialtythiefskills_install(){
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
$specialty="TS";
while($row = db_fetch_assoc($result)) {
// Convert the user over
if ($row['Field'] == "thievery") {
debug("Migrating thieving skills field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtythiefskills', 'skill', acctid, thievery FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping thievery field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP thievery";
db_query($sql);
} elseif ($row['Field']=="thieveryuses") {
debug("Migrating thieving skills uses field");
$sql = "INSERT INTO " . db_prefix("module_userprefs") . " (modulename,setting,userid,value) SELECT 'specialtythiefskills', 'uses', acctid, thieveryuses FROM " . db_prefix("accounts");
db_query($sql);
debug("Dropping thieveryuses field from accounts table");
$sql = "ALTER TABLE " . db_prefix("accounts") . " DROP thieveryuses";
db_query($sql);
}
}
debug("Migrating Thieving Skills Specialty");
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='$specialty' WHERE specialty='3'";
db_query($sql);
module_addhook("choose-specialty");
module_addhook("set-specialty");
module_addhook("fightnav-specialties");
module_addhook("apply-specialties");
module_addhook("newday");
module_addhook("incrementspecialty");
module_addhook("specialtynames");
module_addhook("specialtymodules");
module_addhook("specialtycolor");
module_addhook("dragonkill");
return true;
}
function specialtythiefskills_uninstall(){
// Reset the specialty of anyone who had this specialty so they get to
// rechoose at new day
$sql = "UPDATE " . db_prefix("accounts") . " SET specialty='' WHERE specialty='TS'";
db_query($sql);
return true;
}
function specialtythiefskills_dohook($hookname,$args){
global $session,$resline;
$spec = "TS";
$name = "Thieving Skills";
$ccode = "`^";
switch ($hookname) {
case "dragonkill":
set_module_pref("uses", 0);
set_module_pref("skill", 0);
break;
case "choose-specialty":
if ($session['user']['specialty'] == "" ||
$session['user']['specialty'] == '0') {
addnav("$ccode$name`0","newday.php?setspecialty=".$spec."$resline");
$t1 = translate_inline("Stealing from the rich and giving to yourself");
$t2 = appoencode(translate_inline("$ccode$name`0"));
rawoutput("<a href='newday.php?setspecialty=$spec$resline'>$t1 ($t2)</a><br>");
addnav("","newday.php?setspecialty=$spec$resline");
}
break;
case "set-specialty":
if($session['user']['specialty'] == $spec) {
page_header($name);
output("`6Growing up, you recall discovering that a casual bump in a crowded room could earn you the coin purse of someone otherwise more fortunate than you.");
output("You also discovered that the back side of your enemies were considerably more prone to a narrow blade than the front side was to even a powerful weapon.");
}
break;
case "specialtycolor":
$args[$spec] = $ccode;
break;
case "specialtynames":
$args[$spec] = translate_inline($name);
break;
case "specialtymodules":
$args[$spec] = "specialtythiefskills";
break;
case "incrementspecialty":
if($session['user']['specialty'] == $spec) {
$new = get_module_pref("skill") + 1;
set_module_pref("skill", $new);
$name = translate_inline($name);
$c = $args['color'];
output("`n%sYou gain a level in `&%s%s to `#%s%s!",
$c, $name, $c, $new, $c);
$x = $new % 3;
if ($x == 0){
output("`n`^You gain an extra use point!`n");
set_module_pref("uses", get_module_pref("uses") + 1);
}else{
if (3-$x == 1) {
output("`n`^Only 1 more skill level until you gain an extra use point!`n");
} else {
output("`n`^Only %s more skill levels until you gain an extra use point!`n", (3-$x));
}
}
output_notl("`0");
}
break;
case "newday":
$bonus = getsetting("specialtybonus", 1);
if($session['user']['specialty'] == $spec) {
$name = translate_inline($name);
if ($bonus == 1) {
output("`n`2For being interested in %s%s`2, you receive `^1`2 extra `&%s%s`2 use for today.`n",$ccode,$name,$ccode,$name);
} else {
output("`n`2For being interested in %s%s`2, you receive `^%s`2 extra `&%s%s`2 uses for today.`n",$ccode,$name,$bonus,$ccode,$name);
}
}
$amt = (int)(get_module_pref("skill") / 3);
if ($session['user']['specialty'] == $spec) $amt = $amt + $bonus;
set_module_pref("uses", $amt);
break;
case "fightnav-specialties":
$uses = get_module_pref("uses");
$script = $args['script'];
if ($uses > 0) {
addnav(array("$ccode$name (%s points)`0", $uses), "");
addnav(array("$ccode &#149; Insult`7 (%s)`0", 1),
$script."op=fight&skill=$spec&l=1", true);
}
if ($uses > 1) {
addnav(array("$ccode &#149; Poison Blade`7 (%s)`0", 2),
$script."op=fight&skill=$spec&l=2",true);
}
if ($uses > 2) {
addnav(array("$ccode &#149; Hidden Attack`7 (%s)`0", 3),
$script."op=fight&skill=$spec&l=3",true);
}
if ($uses > 4) {
addnav(array("$ccode &#149; Backstab`7 (%s)`0", 5),
$script."op=fight&skill=$spec&l=5",true);
}
break;
case "apply-specialties":
$skill = httpget('skill');
$l = httpget('l');
if ($skill==$spec){
if (get_module_pref("uses") >= $l){
switch($l){
case 1:
apply_buff('ts1',array(
"startmsg"=>"`^You call {badguy} a bad name, making it cry.",
"name"=>"`^Insult",
"rounds"=>5,
"wearoff"=>"Your victim stops crying and wipes its nose.",
"roundmsg"=>"{badguy} feels dejected and cannot attack as well.",
"badguyatkmod"=>0.5,
"schema"=>"module-specialtythiefskills"
));
break;
case 2:
apply_buff('ts2',array(
"startmsg"=>"`^You apply some poison to your {weapon}.",
"name"=>"`^Poison Attack",
"rounds"=>5,
"wearoff"=>"Your victim's blood has washed the poison from your {weapon}.",
"atkmod"=>2,
"roundmsg"=>"Your attack is multiplied!",
"schema"=>"module-specialtythiefskills"
));
break;
case 3:
apply_buff('ts3', array(
"startmsg"=>"`^With the skill of an expert thief, you virtually disappear, and attack {badguy} from a safer vantage point.",
"name"=>"`^Hidden Attack",
"rounds"=>5,
"wearoff"=>"Your victim has located you.",
"roundmsg"=>"{badguy} cannot locate you, and swings wildly!",
"badguyatkmod"=>0,
"schema"=>"module-specialtythiefskills"
));
break;
case 5:
apply_buff('ts5',array(
"startmsg"=>"`^Using your skills as a thief, you disappear behind {badguy} and slide a thin blade between its vertebrae!",
"name"=>"`^Backstab",
"rounds"=>5,
"wearoff"=>"Your victim won't be so likely to let you get behind it again!",
"atkmod"=>3,
"defmod"=>3,
"roundmsg"=>"Your attack is multiplied, as is your defense!",
"schema"=>"module-specialtythiefskills"
));
break;
}
set_module_pref("uses", get_module_pref("uses") - $l);
}else{
apply_buff('ts0', array(
"startmsg"=>"You try to attack {badguy} by putting your best thievery skills into practice, but instead, you trip over your feet.",
"rounds"=>1,
"schema"=>"module-specialtythiefskills"
));
}
}
break;
}
return $args;
}
function specialtythiefskills_run(){
}
?>