[水怪RPG複雜化委員會]天空鬥技場興建計劃啟動
版主: 版主管理群
[水怪RPG複雜化委員會]天空鬥技場興建計劃啟動
請問我把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產生的間隔和數量要怎麼調整呢?_?
最後由 ilove1291 於 2004-02-05 09:19 編輯,總共編輯了 10 次。
找到 :數量要怎麼調整呢?_?
代碼: 選擇全部
$npc_count = [color=red]10[/color];
另外 :
代碼: 選擇全部
$npc_level = [color=blue]1[/color];
在來 :
代碼: 選擇全部
$sql = "select avg(rpg_level) as eol_level from phpbb_users where rpg_level > [color=red]10[/color]
善用 搜尋 可以解決您 90% 的問題
頭腦清晰,選擇正確。 (╯▔︹▔)╯~╘═╛
頭腦清晰,選擇正確。 (╯▔︹▔)╯~╘═╛
-
- 竹貓忠實會員
- 文章: 1086
- 註冊時間: 2003-10-28 14:50
-
- 竹貓忠實會員
- 文章: 1086
- 註冊時間: 2003-10-28 14:50
-
- 竹貓忠實會員
- 文章: 1086
- 註冊時間: 2003-10-28 14:50
-
- 竹貓忠實會員
- 文章: 1086
- 註冊時間: 2003-10-28 14:50
阿呆aiken 寫:吉川先生~~
你的論壇在哪啊~~
找不到連結~想要參考看看咧~~
給個連結吧~~
他的簽名檔圖片上按下滑鼠右鍵\r
選擇內容
你就會知道他從那邊來的了
http://nt66.com.tw/LineII/
再也不當爛好人...
好人是小白轉型成大白的墊腳石...
好人是小白轉型成大白的墊腳石...