Exemplo n.º 1
0
function auto_ground()
{
    if (rand(0, 9) == 0 || defined('DEBUG') && DEBUG) {
        fix_ground();
    }
    $nlocations = fetch_value("select count(*) from phaos_locations", __FILE__, __LINE__, __FUNCTION__);
    //CAVEAT: this includes items stored in shops
    $nground = fetch_value("select count(DISTINCT(location)) from phaos_ground where number>0 and location>'0'", __FILE__, __LINE__, __FUNCTION__);
    $proportion = 25;
    $missingitems = (int) ($nlocations / $proportion) - $nground;
    defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = "Ground: missing {$missingitems} items ({$nground}/{$nlocations}).";
    if ($missingitems > 0) {
        $add = $missingitems < 12 ? $missingitems : 12;
        while ($add-- > 0) {
            $location = random_location("item_drop");
            $item_cluster_limit = 4;
            $items_here = fetch_items_for_location($location);
            if (count($items_here) >= $item_cluster_limit) {
                continue;
            }
            $minvalue = 1;
            $maxvalue = powrand(2.75, 0.83, 5) * powrand(2.75, 0.5, 8);
            $item = random_item($minvalue, $maxvalue);
            if ($item) {
                item_drop($location, $item);
            }
        }
    }
}
Exemplo n.º 2
0
	<td align="center">
		<a href="market.php"><?php 
echo $lang_area["trade"];
?>
</a>
	</td>
</tr>

