local bpitem = {50076,1} --支付道具
local bpbditem = {58012,1} --支付道具
local qiehuangold = 1000
--field库的key值为0,1,2,3,4。0为正在使用的bp,1,2,3,4为存储BP按钮。V值为nil时,判断是否有道具,开启对应bp按钮并洗点,存储V值为0。V值为0时存储当前BP到key,key设置为0和对应按钮。
--其余V值情况将key值为0的与对应key值按钮对换。
function Win_ButtonEvent(Fd,Pack)
local ScapePack = WinMl_LocalSplit(Pack," ");
if(#ScapePack < 2 or ScapePack[2] == nil)then
return 0;
end
local Number = tonumber(ScapePack[2]);
local player = Protocol.GetCharByFd(Fd);
if(Number > 0 and Number < 5)then --判断按了哪个BP按钮
if Char.GetData(player,(%对象_是否战斗中%)) <= 0 then
local bpfield = Field.Get(player,"bpanniu_"..Number) --读取对应BP按钮field
local bp0field = Field.Get(player,"bpanniu_0")-- 读取目前处于几号field
local bp0fieldnum = tonumber(bp0field)
local haveitem = Char.ItemNum(player, bpitem[1])
local havebditem = Char.ItemNum(player, bpbditem[1])
local a = Char.GetData(player,%对象_体力%)
local b = Char.GetData(player,%对象_力量%)
local c = Char.GetData(player,%对象_强度%)
local d = Char.GetData(player,%对象_速度%)
local e = Char.GetData(player,%对象_魔法%)
local f = Char.GetData(player,%对象_升级点%)
local bp = (a+b+c+d+e)/100+f
if bpfield == nil then
if haveitem >= bpitem[2] then--非绑洗点水
NLG.DelItem(player, bpitem[1], bpitem[2])
Field.Set(player,"bpanniu_"..Number,"0") --设置field,最终格式bpanniu_x,0
Field.Set(player,"bpanniu_0",""..Number.."") --设置field,最终格式bpanniu_x,0
Char.SetData(player,%对象_升级点%,bp)
Char.SetData(player,%对象_体力%,0)
Char.SetData(player,%对象_力量%,0)
Char.SetData(player,%对象_强度%,0)
Char.SetData(player,%对象_速度%,0)
Char.SetData(player,%对象_魔法%,0)
NLG.UpChar(player)
NLG.SystemMessage(player,""..Number.."号BP页已成功开启,并清空所有BP。")
-- NLG.SystemMessage(player,"Bp为"..bpfield.."")
elseif havebditem >= bpbditem[2] then--绑定洗点水
NLG.DelItem(player, bpbditem[1], bpbditem[2])
Field.Set(player,"bpanniu_"..Number,"0") --设置field,最终格式bpanniu_x,0
Field.Set(player,"bpanniu_0",""..Number.."") --设置field,最终格式bpanniu_x,0
Char.SetData(player,%对象_升级点%,bp)
Char.SetData(player,%对象_体力%,0)
Char.SetData(player,%对象_力量%,0)
Char.SetData(player,%对象_强度%,0)
Char.SetData(player,%对象_速度%,0)
Char.SetData(player,%对象_魔法%,0)
NLG.UpChar(player)
NLG.SystemMessage(player,""..Number.."号BP页已成功开启,并清空所有BP。")
else
NLG.SystemMessage(player,"您身上需要一瓶再生药水开启BP页面。")
return 0;
end
elseif bpfield == "0" or bp0fieldnum == Number then --field为0时
Field.Set(player,"bpanniu_"..Number,""..a..","..b..","..c..","..d..","..e..","..f.."")--存储5V数据,为字符串
Field.Set(player,"bpanniu_0",""..Number.."")--存储正在使用5V数据,为字符串
NLG.SystemMessage(player,"BP已存入"..Number.."号BP页。正在使用的是"..Number.."号BP页")
-- NLG.SystemMessage(player,"bp0fieldnum为"..(bpfield)..",类型是"..type(bpfield).."")
elseif (bpfield ~= nil and bpfield ~= "0") then --field为五维时
local gold = Char.GetData(player,%对象_金币%)
if gold >= qiehuangold then
-- local fieldkey0 = Field.Get(player,"bpanniu_0")
local bptab = splitplus(bpfield,",") --提取5V数据表,为表
local aa = tonumber(bptab[1])
local bb = tonumber(bptab[2])
local cc = tonumber(bptab[3])
local dd = tonumber(bptab[4])
local ee = tonumber(bptab[5])
local ff = tonumber(bptab[6])
local bbpp = (aa+bb+cc+dd+ee)/100+ff
local bpjdz = math.abs(bp-bbpp) --取绝对值
Char.SetData(player,%对象_金币%,gold-qiehuangold)
Field.Set(player,"bpanniu_"..bp0fieldnum,""..a..","..b..","..c..","..d..","..e..","..f.."") --设置field,最终格式bpanniu_x,0
Field.Set(player,"bpanniu_"..Number,""..aa..","..bb..","..cc..","..dd..","..ee..","..ff.."") --设置field,最终格式bpanniu_x,0
Field.Set(player,"bpanniu_0",""..Number.."")--存储正在使用5V数据,为字符串
Char.SetData(player,%对象_升级点%,ff+bpjdz)
Char.SetData(player,%对象_体力%,aa)
Char.SetData(player,%对象_力量%,bb)
Char.SetData(player,%对象_强度%,cc)
Char.SetData(player,%对象_速度%,dd)
Char.SetData(player,%对象_魔法%,ee)
NLG.UpChar(player)
NLG.SystemMessage(player,"BP已切换为"..Number.."号BP页,收取"..qiehuangold.."魔币。正在使用的是"..Number.."号BP页")
-- NLG.SystemMessage(player,"aa="..aa..",bb="..bb..",cc="..cc..",dd="..dd..",ee="..ee..",ff="..ff.."")
else
NLG.SystemMessage(player,"你身上的魔币不足以切换BP页")
end
else
NLG.SystemMessage(player,"设置出错,请联系GM")
return 0;
end
else
NLG.SystemMessage(player,"战斗中不能使用此功能。")
end
end
if(Number > 4 and Number < 10)then
local int = splitplus(Pack," ")
local petpos = tonumber(int[2])--宠物算档部分
local petindex = Char.GetPetIndex(player,petpos-5)
PetCalc(petindex,player)
end
return 0;
end
|
|