[水怪RPG複雜化委員會]天空鬥技場興建計劃啟動
發表於 : 2004-01-03 00:04
請問我把fuction_eol.php的這一段刪掉可以阻止EOL
自動刪除NPC嗎??
[php]<?php
// 自爆
$sql = "delete from phpbb_rpg_npc where (rpg_cur_hp = rpg_max_hp and generate_time <= " . (time() - 21600) .
") or generate_time is null or generate_time <= " . (time() - 43200);
$db->sql_query($sql);
?>[/php]
詳細完整版如下
[php]<?php
function GenerateNPC()
{
global $db;
// 自爆
$sql = "delete from phpbb_rpg_npc where (rpg_cur_hp = rpg_max_hp and generate_time <= " . (time() - 21600) .
") or generate_time is null or generate_time <= " . (time() - 43200);
$db->sql_query($sql);
$rpg_lv = array();
$npc_lv = array();
$sql = "select distinct rpg_level from phpbb_rpg_npc where npc_name is null";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$npc_lv[] = $row['rpg_level'] - 5;
}
while ( $row = $db->sql_fetchrow($result) );
}
$sql = "select rpg_level from phpbb_users where rpg_eol_data is not null and right(rpg_eol_data, 6) <> '000086' and rpg_level not in (" .
implode(', ', $npc_lv) . ")";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$rpg_lv[] = $row['rpg_level'] + 5;
}
while ( $row = $db->sql_fetchrow($result) );
}
$npc_count = 10;
$npc_level = 1;
// 普通路人
$sql = "select avg(rpg_level) as eol_level from phpbb_users where rpg_level > 10 and rpg_eol_data is not null";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
$npc_level = $row['eol_level'];
}
$sql = "select count(*) as now_count from phpbb_rpg_npc where (npc_name is null or npc_name = '') and now_x < 24 and now_y > 47";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
if ( $row['now_count'] < $npc_count )
{
for ($i = $row['now_count']; $i < $npc_count; $i++)
{
$rpg_lv[] = rand(($npc_level - 10 > 0 ? $npc_level - 10 : 1), $npc_level + 100);
}
}
}
if ( count($rpg_lv) > 0 )
{
srand((double)microtime()*1000000);
$sql = "select count(*) as map_count from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 and map_x < 24 and map_y > 47";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$map_count = $row['map_count'] - 1;
for ($i = 0; $i < count($rpg_lv); $i++)
{
$now_level = $rpg_lv[$i];
$rpg_max_hp = floor( $now_level * (100 + $now_level));
$rpg_attack = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_defense = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_magic = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_speed = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$sql = "insert into phpbb_rpg_npc (map_id, now_x, now_y, now_icon, now_dir, rpg_level,
rpg_cur_hp, rpg_max_hp, rpg_attack, rpg_defense, rpg_magic, rpg_speed, generate_time)
select map_id, map_x as now_x, map_y as now_y, '" . sprintf("%02d", rand(0, 22)) . "' as now_icon, " .
rand(0, 3) . " as now_dir, $now_level as now_level, $rpg_max_hp as rpg_cur_hp, $rpg_max_hp as rpg_max_hp,
$rpg_attack as rpg_attack, $rpg_defense as rpg_defense, $rpg_magic as rpg_magic, $rpg_speed as rpg_speed, " . time() .
" as generate_time from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 and map_x < 24 and map_y > 47 limit " . rand(0, $map_count) . ", 1";
$db->sql_query($sql);
}
}
// 進階路人
$npc_level = 0;
$sql = "select rpg_level from phpbb_users order by rpg_level desc limit 0, 20";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$npc_level += $row['rpg_level'];
}
while ( $row = $db->sql_fetchrow($result) );
}
$npc_level = floor($npc_level / 20);
$sql = "select count(*) as eol_count from phpbb_users
where rpg_eol_data is not null and right(rpg_eol_data, 6) <> '000086'";
$result = $db->sql_query($sql);
$npc_count = 10;
if ( $row = $db->sql_fetchrow($result) )
{
$npc_count = ($row['eol_count'] * 2 > 10 ? $row['eol_count'] * 2 : 10);
}
$sql = "select count(*) as now_count from phpbb_rpg_npc where (npc_name is null or npc_name = '') and rpg_level >= $npc_level";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
if ( $row['now_count'] < $npc_count )
{
$now_count = $row['now_count'];
srand((double)microtime()*1000000);
$sql = "select count(*) as map_count from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$map_count = $row['map_count'] - 1;
for ($i = $now_count; $i < $npc_count; $i++)
{
$now_level = rand($npc_level, $npc_level + 50);
$rpg_max_hp = floor( $now_level * (100 + $now_level));
$rpg_attack = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_defense = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_magic = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_speed = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$sql = "insert into phpbb_rpg_npc (map_id, now_x, now_y, now_icon, now_dir, rpg_level,
rpg_cur_hp, rpg_max_hp, rpg_attack, rpg_defense, rpg_magic, rpg_speed, generate_time)
select map_id, map_x as now_x, map_y as now_y, '" . sprintf("%02d", rand(0, 22)) . "' as now_icon, " .
rand(0, 3) . " as now_dir, $now_level as now_level, $rpg_max_hp as rpg_cur_hp, $rpg_max_hp as rpg_max_hp,
$rpg_attack as rpg_attack, $rpg_defense as rpg_defense, $rpg_magic as rpg_magic, $rpg_speed as rpg_speed, " . time() .
" as generate_time from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 limit " . rand(0, $map_count) . ", 1";
$db->sql_query($sql);
}
}
}
unset($i);
unset($npc_count);
unset($npc_level);
unset($now_level);
unset($rpg_max_hp);
unset($rpg_attack);
unset($rpg_defense);
unset($rpg_magic);
unset($rpg_speed);
unset($map_count);
unset($now_count);
unset($sql);
unset($row);
unset($result);
unset($rpg_lv);
unset($npc_lv);
}
?>[/php]
問題2: NPC產生的間隔和數量要怎麼調整呢?_?
自動刪除NPC嗎??
[php]<?php
// 自爆
$sql = "delete from phpbb_rpg_npc where (rpg_cur_hp = rpg_max_hp and generate_time <= " . (time() - 21600) .
") or generate_time is null or generate_time <= " . (time() - 43200);
$db->sql_query($sql);
?>[/php]
詳細完整版如下
[php]<?php
function GenerateNPC()
{
global $db;
// 自爆
$sql = "delete from phpbb_rpg_npc where (rpg_cur_hp = rpg_max_hp and generate_time <= " . (time() - 21600) .
") or generate_time is null or generate_time <= " . (time() - 43200);
$db->sql_query($sql);
$rpg_lv = array();
$npc_lv = array();
$sql = "select distinct rpg_level from phpbb_rpg_npc where npc_name is null";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$npc_lv[] = $row['rpg_level'] - 5;
}
while ( $row = $db->sql_fetchrow($result) );
}
$sql = "select rpg_level from phpbb_users where rpg_eol_data is not null and right(rpg_eol_data, 6) <> '000086' and rpg_level not in (" .
implode(', ', $npc_lv) . ")";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$rpg_lv[] = $row['rpg_level'] + 5;
}
while ( $row = $db->sql_fetchrow($result) );
}
$npc_count = 10;
$npc_level = 1;
// 普通路人
$sql = "select avg(rpg_level) as eol_level from phpbb_users where rpg_level > 10 and rpg_eol_data is not null";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
$npc_level = $row['eol_level'];
}
$sql = "select count(*) as now_count from phpbb_rpg_npc where (npc_name is null or npc_name = '') and now_x < 24 and now_y > 47";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
if ( $row['now_count'] < $npc_count )
{
for ($i = $row['now_count']; $i < $npc_count; $i++)
{
$rpg_lv[] = rand(($npc_level - 10 > 0 ? $npc_level - 10 : 1), $npc_level + 100);
}
}
}
if ( count($rpg_lv) > 0 )
{
srand((double)microtime()*1000000);
$sql = "select count(*) as map_count from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 and map_x < 24 and map_y > 47";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$map_count = $row['map_count'] - 1;
for ($i = 0; $i < count($rpg_lv); $i++)
{
$now_level = $rpg_lv[$i];
$rpg_max_hp = floor( $now_level * (100 + $now_level));
$rpg_attack = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_defense = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_magic = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_speed = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$sql = "insert into phpbb_rpg_npc (map_id, now_x, now_y, now_icon, now_dir, rpg_level,
rpg_cur_hp, rpg_max_hp, rpg_attack, rpg_defense, rpg_magic, rpg_speed, generate_time)
select map_id, map_x as now_x, map_y as now_y, '" . sprintf("%02d", rand(0, 22)) . "' as now_icon, " .
rand(0, 3) . " as now_dir, $now_level as now_level, $rpg_max_hp as rpg_cur_hp, $rpg_max_hp as rpg_max_hp,
$rpg_attack as rpg_attack, $rpg_defense as rpg_defense, $rpg_magic as rpg_magic, $rpg_speed as rpg_speed, " . time() .
" as generate_time from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 and map_x < 24 and map_y > 47 limit " . rand(0, $map_count) . ", 1";
$db->sql_query($sql);
}
}
// 進階路人
$npc_level = 0;
$sql = "select rpg_level from phpbb_users order by rpg_level desc limit 0, 20";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
$npc_level += $row['rpg_level'];
}
while ( $row = $db->sql_fetchrow($result) );
}
$npc_level = floor($npc_level / 20);
$sql = "select count(*) as eol_count from phpbb_users
where rpg_eol_data is not null and right(rpg_eol_data, 6) <> '000086'";
$result = $db->sql_query($sql);
$npc_count = 10;
if ( $row = $db->sql_fetchrow($result) )
{
$npc_count = ($row['eol_count'] * 2 > 10 ? $row['eol_count'] * 2 : 10);
}
$sql = "select count(*) as now_count from phpbb_rpg_npc where (npc_name is null or npc_name = '') and rpg_level >= $npc_level";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
if ( $row['now_count'] < $npc_count )
{
$now_count = $row['now_count'];
srand((double)microtime()*1000000);
$sql = "select count(*) as map_count from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$map_count = $row['map_count'] - 1;
for ($i = $now_count; $i < $npc_count; $i++)
{
$now_level = rand($npc_level, $npc_level + 50);
$rpg_max_hp = floor( $now_level * (100 + $now_level));
$rpg_attack = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_defense = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_magic = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$rpg_speed = floor($now_level * rand((floor($now_level / 10) + 1) * 10, (floor($now_level / 10) * 2 + 5) * 10) / 10);
$sql = "insert into phpbb_rpg_npc (map_id, now_x, now_y, now_icon, now_dir, rpg_level,
rpg_cur_hp, rpg_max_hp, rpg_attack, rpg_defense, rpg_magic, rpg_speed, generate_time)
select map_id, map_x as now_x, map_y as now_y, '" . sprintf("%02d", rand(0, 22)) . "' as now_icon, " .
rand(0, 3) . " as now_dir, $now_level as now_level, $rpg_max_hp as rpg_cur_hp, $rpg_max_hp as rpg_max_hp,
$rpg_attack as rpg_attack, $rpg_defense as rpg_defense, $rpg_magic as rpg_magic, $rpg_speed as rpg_speed, " . time() .
" as generate_time from phpbb_rpg_eol where map_id = 0 and can_not_pass = 0 limit " . rand(0, $map_count) . ", 1";
$db->sql_query($sql);
}
}
}
unset($i);
unset($npc_count);
unset($npc_level);
unset($now_level);
unset($rpg_max_hp);
unset($rpg_attack);
unset($rpg_defense);
unset($rpg_magic);
unset($rpg_speed);
unset($map_count);
unset($now_count);
unset($sql);
unset($row);
unset($result);
unset($rpg_lv);
unset($npc_lv);
}
?>[/php]
問題2: NPC產生的間隔和數量要怎麼調整呢?_?