[分享]一次接多個任務
發表於 : 2007-02-13 6:53 pm
因為有些部分會改比較多,所以改比較多的部份將直接列出整個函式,並以紅色標示修改過的地方
開啟檔案 wog/class/wog_act_chara.php 寫:尋找
- 代碼: 選擇全部
setcookie("wog_cookie_mission_id",$m_item["m_id"]);
setcookie("wog_cookie_mission_area",$m_item["m_area_id"]);
刪除
開啟檔案 wog/class/wog_fight_select.php 寫:
- 代碼: 選擇全部
[color=red] function fire($user_id,$mission=array(),$mission_id=array())[/color]
{
global $DB_site,$_POST,$wogclass,$wog_arry,$wog_event_class,$lang;
$mission_chk=1;
[color=red]$mission_str=" and m_mission in (".implode(",",$mission_id).",0)";[/color]
$datecut=time()-$wog_arry["f_time"];
$sql="select a.p_name,a.p_at,a.p_df,a.p_mat,a.p_mdf,a.p_s,a.p_agl,a.p_hp,a.p_hpmax,a.p_luck
,a.p_sat_name,a.p_lv,a.p_exp,a.p_nextexp,a.p_life,a.p_smart,a.ch_id,a.a_id,a.p_ch_s_id,a.p_key,a.p_st
,f.d_g_hp,f.d_name,a.d_item_id,a.i_img,a.p_img_set,a.p_img_url,a.p_au,a.t_id,g.d_s,a.p_bag,a.p_attempts
from wog_player a left join wog_df f on a.d_item_id=f.d_id
left join wog_df g on a.a_id=g.d_id
where a.p_id=".$user_id." and a.p_act_time < $datecut and a.p_lock=0
";
if($p=$DB_site->query_first($sql))//check act_timt benig
{
if($p[p_hp]==0)
{
alertWindowMsg($lang['wog_fight_no_hp']);
}
if($p[p_key]!="" && $wog_arry["event_ans"])
{
$wog_event_class->event_start($user_id,$p["p_attempts"]);
}
if(rand(1,$wog_arry["event_ans_max"])==1 && $wog_arry["event_ans"])
{
$wog_event_class->event_creat($user_id);
}
if(eregi("[^0-9]",$_POST["act"]))
{
alertWindowMsg($lang['wog_fight_select_area']);
}
[color=red] if( count($mission_id) <= 0)
{
$mission_str="and m_mission=0";
$mission_chk=0;
}[/color] $sql="select * from wog_monster where m_place in (".$_POST["act"].",0) and m_meet <= ".rand(0,100)." ".$mission_str." ORDER BY RAND() LIMIT 1 ";
$m=$DB_site->query_first($sql);
if($m)//m date check start
{
echo charset();
echo "<script language=JavaScript >\n";
if($m["m_npc"]==1)
{
if($mission_chk==1 && [color=red]$mission_id[$m['m_id']][/color])
{
echo "parent.fire_date('$p[p_at]','$p[p_df]','$p[p_mat]','$p[p_mdf]','$p[p_hp]','$p[p_hpmax]','$p[p_s]',$p[p_img_set],'$p[i_img]','?????','?????','?????','?????','?????','?????','$m[m_s]','$m[m_name]','$m[m_img]',0);\n";
$sql="update wog_mission_book set m_kill_num=m_kill_num-1 where p_id=".$user_id." and m_id=".[color=red]$mission_id[$m['m_id']][/color];
$DB_site->query($sql);
echo "parent.setup_mname('".$m["m_name"]."');\n";
$m["m_npc_message"]=str_replace("\r\n","&n",$m["m_npc_message"]);
echo "parent.npc_message('".$m["m_npc_message"]."',".([color=red]$mission[$m['m_mission']]['m_kill_num'][/color]-1).",".[color=red]$mission[$m['m_mission']]['m_need_num'][/color].");\n";
}
}else
{
if($p["t_id"]>0)
{
$datecut=time()-($wog_arry["t_time"]*60);
$sql="select a.p_name,a.p_at,a.p_df,a.p_mat,a.p_mdf,a.p_s,a.p_agl,a.p_hp,a.p_hpmax
,a.p_sat_name,a.p_lv,a.i_img,a.p_ch_s_id,a.p_img_set,a.p_img_url
from wog_player a
where a.p_support=".$user_id." and a.t_id=".$p["t_id"]." and a.p_act_time > $datecut and a.p_place=".$_POST["act"]." and a.p_lock=0 ORDER BY RAND() LIMIT 1
";
$p_support=$DB_site->query_first($sql);
if(!$p_support)
{
$p_support=NULL;
}else
{
if($p_support[p_img_set]==1)
{
$p_support[i_img]=$p_support[p_img_url];
}
$p_support["p_at"]=$p_support["p_at"]*0.9;
$p_support["p_mat"]=$p_support["p_mat"]*0.9;
echo "parent.p_support_name='$p_support[p_name]';";
echo "parent.p_support_img='$p_support[i_img]';";
}
$sql="select count(a.p_id) as members from wog_player a
where a.p_id<>".$user_id." and a.t_id=".$p["t_id"]." and a.p_act_time > $datecut and a.p_place=".$_POST["act"]." and a.p_lock=0";
$my_member=$DB_site->query_first($sql);
}else
{
$p_support=NULL;
}
$sql="select pe_id,pe_name,pe_at,pe_mt,pe_fu,pe_def,pe_hu,pe_type,pe_age,pe_he,pe_fi,pe_b_old,pe_mimg from wog_pet where pe_p_id=".$user_id." and pe_st=0";
$pet=$DB_site->query_first($sql);
if(!$pet)
{
$pet=NULL;
}else
{
echo "parent.pet_pname='$pet[pe_name]';";
echo "parent.pet_img='$pet[pe_mimg]';";
}
if($p[p_img_set]==1)
{
$p[i_img]=$p[p_img_url];
}
echo "parent.m_name='$m[m_name]';";
if(($p[p_at]*2)<$m[m_at] && ($p[p_mt]*2)<$m[m_mat])
{
echo "parent.fire_date('$p[p_at]','$p[p_df]','$p[p_mat]','$p[p_mdf]','$p[p_hp]','$p[p_hpmax]','$p[p_s]',$p[p_img_set],'$p[i_img]','?????','?????','?????','?????','$m[m_hp]','$m[m_hp]','$m[m_s]','$m[m_name]','$m[m_img]',0);\n";
}else
{
echo "parent.fire_date('$p[p_at]','$p[p_df]','$p[p_mat]','$p[p_mdf]','$p[p_hp]','$p[p_hpmax]','$p[p_s]',$p[p_img_set],'$p[i_img]','$m[m_at]','$m[m_df]','$m[m_mat]','$m[m_mdf]','$m[m_hp]','$m[m_hp]','$m[m_s]','$m[m_name]','$m[m_img]',0);\n";
}
echo "fightrow = new Array("戰鬥開始"";
$wogclass->p_place=$_POST["act"];
[color=red]$wogclass->fight_count($user_id,$p,$m,0,$pet,$p_support,$my_member,$datecut);
if($wogclass->win > $wogclass->lost)[/color]
{
// {
if($p[d_name]=="捕捉器" && !$pet )
{
if(rand(1,15)==1)
{
echo ","parent.pet_break()"";
echo ","parent.d_item_name=''"";
$DB_site->query("update wog_player set d_item_id=0 where p_id=".$user_id);
}
if(rand(1,25)==1)
{
$sql="select count(pe_id) as num from wog_pet where pe_p_id=".$user_id." and pe_st in (0,2) ";
$pet=$DB_site->query_first($sql);
if($pet["num"]<3)
{
$pet=$wog_event_class->pet_stats();
$sql="insert into wog_pet(pe_p_id,pe_name,pe_at,pe_mt,pe_fu,pe_def,pe_hu,pe_type,pe_age,pe_he,pe_fi,pe_dateline,pe_mname,pe_m_id,pe_b_dateline,pe_mimg,pe_st)";
$sql.="values(".$user_id.",'".$m[m_name]."',".$pet[pe_at].",".$pet[pe_mt].",80,".$pet[pe_def].",0,".$pet[pe_type].",1,0,1,".(time()-20).",'".$m[m_name]."',".$m[m_id].",".time().",'".$m[m_img]."',2)";
$DB_site->query($sql);
$DB_site->query("update wog_player set d_item_id=0 where p_id=".$user_id);
echo ","parent.pet_get('".$m[m_name]."')"";
echo ","parent.d_item_name=''"";
}
}
}
if($mission_chk==1 && [color=red]$mission_id[$m['m_id']][/color])
{
$sql="update wog_mission_book set m_kill_num=m_kill_num-1 where p_id=".$user_id." and m_id=".[color=red]$mission_id[$m['m_id']][/color];
$DB_site->query($sql);
echo ","parent.mission_achieve(".([color=red]$mission[$mission_id[$m['m_id']]]['m_kill_num'][/color]-1).",".[color=red]$mission[$mission_id[$m['m_id']]]['m_need_num'][/color].")"";
}
[color=red]if($m['m_mission']==0 || ($m['m_mission']!=0 && $m['m_id']==$mission[$m['m_mission']]['m_monster_id']))[/color]
{
if($m[d_id] && rand(1,$m[m_topr])<=1 )//判斷是否撿到物品
{
$wog_event_class->get_item($user_id,$m[d_id],$p[p_st],$p[p_bag]);
}
}
}else
{
if($pet!=NULL)
{
$DB_site->query("update wog_pet set pe_he=pe_he-".rand(0,1)." where pe_id=".$pet["pe_id"]);
}
}
echo ");\n";
echo "parent.set_fight(fightrow);\n";
}
}else
{
alertWindowMsg($lang['wog_fight_no_date']);
}//m date check end
}else
{
alertWindowMsg($wog_arry["f_time"].$lang['wog_fight_cant_fight1']);
}//check act_time end
unset($m);
unset($p);
unset($pet);
echo "parent.cd(".$wog_arry["f_time"].")\n";
echo "parent.p_sat_name='".$_POST["sat_name"]."'\n";
}
開啟檔案 wog/class/wog_act_mission.php 寫:
- 代碼: 選擇全部
function mission_get($user_id)
{
global $DB_site,$_POST,$lang[color=red],$wog_arry[/color];
if(empty($_POST["m_id"])){alertWindowMsg($lang['wog_act_mission_error1']);}
$sql="select p_lv,p_sex,ch_id from wog_player where p_id=".$user_id."";
$p=$DB_site->query_first($sql);
if(!$p)
{
alertWindowMsg($lang['wog_act_relogin']);
}
[color=red] $m_item=$DB_site->query_first("select count(m_id) as num from wog_mission_book where p_id=".$user_id." and m_status<2");
if($m_item['num'] >= $wog_arry['mission_get_num'])
{
alertWindowMsg($lang['wog_act_mission_error6']);
}[/color]
$m_item=$DB_site->query_first("select a.m_id from wog_mission_main a ,wog_mission_book b where b.p_id=".$user_id." and a.m_id=".$_POST["m_id"]." and a.m_not_id=b.m_id ");
if($m_item){alertWindowMsg($lang['wog_act_mission_error3']);}
$m_item=$DB_site->query_first("select a.m_id,a.m_area_id,a.m_kill_num from wog_mission_main a LEFT JOIN wog_mission_book b ON b.p_id=".$user_id." and a.m_id<>b.m_id
where a.m_id=".$_POST["m_id"]." and (a.m_job=".$p["ch_id"]." or a.m_job=99) and a.m_lv <= ".$p["p_lv"]." and (a.m_sex=".$p["p_sex"]." or a.m_sex=3)");
if(!$m_item){alertWindowMsg($lang['wog_act_mission_error3']);}
$sql="insert wog_mission_book (m_id,p_id,m_status,m_kill_num)values(".$_POST["m_id"].",".$user_id.",0,".$m_item["m_kill_num"].")";
[color=red] $DB_site->query($sql);
unset($m_item);[/color]
showscript("parent.job_end(20)");
unset($temp_s);
}
function mission_book($user_id)
{
global $DB_site,$_POST,$lang;
[color=red] $m_id=array();
$result=$DB_site->query("select a.m_body,a.m_subject,a.m_name,a.m_id from wog_mission_main a,wog_mission_book b where b.p_id=".$user_id." and b.m_status<2 and b.m_id=a.m_id");
while($m_item=$DB_site->fetch_array($result))
{
$m_item['m_body']=str_replace("\r\n","&n",$m_item['m_body']);
$temp_s.=';'.$m_item["m_subject"].",".$m_item["m_name"].",".$m_item["m_body"];
$m_id[]=$m_item['m_id'];
}
if(!$temp_s){alertWindowMsg($lang['wog_act_mission_error5']);}
$temp_s=substr($temp_s,1,strlen($temp_s));
$m_id=implode(',',$m_id);
showscript("parent.mission_book('$temp_s','".$m_id."')");[/color]
unset($m_item);
unset($temp_s);
}
開啟檔案wog/wog.js 寫:
- 代碼: 選擇全部
function mission_book(s,m_id)
{
message_cls();
var f=parent.wog_view.document;
[color=red] m_id=m_id.split(",");
var s1=s.split(";");
for(var i=0;i<m_id.length;i++)
{
f.write('<form action="wog_act.php" method="post" target="mission" name=f1>');
f.write(temp_table1);
var s2=s1[i].split(",");
f.write('<tr><td >'+s2[0]+'</td></tr>');
f.write('<tr><td >委託者:'+s2[1]+'</td></tr>');
var temp=s2[2];
while(temp.indexOf("&n") > 0)
{
temp=temp.replace("&n","<br>");
}
f.write('<tr><td class=b1>'+temp+'</td></tr>');
f.write('<tr><td ><input type="button" value="完成任務" onClick="parent.foot_trun(\'mission\',\'end\',\'\','+m_id[i]+',\'\')"> <input type="button" value="放棄任務" onClick="parent.foot_trun(\'mission\',\'break\',\'\','+m_id[i]+',\'\')"></td></tr>');
f.write(temp_table2);
f.write('</form>');
}[/color]
}
開啟檔案 wog/wog_fight.php 寫:
- 代碼: 選擇全部
function fire($user_id)
{
global $DB_site;
[color=red] $mission=array();
$mission_id=array();
$result=$DB_site->query("SELECT a.m_id,a.m_monster_id,a.m_kill_num as m_need_num,b.m_kill_num FROM wog_mission_main a,wog_mission_book b WHERE b.p_id=".$user_id." AND b.m_status=0 AND a.m_id=b.m_id AND a.m_area_id=".$_POST['act']);
while($m_item=$DB_site->fetch_array($result))
{
if($m_item['m_kill_num'] == 0)
$DB_site->query("update wog_mission_book set m_status=1 where p_id=".$user_id." and m_id=".$m_item['m_id']." ");
else
{
$mission[$m_item['m_id']]=array('m_id' => $m_item['m_id'],'m_monster_id' => $m_item['m_monster_id'],'m_kill_num' => $m_item['m_kill_num'],'m_need_num' => $m_item['m_need_num']);
$m_id=@explode(',',$m_item['m_monster_id']);
foreach($m_id as $key=>$value)
$mission_id[$m_id[$key]]=$m_item['m_id'];
}
}[/color] $wog_act_class = new wog_fight_select;
[color=red] $wog_act_class->fire($user_id,$mission,$mission_id);[/color]
}
應該就這些了,有問題的話在提出來吧