魔力宝贝

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

[GP] friendgiveitem.lua--佣兵送礼模块

[复制链接]
发表于 5 天前 | 显示全部楼层 |阅读模式
--Global_Reg.RegInit("ybslScript");--自动启动函数
Global_Reg.RegBattleOverEvent ("NPC_mate_Over_res");--战斗结束回血
--[[
function ybslScript()
        NL.RegBattleGiveItem(nil,"yongbingsongli");--佣兵送礼
        return 0
end--]]

local ybsonglitab=ybsonglitab or {}
ybsonglitab[0]={}--N佣兵
ybsonglitab[0][1]=13--13
ybsonglitab[0][2]=16
ybsonglitab[0][3]=19
ybsonglitab[0][4]=22
ybsonglitab[0][5]=25
ybsonglitab[0][6]=28
ybsonglitab[0][7]=31
ybsonglitab[0][8]=34
ybsonglitab[0][9]=37
ybsonglitab[0][10]=40
ybsonglitab[1]={}
ybsonglitab[2]={}--SSR佣兵
ybsonglitab[2][1]=25
ybsonglitab[2][2]=29
ybsonglitab[2][3]=34
ybsonglitab[2][4]=38
ybsonglitab[2][5]=43
ybsonglitab[2][6]=47
ybsonglitab[2][7]=52
ybsonglitab[2][8]=56
ybsonglitab[2][9]=61
ybsonglitab[2][10]=65
ybsonglitab[3]={}
ybsonglitab[4]={}--UR佣兵
ybsonglitab[4][1]=20
ybsonglitab[4][2]=25
ybsonglitab[4][3]=30
ybsonglitab[4][4]=35
ybsonglitab[4][5]=40
ybsonglitab[4][6]=45
ybsonglitab[4][7]=50
ybsonglitab[4][8]=55
ybsonglitab[4][9]=60
ybsonglitab[4][10]=65
ybsonglitab[5]={}
ybsonglitab[6]={}
ybsonglitab[7]={}
ybsonglitab[8]={}--SR佣兵
ybsonglitab[8][1]=14
ybsonglitab[8][2]=18
ybsonglitab[8][3]=22
ybsonglitab[8][4]=26
ybsonglitab[8][5]=30
ybsonglitab[8][6]=34
ybsonglitab[8][7]=38
ybsonglitab[8][8]=42
ybsonglitab[8][9]=46
ybsonglitab[8][10]=50
ybsonglitab[9]={}--R佣兵
ybsonglitab[9][1]=14
ybsonglitab[9][2]=17
ybsonglitab[9][3]=21
ybsonglitab[9][4]=24
ybsonglitab[9][5]=28
ybsonglitab[9][6]=31
ybsonglitab[9][7]=35
ybsonglitab[9][8]=38
ybsonglitab[9][9]=42
ybsonglitab[9][10]=45

