⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 travel.php

📁 三國好好 子
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?
session_start();
if(@$_SESSION['opponent_id']) {
	header ('Location: combat.php?opp_type=npc');
	exit;
}
include "header.php";
include_once "functions.php";
include_once "class_character.php";

beginTiming();

## Variables
$params = array();
$DEBUG	= 0;	// 0 means turn off debugging;   1 means turn on debugging

// population control
$where= "username='phaos_npc' and race <> 'Dwarf'";
$result = mysql_query("select count(id) from phaos_characters where $where");
list($count) = mysql_fetch_row($result);

//number of
$lowerlimit= 3000;

$upperlimit= $lowerlimit+200;
if ($count > $upperlimit ) {
	$delta= 3+(int)(($count-$upperlimit)/100);
	$result = mysql_query("select id,location,username,name,race from phaos_characters where $where order by rand() LIMIT $delta");
	while( $row = mysql_fetch_assoc($result) ){
		$mob = new character($row['id']);
		$mob->kill_characterid();
	}
}

//@$_COOKIE['_speed'] is just a HACK to speed up testing on my PC, which is very slow

if ($count < $lowerlimit ) {
	$n = ceil(sqrt($lowerlimit-$count)*0.20*(@$_COOKIE['_speed']?0.5:1.0));
	$n>6 and $n= 6;
	for($i=0;$i<$n;++$i) {
		npcgen();
	}
}

if(@$_COOKIE['_timing']) { echo "time end pop control=".endTiming()."<br>\n"; };



// move some NPC first

$npctomov= (@$_COOKIE['_speed'])?3:9;

for($i=0;$i<$npctomov;$i++){
    movenpc();
}

if(@$_COOKIE['_timing']) { echo "time end pop movement=".endTiming()."<br>\n"; };

updateshops();

if(@$_COOKIE['_timing']) { echo "time end shop updates=".endTiming()."<br>\n"; };

// CHARACTER INFORMATION
$character= new character($PHP_PHAOS_CHARID);

// Make sure character is strong enough to travel
if ($character->hit_points<="0") {
	$destination = "";
} elseif ($character->stamina_points<="0") {
	$destination = "";
} else {
    //FIXME: this allows an instant gate travel hack, uhm, I mean, spell
	if (is_numeric(@$_POST['destination']) and $_POST['destination'] > 0) {
		$destination = $_POST['destination'];
	} else {
		$destination = "";
	}
}

if(@$_COOKIE['_timing']) { echo "time 1=".endTiming(); };

if($destination != "")
   {
      //new stamina reduction formula:
      $inv_count=$character->invent_count();
      $degrade=($inv_count-($character->constitution+$character->strength*4));
      if ($inv_count>$character->max_inventory){$degrade=$degrade*2;}
      if ($degrade<0) {$degrade=1;}
      //end stamina reduction update table:

      $character->reduce_stamina($degrade);
      $result = mysql_query('SELECT `above_left`, `above`, `above_right`, `leftside`, `rightside`, `below_left`, `below`, `below_right` FROM  phaos_locations WHERE id = \'' . $character->location . '\'');
      $row = mysql_fetch_assoc($result);
      foreach ($row as $item)
         {
            //FIXME: uses untrusted input by the user
            if ($item == $destination OR @$_POST['rune_gate'] == "yes" OR @$_POST['explorable'] == "yes")
               {
                  $query = ("UPDATE phaos_characters SET location = '$destination', stamina=".$character->stamina_points." WHERE id = '$PHP_PHAOS_CHARID'");
                  $req = mysql_query($query);
                  if (!$req) {echo "<B>Error ".mysql_errno()." :</B> ".mysql_error().""; exit;}
                  $result = mysql_query ("SELECT * FROM phaos_locations WHERE id = '$destination'");
                  $character->location=$destination;
                  if ($row = mysql_fetch_array($result)) {$location_name = $row["name"];}
               }
          }
   }

// define mob separators for php and escaped for javascript
$info_eol= "\r";
$js_info_eol= "\\r";

if($character->name == "") {
     $message =  ("<font size=4><b>".$lang_area["must_create_a_char"]."</b></font><p>".$lang_area["create_a_char"]);
} else {
    $message= '';

	if  ($character->hit_points <= "0") {
		$message =  $lang_trav["zero_hp"]."<br>";
	}
	if  ($character->stamina_points <= "0") {
		$message .= $lang_trav["zero_st"]."<br>";
	}
	if  ($destination == "") {
		$message .= "<b>".$lang_trav["dest"]."</b>";
		draw_html($message);
	}
	if  ($destination != "") {
		$list = whos_here($character->location,'phaos_npc');
		if (count($list)) {
			$result = mysql_query("SELECT buildings,special FROM phaos_locations WHERE id = '".$character->location."'");
			list($buildings,$special) = mysql_fetch_array($result);
			if ($buildings == "n" AND $special == 0) {
				?>
				<script language="javascript">
				window.location = "combat.php?opp_type=roammonst";
				</script>
				<?
//				header ("Location: combat.php?opp_type=roammonst");
				exit;
			}
		}
	    draw_html(@$message);
	}
}

