Junho 14junho 14 Licença Plus comment_200 Clear configuration list for easy setup, including levels, attributes and randomly exchangeable items.However, there is a minor bug. When multiple exchangeable gems are available simultaneously, they will be processed in the order specified in the NpcExchangeConfig.lua list.It would be better if a UI interaction could be added to support selective exchange.-- NpcExchangeConfig.luaNpcExchangeConfig = { npcClass = 381, npcMap = 0, npcX = 140, npcY = 120, npcDir = 3, checkPosition = true, priceZen = 10000, -- Default Item Attribute Settings rewardLevel = 13, rewardSkill = 1, rewardLuck = 1, rewardOption = 7, rewardExcellent = 63, -- Multi-plan Exchange List ExchangeRecipes = { { name = "Blessing Exchange", sec = 14, idx = 13, lvl = -1, count = 1, coin1 = 100, pool = {{0,13},{0,14},{0,15},{0,16}} }, { name = "Soul Exchange", sec = 14, idx = 14, lvl = -1, count = 1, coin1 = 200, pool = {{5,5},{5,10},{5,11}} }, { name = "Life Exchange", sec = 14, idx = 16, lvl = -1, count = 1, coin1 = 300, pool = {{8,5},{8,10},{8,11}} }, { name = "Creation Exchange", sec = 14, idx = 22, lvl = -1, count = 1, coin1 = 400, pool = {{9,5},{9,10},{9,11}} }, { name = "Chaos Exchange", sec = 12, idx = 15, lvl = -1, count = 1, coin1 = 400, pool = {{10,5},{10,10},{10,11}} } }}-- NpcExchange.lua-- NPC Auto Exchange Script (Randomized Stats & Level Version)local config = NpcExchangeConfig or {}NpcExchange = NpcExchange or {}function NpcExchange.SpawnNpc() local npcIndex = AddMonster(config.npcMap) if npcIndex == -1 then return -1 end SetMapMonster(npcIndex, config.npcMap, config.npcX, config.npcY) local npc = User.new(npcIndex) npc:setDir(config.npcDir) SetMonster(npcIndex, config.npcClass) npc:setType(3) LogPrint("NPC Exchange spawned.") return npcIndexendif LuaCore ~= nil and LuaCore.SafeCall ~= nil then LuaCore.SafeCall("NpcExchange.SpawnNpc.Init", NpcExchange.SpawnNpc)else NpcExchange.SpawnNpc()endGameServerFunctions.NpcTalk(function(npcIndex, playerIndex) local player = User.new(playerIndex) local npc = User.new(npcIndex) if npc:getClass() ~= config.npcClass then return false end -- 1. Matching Scheme local recipe = nil for _, v in ipairs(config.ExchangeRecipes) do if GetItemCount(playerIndex, v.sec, v.idx, v.lvl) >= v.count then recipe = v break end end if not recipe then SendMessage("NPC Lua: You do not have the required materials.", playerIndex, 1) return true end if player:getMoney() < config.priceZen then SendMessage("NPC Lua: Zen not enough.", playerIndex, 1) return true end -- 2. Deduct items and Zen TakeItem(playerIndex, recipe.sec, recipe.idx, recipe.lvl, recipe.count) player:addMoney(-config.priceZen) -- 3. Random attribute generation local rLevel = math.random(7, 15) -- Level: 7 to 15 local rLuck = math.random(0, 1) -- Luck: 0 or 1 local rOption = math.random(1, 7) -- Option: 1 to 7 local rExc = math.random(10, 63) -- Excellent: 10 to 63 -- 4. Distribute reward items with random attributes local item = recipe.pool[math.random(1, #recipe.pool)] -- Pass the randomized rLevel, rLuck, rOption, rExc GiveItem(playerIndex, item[1], item[2], rLevel, 0, 1, rLuck, rOption, rExc, 0, 0, 0, 0) -- 5. Distribute points if recipe.coin1 and recipe.coin1 > 0 then player:addCoin1(recipe.coin1) end SendMessage("NPC Lua: " .. recipe.name .. " completed!", playerIndex, 1) LogPrint(string.format("Exchange Success: %s | Recipe: %s | LV:%d L:%d O:%d E:%d", player:getName(), recipe.name, rLevel, rLuck, rOption, rExc)) return trueend) One single ding, the whole of MU Online unfolds. Relatório
Junho 15junho 15 comment_211 Thank you for sharing.This was the first script I made just for testing and I left it there as an idea, especially since Chaos Machine Genesis already does this, but this script could become something different, like just gems, or some specific event, that's why I left it like this.Feel free to modify it, your suggestion was very good. Rivify Brasil LtdaHolding de tecnologia, Software, Cloud, IAe infraestrutura digital.[email protected] • www.rivify.com.brAv. Tiradentes, 960, 9.º andar, sala 2 — LuzSão Paulo/SP — CEP 01102-000CNPJ 68.145.965/0001-06Nos acompanhem nas redes @rivifybrasil Relatório
Junho 15junho 15 Autor Licença Plus comment_212 22 minutos atrás, José Silva disse:Thank you for sharing.This was the first script I made just for testing and I left it there as an idea, especially since Chaos Machine Genesis already does this, but this script could become something different, like just gems, or some specific event, that's why I left it like this.Feel free to modify it, your suggestion was very good.In short, I think the execution logic you wrote is very rigorous.,nice One single ding, the whole of MU Online unfolds. Relatório
Participe da conversa
Você pode publicar agora e se cadastrar depois. Se você tem uma conta, entre agora para publicar com sua conta.