<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="YD_pet_conn.asp"-->

<%
dim menu,savem,rsbank,rssql,chentitle,chenbackasp,stats,errmsg,founderr,action
chentitle = "宠物大冒险"
Dv_plus.name="petcenter"
'Dv_plus.checklogin()
Dvbbs.LoadTemplates("")
Dvbbs.stats= "宠物大冒险"
Dvbbs.Nav()
Dvbbs.Head_var 0,"","宠物中心","YD_petcenter.asp"

if DvBBS.UserId = 0 then
	AlarmErrmsg
else
	'宠物插件状态
	if DEF_PET_close>1 then
		'暂时关掉开始
		if not dvbbs.master then
			call showmessage("调试中,请以后再来~","index.asp")
		end if
		'暂时关掉结束
	end if

	dim allpetpeople,mypetname,mypet,levelpic,mypetlevel,username
	Dim Rs,SQL
	SQL = "SELECT * FROM mypetdata WHERE username='"&Dvbbs.MemberName&"'"
	set rs = connpet.execute(SQL)
	if rs.eof then
		call showmessage("你还没有宠物啊，快攒钱去买吧~","YD_petshop.asp")
	else
		'用很无聊的循环使用变量得到每种道具的名字……
		dim rs3,swordname,necklacename,headname,bodyname,footname
		set rs3 = connpet.execute("select * from petitemshop where itemclass='sword' and itemnum="&rs("item1"))
		swordname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='necklace' and itemnum="&rs("item2"))
		necklacename = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='head' and itemnum="&rs("item3"))
		headname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='body' and itemnum="&rs("item4"))
		bodyname = rs3("itemname")
		rs3.close
		set rs3 = connpet.execute("select * from petitemshop where itemclass='foot' and itemnum="&rs("item5"))
		footname = rs3("itemname")
		rs3.close

		'注册宠物物品箱中物品
		dim today,pett,petlevel,petep,petshowlevel,intval,level1,level2,petpic,pethp,petmaxhp,hpmaxskill,maxhp
		dim petatk,petdef,updat,newpettoday,petsp,petsex,petpk,speed
		dim hpf,spf,mypetdead,petdead,mypetsex
		dim item1,item2,item3,item4,item5,mypetsx,imgset
		Dim Rs2,SQL2,hpitem,spitem,expitem,liveitem,weopitem,amoritem,jewel,ring,it1,it1n,it2,it2n,it3,it3n,it4,it4n,it5,it5n,it6,it6n,it7,it7n,it8,it8n
		dim tempname,tempclass,tempNum,tempN,it,temp,temp3
		dim str,ski,def,vit
		sql2 = "SELECT * FROM useritem WHERE username='"&Dvbbs.MemberName&"' "
		set rs2=connpet.ExeCute(sql2)
		hpitem=rs2("hpitem")
		spitem=rs2("spitem")
		expitem=rs2("expitem")
		liveitem=rs2("liveitem")
		weopitem=rs2("weopitem")
		amoritem=rs2("amoritem")
		jewel=rs2("jewel")
		ring=rs2("ring")
		it1=rs2("it1")
		it1n=rs2("it1n")
		it2=rs2("it2")
		it2n=rs2("it2n")
		it3=rs2("it3")
		it3n=rs2("it3n")
		it4=rs2("it4")
		it4n=rs2("it4n")
		it5=rs2("it5")
		it5n=rs2("it5n")
		it6=rs2("it6")
		it6n=rs2("it6n")
		it7=rs2("it7")
		it7n=rs2("it7n")
		it8=rs2("it8")
		it8n=rs2("it8n")
		rs2.close
		today = date()
		pett= DateDiff("d", rs("petregdate"), today)
		petlevel = sqr((Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)) * (Log(rs("mypetexp")) / Log(10)))
		petep = int (100 * (petlevel - int (petlevel)))
		petshowlevel = int (petlevel + 1)
		levelpic=int(petshowlevel/10)
		if levelpic>10 then levelpic=11 end if
		level1=int(petshowlevel)
		level2=int(petshowlevel)
		petpic=rs("mypetname")
		pethp=rs("mypethp")
		str=rs("str")
		ski=rs("ski")
		def=rs("def")
		vit=rs("vit")
		speed=rs("speed")+def
		petatk=rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(str/2)
		petdef=rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(ski/2)
		'获取生命上限
		hpmaxskill=1
		if rs("hpmaxskill")>0 then
			hpmaxskill=1+rs("hpmaxskill")/100
		end if
		if rs("hpmaxskill")>30 then
			hpmaxskill=1.2+rs("hpmaxskill")/100
		end if
		if rs("hpmaxskill")>100 then
			hpmaxskill=1.5+rs("hpmaxskill")/100
		end if

		petmaxhp = int((rs("mypetmaxhp")+vit)*hpmaxskill)
		maxhp=petmaxhp
		petsp=rs("mypetsp")-pett*DEF_PET_basicsp2
		if(petsp>DEF_PET_basicsp) then petsp=DEF_PET_basicsp end if
		hpf= int (100 * (pethp / petmaxhp)) - 1
		spf= int (100 * (petsp / DEF_PET_basicsp)) - 1

		if (pethp<0) then pethp=0 end if
		if (petsp<0) then petsp=0 end if
		if (pethp<1 or petsp<1) then
			petdead="死亡"
			'增加判断~宠物是否死亡!
			call showmessage("你的宝宝好象已经挂了， 救活它再冒险吧。","YD_petrisk.asp")
		else
			petdead="生存"
		end if

		if (rs("mypetsex")<2) then
			petsex="雄" 
		else
			petsex="雌"
		end if
		if (rs("openpk") < 2) then
			petpk="等待挑战"
		else 
			petpk="拒绝挑战"
		end if

		if hpf >= 98 then hpf = hpf - 2 end if
		if spf >= 98 then spf = spf - 2 end if

		item1 = rs("item1")
		item2 = rs("item2")
		item3 = rs("item3")
		item4 = rs("item4")
		item5 = rs("item5")
		mypet = rs("mypet")
		mypetsx = rs("mypetsx")
		imgset = rs("imgset")
		dim petkill

		if petdead="死亡" then
			petkill="d-"
		else
			petkill=""
		end if
	end if
	call main()		'调用主页面
	rs.close