function NPC_mate_Over_res(battleIndex)
        local battype= Battle.GetType(battleIndex)
       
        if battype==1 then--PVE战斗
       
                for Num=0,9 do
                        local player = Battle.GetPlayIndex(battleIndex,0,Num)
                        if player >= 0 then
                                local job = Char.GetData(player,51)
                                local CDK = Char.GetData(player,2002)
                                local catordog = string.sub(CDK,-1,-1)
                                if job ==540 and catordog=="?" then
                                        local ItemIndex = Char.GetItemIndex(player,2)
                                        Char.SetData(player,150,0)
                                        Char.SetData(player,%对象_受伤%,0)
                                        local jiban=Item.GetData(ItemIndex,36)
                                        local chushi=0.3
                                        if jiban==2 then
                                                chushi=0.35
                                        elseif jiban==3 then
                                                chushi=0.4
                                        elseif jiban==4 then
                                                chushi=0.45
                                        elseif jiban==5 then
                                                chushi=0.5
                                        elseif jiban==6 then
                                                chushi=0.55
                                        elseif jiban==7 then
                                                chushi=0.6
                                        elseif jiban==8 then
                                                chushi=0.65
                                        elseif jiban==9 then
                                                chushi=0.7
                                        elseif jiban==10 then
                                                chushi=0.8
                                        end
                                        local maxhp=Char.GetData(player,%对象_最大血%)
                                        local hp=Char.GetData(player,%对象_血%)
                                        Char.SetData(player,%对象_血%,hp+math.floor(maxhp*chushi))
                                       
                                        local maxmp=Char.GetData(player,%对象_最大魔%)
                                        local mp=Char.GetData(player,%对象_魔%)
                                        Char.SetData(player,%对象_魔%,mp+math.floor(maxmp*chushi))
                                        local ItemIndex = Char.GetItemIndex(player,2);--获取武器的index
                                        local pettype = tonumber(Item.GetData(ItemIndex,2008))--获取使用的宠物代码(0~4)
                                        local petindex = Char.GetPetIndex(player,pettype) or -1
                                        if petindex>=0 then
                                                local zc = Char.GetData(petindex,312211)
                                                if zc<100 then
                                                        Char.SetData(petindex,312211,100)
                                                end
                                                Char.SetData(petindex,%对象_受伤%,0)
                                                local maxhp=Char.GetData(petindex,%对象_最大血%)
                                                local hp=Char.GetData(petindex,%对象_血%)
                                                Char.SetData(petindex,%对象_血%,hp+math.floor(maxhp*chushi))
                                               
                                                local maxmp=Char.GetData(petindex,%对象_最大魔%)
                                                local mp=Char.GetData(petindex,%对象_魔%)
                                                Char.SetData(petindex,%对象_魔%,mp+math.floor(maxmp*chushi))
                                                Pet.UpPet(player,pettype)
                                        end
                                        for i=0,7 do
                                                local nowitemindex=Char.GetItemIndex(player,i)
                                                if nowitemindex>=0 then
                                                        Item.SetData(nowitemindex,%道具_耐久%,Item.GetData(nowitemindex,%道具_最大耐久%))
                                                        Item.UpItem(player,i)
                                                end
                                        end
                                        NLG.UpChar(player)
                                elseif job ==540 and catordog=="!" then
                                        Char.SetData(player,150,0)
                                        Char.SetData(player,%对象_受伤%,0)
                                        local maxhp=Char.GetData(player,%对象_最大血%)
                                        local hp=Char.GetData(player,%对象_血%)
                                        Char.SetData(player,%对象_血%,hp+math.floor(maxhp*0.3))
                                       
                                        local maxmp=Char.GetData(player,%对象_最大魔%)
                                        local mp=Char.GetData(player,%对象_魔%)
                                        Char.SetData(player,%对象_魔%,mp+math.floor(maxmp*0.3))
                                       
                                        local petindex = Char.GetPetIndex(player,0) or -1
                                        if petindex>=0 then
                                                local zc = Char.GetData(petindex,312211)
                                                if zc<100 then
                                                        Char.SetData(petindex,312211,100)
                                                end
                                                Char.SetData(petindex,%对象_受伤%,0)
                                                local maxhp=Char.GetData(petindex,%对象_最大血%)
                                                local hp=Char.GetData(petindex,%对象_血%)
                                                Char.SetData(petindex,%对象_血%,hp+math.floor(maxhp*0.3))
                                               
                                                local maxmp=Char.GetData(petindex,%对象_最大魔%)
                                                local mp=Char.GetData(petindex,%对象_魔%)
                                                Char.SetData(petindex,%对象_魔%,mp+math.floor(maxmp*0.3))
                                                Pet.UpPet(player,0)
                                        end
                                        for i=0,7 do
                                                local nowitemindex=Char.GetItemIndex(player,i)
                                                if nowitemindex>=0 then
                                                        Item.SetData(nowitemindex,%道具_耐久%,Item.GetData(nowitemindex,%道具_最大耐久%))
                                                        Item.UpItem(player,i)
                                                end
                                        end
                                        NLG.UpChar(player)
                                end
                        end
                end
        elseif  battype==2 then--PVP战斗
                for side=0,1 do
                        for Num=0,9 do
                                local player = Battle.GetPlayIndex(battleIndex,side,Num)
                                if player>=0 then
                                        local job = Char.GetData(player,51)
                                        if job==540 then
                                                for i=0,7 do
                                                        local nowitemindex=Char.GetItemIndex(player,i)
                                                        if nowitemindex>=0 then
                                                                Item.SetData(nowitemindex,%道具_耐久%,Item.GetData(nowitemindex,%道具_最大耐久%))
                                                                Item.UpItem(player,i)
                                                        end
                                                end
                                        end
                                end
                        end
                end
        end
end

function yongbingsongli(BattleIndex,player,ItemList,EncountID)--佣兵送礼模块
        ItemList = zuoqi_diaoluozc(BattleIndex,player,ItemList,EncountID)
        --NLG.SystemMessage(-1,"触发成功")
        local job = Char.GetData(player,%对象_职类ID%)
        local CDK = Char.GetData(player,%对象_帐号%)
        local catordog = string.sub(CDK,-1,-1)
        if job ==540 and catordog=="?" then
                if ItemList[1] == -1 then
                        if ItemList[2] ~= -1 or ItemList[3] ~= -1 then
                                NLG.SystemMessage(player,"警告:出现掉落错误,请截图联系GM")
                        end
                        for i=8,12 do--清理一部分道具栏
                                local tNum = NLG.DelItemByPos(player, i);
                        end
                elseif ItemList[1]~= -1 then
                        local masterindex = Char.GetTeamIndex(player,0);
                        local Num = Char.FindEmptyItemBox(masterindex);
                        local pos =-1
                        if Num>=0 then
                                for i=8,47 do
                                        local ItemIndex2 = Char.GetItemIndex(masterindex,i);
                                        if ItemIndex2<=-1 then
                                                pos = i
                                                break
                                        end
                                end
                        end
                        local ybnamecolor = Char.GetData(player,%对象_名色%)--名色
                        local ybwqIndex = Char.GetItemIndex(player,2);
                        local ybjb = Item.GetData(ybwqIndex,36); --羁绊
                        if pos ~=-1 then
                                local sl = math.random(1,100)
                                if ybsonglitab[ybnamecolor][ybjb]>=sl then
                                        local name = Char.GetData(player,%对象_原名%)
                                        local itemname = Item.GetData(ItemList[1], %道具_已鉴定名%) or -1
                                        if itemname~=-1 then
                                                local itemid = Item.GetData(ItemList[1], %道具_ID%)
                                                NLG.GiveItem(masterindex, itemid,1);
                                                NLG.SystemMessage(masterindex,name.."将"..itemname.."送给了您")
                                        end
                                end
                        end
                end
                for i=1,3 do
                        if ItemList[i] ~= -1 then
                                Item.DeleteItemIndex(ItemList[i]);--销毁此物品索引,注意,此步骤不能省略。。
                                ItemList[i] = -1
                        end
                end
        end
        return ItemList;
end

回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-15 18:23 , Processed in 0.122965 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表