魔力宝贝

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

[GA] CacheStack.lua--血魔池

[复制链接]
发表于 前天 02:00 | 显示全部楼层 |阅读模式
local CacheStackItemList = {} --道具列表
CacheStackItemList[800510] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800511] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800512] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800513] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800514] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800515] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800516] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800517] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800518] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800519] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800520] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800521] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800522] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800523] = 1 --注册道具id为200的道具属于血魔储存道具
CacheStackItemList[800524] = 1 --注册道具id为200的道具属于血魔储存道具
-------------------------------------------------------
Delegate.RegDelLoginEvent("CacheStackLogin");
Delegate.RegDelBattleOverEvent("CacheStackBattleOverCallBack");

CacheStackMainTable = CacheStackMainTable or {}

function DelItemByPos(player,pos)
        local itemindex = Char.GetItemIndex(player,pos)
        if itemindex >= 0 then
                Item.SetData(itemindex,%道具_ID%,999999)
                Item.SetData(itemindex,%道具_堆叠数%,1)
        end
        Char.DelItem(player,999999,1)
end

function CacheStackLogin(player)
        CacheStackMainTable[player] = nil
end

function CacheStackBattleOverCallBack(battle)
        local battletype = Battle.GetType(battle)
        if battletype == %战斗_普通% then
                for i = 0,9 do
                        local playerindex = Battle.GetPlayer(battle,i)
                        if playerindex >= 0 then
                                if Char.GetData(playerindex,(%对象_序%)) == (%对象类型_人%) then
                                        if CacheStackMainTable[playerindex] then
                                                local hp = Char.GetData(playerindex,%对象_最大血%) - Char.GetData(playerindex,%对象_血%)
                                                local mp = Char.GetData(playerindex,%对象_最大魔%) - Char.GetData(playerindex,%对象_魔%)
                                                local hptemp = hp
                                                local mptemp = mp
                                                for j = 8,27 do
                                                        if hp > 0 or mp > 0 then
                                                                local itemindex = Char.GetItemIndex(playerindex,j)
                                                                if itemindex > 0 then
                                                                        local itemid = Item.GetData(itemindex,%道具_ID%)
                                                                        if CacheStackItemList[itemid] then
                                                                                local itemhp = Item.GetData(itemindex,%道具_生命%)
                                                                                local itemmp = Item.GetData(itemindex,%道具_魔力%)
                                                                                if hp > 0 then
                                                                                        if itemhp >= hp then
                                                                                                itemhp = itemhp - hp
                                                                                                hp = 0
                                                                                        else
                                                                                                hp = hp - itemhp
                                                                                                itemhp = 0
                                                                                        end
                                                                                end
                                                                                if mp > 0 then
                                                                                        if itemmp >= mp then
                                                                                                itemmp = itemmp - mp
                                                                                                mp = 0
                                                                                        else
                                                                                                mp = mp - itemmp
                                                                                                itemmp = 0
                                                                                        end
                                                                                end
                                                                                if itemhp > 0 or itemmp > 0 then
                                                                                        Item.SetData(itemindex,%道具_生命%,itemhp)
                                                                                        Item.SetData(itemindex,%道具_魔力%,itemmp)
                                                                                        Item.UpItem(playerindex,j)
                                                                                else
                                                                                        DelItemByPos(playerindex,j)
                                                                                end
                                                                        end
                                                                end
                                                        else
                                                                break
                                                        end
                                                end
                                                if hptemp == hp and mptemp == mp and hptemp > 0 and mptemp > 0 then
                                                        CacheStackMainTable[playerindex] = nil
                                                        NLG.SystemMessage(playerindex,"已自动停止自动补给。")
                                                else
                                                        Char.SetData(playerindex,%对象_血%,Char.GetData(playerindex,%对象_最大血%)-hp)
                                                        Char.SetData(playerindex,%对象_魔%,Char.GetData(playerindex,%对象_最大魔%)-mp)
                                                        NLG.UpChar(playerindex)
                                                        --NLG.SystemMessage(playerindex,"自动补充了"..(hptemp-hp).."生命和"..(mptemp-mp).."魔力。")
                                                end
                                        end
                                end
                        end
                end
        end
end


回复

使用道具 举报

Archiver|魔力研究社

GMT+8, 2025-5-12 18:06 , Processed in 0.127192 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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