Pular para o conteúdo
Ver no aplicativo

Uma forma melhor de navegar. Saiba mais.

Genesys Forum

Um aplicativo em tela cheia na sua tela inicial com notificações push, distintivos e mais.

Para instalar este aplicativo no iOS e iPadOS
  1. Toque no ícone Compartilhar no Safari
  2. Role o menu e toque em Adicionar à Tela de Início.
  3. Toque em Adicionar no canto superior direito.
Para instalar este aplicativo no Android
  1. Toque no menu de 3 pontos (⋮) no canto superior direito do navegador.
  2. Toque em Adicionar à tela inicial ou Instalar aplicativo.
  3. Confirme tocando em Instalar.

Upgraded the NpcExchange function. I have plenty of ideas for further improvements, so I'd like to share the NpcExchange.lua file I updated here.

Respostas Destacadas

  • Licença Plus

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.lua

NpcExchangeConfig = {

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 npcIndex

end

if LuaCore ~= nil and LuaCore.SafeCall ~= nil then

LuaCore.SafeCall("NpcExchange.SpawnNpc.Init", NpcExchange.SpawnNpc)

else

NpcExchange.SpawnNpc()

end

GameServerFunctions.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 true

end)

MuOnline

One single ding, the whole of MU Online unfolds.

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 Ltda

Holding de tecnologia, Software, Cloud, IA
e infraestrutura digital.

[email protected]  •  www.rivify.com.br

Av. Tiradentes, 960, 9.º andar, sala 2 — Luz
São Paulo/SP — CEP 01102-000
CNPJ 68.145.965/0001-06

Nos acompanhem nas redes @rivifybrasil

  • Autor
  • Licença Plus
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

MuOnline

One single ding, the whole of MU Online unfolds.

Participe da conversa

Você pode publicar agora e se cadastrar depois. Se você tem uma conta, entre agora para publicar com sua conta.

Convidado
Responder a este tópico...

Conta

Navegação

Procurar

Procurar

Configurar notificações push do navegador

Chrome (Android)
  1. Toque no ícone de cadeado ao lado da barra de endereços.
  2. Toque em Permissões → Notificações.
  3. Ajuste sua preferência.
Chrome (Desktop)
  1. Clique no ícone de cadeado na barra de endereços.
  2. Selecione Configurações do site.
  3. Encontre Notificações e ajuste sua preferência.