local zuoqidl_tab = zuoqidl_tab or {} -- 玩家索引表
local zuoqiitem_tab = zuoqiitem_tab or {} -- 掉落道具表
local zuoqipl_tab = zuoqipl_tab or {} -- 玩家分配道具表
--记录方案tab[player][x] = itemid+battleindex
local zuoqimap_tab = {} --练级点地图掉落几率
zuoqimap_tab[0] = {}
zuoqimap_tab[0][100] = 4 --练级点掉率,zuoqimap_tab[0][map] = 掉率,小于等于0即不会掉落
zuoqimap_tab[0][11003] = 4 --哈洞
zuoqimap_tab[0][15005] = 4 --海底
zuoqimap_tab[0][38015] = 4 --雪山
zuoqimap_tab[0][33000] = 4 --坎村
zuoqimap_tab[0][38016] = 4 --炎洞
zuoqimap_tab[0][38017] = 4 --水洞
zuoqimap_tab[0][38086] = 4 --龙城
zuoqimap_tab[0][38019] = 4 --火山
zuoqimap_tab[0][38020] = 4 --兰一
zuoqimap_tab[0][38051] = 4 --怪物硬币
zuoqimap_tab[0][38052] = 4 --怪物硬币
zuoqimap_tab[0][38053] = 4 --怪物硬币
zuoqimap_tab[0][38054] = 4 --怪物硬币
zuoqimap_tab[0][60061] = 1 --爱岛
zuoqimap_tab[1] = {}-- 迷宫
--zuoqimap_tab[1][1421] = 4 --龙城迷宫
zuoqimap_tab[1][3] = 4 --灵堂迷宫
zuoqimap_tab[1][1401] = 2 --迷宫之城
zuoqimap_tab[1][1402] = 2 --迷宫之城
zuoqimap_tab[1][1403] = 2 --迷宫之城
zuoqimap_tab[1][1404] = 2 --迷宫之城
zuoqimap_tab[1][1405] = 2 --迷宫之城
zuoqimap_tab[1][1406] = 2 --迷宫之城
zuoqimap_tab[1][1407] = 2 --迷宫之城
zuoqimap_tab[1][1408] = 2 --迷宫之城
zuoqimap_tab[1][1409] = 2 --迷宫之城
-------
--Global_Reg.RegBattleOverEvent ("zuoqi_battlejs")--战斗结束函数
Global_Reg.RegBattleStartEvent("zuoqi_battlezc");--进入战斗注册
--NL.RegBattleGiveItem(nil, "zuoqi_diaoluozc")
function zuoqi_diaoluozc(battleIndex,player,ItemList,EncountID)--注册战斗结束获得道具函数
if zuoqipl_tab[player] then
local a = #zuoqipl_tab[player]
local itemid1 = tostring(zuoqipl_tab[player][1])
local b = #itemid1
if b>=7 then
-- local itemid1 = string.sub(zuoqipl_tab[player][1],1,6)
local itemid2 = 0
local itemid3 = 0
local cishu1 = 0
local cishu2 = 0
local cishu3 = 0
local batte = tonumber(string.sub(itemid1,7,-1))
-- NLG.SystemMessage(player,"batte="..batte.."")
if batte and batte == battleIndex then
for k,v in pairs (zuoqipl_tab[player]) do
if v ~= itemid1 and v ~= itemid2 then
itemid2 = v
break
end
end
for k,v in pairs (zuoqipl_tab[player]) do
if v ~= itemid1 and v ~= itemid2 and v ~= itemid3 then
itemid3 = v
break
end
end
for k,v in pairs (zuoqipl_tab[player]) do
if itemid1 == v then--获取次数
cishu1 = cishu1 + 1
elseif itemid2 == v then
cishu2 = cishu2 +1
elseif itemid3 == v then
cishu3 = cishu3 +1
end
end
itemid1 = tonumber(string.sub(itemid1,1,6))--道具1id
itemid2 = tonumber(string.sub(itemid2,1,6))--道具2id
itemid3 = tonumber(string.sub(itemid3,1,6))--道具3id
-- NLG.SystemMessage(player,"道具原名是:[1]="..q..",[2]="..w..",[3]="..e)
-- NLG.SystemMessage(player,"[1]="..ItemList[1]..",[2]="..ItemList[2]..",[3]="..ItemList[3].."")
-- NLG.SystemMessage(player,"itemid1="..itemid1..",itemid2="..itemid2..",itemid3="..itemid3.."")
-- NLG.SystemMessage(player,"[1]="..Item.GetData(ItemList[1],%道具_ID%).."")
local playerjob = Char.GetData(player,51)--获取职业
if (playerjob >= 10 and playerjob <= 59) or (playerjob >= 70 and playerjob <= 89) or (playerjob >= 110 and playerjob <= 119) or (playerjob >= 130 and playerjob <= 199) or (playerjob >= 540 and playerjob <= 549) then --若是战斗职业,除去传教封印、盗贼、饲养或者是佣兵
if itemid3 >= 1 and itemid2 >= 1 and itemid3 >= 1 then --有三种碎片
-- NLG.SystemMessage(player,"三碎片")
if ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] >= 0 then --若本身有3种掉落
ItemList[1] = ItemList[1]
ItemList[2] = ItemList[2]
ItemList[3] = Battle.AddItem(itemid1)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu1)
elseif ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] < 0 then --若本身有2种掉落
ItemList[1] = ItemList[1]
ItemList[2] = ItemList[2]
ItemList[3] = Battle.AddItem(itemid1)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu1)
elseif ItemList[1] >= 0 and ItemList[2] < 0 and ItemList[3] < 0 then --若本身有1种掉落
ItemList[1] = ItemList[1]
ItemList[2] = Battle.AddItem(itemid1)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu1)
ItemList[3] = Battle.AddItem(itemid2)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu2)
else--其他情况都是给3种碎片
ItemList[1] = Battle.AddItem(itemid1)
Item.SetData(ItemList[1],%道具_堆叠数%,cishu1)
ItemList[2] = Battle.AddItem(itemid2)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu2)
ItemList[3] = Battle.AddItem(itemid3)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu3)
end
elseif itemid3 == 0 and itemid2 >= 1 and itemid1 >= 1 then--有两种碎片
-- NLG.SystemMessage(player,"二碎片")
if ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] >= 0 then --若本身有3种掉落
ItemList[1] = ItemList[1]
ItemList[2] = ItemList[2]
ItemList[3] = Battle.AddItem(itemid1)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu1)
elseif ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] < 0 then --若本身有2种掉落
ItemList[1] = ItemList[1]
ItemList[2] = Battle.AddItem(itemid1)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu1)
ItemList[3] = ItemList[3]
elseif ItemList[1] >= 0 and ItemList[2] < 0 and ItemList[3] < 0 then --若本身有1种掉落
ItemList[1] = ItemList[1]
ItemList[2] = Battle.AddItem(itemid1)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu1)
ItemList[3] = Battle.AddItem(itemid2)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu2)
else--其他情况都是给2种碎片
ItemList[1] = Battle.AddItem(itemid1)
Item.SetData(ItemList[1],%道具_堆叠数%,cishu1)
ItemList[2] = Battle.AddItem(itemid2)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu2)
end
elseif itemid3 == 0 and itemid2 == 0 and itemid1 >= 1 then--有1种碎片
-- NLG.SystemMessage(player,"一碎片")
if ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] >= 0 then --若本身有3种掉落
ItemList[1] = ItemList[1]
ItemList[2] = ItemList[2]
ItemList[3] = Battle.AddItem(itemid1)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu1)
elseif ItemList[1] >= 0 and ItemList[2] >= 0 and ItemList[3] < 0 then --若本身有2种掉落
ItemList[1] = ItemList[1]
ItemList[2] = ItemList[2]
ItemList[3] = Battle.AddItem(itemid1)
Item.SetData(ItemList[3],%道具_堆叠数%,cishu1)
elseif ItemList[1] >= 0 and ItemList[2] < 0 and ItemList[3] < 0 then --若本身有1种掉落
ItemList[1] = ItemList[1]
ItemList[2] = Battle.AddItem(itemid1)
Item.SetData(ItemList[2],%道具_堆叠数%,cishu1)
else--其他情况都是给2种碎片
ItemList[1] = Battle.AddItem(itemid1)
Item.SetData(ItemList[1],%道具_堆叠数%,cishu1)
end
end
end
end
end
-- NLG.SystemMessage(player,"[1]="..ItemList[1]..",[2]="..ItemList[2]..",[3]="..ItemList[3].."")
-- NLG.SystemMessage(player,"-----------------")
zuoqipl_tab[player] = nil --回收玩家分配道具表
end
return ItemList
end
function zuoqi_battlezc(battleIndex)
local battype= Battle.GetType(battleIndex)
if battype == 1 then--PVE战斗
if zuoqiitem_tab[battleIndex] == nil then --只触发一个玩家
for Num = 0,9 do
local enemyindex = Battle.GetPlayIndex(battleIndex, 1, Num)--获取上方对象索引
local b = Char.GetData(enemyindex,17)--判断是什么种族
if b ~= 9 then -- 判断不是邪魔系
if enemyindex >= 0 then
local enemybase = Char.GetData(enemyindex ,57) --获取ebase
local img = BaseEnemyBaseTable[enemybase][8] --获取图档
local itemid = 610000+img --获取该图档对应的道具ID
local pditemid = Item.MakeItemStatusString(itemid)
if pditemid then --判断是否有该道具ID
zuoqiitem_tab[battleIndex] = zuoqiitem_tab[battleIndex] or {}
table.insert(zuoqiitem_tab[battleIndex],itemid)
end
end
end
end
end
if zuoqiitem_tab[battleIndex] then
local f = #(zuoqiitem_tab[battleIndex]) -- 道具表长度
local player0index = Battle.GetPlayIndex(battleIndex, 0, 0) --获取下方0号位index
local player5index = Battle.GetPlayIndex(battleIndex, 0, 5) --获取下方0号位index
local type0 = Char.GetData(player0index,%对象_类型%)
-- local type5 = Char.GetData(player5index,%对象_类型%)
local type5 = Char.GetData(player5index,%对象_类型%)
-- local map = Char.GetData(player0index,%对象_地图%)
local map = -1
local Maptype = -1
if type0 == 1 then
Maptype = Char.GetData(player0index,%对象_地图类型%)
if Maptype == 0 then
map = Char.GetData(player0index,%对象_地图%)
elseif Maptype == 1 then
map = NLG.Get_Dungeonconf_Int(player0index,0)
end
elseif type5 == 1 then
Maptype = Char.GetData(player5index,%对象_地图类型%)
if Maptype == 0 then
map = Char.GetData(player5index,%对象_地图%)
elseif Maptype == 1 then
map = NLG.Get_Dungeonconf_Int(player5index,0)
end
end
local jilv = 18 --初始几率
if zuoqimap_tab[Maptype][map] then --若是练级点地图改为对应几率
jilv = zuoqimap_tab[Maptype][map]
end
-- NLG.SystemMessage(-1,"map="..map..",jilv="..jilv.."")
for x = f,1,-1 do
local s = math.random(1, 100) --作出道具出现的几率
if s > jilv then
-- NLG.SystemMessage(-1,"x="..x..",s="..s.."")
table.remove(zuoqiitem_tab[battleIndex],x) --删减表
end
end
local y = #(zuoqiitem_tab[battleIndex])
-- NLG.SystemMessage(-1,"y="..y.."")
if y <= 0 then
zuoqiitem_tab[battleIndex] = nil --回收道具表
-- NLG.SystemMessage(-1,"表回收")
elseif y >= 1 then -- 判断表长度大于等于1,即有道具
if zuoqidl_tab[battleIndex] == nil then --只触发一个玩家的表
for plNum = 0,9 do
local player = Battle.GetPlayIndex(battleIndex, 0, plNum) --获取下方对象索引
local p = Char.GetData(player, 0) --判断是什么对象类别
-- NLG.SystemMessage(-1,"player="..player..",p="..p.."")
if player >= 0 and p == 1 then
zuoqipl_tab[player] = {} --清空玩家分配道具表
zuoqidl_tab[battleIndex] = zuoqidl_tab[battleIndex] or {}
table.insert(zuoqidl_tab[battleIndex],player)--记录玩家索引
-- NLG.SystemMessage(-1,"tab="..zuoqidl_tab[battleIndex][plNum+1].."")
end
end
local z = #(zuoqidl_tab[battleIndex]) -- 计算表长度
-- NLG.SystemMessage(-1,"z="..z.."")
for a,b in pairs (zuoqiitem_tab[battleIndex]) do
local e = math.random (1,z)
local g = b..battleIndex
local player = zuoqidl_tab[battleIndex][e]
-- NLG.SystemMessage(-1,"e="..e..",player="..player.."")
-- NLG.SystemMessage(-1,"g="..g..",b="..b..",battleIndex="..battleIndex.."")
table.insert(zuoqipl_tab[player],g)
-- NLG.SystemMessage(-1,"e="..e..",g="..g.."")
end
zuoqidl_tab[battleIndex] = nil --回收玩家表
end
end
zuoqiitem_tab[battleIndex] = nil --回收道具表
end
end
return 0
end
|
|