在functioc_post.php中:
代碼: 選擇全部
include($phpbb_root_path . 'rpg/function_rpg.'.$phpEx);
這一行不要加入。
接著在下面加入經驗值的部份
尋找:
代碼: 選擇全部
if ($mode != 'poll_delete')
{
// 水怪 RPG
if ( $mode == "newtopic" )
{
$reward_sql = ", rpg_cur_hp = rpg_cur_hp - 3, rpg_cur_mp = rpg_cur_mp - 3, rpg_cur_exp = rpg_cur_exp + 3"; // 發表主題 HP - 3 , MP - 3 , 經驗值 + 3
}
if ( $mode == "reply" )
{
$reward_sql = ", rpg_cur_hp = rpg_cur_hp - 2, rpg_cur_mp = rpg_cur_mp - 2, rpg_cur_exp = rpg_cur_exp + 2"; // 回覆文章 HP - 2 , MP - 2 , 經驗值 + 2
}
$sql = "UPDATE " . USERS_TABLE . "
SET user_posts = user_posts $sign $reward_sql
WHERE user_id = $user_id";
if (!$db->sql_query($sql, END_TRANSACTION))
{
message_die(GENERAL_ERROR, 'Error in posting' . $sql, '', __LINE__, __FILE__, $sql);
}
[color=#ff002a]LevelUp_Post($user_id);[/color]
}
return;
}
請注意紅色部分,這部份是呼叫LevelUp參數,我已經有修改過,我改成LevelUp_Post,這個參數可隨意改但是要和下面的部份一樣。在上述CODE之後加上:
代碼: 選擇全部
//以下判斷升級
[color=#ff00ff]function UpdateRPGProperties_Post($uid)[/color]
{
global $db;
$attplus = 1.0;
$defplus = 1.0;
$magplus = 1.0;
$spdplus = 1.0;
$hp_plus = 0.0;
$mp_plus = 0.0;
$sql = 'SELECT MAX(position_order) as basetop FROM phpbb_rpg_position WHERE position_class = 0';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$sql = 'SELECT * FROM phpbb_rpg_position WHERE position_class = 0 AND position_order = ' . $row['basetop'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
// 取得基礎職業的標準值\r
$base_att = $row['attack_property'];
$base_def = $row['defense_property'];
$base_mag = $row['magic_property'];
$base_spd = $row['speed_property'];
$base_hpp = $row['hp_property'];
$base_mpp = $row['magic_property'];
}
$sql = 'SELECT p.* FROM phpbb_rpg_position p, phpbb_rpg_medals m WHERE p.position_class = m.position_class
AND p.position_order = m.position_order AND m.last_class = 1 AND m.position_class <> 0 AND m.user_id = ' . $uid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得專業職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$i = 1;
$newposition = '';
do
{
if ($i == 1)
{
$attplus = $row['attack_property'];
$defplus = $row['defense_property'];
$magplus = $row['magic_property'];
$spdplus = $row['speed_property'];
$hp_plus = $row['hp_property'];
$mp_plus = $row['magic_property'];
$newposition = $row['position_name'];
}
else
{
$attplus += $row['attack_property'] - $base_att;
$defplus += $row['defense_property'] - $base_def;
$magplus += $row['magic_property'] - $base_mag;
$spdplus += $row['speed_property'] - $base_spd;
$hp_plus += $row['hp_property'] - $base_hpp;
$mp_plus += $row['magic_property'] - $base_mpp;
$newposition .= '<br />' . $row['position_name'];
}
$i++;
}
while ( $row = $db->sql_fetchrow($result) );
if(strlen($newposition) > 200)
{
$newposition = substr($newposition, 0, 200);
}
}
else
{
// 只有基礎職業
$sql = 'SELECT p.* FROM phpbb_rpg_position p, phpbb_rpg_medals m WHERE p.position_class = 0 AND m.last_class = 1
AND m.position_class = 0 AND p.position_order = m.position_order AND m.user_id = ' . $uid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$attplus = $row['attack_property'];
$defplus = $row['defense_property'];
$magplus = $row['magic_property'];
$spdplus = $row['speed_property'];
$hp_plus = $row['hp_property'];
$mp_plus = $row['magic_property'];
$newposition = $row['position_name'];
}
}
}
$sql = 'SELECT IFNULL(SUM(i.attack_property), 0) as attack_x, IFNULL(SUM(i.defense_property), 0) as defense_x,
IFNULL(SUM(i.magic_property), 0) as magic_x, IFNULL(SUM(i.speed_property), 0) as speed_x,
IFNULL(SUM(i.hp_property), 0) as hp_x, IFNULL(SUM(i.mp_property), 0) as mp_x FROM phpbb_rpg_items i,
phpbb_rpg_owns o WHERE i.item_id = o.item_id AND o.user_id = ' . $uid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得攜帶物品屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$attplus += $row['attack_x'];
$defplus += $row['defense_x'];
$magplus += $row['magic_x'];
$spdplus += $row['speed_x'];
$hp_plus += $row['hp_x'];
$mp_plus += $row['mp_x'];
}
$sql = "update phpbb_users set rpg_max_hp = floor(rpg_level * (100 + $hp_plus + rpg_level)),
rpg_max_mp = floor(rpg_level * (80 + rpg_level) + rpg_level * $mp_plus),
rpg_attack = round(rpg_level * $attplus), rpg_defense = round(rpg_level * $defplus),
rpg_magic = round(rpg_level * $magplus), rpg_speed = round(rpg_level * $spdplus),
rpg_medals = '$newposition' where user_id = $uid";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法更新 RPG 屬性!!', '', __LINE__, __FILE__, $sql);
}
}
[color=#ff002a]function LevelUp_Post($uid, $full_mh = false)[/color]
{
global $db;
$sql = "select rpg_level, rpg_cur_exp, rpg_max_exp from phpbb_users where user_id = $uid";
$result = $db->sql_query($sql);
if ( $row2 = $db->sql_fetchrow($result) )
{
if ( $row2['rpg_cur_exp'] >= $row2['rpg_max_exp'] )
{
if ( $row2['rpg_level'] < 250 )
{
$sql = "update phpbb_users set rpg_level = rpg_level + 1, rpg_cur_exp = rpg_cur_exp - rpg_max_exp, rpg_cur_hp = rpg_max_hp, rpg_cur_mp = rpg_max_mp,
rpg_max_exp = FLOOR( POW( 10, POW( rpg_level, (1/3) ) ) ) - FLOOR( POW( 10, POW( rpg_level - 1, (1/3) ) ) )
where user_id = $uid";
$db->sql_query($sql);
[color=#ff00ff]UpdateRPGProperties_Post($uid);[/color]
}
if ( $full_mh )
{
$sql = "update phpbb_users set rpg_cur_hp = rpg_max_hp, rpg_cur_mp = rpg_max_mp where user_id = $uid";
$db->sql_query($sql);
}
}
}
unset($sql);
unset($row2);
unset($result);
}
//判斷升級結束
存檔,functions_post.php修改完畢。這樣應該OK了,至少我目前還沒發現問題。
請注意以上顏色對應部份,那是相關的function呼叫,名字必須一樣。
下面這一段CODE我是從function_rpg.php最後兩段抄過來的,因為include($phpbb_root_path . 'rpg/function_rpg.'.$phpEx);這一段就是呼叫function_rpg.php裡面那兩段關於升級判斷的參數,加上上面那段敘述會無法進入水怪RPG頁面,不加入的話PO文無法升級(只要PO文一律出現錯誤訊息)。所以我只好土法煉鋼,把兩段敘述抄過來並且更改參數名稱。這是最不得已的方法,因為等於有重複的敘述,我不知道對於論壇速度影響有多大。(小弟不會寫程式,只會改)
如果有人有更佳解決方案,一起討論唷~