session_destroy();

##---Functions--##
function draw_html($message = '')
	{
		global $character;
		global $params;
		global $DEBUG;
		global $lang_area;
        global $js_info_eol;

        if ($DEBUG >= 1) { $message.= "<p>** DEBUG - Location: ".$character->location."<br>"; }
		//if ($DEBUG >= 1) { $message.= "<p>** DEBUG - whos_here: ".print_r($list,true); }
		// FFIXME:  had to change this to NONE.css or link/input squares have css background !
?>
<script language="JavaScript" type="text/JavaScript"><!--
function displayInfo(info){
    var infoDiv= document.getElementById("info");
    var re = /<?=$js_info_eol?>/g;
    info = info.replace(re,"<br>");
    infoDiv.innerHTML= info;
}
//-->
</script>
<?php
			print '<table border="0" cellspacing="0" cellpadding="0" width="100%">
				  <tr>
					 <td align="center" valign="top">
						<table border="0" cellspacing="0" cellpadding="0">
						   <tr>
							  <td align="center" colspan="2">
								'.$message . '<br>';
                                    //print '<div style="z-Index:30;position:absolute;top:20px;left:20px;">';
                                    // build and print map
                                    list($out_loc,$marker_loc) = data_collect();
                                    draw_all($out_loc);
                                    //print '</div>'."\n";
                                    //print '<div style="z-Index:40;position:absolute;top:20px;left:20px;">';
                                    //draw_all($marker_loc);
                                    //print '</div>'."\n";

			print			  '<br></td>
						   </tr><tr>
						   <td>';
        if(!isset($params['name'])){
            $params['name']='';
        }
		if ($params["buildings"] == "y" AND $params["one_building"] > "1")
			{
				echo "<a href='town.php'>
					<img src='images/icons/enter.gif' alt='$lang_area[enter]' border=0 align=left> $lang_area[enter]<br> $params[name]</a><br>";
			}
		if ($params["buildings"] == "y" AND $params["one_building"] == "1")
			{
				echo "<a href='town.php'>
					<img src='images/icons/enter.gif' alt='$lang_area[enter]' border=0 align=left> $lang_area[enter]<br> $params[name]</a><br>";
			}
		if ($params["explore"] != "")
			{
		echo "<table border=0 cellspacing=0 cellpadding=0>";
		      echo "<form action='travel.php' method='post'>
		      	    <tr>
			    <td align=left>
			    <input type='hidden' name='explorable' value='yes'>
			    <input type='hidden' name='destination' value='$params[explore]'>
			    <button style='background:#000000;border:none;color:#FFFFFF;' type=submit><img src='images/icons/enter.gif' alt='$lang_area[enter]' border=0 align=left>$lang_area[enter]</button>
			    </td>
			    </tr>
			    </form>";
		 echo "</table>";
			}
		if ($params["special_id"] > 0){
			  echo "<a href=\"area.php\">";
			  echo "<img src=\"images/icons/invest.gif\" alt=\"".$lang_trav["invest"]."\" border=\"0\"></a>";
		 }
		if (@$params['rune_gate'] == "yes"){
		echo "<table border=0 cellspacing=0 cellpadding=0>
			<tr><td align=left><b>Gate Travel:</b></td></tr>";

		      $result = mysql_query ("SELECT * FROM phaos_locations WHERE name LIKE 'Rune Gate%' AND id != '$character->location' ORDER BY name ASC");
		      while ($row = mysql_fetch_array($result)) {
		      echo "<form action='travel.php' method='post'>
		        <tr>
			    <td align=left>
			    <input type='hidden' name='destination' value='$row[id]'>
			    <input type='hidden' name='rune_gate' value='yes'>
			    <input type='submit' style='text-align:left;background:#000000;color:#FFFFFF;border:none;' value='$row[name]'>
			    </td>
			    </tr>
			    </form>";
		      }
		 echo "</table>";
		 }
if(@$_COOKIE['_timing']) { echo "time F=".endTiming(); };

		print '
								  </td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
        ';
        ?><center><div id="info" style="overflow:auto;height:180px;width: 420px;z-Index:20;"></div><?php include "trailer.php";?></center><?php
	}

function draw_all($out_loc) {
	// locations of sight from center(25) starting north, going clockwise
	$locs = array(
		23 , 24 ,  2 ,  4 ,  5,
		22 , 21 ,  1 ,  3 ,  6,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -