搜索
LUA

LUA

本版块未设置版块简介!请后台版块编辑添加。
  •  帖子: 115
  •  讨论: 115
  •  关注: 0

CacheStack.lua--血魔池

GA 发表于 2025-5-10 02:00:21 | 显示全部楼层 |阅读模式
109 0
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


回复

使用道具 举报

全部评论

暂无评论,期待您打破宁静

TA的帖子
相关帖子
  • admin 2025-5-10

    RegBattleGetProfitEvent NL.RegBattleGetProfitEvent(Dofile, FuncName) 函数功能 创 ...

  • admin 2025-5-10

    ShowTalked NLG.ShowTalked(PlayerIndex, NpcIndex) 函数功能 触发玩家和NPC对话窗口 ...

  • admin 2025-5-10

    GetStallItemPrice NLG.GetStallItemPrice(CharIndex) 函数功能 获取玩家对象的摆摊道 ...

  • admin 2025-5-10

    常量 (BIG5) 常量 常量值 %對象_點卷% -1 %對象_積分% -1 %寵物狀態_無% 0 %寵物狀態_ ...

  • admin 2025-5-10

    [*]常量 [*]常量 常量值 [*]%对象_点卷% -1 [*]%对象_积分% -1 [*]%宠物状态_无% 0 [* ...

  • admin 2025-5-10

    道具index道具index在Cgdev Lua引擎中所定义的Lua脚本中表示: [*]道具对象 道具index ...

  • admin 2025-5-10

    首先,到阿凯鲁法村找到NPC勇者阿黄那里得知深绿的山道附近总有奇怪的事情发生。 (你 ...

  • admin 2025-5-11

    简单的宠物改造任务 使用时请自行将道具放到自己服某个BOSS战斗中掉落 山羊 大狮子 P ...

  • admin 2025-5-11

    首先到教堂招魂的那个地方找到NPC牧师乌咝 和她对话 (年轻人,你相信爱情会是永远的 ...

  • admin 2025-5-11

    #####耐久版##### 道具? 魔石转化器 Cayenne_moshi_02.txt ITEM_useMystery 95 ...

发布 联系QQ