<!--#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,mypetexp
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 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

		'注册宠物数据
		dim t,today,petdiff,pett,petlevel,petep,petshowlevel,intval,level1,level2,petpic,pethp,petmaxhp,hpmaxskill,maxhp
		dim petatk,petdef,updat,newpettoday,petsp,petsex,petpk
		dim hpf,spf,mypetdead,petdead,mypetsex,szd,skill
		dim item1,item2,item3,item4,item5,mypetsx,imgset,speed
		t=now()
		today = date()
		petdiff = DateDiff("d", rs("petregdate"), today)
		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")
		szd=rs("szd")+petshowlevel*5-str-ski-def-vit
		skill=rs("skill")+petshowlevel-rs("atkskill")-rs("defskill")-rs("lifeskill")-rs("luckskill")-rs("learnskill")-rs("hpmaxskill")
		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
		speed=rs("speed")+def
		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

		'注册怪物数据

		dim monsid,maxatk,minatk,maxdef,mindef,atkrnd,defrnd,dropgoods,monshp,dropwp,dropam,riskexp,monssx,monsx,monslv,monspeed
		dim time1,time2,atkrand,defrand,atktemp,atk,atktemp2,atk2,atktmp,atktmp2,monsclass,riskmoney
		dim atkrand1,defrand1,atkskill1,defskill1,luck1,life1,learn1,atktemp1,deftemp1,deftemp2,skill1,skill2,skill3,skill4,skill5,skill6,atkrand2,defrand2
		monsid=cint(request("monsid"))
		monssx=checkstr(request("monssx"))
		monsclass=checkstr(request("monsclass"))
		set rs2 = connpet.execute("select * from [petmonster] where id="&monsid)
		maxatk = rs2("Maxatk")
		minatk = rs2("Minatk")
		maxdef = rs2("Maxdef")
		mindef = rs2("Mindef")
		monshp = rs2("MonsHP")
		dropwp = rs2("Dropwp")
		dropam = rs2("Dropam")
		monspeed=rs2("monspeed")
		monslv = rs2("Monslevel")
		rs2.close

		'等级限制
		if monslv = 10 then
			if (rs("mypetlevel") < 30) then
				call showmessage("你的宝宝很英勇， 但这里要30级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 15 then
			if (rs("mypetlevel") < 40) then
				call showmessage("你的宝宝很英勇， 但这里要40级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 20 then
			if (rs("mypetlevel") < 50) then
				call showmessage("你的宝宝很英勇， 但这里要50级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 25 then
			if (rs("mypetlevel") < 60) then
				call showmessage("你的宝宝很英勇， 但这里要60级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 30 then
			if (rs("mypetlevel") < 70) then
				call showmessage("你的宝宝很英勇， 但这里要70级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 40 then
			if (rs("mypetlevel") < 80) then
				call showmessage("你的宝宝很英勇， 但这里要80级以上才能进入。","YD_petrisk.asp")
			end if
		end if
		if monslv = 50 then
			if (rs("mypetlevel") < 90) then
				call showmessage("你的宝宝很英勇， 但这里要90级以上才能进入。","YD_petrisk.asp")
			end if
		end if

		'注册回合
		dim times
		if request("times") = "" and request("times") = 0 then
			times = 0
		else
			times = lcase(request("times"))
		end if

		'注册怪物属性
		if times = 0 then
			randomize
			monsx = cint(rnd*6)+1
			if int(rnd*10000)<100 then
				monsx = 8
			end if
			select case monsx
				case 1
					monssx = "金"
					monsclass = "devil"
				case 2
					monssx = "木"
					monsclass = "green"
				case 3
					monssx = "水"
					monsclass = "bird"
				case 4
					monssx = "火"
					monsclass = "dragon"
				case 5
					monssx = "土"
					monsclass = "bst"
				case 6
					monssx = "水"
					monsclass = "bleb"
				case 7
					monssx = "无"
					monsclass = "flower"
				case 8
					monssx = "龙"
					monsclass = "Gol"
			end select
		end if

		'各种属性的基础参数
		atkrand1=1
		defrand1=1
		atkskill1=1
		defskill1=1
		luck1=1
		life1=1
		learn1=1
		skill1=rs("atkskill")
		skill2=rs("defskill")
		skill3=rs("luckskill")
		skill4=rs("learnskill")
		skill5=rs("lifeskill")
		skill6=rs("hpmaxskill")

		'攻击者的五行生克参数
		select case rs("mypetsx")
			case "金"
				if monssx = "木" then atkrand1=1.5
				if monssx = "土" then defrand1=0.75
				if monssx = "龙" then atkrand1=0.8
			case "木"
				if monssx = "土" then atkrand1=1.5
				if monssx = "水" then defrand1=0.75
				if monssx = "龙" then atkrand1=0.8
			case "水"
				if monssx = "火" then atkrand1=1.5
				if monssx = "金" then defrand1=0.75
				if monssx = "龙" then atkrand1=0.8
			case "火"
				if monssx = "金" then atkrand1=1.5
				if monssx = "木" then defrand1=0.75
				if monssx = "龙" then atkrand1=0.8
			case "土"
				if monssx = "水" then atkrand1=1.5
				if monssx = "火" then defrand1=0.75
				if monssx = "龙" then atkrand1=0.8
			case "无"
				if monssx = "龙" then atkrand1=0.7
			case "龙"
				atkrand1=1.3
		end select

		'防御者的五行生克参数
		select case monssx
			case "金"
				if rs("mypetsx") = "木" then atkrand2=1.5
				if rs("mypetsx") = "土" then defrand2=0.75
				if rs("mypetsx") = "龙" then atkrand2=0.8
			case "木"
				if rs("mypetsx") = "土" then atkrand2=1.5
				if rs("mypetsx") = "水" then defrand2=0.75
				if rs("mypetsx") = "龙" then atkrand2=0.8
			case "水"
				if rs("mypetsx") = "火" then atkrand2=1.5
				if rs("mypetsx") = "金" then defrand2=0.75
				if rs("mypetsx") = "龙" then atkrand2=0.8
			case "火"
				if rs("mypetsx") = "金" then atkrand2=1.5
				if rs("mypetsx") = "木" then defrand2=0.75
				if rs("mypetsx") = "龙" then atkrand2=0.8
			case "土"
				if rs("mypetsx") = "水" then atkrand2=1.5
				if rs("mypetsx") = "火" then defrand2=0.75
				if rs("mypetsx") = "龙" then atkrand2=0.8
			case "无"
				if rs("mypetsx") = "龙" then atkrand2=0.7
			case "龙"
				atkrand2=1.3
		end select

		'攻击者攻击技能的加成
		if rs("atkskill")>0 then
			atkskill1=1+rs("atkskill")/100
			if rs("atkskill")>30 then
				atkskill1=1.1+rs("atkskill")/100
				if rs("atkskill")>100 then
					atkskill1=1.3+rs("atkskill")/100
				end if
			end if
		end if

		'攻击者防御技能的加成
		if rs("defskill")>0 then
			defskill1=1+rs("defskill")/100
			if rs("defskill")>30 then
				defskill1=1.1+rs("defskill")/100
				if rs("defskill")>100 then
					defskill1=1.3+rs("defskill")/100
				end if
			end if
		end if

		'攻击者幸运技能的加成
		if rs("luckskill")>0 then
			if int((100-rs("luckskill")/2)*rnd)<2 then luck1=2
		end if
		if rs("luckskill")>30 then
			if int((100-rs("luckskill")/1.8)*rnd)<2 then luck1=2
		end if
		if rs("luckskill")>100 then
			if int((100-rs("luckskill")/1.5)*rnd)<2 then luck1=2
		end if

		'攻击者治疗技能的加成
		if rs("lifeskill")>0 then
			life1=1+rs("lifeskill")/100
		end if
		if rs("lifeskill")>30 then
			life1=1.2+rs("lifeskill")/100
		end if
		if rs("lifeskill")>100 then
			life1=1.5+rs("lifeskill")/100
		end if

		'攻击者学习技能的加成
		if rs("learnskill")>0 then
			learn1=1+rs("learnskill")/100
		end if
		if rs("learnskill")>30 then
			learn1=1.5+rs("learnskill")/100
		end if
		if rs("learnskill")>100 then
			learn1=2+rs("learnskill")/100
		end if

		'注册怪物HP,并写入宠物数据库
		dim monhp
		'龙系怪物HP
		if monssx="龙" then
			monshp=monshp*10
		end if

		if times=0 then
			monhp=monshp
			Session(DvBBS.MemberName & "YD_Pet_monhp") = monhp			
		end if
		monhp = Session(DvBBS.MemberName & "YD_Pet_monhp")

		'躲避参数
		dim miss1,miss2
		speed=speed+5
		miss1=int(rnd*(200+monspeed/10-speed/10))
		miss2=int(rnd*(200+speed/10-monspeed/10))
%>    
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%" id="AutoNumber1">
  <tr>
    <td>
<%
'回合制开始
if monhp>0 then
	if (rs("mypetdead") = 1) then
		call showmessage("你的宝宝好象已经挂了， 救活它再冒险吧。","YD_petrisk.asp")
	else
	'初始回合,不进行战斗判断
	if times>0 then
		'计算怪物随机攻防
		randomize
		atkrnd = clng(Minatk+(Maxatk-Minatk)*rnd)
		defrnd = clng(Mindef+(Maxdef-Mindef)*rnd)
		'龙系怪物攻击防御
		if monssx="龙" then
			atkrnd=atkrnd*10
			defrnd=defrnd*10
		end if
		'攻击者对防御者的伤害
		atktemp1=(rs("mypetatk")+rs("item1Num")+rs("item2Num")+int(rs("str")/2))
		deftemp2=defrnd
		atktmp=int((atktemp1/2+atktemp1/2*rnd)*1.5*atkrand1*atkskill1-deftemp2)
		if luck1=2 then
			atktmp=int((atktemp1*1.5*atkrand1*atkskill1-deftemp2)*1.5)
		end if
		if (atktmp<1) then
			atk=0
		elseif atktmp>Monshp then
			atk=Monshp
		else
			atk=atktmp
		end if
		'防御者对攻击者的伤害			
		atktemp2=atkrnd
		deftemp1=(rs("mypetdef")+rs("item3Num")+rs("item4Num")+rs("item5Num")+int(rs("ski")/2))
		atktmp2=int(((atktemp2/2+atktemp2/2*rnd)*1.5-deftemp1*defrand1*defskill1))
		if (atktmp2<1) then
			atk2=0
		elseif atktmp2>maxhp then
			atk2=maxhp
		else
			atk2=atktmp2
		end if
		'攻击先手优势
		if speed > monspeed and atk>monhp then atk2=0 end if
		if speed < monspeed and atk2>pethp then atk=0 end if
		'是否躲避成功
		if miss1<10 then atk2=0 end if
		if miss2<10 then atk=0 end if
		'初始化回合数据
		if times=0 then atk=0 end if
		if times=0 then atk2=0 end if
		'判断防御者是否死亡
		if (monhp-atk<1) then
			monhp=0
			'取经验
			select case monslv
				case 1
					riskexp=2
				case 2
					riskexp=5
				case 5
					riskexp=10
				case 8
					riskexp=20
				case 10
					riskexp=30	
				case 15
					riskexp=50 
				case 20
					riskexp=80
				case 25
					riskexp=100
				case 30
					riskexp=150	
				case 40
					riskexp=250
				case 50
					riskexp=400 
			end select
			'龙系怪物的经验
			if monssx="龙" then
				riskexp=riskexp*50
			end if
			'学习技能
			if learn1>1 then
				riskexp=int(riskexp*learn1)
			end if
			'治疗技能,被攻击至少掉3以上的HP才起作用								
			if life1>1 and atk2>3 then
				pethp= int(pethp+maxhp*(life1-1))
			end if
			if pethp>maxhp then
				pethp=maxhp
			end if	
			'物品几率设置
			dim temp1,temp2,temp4,itemmsg
			temp1=int(rnd*(300000-int(monslv*1000))+1)
			'龙系掉宝几率	
			if monssx="龙" then
				temp1=int(rnd*(100000-int(monslv*1000))+1)
			end if
			temp2=0
			if temp1 < 10000 and temp1 > 8000 then
				temp2 = 2 '掉防具升级材料
			end if
			if temp1 <8000 and temp1> 6000 then
				temp2 = 3 '掉武器升级材料
			end if
			if temp1 < 6000 then
				temp2 = 1 '掉HP
			end if
			if temp1 <3000 and monslv >5 then
				temp2 = 4
			end if
			if temp1 < 2000 and monslv >8 then
				temp2 = 5
			end if
			if temp1 < 1000 and monslv >10 then
				temp2 = 6
			end if
			if temp1 < 200 and monslv >15 then
				temp2 = 7
			end if
			if temp1 < 50 and monslv >20 then
				temp2 = 8
			end if
			if temp1 < 10 and monslv >25 then
				temp2 = 9
			end if
			if temp1 =2 and monslv >30 then
				temp2 =10
			end if
			if pethp<1 then temp2=0 end if
			if temp2>0 then
				temp4=int(5*rnd+1)  '随机物品的类型
				'判断物品栏是否已经满
				temp=0
				if it8=0 then temp=8 end if
				if it7=0 then temp=7 end if
				if it6=0 then temp=6 end if
				if it5=0 then temp=5 end if
				if it4=0 then temp=4 end if
				if it3=0 then temp=3 end if
				if it2=0 then temp=2 end if
				if it1=0 then temp=1 end if

				itemmsg=""
				if temp = 0 then
					itemmsg=itemmsg &"<br>怪物掉出了一个宝物<br>可惜你的物品箱已满，没有检到！<br>"
					temp2=0
				else
					'写入物品掉落代码
					dim id,itname
					select case temp4 '读物品类型
						case 1
							temp4="sword"
						case 2
							temp4="necklace"
						case 3
							temp4="head"
						case 4
							temp4="body"
						case 5
							temp4="foot"
					end select
							
					set rs3 = connpet.execute("select * from petitemshop where itemclass='"&temp4&"' and itemnum="&temp2&"")
					id=rs3("id")
					itname=rs3("itemname")
					set rs2 = connpet.execute("select * from useritem where username='"&Dvbbs.MemberName&"'")

					select case temp2
						case 1
							hpitem=hpitem+1
							connpet.ExeCute("update useritem SET hpitem='" & hpitem & "' where username='"& DvBBS.MemberName &"'")	
							itemmsg=itemmsg &"<br>怪物掉出了<img src=YD_plus/YD_pet/PET/hp.gif>被你检到了"
						case 3
							weopitem=weopitem+1
							connpet.ExeCute("update useritem SET weopitem='" & weopitem & "' where username='"& DvBBS.MemberName &"'")	
							itemmsg=itemmsg &"<br>怪物掉出了<img src=YD_plus/YD_pet/PET/wp.gif>被你检到了"
						case 2
							amoritem=amoritem+1
							connpet.ExeCute("update useritem SET amoritem='" & amoritem & "' where username='"& DvBBS.MemberName &"'")	
							itemmsg=itemmsg &"<br>怪物掉出了<img src=YD_plus/YD_pet/PET/am.gif>被你检到了"					
						case 4
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
							end select
						case 5
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
							end select
						case 6
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								end select
						case 7
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
							end select
						case 8
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
							end select
						case 9
							select case temp
								case 1
									connpet.execute("update [useritem] set it1="&id&",it1n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2="&id&",it2n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3="&id&",it3n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4="&id&",it4n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5="&id&",it5n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6="&id&",it6n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7="&id&",it7n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8="&id&",it8n="&temp2&"*3 where username='"&DvBBS.MemberName&"'")
							end select
						case 10
							select case temp
								case 1
									connpet.execute("update [useritem] set it1=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 2
									connpet.execute("update [useritem] set it2=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 3
									connpet.execute("update [useritem] set it3=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 4
									connpet.execute("update [useritem] set it4=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 5
									connpet.execute("update [useritem] set it5=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 6
									connpet.execute("update [useritem] set it6=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 7
									connpet.execute("update [useritem] set it7=51,it1n=30 where username='"&DvBBS.MemberName&"'")
								case 8
									connpet.execute("update [useritem] set it8=51,it1n=30 where username='"&DvBBS.MemberName&"'")
							end select
					end select
				end if
			end if
				
			dim itemmsg1
			itemmsg1="<img src=YD_plus/YD_pet/PET/"&temp4&"/"&temp2&".gif>"
			if temp2>3 then
				itemmsg=itemmsg &"<br><br>怪物掉出了"
				itemmsg=itemmsg &itemmsg1 &"被你捡到了<br>"
			end if

			if temp2=0 then 
 if monslv = 1 then
		riskmoney="1"
		end if
 if monslv = 2 then
		riskmoney="1"
		end if
 if monslv = 5 then
		riskmoney="1"
		end if
 if monslv = 8 then
		riskmoney="1"
		end if
 if monslv = 10 then
		riskmoney="1"
		end if
		if monslv = 15 then
                riskmoney="1"
		end if
		if monslv = 20 then
                riskmoney=2
		end if
		if monslv = 25 then
                riskmoney=2
		end if
		if monslv = 30 then
                riskmoney=3
		end if
		if monslv = 40 then
		riskmoney=3
		end if
                if monslv = 50 then
		riskmoney=5
		end if
				
				itemmsg="<br>您获得 "&riskmoney&" "&DEF_PointsName&""
				Dvbbs.execute("update [DV_user] set userwealth = userwealth+"&riskmoney&" where username='"&DvBBS.MemberName&"'")
				Call updateUserInfo(riskmoney,0,0,0,0,0)
			end if
		else
			riskexp=0
			monhp=Session(DvBBS.MemberName & "YD_Pet_monhp")-atk
		end if

		'判断攻击者是否死亡
		if (pethp-atk2<1) then
			pethp=0
			mypetdead=1
			riskexp=-int(rs("mypetexp")*0.01)
			connpet.ExeCute("update mypetdata SET mypetdead=" & mypetdead & " where username='"& DvBBS.MemberName &"'")
		else
			pethp=pethp-atk2
			mypetdead=0
		end if	
		Session(DvBBS.MemberName & "YD_Pet_monhp") = monhp
	' 初始回合,不进行战斗判断结束
	end if
%>
      <TABLE WIDTH=772 CELLPADDING=0 CELLSPACING=0>
	<TR>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=150 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=30 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=20 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=172 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=20 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=30 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=150 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD></TD>
	</TR>
	<TR>
	  <TD COLSPAN=11><IMG SRC="YD_plus/YD_pet/PET/npc/npc_01.jpg" WIDTH=772 HEIGHT=20></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=20></TD>
	</TR>
	<TR>
	  <TD COLSPAN=5><IMG SRC="YD_plus/YD_pet/PET/npc/npc_02.jpg" WIDTH=300 HEIGHT=10></TD>
	  <TD ROWSPAN=2 bgcolor="#ffffff" align="center"><%if pethp<>0 and monhp<>0 then%>第<%=times%>回合<%else%>战斗结束<%end if%></TD>
	  <TD COLSPAN=5><IMG SRC="YD_plus/YD_pet/PET/npc/npc_04.jpg" WIDTH=300 HEIGHT=10></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=10></TD>
	</TR>
	<TR>
	  <TD ROWSPAN=6><IMG SRC="YD_plus/YD_pet/PET/npc/npc_05.jpg" WIDTH=50 HEIGHT=173></TD>
	  <TD COLSPAN=2 ROWSPAN=4 bgcolor="#ffffff">
	    <table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
	      <tr>
		<td width="100%" align="center"><img src="YD_plus/YD_pet/PET/<%=petpic%>/<%=petkill%><%=petpic%><%=levelpic%>.gif" border="0" width="100" height="100"></td>
	      </tr>
	      <tr>
		<td width="100%" rowspan="2" align="center">HP : <%=pethp%> / <%=petmaxhp%>　<font color="#FF0000">[<%if atk2>0 then%><%=-atk2%><%else%>MISS<%end if%>]</font></td>
	      </tr>
	      <tr>
		<TD width=114 background=YD_plus/YD_pet/PET/npc/rpg/img_backing.gif height=13>　</td>
		<TD width=3 height=13></TD>
	      </tr>
	    </table>
	  </TD>
	  <TD COLSPAN=2 ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_07.jpg" WIDTH=50 HEIGHT=20></TD>
	  <TD COLSPAN=2 ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_08.jpg" WIDTH=50 HEIGHT=20></TD>
	  <TD COLSPAN=2 ROWSPAN=4 bgcolor="#ffffff">
	    <table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3">
	      <tr>
		<td width="100%" align="center"><img src="YD_plus/YD_pet/PET/<%=monsclass%>/<%=monsclass%><%=monsid%>.gif" border="0" width="100" height="100"></td>
	      </tr>
	      <tr>
		<td width="100%" rowspan="2" align="center">HP : <%=monhp%> / <%=monshp%>　<font color="#FF0000">[<%if atk>0 then%><%=-atk%><%else%>MISS<%end if%>]</font></td>
	      </tr>
	      <tr>
		<TD width=114 background=YD_plus/YD_pet/PET/npc/rpg/img_backing.gif height=13>　</td>
		<TD width=3 height=13></TD>
	      </tr>
	    </table>
	  </TD>
	  <TD ROWSPAN=6><IMG SRC="YD_plus/YD_pet/PET/npc/npc_10.jpg" WIDTH=50 HEIGHT=173></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=10></TD>
	</TR>
	<TR>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/npc_11.jpg" WIDTH=172 HEIGHT=10></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=10></TD>
	</TR>
	<TR>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_12.jpg" WIDTH=30 HEIGHT=110></TD>
	  <TD COLSPAN=3>
	    <table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4">
	      <tr>
		<td width="100%" align="center"><%if pethp<>0 and monhp<>0 then%><IMG SRC="YD_plus/YD_pet/PET/npc/npc_13.jpg" WIDTH=212 HEIGHT=100><%end if%><%if pethp<>0 and monhp=0 then%><font color="#FF0000">您的宠物获得<%=riskexp%>点经验</font><%end if%><%if pethp=0 then%>不幸牺牲<%end if%><%=itemmsg%></td>
	      </tr>
	    </table>
	  </TD>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_14.jpg" WIDTH=30 HEIGHT=110></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=100></TD>
	</TR>
	<TR>
	  <TD COLSPAN=3><IMG SRC="YD_plus/YD_pet/PET/npc/npc_15.jpg" WIDTH=212 HEIGHT=10></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=10></TD>
	</TR>
	<TR>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_16.jpg" WIDTH=150 HEIGHT=43></TD>
	  <TD COLSPAN=7 bgcolor="#ffffff" align="center"><%if monhp<>0 and pethp<>0 then%>》<a href="YD_petpknpc.asp?times=<%=times+1%>&monsid=<%=monsid%>&monssx=<%=monssx%>&monsclass=<%=monsclass%>">攻击</a>《　　｜　　》<a href="YD_PETRISK.ASP">逃跑</a>《<%end if%><%if pethp=0 then%><a href="YD_PETMYPET.ASP">失败了，回家吧</a><%end if%><%if monhp=0 and pethp<>0 then%><a href="YD_petpknpc.asp?monsid=<%=monsid%>">寻找新的怪物</a><%end if%></TD>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc_18.jpg" WIDTH=150 HEIGHT=43></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=20></TD>
	</TR>
	<TR>
	  <TD COLSPAN=7><IMG SRC="YD_plus/YD_pet/PET/npc/npc_19.jpg" WIDTH=372 HEIGHT=23></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=1 HEIGHT=23></TD>
	</TR>
      </TABLE>
    </td>
  </tr>
  <tr>
    <td>
      <TABLE WIDTH=772 CELLPADDING=0 CELLSPACING=0>
	<TR>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=30 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=350 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=50 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=212 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=38 HEIGHT=1></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/Spacer.gif" WIDTH=42 HEIGHT=1></TD>
	</TR>
	<TR>
	  <TD COLSPAN=7><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_01.jpg" WIDTH=772 HEIGHT=35></TD>
	</TR>
	<TR>
	  <TD ROWSPAN=3><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_02.jpg" WIDTH=30 HEIGHT=136></TD>
	  <TD COLSPAN=2 bgcolor="#ffffff"></TD>
	  <TD><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_04.jpg" WIDTH=50 HEIGHT=100></TD>
	  <TD COLSPAN=2 bgcolor="#ffffff">
	    <table cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5">
	      <tr>
		<td width="50%" align="left">宠物名称：<%=mypet%><br>
		宠物状态：<%=petdead%><br>
		宠物属性：<%=mypetsx%><br>
		宠物转生：<%=rs("relive")%><br>
		宠物级别：<%=petshowlevel%>
		</td>
		<td width="50%">攻击力：<%=petatk%><br>
		防御力：<%=petdef%> <br>
		攻击速度：<%=speed%><br>
		躲避：<%=int(speed/10-monspeed/10)%><br>
		HP药水：<%=hpitem%> [<a target="_blank" href="YD_petitemuse.asp?action=usehp">使用</a>]
		</td>
	      </tr>
	      <tr>
		<td width="50%">SP : <%=petsp%> / <%=DEF_PET_basicsp%></td>
		<td width="50%">EXP : <%=petep%>%[<%=rs("mypetexp")%>]</td>
	      </tr>
	    </table>
	  </TD>
	  <TD ROWSPAN=3><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_06.jpg" WIDTH=42 HEIGHT=136></TD>
	</TR>
	<TR>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_07.jpg" WIDTH=50 HEIGHT=36></TD>
	  <TD COLSPAN=3><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_08.jpg" WIDTH=612 HEIGHT=20></TD>
	  <TD ROWSPAN=2><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_09.jpg" WIDTH=38 HEIGHT=36></TD>
	</TR>
	<TR>
	  <TD COLSPAN=3><IMG SRC="YD_plus/YD_pet/PET/npc/npc1_10.jpg" WIDTH=612 HEIGHT=16></TD>
	</TR>
      </TABLE>
<%
	end if
else
	call showmessage("不好意思~~怪物突然跑不见了.是不是你太厉害了呀?","YD_petrisk.asp")
end if
%>
    </td>
  </tr>
</table>
<%
	'宠物新数据			
	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)))
	petshowlevel = int (petlevel + 1)
	dim ddsql 
	if times = 0 then riskexp=0

	ddsql = "update mypetdata SET mypetexp=mypetexp+"&riskexp&",mypetlevel="&petshowlevel&",mypethp="&pethp&" where username='"&DvBBS.MemberName&"'"
	connpet.ExeCute(ddsql)
	rs.close
	end if
End If
Set Dv_plus=Nothing
Dvbbs.Footer
%>