<?php 
//------------- stuff on the ground -------------
auto_ground();
//tick
//$fchance= $character->finding();
$fchance = 100;
//always find at same place, so you can pick up items you dropped
$ground_items = fetch_items_for_location($char_loc, $fchance);
if (count($ground_items) > 0) {
    ?>
<tr><td><center><hr width="50%"><table><?php 
    ?>
<tr><th colspan="4"><?php 
    echo $lang_town["u_find"];
    ?>
</th></tr><?php 
    foreach ($ground_items as $item) {
        $info = fetch_item_additional_info($item, $character);
        $info['number'] = $info['number'] > 1 ? $info['number'] . " " : "";
        ?>
<tr><?php 
        ?>
<td><?php 
Exemplo n.º 3
0
?>
</b>
</td>
<td align=center width="50%">
<br>
<br>
<b><?php 
echo $lang_shop["armor"];
?>
</b>
</td>
</tr>
<tr>
<td align=center valign=top width="50%">
<?php 
$items = fetch_items_for_location($shop_basics['item_location_id']);
if (is_array($items) && count($items) > 0) {
    foreach ($items as $item) {
        if ($item['type'] == 'weapon') {
            $info = fetch_item_additional_info($item, $character);
            if ($info) {
                print "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">\n                \t<hr><img src=\"{$info['image_path']}\"><br>";
                print "<input type=\"hidden\" name=\"buy_id[]\" value=\"{$item['id']}\">\n                \t<input type=\"hidden\" name=\"buy_type[]\" value=\"{$item['type']}\">\n                \t<input type=\"hidden\" name=\"buy_number[]\" value=\"1\">\n                \t<input type=\"hidden\" name=\"shop_id\" value=\"{$shop_id}\">\n                \t  {$info['description']}<br>\n                \t  " . $lang_shop["dam"] . " {$info['min_damage']}-{$info['max_damage']}<br>\n                \t  <font color={$info['skill_need']}>" . $lang_shop["req"] . " {$info['skill_req']} " . $lang_att . "</font><br>\n                \t  {$info['buy_price']} " . $lang_shop["gp"] . "<br>\n                \t<input type=submit value=" . $lang_shop["purc"] . ">";
                print "</form>";
            }
        }
    }
} else {
    ?>
<h2><?php 
    echo $lang_shop["sold_out"];
Exemplo n.º 4
0
function data_collect()
{
    global $character;
    global $params;
    $fchance = $character->finding();
    if (@$_COOKIE['_timing']) {
        echo "time begin DC=" . endTiming();
    }
    $result = mysql_query("SELECT * FROM phaos_locations WHERE id = '" . $character->location . "'");
    if ($row = mysql_fetch_array($result)) {
        $out_loc[25]['id'] = $character->location;
        $character_locname = $row['name'];
        $markers = array();
        $ground_items = fetch_items_for_location($character->location, $fchance);
        if (count($ground_items) > 0) {
            $markers[] = 'icons/gold.gif';
        }
        $out_loc[25]['html'] = draw_square(false, $row["image_path"], '', $character->image, $row["name"], array('text' => ''), $markers, 25);
        $params['name'] = $row['name'];
        if (strstr($row['name'], "Rune Gate")) {
            $params['rune_gate'] = "yes";
        }
        $params['special_id'] = $row["special"];
        $params['buildings'] = $row['buildings'];
        $params['explore'] = $row['explore'];
        $build_check = mysql_query("SELECT type FROM phaos_buildings WHERE location = '" . $character->location . "'");
        $numrows = mysql_num_rows($build_check);
        $params['one_building'] = $numrows;
        if ($bui = mysql_fetch_array($build_check)) {
            $params['building_type'] = $bui['type'];
        } else {
            $params['building_type'] = "";
        }
        $out_loc[1]['id'] = $row["above"];
        $out_loc[1]['link'] = true;
        $out_loc[1]['block'] = 0;
        $out_loc[3]['id'] = $row["above_right"];
        $out_loc[3]['link'] = true;
        $out_loc[3]['block'] = 0;
        $out_loc[7]['id'] = $row["rightside"];
        $out_loc[7]['link'] = true;
        $out_loc[7]['block'] = 0;
        $out_loc[9]['id'] = $row["below_right"];
        $out_loc[9]['link'] = true;
        $out_loc[9]['block'] = 0;
        $out_loc[13]['id'] = $row["below"];
        $out_loc[13]['link'] = true;
        $out_loc[13]['block'] = 0;
        $out_loc[15]['id'] = $row["below_left"];
        $out_loc[15]['link'] = true;
        $out_loc[15]['block'] = 0;
        $out_loc[19]['id'] = $row["leftside"];
        $out_loc[19]['link'] = true;
        $out_loc[19]['block'] = 0;
        $out_loc[21]['id'] = $row["above_left"];
        $out_loc[21]['link'] = true;
        $out_loc[21]['block'] = 0;
        // We try to collect the data from mysql in one go to speed up things
        $set = "('" . $out_loc[3]['id'] . "','" . $out_loc[9]['id'] . "','" . $out_loc[15]['id'] . "','" . $out_loc[21]['id'] . "')";
        $data_locations = fetch_all("SELECT * FROM phaos_locations WHERE id IN " . $set);
        foreach ($data_locations as $data_location) {
            $cache_row[$data_location['id']] = $data_location;
        }
        // We do some of these twice because they might not be accessible from one angle
        if ($out_loc[3]['id']) {
            //$result = mysql_query ("SELECT * FROM phaos_locations WHERE id = ".$out_loc[3]['id']);
            //$row = mysql_fetch_array($result);
            $row = @$cache_row[$out_loc[3]['id']];
            $out_loc[2]['id'] = $row["above_left"];
            $out_loc[2]['block'] = 0;
            $out_loc[4]['id'] = $row["above"];
            $out_loc[4]['block'] = 0;
            $out_loc[5]['id'] = $row["above_right"];
            $out_loc[5]['block'] = 0;
            $out_loc[6]['id'] = $row["rightside"];
            $out_loc[6]['block'] = 0;
            $out_loc[8]['id'] = $row["below_right"];
            $out_loc[8]['block'] = 0;
        }
        if ($out_loc[9]['id']) {
            //$result = mysql_query ("SELECT * FROM phaos_locations WHERE id = ".$out_loc[9]['id']);
            //$row = mysql_fetch_array($result);
            $row = @$cache_row[$out_loc[9]['id']];
            $out_loc[8]['id'] = $row["above_right"];
            $out_loc[8]['block'] = 0;
            $out_loc[10]['id'] = $row["rightside"];
            $out_loc[10]['block'] = 0;
            $out_loc[11]['id'] = $row["below_right"];
            $out_loc[11]['block'] = 0;
            $out_loc[12]['id'] = $row["below"];
            $out_loc[12]['block'] = 0;
            $out_loc[14]['id'] = $row["below_left"];
            $out_loc[14]['block'] = 0;
        }
        if ($out_loc[15]['id']) {
            //$result = mysql_query ("SELECT * FROM phaos_locations WHERE id = ".$out_loc[15]['id']);
            //$row = mysql_fetch_array($result);
            $row = @$cache_row[$out_loc[15]['id']];
            $out_loc[14]['id'] = $row["below_right"];
            $out_loc[14]['block'] = 0;
            $out_loc[16]['id'] = $row["below"];
            $out_loc[16]['block'] = 0;
            $out_loc[17]['id'] = $row["below_left"];
            $out_loc[17]['block'] = 0;
            $out_loc[18]['id'] = $row["leftside"];
            $out_loc[18]['block'] = 0;
            $out_loc[20]['id'] = $row["above_left"];
            $out_loc[20]['block'] = 0;
        }
        if ($out_loc[21]['id']) {
            //$result = mysql_query ("SELECT * FROM phaos_locations WHERE id = ".$out_loc[21]['id']);
            //$row = mysql_fetch_array($result);
            $row = @$cache_row[$out_loc[21]['id']];
            $out_loc[20]['id'] = $row["below_left"];
            $out_loc[20]['block'] = 0;
            $out_loc[22]['id'] = $row["leftside"];
            $out_loc[22]['block'] = 0;
            $out_loc[23]['id'] = $row["above_left"];
            $out_loc[23]['block'] = 0;
            $out_loc[24]['id'] = $row["above"];
            $out_loc[24]['block'] = 0;
            $out_loc[2]['id'] = $row["above_right"];
            $out_loc[2]['block'] = 0;
        }
    }
    // some views might be blocked
    if ($out_loc[1]['block']) {
        $out_loc[24]['block'] = 1;
        $out_loc[2]['block'] = 1;
        $out_loc[4]['block'] = 1;
    }
    if ($out_loc[3]['block']) {
        $out_loc[4]['block'] = 1;
        $out_loc[5]['block'] = 1;
        $out_loc[6]['block'] = 1;
    }
    if ($out_loc[7]['block']) {
        $out_loc[6]['block'] = 1;
        $out_loc[8]['block'] = 1;
        $out_loc[10]['block'] = 1;
    }
    if ($out_loc[9]['block']) {
        $out_loc[10]['block'] = 1;
        $out_loc[11]['block'] = 1;
        $out_loc[12]['block'] = 1;
    }
    if ($out_loc[13]['block']) {
        $out_loc[12]['block'] = 1;
        $out_loc[14]['block'] = 1;
        $out_loc[16]['block'] = 1;
    }
    if ($out_loc[15]['block']) {
        $out_loc[16]['block'] = 1;
        $out_loc[17]['block'] = 1;
        $out_loc[18]['block'] = 1;
    }
    if ($out_loc[19]['block']) {
        $out_loc[18]['block'] = 1;
        $out_loc[20]['block'] = 1;
        $out_loc[22]['block'] = 1;
    }
    if ($out_loc[21]['block']) {
        $out_loc[22]['block'] = 1;
        $out_loc[23]['block'] = 1;
        $out_loc[24]['block'] = 1;
    }
    $marker_loc = array();
    $close_locs = array(1, 3, 7, 9, 13, 15, 19, 21, 25);
    $locs = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24);
    foreach ($locs as $i) {
        if (@$out_loc[$i]['html'] == '') {
            if (@$out_loc[$i]['block'] == 0 and @$out_loc[$i]['id'] != 0) {
                $mobs = "";
                $mobs = getmobs($out_loc[$i]['id']);
                $result = mysql_query('SELECT name,image_path,pass FROM phaos_locations WHERE id= \'' . $out_loc[$i]['id'] . '\'');
                $row = mysql_fetch_assoc($result);
                $markers = array();
                if (in_array($i, $close_locs) || $character->finding() >= 100) {
                    $ground_items = fetch_items_for_location($out_loc[$i]['id'], $fchance);
                    if (count($ground_items) > 0) {
                        $markers[] = 'icons/gold.gif';
                    }
                }
                if ($row['pass'] == 'n') {
                    $out_loc[$i]['html'] = draw_square(false, $row['image_path'], $out_loc[$i]['id'], '', $row['name'], $mobs, $markers, $i);
                } else {
                    //                    $out_loc[$i]['html'] = draw_square(false, $row['image_path'], $out_loc[$i]['id'],'',$row['name'],$mobs, $markers, $i);
                    $out_loc[$i]['html'] = draw_square(@$out_loc[$i]['link'], $row['image_path'], $out_loc[$i]['id'], '', $row['name'], $mobs, $markers, $i);
                }
            } else {
                //HACK: is a hack because it will break if a location is inside but is not named like %Dungeon%
                if (stristr($character_locname, 'Dungeon') !== false) {
                    $out_loc[$i]['html'] = draw_square(false, "images/land/195.png", 0, '', "Dungeon");
                } else {
                    $out_loc[$i]['html'] = draw_square(false, "images/land/49.png", 0, '', "Water");
                }
            }
        }
    }
    if (@$_COOKIE['_timing']) {
        echo "<br>time end DC=" . endTiming();
    }
    return array($out_loc, $marker_loc);
}