function War_AddPersonLVUP(pid)
  local tmplevel = JY.Person[pid]["等级"]
  if CC.Level <= tmplevel then
    return false
  end
  if JY.Person[pid]["经验"] < CC.Exp[tmplevel] then
    return false
  end
  while CC.Exp[tmplevel] <= JY.Person[pid]["经验"] do
    tmplevel = tmplevel + 1
    if CC.Level <= tmplevel then
    	break;
    end
  end
  
  DrawStrBoxWaitKey(string.format(CC.WARS125, JY.Person[pid]["姓名"]), C_WHITE, CC.DefaultFont)
  --计算提升的等级
	local leveladd = tmplevel - JY.Person[pid]["等级"]
	
	JY.Person[pid]["等级"] = JY.Person[pid]["等级"] + leveladd
	
	--提高生命增长
	AddPersonAttrib(pid, "生命最大值", (JY.Person[pid]["生命增长"] + Rnd(2) + 2) * leveladd * 4)
	
	JY.Person[pid]["生命"] = JY.Person[pid]["生命最大值"]
--	JY.Person[pid]["体力"] = CC.PersonAttribMax["体力"]
	JY.Person[pid]["受伤程度"] = 0
	JY.Person[pid]["中毒程度"] = 0
	
	--属性点资质加成
	local function cleveradd()
	  local ca, rndnum = nil, nil
	  if CC.Debug then
	    rndnum = math.random(1)
	  else
	    rndnum = math.random(1)
	  end
	  ca = JY.Person[pid]["资质"] / (rndnum + 4)
	  return ca
	end

	
	local theadd = cleveradd()
    JY.Person[pid]["内力最大值"]=JY.Person[pid]["内力最大值"]+JY.Person[pid]["生命增长"]*100
    if JY.Person[pid]["内力最大值"] >  10000-JY.Person[pid]["资质"]*50 then 
	JY.Person[pid]["内力最大值"]=10000-JY.Person[pid]["资质"]*50
	end
	
	JY.Person[pid]["内力"] = JY.Person[pid]["内力最大值"]
	
	--循环提升等级，累加属性
	for i = 1, leveladd do
	  local ups = math.modf((JY.Person[pid]["资质"] - 1) / 15) + 1
	  
	
	  
	  --郭靖 20级之后，每级6点
	  if pid == 55 and JY.Person[pid]["等级"] > 20 then
	    ups = 6
	  end
	
	  
	
	  
	  AddPersonAttrib(pid, "攻击力", ups)
	  AddPersonAttrib(pid, "防御力", ups)
	  AddPersonAttrib(pid, "轻功", ups)
	  

    
	  --修复医疗、用毒、解毒能力不与等级挂钩的问题
	  if JY.Person[pid]["医疗能力"] >= 20 then
  		AddPersonAttrib(pid, "医疗能力", math.random(2))
		end
		if JY.Person[pid]["用毒能力"] >= 20 then
  		AddPersonAttrib(pid, "用毒能力", math.random(2))
		end
		if JY.Person[pid]["解毒能力"] >= 20 then
  		AddPersonAttrib(pid, "解毒能力", math.random(2))
		end
		
		--ivansz:陈家洛 升级027跟着加四围
		if pid == 75 and T1LEQ(0) and inteam(75) then
		  if JY.Person[pid]["拳掌功夫"] >= 0 then
		    AddPersonAttrib(pid, "拳掌功夫", math.random(3))
			AddPersonAttrib(0, "拳掌功夫", 5)
		  end
		  if JY.Person[pid]["御剑能力"] >= 0 then
		    AddPersonAttrib(pid, "御剑能力", (7 + math.random(0,1)))
			AddPersonAttrib(0, "御剑能力", 5)
		  end
		  if JY.Person[pid]["耍刀技巧"] >= 0 then
		    AddPersonAttrib(pid, "耍刀技巧", (7 + math.random(0,1)))
			AddPersonAttrib(0, "耍刀技巧", 5)
		  end
		  if JY.Person[pid]["特殊兵器"] >= 0 then
		  	AddPersonAttrib(pid, "特殊兵器", (7 + math.random(0,1)))
			AddPersonAttrib(0, "特殊兵器", 5)
			end
		end
		
		--暗器每级提高
		if JY.Person[pid]["暗器技巧"] >= 20 then
		  AddPersonAttrib(pid, "暗器技巧", math.random(2))
		end
	end

	local ey = 1;  --每级的随机点数
	  
  

 --以下为改动部分
	
	local n = ey*leveladd;		--计算随机额外点数
	local gj = JY.Person[pid]["攻击力"];
  local fy = JY.Person[pid]["防御力"];
  local qg = JY.Person[pid]["轻功"];
  local ee=0
  local ff=0
  local gg=0
  local tmpN = n;
	repeat
  	Cls();
  	
		local title = JY.Person[pid]["姓名"].." 升级随机点分配";
		local str = string.format("☆剩余的额外随机升级点数：%d 点☆*攻击：%d + %d*防御：%d + %d*轻功：%d + %d",tmpN, gj, ee, fy, ff, qg, gg);
		local btn = {"自动","加攻","加防","加轻","重置","确定"};
		local num = #btn;
		local r = JYMsgBox(title,str,btn,num);
		
		local T = {}
    for a = 0, 1000 do
      local b = "" .. a
      T[b] = a
    end
    

        if r == 1 then
          local e1=n/3 
		  ee=e1
		  gj = JY.Person[pid]["攻击力"]+e1
		  
		  if gj>CC.PersonAttribMax["攻击力"] then
		  gj=CC.PersonAttribMax["攻击力"]
		  end
		  
		  
		  
		  
		  local f1=n-e1
		  if f1==0 then
		  f1=1
		  end		  
		  local e2=n/3
		  local f2={0,1}
		  
		  if e2==1 then
		  e2=f2[math.random(2)]
		  end
		  if e1+e2>n then
		  e2=0
		  end
		  
		  ff=e2
		  fy = JY.Person[pid]["防御力"]+e2
		  
		  if fy>CC.PersonAttribMax["防御力"] then
		  fy=CC.PersonAttribMax["防御力"]
		  end
		  
		  local e3=n-e1-e2
		  local qy=math.random(100)
		  
		  if qy < 8 then
		  	local x1 = CC.ScreenW/2 - 200 ;
	        local y1 = 100
			
		 -- DrawStrBoxWaitKey("天降奇缘！轻功额外增加5点～恭喜！", C_GOLD, CC.DefaultFont)
		 -- e3=e3+5
		  end
		  gg=e3
  		  qg = JY.Person[pid]["轻功"]+e3
		  
		  
		  if qg>CC.PersonAttribMax["轻功"] then
		  qg=CC.PersonAttribMax["轻功"]
		  end
		  
  	      tmpN = 0
          		 

	    elseif r ==  2 then			--输入攻击力
	    local r = GetPinyin1(32, CC.ScreenH - CC.Fontbig * 6)
	    if T[r] == 0 or r == "" then

	    elseif T[r] ~= nil and T[r] > -1 and T[r] <= tmpN then
		  ee=T[r]
	      gj =  gj + T[r]
		  
		  if gj>CC.PersonAttribMax["攻击力"] then
		  gj=CC.PersonAttribMax["攻击力"]
		  end
		  
		  
	      tmpN = tmpN-T[r];

	    else
	    	DrawStrBoxWaitKey("对不起，你输入的攻击力数据不正确!", C_WHITE, 30)
	    end
		
		elseif r ==  3 then		--输入防御力
	    local r = GetPinyin1(32, CC.ScreenH - CC.Fontbig * 6)
	    if T[r] == 0 or r == "" then

	    elseif T[r] ~= nil and T[r] > -1 and T[r] <= tmpN then
		  ff=T[r]
	      fy =  fy + T[r]
		  
		  if fy>CC.PersonAttribMax["防御力"] then
		  fy=CC.PersonAttribMax["防御力"]
		  end
		  
	      tmpN = tmpN-T[r];
	    else
	    	DrawStrBoxWaitKey("对不起，你输入的防御力数据不正确!", C_WHITE, 30)
	    end

		elseif r ==  4 then		--输入轻功
	    local r = GetPinyin1(32, CC.ScreenH - CC.Fontbig * 6)
	    if T[r] == 0 or r == "" then
    		
	    elseif T[r] ~= nil and T[r] > -1 and T[r] <= tmpN then
		gg=T[r]
	      qg =  qg + T[r]
		  
		  if qg>CC.PersonAttribMax["轻功"] then
		  qg=CC.PersonAttribMax["轻功"]
		  end
		  
	      tmpN = tmpN-T[r];
	    else
	    	DrawStrBoxWaitKey("对不起，你输入的轻功数据不正确!", C_WHITE, 30)
	    end
		elseif r == 5 then
			gj = JY.Person[pid]["攻击力"];
  	  fy = JY.Person[pid]["防御力"];
  		qg = JY.Person[pid]["轻功"];
  	  tmpN = n;
	  ee=0
	  gg=0
	  ff=0
		
		elseif r == 6 then
			if tmpN > 0 then
				DrawStrBoxWaitKey("对不起，"..JY.Person[pid]["姓名"].."还有剩余的点数没加!", C_WHITE, 30)
			else
				JY.Person[pid]["攻击力"] = gj;
				JY.Person[pid]["防御力"] = fy;
				JY.Person[pid]["轻功"] = qg;
				
				n = 0;
			end
		end
 	until n == 0
	
	      if JY.Person[pid]["攻击力"]>500 then
             JY.Person[pid]["攻击力"]=500
	  end

          if JY.Person[pid]["防御力"]>500 then
             JY.Person[pid]["防御力"]=500
	  end

          if JY.Person[pid]["轻功"]>333 then
             JY.Person[pid]["轻功"]=333
	  end
	  
	
	return true
end--战斗结束处理函数