修改自muscipular的manapool.lua
想法源自http://bbs.cgmsv.com/thread-1402-1-1.html
功能如:
30以下免费使用血魔池,但只能充10000封顶
30以上需要使用血瓶兑换血池
30以上需要使用料理兑换魔池
改过的地方能注释都注释了
- --修改自muscipular的manapool.lua,wx18602101887
-
- local Module = ModuleBase:createModule('manaPool')
-
- local xue = 15615--可生产出的1000血瓶的编号
- local liaoli = 15218--可生产出的鱼翅汤编号
- local caijishangxian = 10000--新人免费血魔池充能上限
- local caijidengji = 30--新人保护,免费充能等级
-
- local itemList = {
- --想要1瓶血换大量补充,改value即可,蓝同理
- { name = '血池补充2000HP', image = 27243, price = 10, desc = '使用1瓶生命力回复药(2000),来补充血池使用量2000点,等级低于'..caijidengji..'的新人免费使用。', count = 1, maxCount = 999, value = 2000, type = 'lp' },
- --{ name = '血池补充(10000LP)', image = 27243, price = 14500, desc = '使用10瓶生命力回复药(1000),来补充血池使用量10000点', count = 1, maxCount = 999, value = 1000, type = 'lp' },
- --{ name = '血池补充(100000LP)', image = 27243, price = 140000, desc = '使用100瓶生命力回复药(1000),来补充血池使用量100000点', count = 1, maxCount = 999, value = 100000, type = 'lp' },
- --原先muscipular使用的魔池道具图档编号为26206
- { name = '魔池补充2000MP', image = 26745, price = 20, desc = '使用1碗鱼翅汤,来补充魔池使用量2000点,等级低于'..caijidengji..'的新人免费使用。', count = 1, maxCount = 999, value = 2000, type = 'fp' },
- --{ name = '魔池补充(10000FP)', image = 26745, price = 24500, desc = '使用10碗鱼翅汤,来补充魔池使用量10000点', count = 1, maxCount = 999, value = 10000, type = 'fp' },
- --{ name = '魔池补充(100000FP)', image = 26745, price = 240000, desc = '使用100碗鱼翅汤,来补充魔池使用量100000点', count = 1, maxCount = 999, value = 100000, type = 'fp' },
- }
-
- --- 加载模块钩子
- function Module:onLoad()
- self:logInfo('load')
- local npc = self:NPC_createNormal('血魔池科技', 100602, { map = 1000, x = 227, y = 83, direction = 4, mapType = 0 })
- self:NPC_regTalkedEvent(npc, Func.bind(self.onSellerTalked, self))
- self:NPC_regWindowTalkedEvent(npc, Func.bind(self.onSellerSelected, self));
- self:regCallback('ResetCharaBattleStateEvent', Func.bind(self.onBattleReset, self))
- end
-
- function Module:onBattleReset(charIndex)
- if Char.IsDummy(charIndex) then
- return
- end
- local lpPool = tonumber(Field.Get(charIndex, 'LpPool')) or 0;
- local fpPool = tonumber(Field.Get(charIndex, 'FpPool')) or 0;
- if lpPool <= 0 and fpPool <= 0 then
- return
- end
- local lp = Char.GetData(charIndex, CONST.CHAR_血)
- local maxLp = Char.GetData(charIndex, CONST.CHAR_最大血)
- local fp = Char.GetData(charIndex, CONST.CHAR_魔)
- local maxFp = Char.GetData(charIndex, CONST.CHAR_最大魔)
- if lpPool > 0 and lp < maxLp then
- lpPool = lpPool - maxLp + lp;
- if lpPool < 0 then
- maxLp = maxLp + lpPool;
- lpPool = 0;
- end
- --NLG.SystemMessage(charIndex, '[血魔池] 已恢复人物: ' .. (maxLp - lp) .. 'HP, 血池剩余: ' .. lpPool);
- NLG.Say(charIndex,-1,'[血池] 你回复了: ' .. (maxLp - lp) .. 'HP, 剩余: ' .. lpPool,11,2)
- else
- maxLp = lp;
- end
- if fpPool > 0 and fp < maxFp then
- fpPool = fpPool - maxFp + fp;
- if fpPool < 0 then
- maxFp = maxFp + fpPool;
- fpPool = 0;
- end
- --NLG.SystemMessage(charIndex, '[血魔池] 已恢复人物: ' .. (maxFp - fp) .. 'MP, 魔池剩余: ' .. fpPool);
- NLG.Say(charIndex,-1,'[魔池] 你回复了: ' .. (maxFp - fp) .. 'MP, 剩余: ' .. fpPool,8,2)
- else
- maxFp = fp;
- end
- Char.SetData(charIndex, CONST.CHAR_血, maxLp)
- Char.SetData(charIndex, CONST.CHAR_魔, maxFp)
- NLG.UpChar(charIndex);
- local petIndex = Char.GetData(charIndex, CONST.CHAR_战宠);
- if petIndex >= 0 then
- petIndex = Char.GetPet(charIndex, petIndex);
- lp = Char.GetData(petIndex, CONST.CHAR_血)
- maxLp = Char.GetData(petIndex, CONST.CHAR_最大血)
- fp = Char.GetData(petIndex, CONST.CHAR_魔)
- maxFp = Char.GetData(petIndex, CONST.CHAR_最大魔)
- if lpPool > 0 and lp < maxLp then
- lpPool = lpPool - maxLp + lp;
- if lpPool < 0 then
- maxLp = maxLp + lpPool;
- lpPool = 0;
- end
- --NLG.SystemMessage(charIndex, '[血魔池] 已恢复宠物: ' .. (maxLp - lp) .. 'HP, 血池剩余: ' .. lpPool);
- NLG.Say(charIndex,-1,'[血池] 宠物回复了: ' .. (maxLp - lp) .. 'HP, 剩余: ' .. lpPool,11,2)
- else
- maxLp = lp;
- end
- if fpPool > 0 and fp < maxFp then
- fpPool = fpPool - maxFp + fp;
- if fpPool < 0 then
- maxFp = maxFp + fpPool;
- fpPool = 0;
- end
- --NLG.SystemMessage(charIndex, '[血魔池] 已恢复宠物: ' .. (maxFp - fp) .. 'MP, 魔池剩余: ' .. fpPool);
- NLG.Say(charIndex,-1,'[魔池] 宠物回复了: ' .. (maxFp - fp) .. 'MP, 剩余: ' .. fpPool,8,2)
- else
- maxFp = fp;
- end
- Char.SetData(petIndex, CONST.CHAR_血, maxLp)
- Char.SetData(petIndex, CONST.CHAR_魔, maxFp)
- NLG.UpChar(petIndex);
- end
- Field.Set(charIndex, 'LpPool', tostring(lpPool));
- Field.Set(charIndex, 'FpPool', tostring(fpPool));
- end
-
- function Module:onSellerTalked(npc, player)
- if NLG.CanTalk(npc, player) then
- local dengji = Char.GetData(player, %对象_等级%)--获取玩家等级
- if dengji <= caijidengji then--新人保护,免费使用
- --NLG.SystemMessage(player, '你是'..caijidengji..'级及以下新人玩家,血魔池免费固定补充为:HP'..caijishangxian..'、MP'..caijishangxian..'。')
- Field.Set(player, 'LpPool', tonumber(caijishangxian))
- Field.Set(player, 'FpPool', tonumber(caijishangxian))
- NLG.ShowWindowTalked(player,npc,%窗口_信息框%,%按钮_确定%,666,'@c\n\n\n你是'..caijidengji..'级及以下新人玩家,血魔池免费固定补充为:HP'..caijishangxian..'、MP'..caijishangxian..'。')
- NLG.SystemMessage(player, '[血魔池] 补充血池: '..caijishangxian..', 共: '..caijishangxian..'');
- NLG.SystemMessage(player, '[血魔池] 补充魔池: '..caijishangxian..', 共: '..caijishangxian..'');
- NLG.SystemMessage(player, '新人,你已经获得强大buff,快去送。');
- NLG.WalkMove(player,4)--节约cpu
- NLG.WalkMove(player,4)--降低功耗
- return
- end
- NLG.ShowWindowTalked(player, npc, CONST.窗口_商店买, CONST.BUTTON_是, 0,
- self:NPC_buildBuyWindowData(101024, '血池黑科技', '充能血魔池', '金钱不足', '背包已满', itemList))
- end
- end
-
- function Module:onSellerSelected(npc, player, seqNo, select, data)
- local items = string.split(data, '|');
- local lpPool = tonumber(Field.Get(player, 'LpPool')) or 0;
- local fpPool = tonumber(Field.Get(player, 'FpPool')) or 0;
- local gold = Char.GetData(player, CONST.CHAR_金币)
- local totalGold = 0;
- local totalLp = 0;
- local totalFp = 0;
- local xpsl = 0--获取玩家商店点击血瓶数量
- local llsl = 0--获取玩家商店点击料理数量
- local dengji = Char.GetData(player, %对象_等级%)--获取玩家等级
- local youxp = Char.HaveItem(player,xue)--玩家身上血瓶数量
- local youll = Char.HaveItem(player,liaoli)--玩家身上料理数量
- for i = 1, #items / 2 do
- local c = itemList[items[(i - 1) * 2 + 1] + 1]
- if c then
- local count = (tonumber(items[(i - 1) * 2 + 2]) or 0);
- if c.type == 'lp' then--红
- totalLp = totalLp + c.value * count;
- xpsl = tonumber(count)
- print('玩家选择的红数量:'..xpsl..'')
- else--蓝
- totalFp = totalFp + c.value * count;
- llsl = tonumber(count)
- print('玩家选择的蓝数量:'..llsl..'')
- end
- totalGold = totalGold + c.price * count;
- end
- end
-
- if gold < totalGold then
- NLG.SystemMessage(player, '金币不足');
- return
- elseif dengji > caijidengji and xpsl > 0 and llsl > 0 and youxp < xpsl and youll < llsl then
- NLG.SystemMessage(player, '生命力回复药(1000)差 '..xpsl-youxp..' 瓶,鱼翅汤差 '..llsl-youll..' 碗,血魔池补充失败。')
- return
- elseif dengji > caijidengji and xpsl > 0 and youxp < xpsl then
- NLG.SystemMessage(player, '生命力回复药(1000)差 '..xpsl-youxp..' 瓶,血魔池补充失败。')
- return
- elseif dengji > caijidengji and llsl > 0 and youll < llsl then
- NLG.SystemMessage(player, '鱼翅汤差 '..llsl-youll..' 碗,血魔池补充失败。')
- return
- end
-
- Char.AddGold(player, -totalGold);
- if xpsl > 0 then
- Char.DelItem(player,xue,xpsl)
- end
- if llsl > 0 then
- Char.DelItem(player,liaoli,llsl)
- end
- Field.Set(player, 'LpPool', tostring(lpPool + totalLp));
- Field.Set(player, 'FpPool', tostring(fpPool + totalFp));
- NLG.UpChar(player);
- if totalLp > 0 then
- NLG.SystemMessage(player, '[血魔池] 补充血池: ' .. totalLp .. ', 共: ' .. (lpPool + totalLp));
- end
- if totalFp > 0 then
- NLG.SystemMessage(player, '[血魔池] 补充魔池: ' .. totalFp .. ', 共: ' .. (fpPool + totalFp));
- end
- end
-
- --- 卸载模块钩子
- function Module:onUnload()
- self:logInfo('unload')
- end
-
- return Module;
复制代码
|