End If
Set Dv_plus=Nothing
Dvbbs.Footer

'======================主页面部分============================
sub main()
%>
<table class=tableborder1 cellspacing=1 cellpadding=3 align=center>
  <tr>
    <th width=100% height=27 align="center"><%=dvbbs.stats%></th>
  </tr>
  <tr>
    <td class=TableBody1 width=100% valign="top">
      <table width="819" cellspacing="1" cellpadding="5" align="center" height="674">
	<tr>
	  <td width="165">
	    <table width="100%" cellspacing="2" cellpadding="2">
	      <tr>
		<td width="35%">　</td>
		<td width="20%" align="center"><img src="YD_plus/YD_pet/PET/head/<%=rs("item3")%>.gif" alt="<%=headname%> 防御力 <%=rs("item3Num")%>"></td>
		<td width="35%">　</td>
	      </tr>
	      <tr>
		<td align="right"><img height=30 src="YD_plus/YD_pet/PET/sword/<%=rs("item1")%>.gif" alt="<%=swordname%> 攻击力 <%=rs("item1Num")%>"></td>
		<td rowspan="2" align="center">
		<%if rs("imgset")=-1 then%>
			<img src="YD_plus/YD_pet/PET/<%=petpic%>/<%=petkill%><%=petpic%><%=levelpic%>.gif" border="0">
		<%else%>
			<img src="YD_plus/YD_pet/PET/<%=petpic%>/<%=petkill%><%=petpic%><%=imgset%>.gif" border="0">
		<%end if%>
		</td>
		<td><img src="YD_plus/YD_pet/PET/body/<%=rs("item4")%>.gif" alt="<%=bodyname%> 防御力 <%=rs("item4Num")%>"></td>
	      </tr>
	      <tr>
		<td align="right"><img src="YD_plus/YD_pet/PET/necklace/<%=rs("item2")%>.gif" alt="<%=necklacename%> 攻击力 <%=rs("item2Num")%>"></td>
		<td><img src="YD_plus/YD_pet/PET/foot/<%=rs("item5")%>.gif" alt="<%=footname%> 防御力 <%=rs("item5Num")%>"></td>
	      </tr>
	    </table>
	    <table width="100%" cellpadding="1" cellspacing="1">
	      <tr>
		<td align="right">
		  <table width="100%" align="center" cellpadding="2" cellspacing="2">
		    <tr>
		      <td align="left">宠物名称：<%=mypet%><br>
			宠物性别：<%=petsex%><br>
			宠物状态：<%=petdead%><br>
			宠物属性：<%=mypetsx%><br>
			宠物PK：<%=petpk%><br>
			宠物转生：<%=rs("relive")%><br>
			宠物级别：<%=petshowlevel%><br>
			--------------<br>
			力量：<%=str%><br>
			皮肤：<%=ski%><br>
			敏捷：<%=def%><br>
			体力：<%=vit%><br>
			攻击力：<%=petatk%><br>
			防御力：<%=petdef%><br>
			攻击速度：<%=speed%><br>
			--------------<br>
			HP : <%=pethp%> / <%=petmaxhp%><br> 
			<table width="120" cellspacing="0" cellpadding="0">
			  <tr>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_left.gif" width=3></TD>
			    <TD width=114 background=YD_plus/YD_pet/RPG/img_backing.gif height=13><img src="YD_plus/YD_pet/RPG/orange.gif" width="<%=hpf%>%" height="9"><img src="YD_plus/YD_pet/RPG/hp.gif" height="9"></td>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_right.gif" width=3></TD>
			  </tr>
			</table>
			SP : <%=petsp%> / <%=DEF_PET_basicsp%><br>
			<table width="120" cellspacing="0" cellpadding="0">
			  <tr>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_left.gif" width=3></TD>
			    <TD width=114 background=YD_plus/YD_pet/RPG/img_backing.gif height=13><img src="YD_plus/YD_pet/RPG/green.gif" width="<%=spf%>%" height="9"><img src="YD_plus/YD_pet/RPG/mp.gif" height="9"></td>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_right.gif" width=3></TD>
			  </tr>
			</table>
			EXP : <%=petep%>%[<%=rs("mypetexp")%>]<br>
			<table width="120" cellspacing="0" cellpadding="0">
			  <tr>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_left.gif" width=3></TD>
			    <TD width=114 background=YD_plus/YD_pet/RPG/img_backing.gif height=13><img src="YD_plus/YD_pet/RPG/blue.gif" width="<%=petep%>%" height="9"><img src="YD_plus/YD_pet/RPG/exp.gif" height="9"></td>
			    <TD width=3 height=13><IMG height=13 src="YD_plus/YD_pet/RPG/img_right.gif" width=3></TD>
			  </tr>
			</table>
		      </td>
		    </tr>
		  </table>
		</td>
	      </tr>
	      <tr>
		<td align="left"><IMG height=35 src="YD_plus/YD_pet/PET/hp.gif" width=34 align="left">拥有数量：<%=hpitem%><BR>[<a href="YD_petitemuse.asp?action=usehp"><font color="#FF0000">使用</font></a>]</td>
	      </tr>
		<td align="left"><IMG height=35 src="YD_plus/YD_pet/PET/sp.gif" width=34 align="left">拥有数量：<%=spitem%><BR>[<a href="YD_petitemuse.asp?action=usesp"><font color="#FF0000">使用</font></a>]</td>
	      </tr>
	    </table>
	  </td>
	  <td width="631" align="center">
		<map name="petrisk">
		<area href="YD_petpknpc.asp?monsid=1" shape="circle" coords="204, 393, 32" alt="新手村">
		<area href="YD_petpknpc.asp?monsid=2" shape="circle" coords="143, 290, 31" alt="兽人营地">
		<area href="YD_petpknpc.asp?monsid=3" shape="circle" coords="233, 196, 42" alt="狩猎城堡">
		<area href="YD_petpknpc.asp?monsid=4" shape="circle" coords="127, 188, 37" alt="昆虫之岛">
		<area href="YD_petpknpc.asp?monsid=5" shape="circle" coords="316, 206, 26" alt="屠夫之家 30级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=6" shape="circle" coords="349, 150, 37" alt="迷失森林 40级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=7" shape="circle" coords="457, 217, 36" alt="狩猎船 50级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=8" shape="circle" coords="427, 95, 34" alt="噩梦平原 60级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=9" shape="circle" coords="283, 71, 40" alt="冰峰山 70级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=10" shape="circle" coords="285, 317, 48" alt="藏宝洞 80级以上级以上可以进入，低等级用户进入后果自负！">
		<area href="YD_petpknpc.asp?monsid=11" shape="circle" coords="546, 143, 26" alt="云中城 90级以上级以上可以进入，低等级用户进入后果自负！">
		<area shape="rect" coords="1,435,136,456" href="http://www.nh315600.com/" target="_blank">
		</map>
		<img border="0" src="YD_plus/YD_pet/PET/map.jpg" width="579" height="442" usemap="#petrisk">
	  </td>
	</tr>
      </table>
    </td>
  </tr>
</table>
<%
end sub
%>