View Source: /source/forest.php

Click here for the source, OR
Other files that you may wish to view the source of:

Source of: /source/forest.php

<?
require_once "common.php";
if (
$HTTP_GET_VARS[op]=="darkhorse"){
    
$HTTP_GET_VARS[op]="";
    
$session[user][specialinc]="darkhorse.php";
}
$fight false;
page_header("The Forest");
if (
$session[user][superuser]>&& $HTTP_GET_VARS[specialinc]!=""){
  
$session[user][specialinc] = $HTTP_GET_VARS[specialinc];
}
if (
$session[user][specialinc]!=""){
  
//echo "$x including special/".$session[user][specialinc];
    
    
output("`^`c`bSomething Special!`c`b`0");
    
$specialinc $session[user][specialinc];
    
$session[user][specialinc] = "";
    include(
"special/".$specialinc);
    if (!
is_array($session['allowednavs']) || count($session['allowednavs'])==0) {
        
addnav("Return to the forest","forest.php");
        
//output(serialize($session['allowednavs']));
    
}
    
page_footer();
    exit();
}
if (
$HTTP_GET_VARS[op]=="run"){
    if (
e_rand()%== 0){
        
output ("`c`b`&You have successfully fled your oponent!`0`b`c`n");
        
$HTTP_GET_VARS[op]="";
    }else{
        
output("`c`b`\$You failed to flee your oponent!`0`b`c");
    }
}
if (
$HTTP_GET_VARS[op]=="dragon"){
    
addnav("Enter the cave","dragon.php");
    
addnav("Run away like a baby","inn.php");
    
output("`\$You approach the blackened entrance of a cave deep in the forest, though ");
    
output(" the trees are scorched to stumps for a hundred yards all around.  ");
    
output("A thin tendril of smoke escapes the roof of the cave's entrance, and is whisked away ");
    
output("by a suddenly cold and brisk wind.  The mouth of the cave lies up a dozen ");
    
output("feet from the forest floor, set in the side of a cliff, with debris making a ");
    
output("conical ramp to the opening.  Stalactites and stalagmites near the entrance ");
    
output("trigger your imagination to inspire thoughts that the opening is really ");
    
output("the mouth of a great leach.  ");
    
output("`n`nYou cautiously approach the entrance of the cave, and as you do, you hear, ");
    
output("or perhaps feel a deep rumble that lasts thirty seconds or so, before silencing ");
    
output("to a breeze of sulfur-air which wafts out of the cave.  The sound starts again, and stops ");
    
output("again in a regular rhythm.  ");
    
output("`n`nYou clamber up the debris pile leading to the mouth of the cave, your feet crunching ");
    
output("on the apparent remains of previous heroes, or herhaps hors d'ouvers.");
    
output("`n`nEvery instinct in your body wants to run, and run quickly, back to the warm inn, and ");
    
output("the even warmer ".($session[user][sex]?"Seth":"Violet").".  What do you do?");
    
$session[user][seendragon]=1;
}
if (
$HTTP_GET_VARS[op]=="search"){
  
checkday();
    if (
$session[user][hashorse]>=3){
        
$session[bufflist][102]=array("name"=>"`&Horse Attack","rounds"=>"25","wearoff"=>"Your horse has fatigued","atkmod"=>1.2);
    }
  if (
$session[user][turns]<=0){
    
output("`\$`bYou are too tired to search the forest any longer today.  Perhaps tomorrow you will have more energy.`b`0");
    
$HTTP_GET_VARS[op]="";
  }else{
      
$session[user][drunkenness]=round($session[user][drunkenness]*.9,0);
      
$specialtychance e_rand()%7;
      if (
$specialtychance==0){
          
output("`^`c`bSomething Special!`c`b`0");
            if (
$handle opendir("special")){
              
$events = array();
              while (
false !== ($file readdir($handle))){
                  if (
strpos($file,".php")>0){
                      
array_push($events,$file);
                    }
                }
                
$x e_rand(0,count($events)-1);
                if (
count($events)==0){
                  
output("`b`@Aww, your administrator has decided you're not allowed to have any special events.  Complain to them, not me.");
                }else{
                  
$y $HTTP_GET_VARS[op];
                    
$HTTP_GET_VARS[op]="";
                  
//echo "$x including special/".$events[$x];
                  
include("special/".$events[$x]);
                    
$HTTP_GET_VARS[op]=$y;
                }
            }else{
              
output("`c`b`\$ERROR!!!`b`c`&Unable to open the special events!  Please notify the administrator!!");
            }
          if (
$nav==""addnav("Return to the forest","forest.php");
      }else{
      
$session[user][turns]--;
          
$battle=true;
            if (
e_rand(0,2)==1){
                
$plev = (e_rand(1,5)==1?1:0);
                
$nlev = (e_rand(1,3)==1?1:0);
            }else{
              
$plev=0;
                
$nlev=0;
            }
            if (
$HTTP_GET_VARS['type']=="slum"){
              
$nlev++;
                
output("`\$You head for the section of forest you know to contain foes that you're a bit more comfortable with.`0`n");
            }
            if (
$HTTP_GET_VARS['type']=="thrill"){
              
$plev++;
                
output("`\$You head for the section of forest which contains creatures of your nightmares, hoping to find one of them injured.`0`n");
            }
          
$targetlevel = ($session['user']['level'] + $plev $nlev );
          if (
$targetlevel<1$targetlevel=1;
          
$sql "SELECT * FROM creatures WHERE creaturelevel = $targetlevel ORDER BY rand(".e_rand().") LIMIT 1";
          
$result db_query($sql) or die(db_error(LINK));
          
//echo "$sql<br>\$plev=$plev<br>\$nlev=$nlev";
          
$badguy db_fetch_assoc($result);
            
$expflux round($badguy['creatureexp']/10,0);
            
$expflux e_rand(-$expflux,$expflux);
            
$badguy['creatureexp']+=$expflux;
            
$badguy['diddamage']=0;
          
$session['user']['badguy']=createstring($badguy);
    }
    }
}
if (
$HTTP_GET_VARS[op]=="fight" || $HTTP_GET_VARS[op]=="run"){
    
$battle=true;
}
if (
$battle){
  include(
"battle.php");
//    output(serialize($badguy));
    
if ($victory){
        if (
getsetting("dropmingold",0)){
            
$badguy[creaturegold]=e_rand($badguy[creaturegold]/4,3*$badguy[creaturegold]/4);
        }else{
            
$badguy[creaturegold]=e_rand(0,$badguy[creaturegold]);
        }
        
$expbonus round(($badguy[creatureexp]* (1+.25*($badguy[creaturelevel]-$session[user][level]))) - $badguy[creatureexp],0);
        
output("`b`&$badguy[creaturelose]`0`b`n"); 
        
output("`b`\$You have slain $badguy[creaturename]!`0`b`n");
        
output("`#You recieve `^$badguy[creaturegold]`# gold!`n");
        if (
$expbonus>0){
          
output("`#***Because of the difficult nature of this fight, you are awarded an additional `^$expbonus`# experience! `n($badguy[creatureexp] + ".abs($expbonus)." = ".($badguy[creatureexp]+$expbonus).") ");
        }else if (
$expbonus<0){
          
output("`#***Because of the simplistic nature of this fight, you are penalized `^".abs($expbonus)."`# experience! `n($badguy[creatureexp] - ".abs($expbonus)." = ".($badguy[creatureexp]+$expbonus).") ");
        }
        
output("You recieve `^".($badguy[creatureexp]+$expbonus)."`# total experience!`n`0");
        
$session[user][gold]+=$badguy[creaturegold];
        
$session[user][experience]+=($badguy[creatureexp]+$expbonus);
        
$creaturelevel $badguy[creaturelevel];
        
$HTTP_GET_VARS[op]="";
        
//if ($session[user][hitpoints] == $session[user][maxhitpoints]){
        
if ($badguy['diddamage']!=1){
            if (
$session[user][level]>=getsetting("lowslumlevel",4) || $session[user][level]<=$creaturelevel){
                
output("`b`c`&~~ Flawless Fight! ~~`\$`n`bYou recieve an extra turn!`c`0`n");
                
$session[user][turns]++;
            }else{
                
output("`b`c`&~~ Flawless Fight! ~~`b`\$`nA more difficult fight would have yielded an extra turn.`c`n`0");
            }
        }
        
$badguy=array();
        
$dontdisplayforestmessage=true;
    }else{
        if(
$defeat){
            
addnav("Daily news","news.php");
            
$sql "SELECT taunt FROM taunts ORDER BY rand(".e_rand().") LIMIT 1";
            
$result db_query($sql) or die(db_error(LINK));
            
$taunt db_fetch_assoc($result);
            
$taunt str_replace("%s",($session[user][sex]?"her":"him"),$taunt[taunt]);
            
$taunt str_replace("%o",($session[user][sex]?"she":"he"),$taunt);
            
$taunt str_replace("%p",($session[user][sex]?"her":"his"),$taunt);
            
$taunt str_replace("%x",($session[user][weapon]),$taunt);
            
$taunt str_replace("%X",$badguy[creatureweapon],$taunt);
            
$taunt str_replace("%W",$badguy[creaturename],$taunt);
            
$taunt str_replace("%w",$session[user][name],$taunt);
            
            
addnews("`%".$session[user][name]."`5 has been slain in the forest by $badguy[creaturename]`n$taunt");
            
$session[user][alive]=false;
            
$session[user][gold]=0;
            
$session[user][hitpoints]=0;
            
$session[user][experience]=round($session[user][experience]*.9,0);
            
$session[user][badguy]="";
            
output("`b`&You have been slain by `%$badguy[creaturename]`&!!!`n");
            
output("`4All gold on hand has been lost!`n");
            
output("`410% of experience has been lost!`n");
            
output("You may begin fighting again tomorrow.");
            
            
page_footer();
        }else{
          
fightnav();
        }
    }
}else{
    
checkday();
}

if (
$HTTP_GET_VARS[op]==""){
    
addnav("Healer's Hut","healer.php");
    
addnav("Look for Something to kill","forest.php?op=search");
    
addnav("Go Slumming","forest.php?op=search&type=slum");
    
addnav("Go Thrillseeking","forest.php?op=search&type=thrill");
    if (
$session[user][hashorse]>=2addnav("Take horse to Dark Horse Tavern","forest.php?op=darkhorse");
    
addnav("Return to the Village","village.php");
    
addnav("","forest.php");
    if (
$session[user][level]>=15  && $session[user][seendragon]==0){
      
addnav("`@Seek out the Green Dragon","forest.php?op=dragon");
    }
    if (
$dontdisplayforestmessage!=true){
        
output("`c`8`bThe Forest`b`0`c");
        
output("The Forest, home to evil creatures and evil doers of all sorts.`n`n");
        
output("The thick foliage of the forest restricts view to only a few yards in most places.  ");
        
output("The paths would be imperceptible except for your trained eye.  You move as silently as ");
        
output("a soft breeze across the thick mould covering the ground, wary to avoid stepping on ");
        
output("a twig or any of numerous bleached pieces of bone that perforate the forest floor, lest ");
        
output("you belie your presence to one of the vile beasts that wander the forest.");
    }
    if (
$session[user][superuser]>1){
      
output("`n`nSUPERUSER special inc's:`n");
      
$d dir("special");
        while (
false !== ($entry $d->read())){
          if (
substr($entry,0,1)!="."){
              
output("<a href='forest.php?specialinc=$entry'>$entry</a>`n",true);
              
addnav("","forest.php?specialinc=$entry");
            }
        }
    }
}

page_footer();
?>