Ir para conteúdo

[TFS 1.1/1.2] [ModalWindows] Alquimia Avançada


Posts Recomendados

Desculpa ae, to com tanto sono que coloquei na sessão errada.. era para aprovação de sistema e eu coloquei aqui.. da um desconto.. to acordado desde 3 da madruga de ontem :s

 

Antes de qualquer coisa o sistema foi feito pelo RazorBlade e eu pedi autorização para estar postando aqui, pois é um sistema super interessante e sei que muitos brs não tem a mínima noção de inglês..

Se curtiu da um rep ae.. posso não ter feito o sistema, mas testar, informar erros, esperar o Razor responder para arrumar, trazer para cá, traduzir e nada de tradutor online.. deixar arrumado da trabalho né :)

Se seguir todos os passos corretamente.. é esperado somente um erro.. olhar item no trade.. ainda estou esperando o razor corrigir.. houve uma alteração feita mas não corrigiu todo.. mas isso não afeta o funcionamento.. verá que é um ótimo sistema vale a pena conferir.. Testado e funcionando perfeitamente em 1.1 e 1.2

 

Vídeo para ter +- uma ideia de como funciona (o vídeo não é meu, o meu ainda n fiz upload)

 

 


Características


Características da Alquimia
- Opções de receitas
- Lista de receitas que o player aprendeu
- Lista de ingredientes necessários para fabricar a poção
- Fabricar poção
- Continuar a fabricar rapidamente se os requisitos forem cumpridos
- Lista de ingredientes
- Lista de ingredientes que podem ser usados, somente se o player os tiver na bp, não mostra os que não estão sendo carregados.
- Ver informação de cada ingredientes
- Efeitos que podem ser adicionados à poção
- Potência do ingredientes
- Adicionar ingredientes individualmente a panela
- Ver o conteúdo da panela em uma lista de ingredientes e da panela
- Remover ingredientes da panela
- Fabricar ingredientes da panela
- Efeitos das poções são definidos pelo numero de instancias dos ingredientes na panela, a categoria é decidida de forma randômica
- Exemplo: ingrediente x aumenta max hp e max mp, ingrediente y aumenta max mp e recupera hp, ingrediente z aumenta max hp e recupera mana. Tem somente um de cada ingrediente na panela, isso significa que temos 2x aumento de max mp, 2x de max hp, 1x recuperação de hp, 1x recuperação de mana. O efeito da poção será aumento de max hp ou mp, decidido de forma randômica, se houvesse 3x aumento de max hp e 2x de max mp o efeito seria garantidamente aumento de max hp.
- A potência da poção é decidida por dois fatores: Potência média de todos os ingredientes na panela, e +1 de potência para cada ingrediente que tenha o efeito "aumento de potência". A Potência não pode ser maior que 10 ou menor que 1 (configurável)
- A duração da poção é decidida pela base de 60 segundos +15 segundos para cada ingrediente que tenha o efeito "aumentar duração" por no máximo 2 minutos (configurável)
- Diferentes efeitos recebem diferentes bônus de potência, a quantidade de hp recuperada pela poção pode aumentar em 10 por cada potência, a mana pode aumentar em 5 ou outra qualquer (configurável)
- Se os ingredientes na panela puderem ser usados para fabricar com base em uma pré-receita, o jogador fabrica a receita e acaba aprendendo como fabricar rapidamente direto da lista de poções. Se ele não souber a receita a poção irá produzir somente um efeito com a duração variável e potência (se aplicado)
- Poções fabricadas de receitas aprendidas sempre irão ter a mesma duração e potência, mas podem ter múltiplos efeitos ao mesmo tempo. (configurável)
- Poções fabricadas de receitas aprendidas irão informar cada efeito individualmente com duração e valores ao dar look.

Características do subsistema de ingredientes
- Olhar um item que pode ser usado como ingrediente irá mostrar seu efeito - se voc~e tiver aprendido
- Cada ingrediente tem dois efeitos, o primeiro aprendido comendo/usando o ingrediente e o segundo ao usar o ingrediente em uma poção
- Cada ingrediente tem os dois efeitos e potências configuráveis, cada efeito tem uma storage para guardar que o player ja aprendeu isso.

Características do subsistema de poções
- Olhar a poção irá mostrar seu nome customizado, efeitos, duração, valores, etc.
- Usar a poção irá ativar o efeito em você (seja instantâneo ou condição)
- Função conveniente para guardar todas as informações sobre as poções para acesso em outro script ou funcionalidade - retorna uma tabela contendo todos os efeitos, valores, durações, o nome da poção e qualquer informação importante sobre
- Poções podem ser transferidas entre vials e outros containers e irão continuar funcionando perfeitamente

Efeitos
- Poções de cura - Recuperam Instantaneamente
-- Vida
-- Mana
-- Soul

- Poções de Regeneração - Regeneram mais rapidamente
-- Vida
-- Mana
-- Soul

- Poções de Resistência - Resiste, absorve, reflete, desvia de um tipo de dano ou de todos
-- Fogo
-- Energia
-- Terra
-- Gelo
-- Sagrado
-- Morte
-- Fisico
-- Todos

- Poções de velocidade - ¬¬ aumentam velocidade O.os

- Poções de Imunidade
-- Afogamento

- Poções de Skill - Aumentam skill em x
-- Punho
-- Corpo a corpo
-- Distancia
-- Defesa
-- Pesca

- Poções de fortificação - aumentam status
-- Vida
-- Mana



Para usar o sistema, (configurável) atualmente você deve usar um empty vial em um bowl with sacred water (id:12289)

-- ACTIONS
Em actions.xml adicione


<action itemid="5881" script="custom/alchemy.lua"/>
<action itemid="5898" script="custom/alchemy.lua"/>
<action itemid="5902" script="custom/alchemy.lua"/>
<action itemid="5920" script="custom/alchemy.lua"/>

 



crie uma pasta chamada custom e crie um arquivo chamado alchemy.lua e adicione isso


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    for i = 1, #aingredients do
        if item.itemid == aingredients[i].id then
            if player:getStorageValue(aingredients[i].storages[1]) ~= 1 then
                if aingredients[i].use == "with" and target == player then
                    item:remove(1)
                    player:setStorageValue(aingredients[i].storages[1], 1)
                    player:say("Kind of chewy...", TALKTYPE_MONSTER_SAY)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the effect " .. aeffects[aingredients[i].effects[1]].fullname .. " from the " .. aingredients[i].name .. "!")
                    return true
                elseif aingredients[i].use == "use" then
                    item:remove(1)
                    player:setStorageValue(aingredients[i].storages[1], 1)
                    player:say("Kind of chewy...", TALKTYPE_MONSTER_SAY)
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the effect " .. aeffects[aingredients[i].effects[1]].fullname .. " from the " .. aingredients[i].name .. "!")
                    return true
                end
            else
                if aingredients[i].use == "with" then
                    if target == player then
                        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already discovered the first effect for this item.")
                    else
                    return false
                    end
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already discovered the first effect for this item.")
                end
                return true
            end
        end
    end
    return false
end

 



é recomendado usar uma versão 'melhorada' do arquivo fluids.lua na pasta other, basta alterar todo seu conteúdo por isso


local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)

local poison = Condition(CONDITION_POISON)
poison:setParameter(CONDITION_PARAM_DELAYED, true)
poison:setParameter(CONDITION_PARAM_MINVALUE, -50)
poison:setParameter(CONDITION_PARAM_MAXVALUE, -120)
poison:setParameter(CONDITION_PARAM_STARTVALUE, -5)
poison:setParameter(CONDITION_PARAM_TICKINTERVAL, 4000)
poison:setParameter(CONDITION_PARAM_FORCEUPDATE, true)

local fluidType = {3, 4, 5, 7, 10, 11, 13, 15, 19}
local fluidMessage = {"Aah...", "Urgh!", "Mmmh.", "Aaaah...", "Aaaah...", "Urgh!", "Urgh!", "Aah...", "Urgh!"}
local specialFluids = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}
local specialMessages = {"Ugh.", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah...", "Aah..."}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        local targetItemType = ItemType(target.itemid)
        if targetItemType and targetItemType:isFluidContainer() then
                if target.type == 0 and item.type ~= 0 then
                        for i = 0, #specialFluids do
                                if item.type == specialFluids[i] then
                                        target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
                                        item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                                end
                        end
                        target:transform(target:getId(), item.type)
                        item:transform(item:getId(), 0)
                        return true
                elseif target.type ~= 0 and item.type == 0 then
                        for i = 0, #specialFluids do
                                if target.type == specialFluids[i] then
                                        item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, target:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
                                        target:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                                end
                        end
                        item:transform(item:getId(), target.type)
                        target:transform(target:getId(), 0)
                        return true
                end
        end
       
        if target:isCreature() then
                if item.type == 0 then
                        player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
                elseif target == player then
                        if item.type == 3 or item.type == 15 then
                                player:addCondition(drunk)
                        elseif item.type == 4 then
                                player:addCondition(poison)
                        elseif item.type == 7 then
                                player:addMana(math.random(50, 150))
                                fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
                        elseif item.type == 10 then
                                player:addHealth(60)
                                fromPosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
                        end
                        for i = 0, #fluidType do
                                if item.type == fluidType[i] then
                                        player:say(fluidMessage[i], TALKTYPE_MONSTER_SAY)
                                        item:transform(item:getId(), 0)
                                        return true
                                end
                        end
                        for i = 0, #specialFluids do
                                if item.type == specialFluids[i] then
                                        local effects = item:getEffects(item)
                                        usePotion(player, effects)
                                        player:say(specialMessages[i], TALKTYPE_MONSTER_SAY)
                                        item:transform(item:getId(), 0)
                                        item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                                        return true
                                end
                        end
                        item:transform(item:getId(), 0)
                        player:say("Gulp.", TALKTYPE_MONSTER_SAY)
                else
                        Game.createItem(2016, item.type, toPosition):decay()
                        item:transform(item:getId(), 0)
                end
        else
                local fluidSource = targetItemType and targetItemType:getFluidSource() or 0
                if fluidSource ~= 0 then
                        item:transform(item:getId(), fluidSource)
                elseif item.type == 0 then
                        if item:getId() == 2006 and target:getId() == 12289 then
                                player:sendAlchemyWindow()
                        else
                                player:sendTextMessage(MESSAGE_STATUS_SMALL, "It is empty.")
                        end
                else
                        if toPosition.x == CONTAINER_POSITION then
                                toPosition = player:getPosition()
                        end
                        for i = 0, #specialFluids do
                                if item.type == specialFluids[i] then
                                        item:removeAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                                end
                        end
                        Game.createItem(2016, item.type, toPosition):decay()
                        item:transform(item:getId(), 0)
                end
        end
        return true
end

 



-- CREATURESCRIPTS
Em creaturescripts.xml adicione


<event type="modalwindow" name="alchemy" script="alchemy.lua"/>
    <event type="healthchange" name="PotRes" script="potionResist.lua"/>

 



Registre em login.lua


player:registerEvent("alchemy")
    player:registerEvent("PotRes")

 



Crie em scripts o arquivo alchemy.lua e adicione isso


function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:ingredientWindowChoice(modalWindowId, buttonId, choiceId)
    player:alchemyWindowChoice(modalWindowId, buttonId, choiceId)
    player:potionWindowChoice(modalWindowId, buttonId, choiceId)
    player:potionRecipeWindowChoice(modalWindowId, buttonId, choiceId)
    player:infoWindowChoice(modalWindowId, buttonId, choiceId)
    player:bowlWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

 



Crie em scripts o arquivo potionResist.lua e adicione isso


local res = {
        {101, COMBAT_FIREDAMAGE}, {102, COMBAT_EARTHDAMAGE}, {103, COMBAT_ENERGYDAMAGE}, {104, COMBAT_ICEDAMAGE}, {105, COMBAT_HOLYDAMAGE}, {106, COMBAT_DEATHDAMAGE}, {107, COMBAT_PHYSICALDAMAGE}, {108, COMBAT_PHYSICALDAMAGE},
        {109, COMBAT_FIREDAMAGE},{110, COMBAT_EARTHDAMAGE}, {111, COMBAT_ENERGYDAMAGE}, {112, COMBAT_ICEDAMAGE}, {113, COMBAT_HOLYDAMAGE}, {114, COMBAT_DEATHDAMAGE}, {115, COMBAT_PHYSICALDAMAGE}, {116, COMBAT_PHYSICALDAMAGE},
        {117, COMBAT_FIREDAMAGE}, {118, COMBAT_EARTHDAMAGE}, {119, COMBAT_ENERGYDAMAGE}, {120, COMBAT_ICEDAMAGE}, {121, COMBAT_HOLYDAMAGE}, {122, COMBAT_DEATHDAMAGE}, {123, COMBAT_PHYSICALDAMAGE}, {124, COMBAT_PHYSICALDAMAGE},
        {125, COMBAT_FIREDAMAGE}, {126, COMBAT_EARTHDAMAGE}, {127, COMBAT_ENERGYDAMAGE}, {128, COMBAT_ICEDAMAGE}, {129, COMBAT_HOLYDAMAGE}, {130, COMBAT_DEATHDAMAGE}, {131, COMBAT_PHYSICALDAMAGE}, {132, COMBAT_PHYSICALDAMAGE},
}

local refs = {
        [COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
        [COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
        [COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
        [COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
        [COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
        [COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
        [COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isPlayer() then
                if primaryType == COMBAT_HEALING then
                        return primaryDamage, primaryType, secondaryDamage, secondaryType
                end
                if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 11) then
                        if primaryType == COMBAT_DROWNDAMAGE then
                                primaryDamage = 0
                        end
                        if secondaryType == COMBAT_DROWNDAMAGE then
                                secondaryDamage = 0
                        end
                end
                for i = 1, 8 do -- resist
                        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                                if primaryType == res[i][2] or i == 8 then
                                        primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                                end
                                if secondaryType == res[i][2] or i == 8 then
                                        secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                                end
                        end
                end
                for i = 9, 16 do -- reflect
                        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                                if not attacker then
                                        return primaryDamage, primaryType, secondaryDamage, secondaryType
                                end
                                if primaryType == res[i][2] or i == 16 then
                                        local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                                        if attacker:isMonster() then
                                                local m = MonsterType(attacker:getName())
                                                local e = m:getElementList()
                                                local f = m:getCombatImmunities()
                                                if type(f) == "number" then
                                                        if f == primaryType then
                                                                a = 0
                                                        end
                                                else
                                                        for i, j in pairs(f) do
                                                                if i == primaryType then
                                                                        a = 0
                                                                end
                                                        end
                                                end
                                                if type(e) == "number" then
                                                        if e == primaryType then
                                                                if e > 0 then
                                                                        a = (a - (a * (e / 100)))
                                                                else
                                                                        a = (a + (a * ((e * -1) / 100)))
                                                                end
                                                        end
                                                else
                                                        for i, j in pairs(e) do
                                                                if i == primaryType then
                                                                        if j > 0 then
                                                                                a = (a - (a * (j / 100)))
                                                                        else
                                                                                a = (a + (a * ((j * -1) / 100)))
                                                                        end
                                                                end
                                                        end
                                                end
                                        end
                                        doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                                end
                        end
                end
                for i = 17, 24 do -- deflect
                        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                                if not attacker then
                                        return primaryDamage, primaryType, secondaryDamage, secondaryType
                                end
                                if primaryType == res[i][2] or i == 24 then
                                        local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                                        if attacker:isMonster() then
                                       
                                                local m = MonsterType(attacker:getName())
                                                local e = m:getElementList()
                                                local f = m:getCombatImmunities()
                                                if type(f) == "number" then
                                                        if f == primaryType then
                                                                a = 0
                                                        end
                                                else
                                                        for i, j in pairs(f) do
                                                                if i == primaryType then
                                                                        a = 0
                                                                end
                                                        end
                                                end
                                                if type(e) == "number" then
                                                        if e == primaryType then
                                                                if e > 0 then
                                                                        a = (a - (a * (e / 100)))
                                                                else
                                                                        a = (a + (a * ((e * -1) / 100)))
                                                                end
                                                        end
                                                else
                                                        for i, j in pairs(e) do
                                                                if i == primaryType then
                                                                        if j > 0 then
                                                                                a = (a - (a * (j / 100)))
                                                                        else
                                                                                a = (a + (a * ((j * -1) / 100)))
                                                                        end
                                                                end
                                                        end
                                                end
                                        end
                                        doTargetCombatHealth(creature, attacker, primaryType, a, a, refs[primaryType])
                                        primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                                        secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                                end
                        end
                end
                for i = 25, 32 do
                        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, res[i][1]) then
                                if primaryType == res[i][2] or i == 32 then
                                        local a = math.floor(primaryDamage * (creature:getStorageValue(5) / 100))
                                        creature:addHealth(a)
                                        primaryDamage = (primaryDamage - (primaryDamage * (creature:getStorageValue(5) / 100)))
                                        secondaryDamage = (secondaryDamage - (secondaryDamage * (creature:getStorageValue(5) / 100)))
                                end
                        end
                end
    end
        if primaryDamage == 0 and secondaryDamage == 0 and creature:isPlayer() and not creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, 20) then
                creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, manaChange, origin)
    return manaChange
end

 



-- EVENTS
Em events.xml certifique-se de alterar ambas as linhas para 10


<event class="Player" method="onLook" enabled="1" />
<event class="Player" method="onLookInTrade" enabled="1" />

 



No arquivo player.lua procure por onLook e após isso

 

local description = "You see " .. thing:getDescription(distance)

 



adicione isso


local numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
        if thing:getId() == 2006 then
                local fluidType = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}
                if isInArray(fluidType, thing:getFluidType()) then
                        local effects = thing:getEffects(thing)
                        if effects[6] == 1 then
                                description = "You see a " .. apotency[tonumber(effects[4])].prefix .. " " .. effects[5] .. ".\n" .. thing:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                        elseif effects[6] == 2 then
                                description = "You see a " .. effects[5] .. ".\n" .. thing:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
                        end
                end
        end
        for i = 1, #aingredients do
                if thing:getId() == aingredients[i].id then
                        description = "You see " .. thing:getDescription(distance) .. "\nEffects:\n1: "
                        if self:getStorageValue(aingredients[i].storages[1]) == 1 then
                                description = description .. aeffects[aingredients[i].effects[1]].fullname
                        else
                                description = description .. "Unknown"
                        end
                        description = description .. "\n2: "
                        if self:getStorageValue(aingredients[i].storages[2]) == 1 then
                                description = description .. aeffects[aingredients[i].effects[2]].fullname
                        else
                                description = description .. "Unknown"
                        end
                end
        end

 



e em onLookIntrade você deveria ver isso

 

self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))

 



altere para isso


local description = "You see " .. item:getDescription(distance)
local numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
if item:getId() == 2006 then
local fluidType = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110}
if isInArray(fluidType, item:getFluidType()) then
local effects = item:getEffects(item)
if effects[6] == 1 then
description = "You see a " .. apotency[tonumber(effects[4])].prefix .. " " .. effects[5] .. ".\n" .. item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
elseif effects[6] == 2 then
description = "You see a " .. effects[5] .. ".\n" .. item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
end
end
end
for i = 1, #aingredients do
if item:getId() == aingredients[i].id then
description = "You see " .. item:getDescription(distance) .. "\nEffects:\n1: "
if self:getStorageValue(aingredients[i].storages[1]) == 1 then
description = description .. aeffects[aingredients[i].effects[1]].fullname
else
description = description .. "Unknown"
end
description = description .. "\n2: "
if self:getStorageValue(aingredients[i].storages[2]) == 1 then
description = description .. aeffects[aingredients[i].effects[2]].fullname
else
description = description .. "Unknown"
end
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. description)

 



--O SISTEMA PRINCIPAL

Em global.lua adicione

 

dofile('data/lib/alchemy.lua')
dofile('data/lib/func.lua')

 



dentro da pasta data/lib crie o arquivo alchemy.lua e adicione isso


-- config
local modalId = 1025

local bowl = {}
local recipe = {}
aingredients = {
        [1] = {name = "bonelord eye", id = 5898, effects = {"potency", "regenhp"}, storages = {20000, 20001}, potency = 1, use = "use"},
        [2] = {name = "honeycomb", id = 5902, effects = {"restorehp", "meleeup"}, storages = {20002, 20003}, potency = 3, use = "with"},
        [3] = {name = "lizard scale", id = 5881, effects = {"regenmp", "duration"}, storages = {20004, 20005}, potency = 1, use = "use"},
        [4] = {name = "green dragon scale", id = 5920, effects = {"absorball", "duration"}, storages = {20006, 20007}, potency = 4, use = "use"},
}

aeffects = {
        --["Name"] = {id = ID, fullname = "Full Name", dur = Duration, val = Value, p = IncreasePerPotency, label = "LabelOnItem"},
        ["restorehp"] = {id = 1, fullname = "Restore Health", dur = 0, val = 100, p = 20, label = "Health"},
        ["regenhp"] = {id = 2, fullname = "Regenerate Health", dur = 60, val = 10, p = 2, label = "HP Regen"},
        ["potency"] = {id = 3, fullname = "Increase Potency", dur = 0, val = 1, p = 0, label = "Potency"},
        ["meleeup"] = {id = 4, fullname = "Increase Melee Skill", dur = 60, val = 2, p = 1, label = "Melee"},
        ["duration"] = {id = 5, fullname = "Increase Duration", dur = 0, val = 12, p = 0, label = "Duration"},
        ["restoremp"] = {id = 6, fullname = "Restore Mana", dur = 0, val = 100, p = 20, label = "Mana"},
        ["regenmp"] = {id = 7, fullname = "Regenerate Mana", dur = 60, val = 20, p = 4, label = "MP Regen"},
        ["maxhp"] = {id = 8, fullname = "Fortify Health", dur = 60, val = 200, p = 25, label = "Max HP"},
        ["maxmp"] = {id = 9, fullname = "Fortify Mana", dur = 60, val = 200, p = 25, label = "Max MP"},
        ["speed"] = {id = 10, fullname = "Increase Speed", dur = 60, val = 40, p = 10, label = "Speed"},
        ["fistup"] = {id = 11, fullname = "Increase Fist Skill", dur = 60, val = 2, p = 1, label = "Fist"},
        ["distup"] = {id = 12, fullname = "Increase Distance Skill", dur = 60, val = 2, p = 1, label = "Distance"},
        ["shieldup"] = {id = 13, fullname = "Increase Shielding Skill", dur = 60, val = 2, p = 1, label = "Shielding"},
        ["fishup"] = {id = 14, fullname = "Increase Fishing Skill", dur = 60, val = 2, p = 1, label = "Fishing"},
        ["resistfire"] = {id = 15, fullname = "Resist Fire", dur = 60, val = 5, p = 2, label = "Fire Percent"},
        ["resistearth"] = {id = 16, fullname = "Resist Earth", dur = 60, val = 5, p = 2, label = "Earth Percent"},
        ["resistenergy"] = {id = 17, fullname = "Resist Energy", dur = 60, val = 5, p = 2, label = "Energy Percent"},
        ["resistice"] = {id = 18, fullname = "Resist Ice", dur = 60, val = 5, p = 2, label = "Ice Percent"},
        ["resistdeath"] = {id = 19, fullname = "Resist Death", dur = 60, val = 5, p = 2, label = "Death Percent"},
        ["resistholy"] = {id = 20, fullname = "Resist Holy", dur = 60, val = 5, p = 2, label = "Holy Percent"},
        ["resistphysical"] = {id = 21, fullname = "Resist Physical", dur = 60, val = 5, p = 2, label = "Physical Percent"},
        ["absorbfire"] = {id = 22, fullname = "Absorb Fire", dur = 60, val = 5, p = 2, label = "Fire Percent"},
        ["absorbearth"] = {id = 23, fullname = "Absorb Earth", dur = 60, val = 5, p = 2, label = "Earth Percent"},
        ["absorbenergy"] = {id = 24, fullname = "Absorb Energy", dur = 60, val = 5, p = 2, label = "Energy Percent"},
        ["absorbice"] = {id = 25, fullname = "Absorb Ice", dur = 60, val = 5, p = 2, label = "Ice Percent"},
        ["absorbdeath"] = {id = 26, fullname = "Absorb Death", dur = 60, val = 5, p = 2, label = "Death Percent"},
        ["absorbholy"] = {id = 27, fullname = "Absorb Holy", dur = 60, val = 5, p = 2, label = "Holy Percent"},
        ["absorbphysical"] = {id = 28, fullname = "Absorb Physical", dur = 60, val = 5, p = 2, label = "Physical Percent"},
        ["reflectfire"] = {id = 29, fullname = "Reflect Fire", dur = 60, val = 5, p = 2, label = "Fire Percent"},
        ["reflectearth"] = {id = 30, fullname = "Reflect Earth", dur = 60, val = 5, p = 2, label = "Earth Percent"},
        ["reflectenergy"] = {id = 31, fullname = "Reflect Energy", dur = 60, val = 5, p = 2, label = "Energy Percent"},
        ["reflectice"] = {id = 32, fullname = "Reflect Ice", dur = 60, val = 5, p = 2, label = "Ice Percent"},
        ["reflectdeath"] = {id = 33, fullname = "Reflect Death", dur = 60, val = 5, p = 2, label = "Death Percent"},
        ["reflectholy"] = {id = 34, fullname = "Reflect Holy", dur = 60, val = 5, p = 2, label = "Holy Percent"},
        ["reflectphysical"] = {id = 35, fullname = "Reflect Physical", dur = 60, val = 5, p = 2, label = "Physical Percent"},
        ["deflectfire"] = {id = 36, fullname = "Deflect Fire", dur = 60, val = 5, p = 2, label = "Fire Percent"},
        ["deflectearth"] = {id = 37, fullname = "Deflect Earth", dur = 60, val = 5, p = 2, label = "Earth Percent"},
        ["deflectenergy"] = {id = 38, fullname = "Deflect Energy", dur = 60, val = 5, p = 2, label = "Energy Percent"},
        ["deflectice"] = {id = 39, fullname = "Deflect Ice", dur = 60, val = 5, p = 2, label = "Ice Percent"},
        ["deflectdeath"] = {id = 40, fullname = "Deflect Death", dur = 60, val = 5, p = 2, label = "Death Percent"},
        ["deflectholy"] = {id = 41, fullname = "Deflect Holy", dur = 60, val = 5, p = 2, label = "Holy Percent"},
        ["deflectphysical"] = {id = 42, fullname = "Deflect Physical", dur = 60, val = 5, p = 2, label = "Physical Percent"},
        ["resistall"] = {id = 43, fullname = "Resist All", dur = 60, val = 5, p = 2, label = "All Percent"},
        ["absorball"] = {id = 44, fullname = "Absorb All", dur = 60, val = 5, p = 2, label = "All Percent"},
        ["reflectall"] = {id = 45, fullname = "Reflect All", dur = 60, val = 5, p = 2, label = "All Percent"},
        ["deflectall"] = {id = 46, fullname = "Deflect All", dur = 60, val = 5, p = 2, label = "All Percent"},
        ["restoresoul"] = {id = 47, fullname = "Restore Soul", dur = 0, val = 10, p = 2, label = "Soul"},
        ["regensoul"] = {id = 48, fullname = "Regenerate Soul", dur = 60, val = 2, p = 1, label = "Soul Regen"},
        ["drown"] = {id = 49, fullname = "Waterbreathing", dur = 60, val = 100, p = 0, label = "Drown Percent"},
}

arecipes = {
        [1] = {name = "Potion of Double Heal", id = 42, effects = {"restorehp", "regenhp"}, values = {200, 10}, durations = {0, 60}, ingredients = {
                [1] = {name = "bonelord eye", id = 5898, count = 1},
                [2] = {name = "honeycomb", id = 5902, count = 2}
        }, storage = 30000},
        [2] = {name = "Potion of the Warrior", id = 43, effects = {"restorehp", "meleeup", "regenhp"}, values = {500, 5, 40}, durations = {0, 120, 120}, ingredients = {
                [1] = {name = "bonelord eye", id = 5898, count = 7},
                [2] = {name = "honeycomb", id = 5902, count = 2},
                [3] = {name = "lizard scale", id = 5881, count = 4}
        }, storage = 30001},
        [3] = {name = "Potion of the Fire God", id = 50, effects = {"drown"}, values = {100}, durations = {120}, ingredients = {
                [1] = {name = "bonelord eye", id = 5898, count = 1},
                [2] = {name = "honeycomb", id = 5902, count = 2},
                [3] = {name = "lizard scale", id = 5881, count = 1}
        }, storage = 30002},
        [4] = {name = "Potion of the Earth God", id = 51, effects = {"deflectall"}, values = {80}, durations = {120}, ingredients = {
                [1] = {name = "bonelord eye", id = 5898, count = 1},
                [2] = {name = "lizard scale", id = 5881, count = 1}
        }, storage = 30003},
}

apotions = {
        [1] = {name = "Potion of Restore Health", id = 58, effect = "restorehp"},
        [2] = {name = "Potion of Regenerate Health", id = 66, effect = "regenhp"},
        [4] = {name = "Potion of Increase Melee Skill", id = 38, effect = "meleeup"},
        [6] = {name = "Potion of Restore Mana", id = 39, effect = "restoremp"},
        [7] = {name = "Potion of Regenerate Mana", id = 47, effect = "regenmp"},
        [8] = {name = "Potion of Fortify Health", id = 74, effect = "maxhp"},
        [9] = {name = "Potion of Fortify Mana", id = 55, effect = "maxmp"},
        [10] = {name = "Potion of Speed", id = 37, effect = "speed"},
        [11] = {name = "Potion of Increase Fist Skill", id = 46, effect = "fistup"},
        [12] = {name = "Potion of Increase Distance Skill", id = 54, effect = "distup"},
        [13] = {name = "Potion of Increase Shielding Skill", id = 61, effect = "shieldup"},
        [14] = {name = "Potion of Increase Fishing Skill", id = 41, effect = "fishup"},
        [15] = {name = "Potion of Resistance", id = 82, effect = "resistfire"},
        [16] = {name = "Potion of Resistance", id = 36, effect = "resistearth"},
        [17] = {name = "Potion of Resistance", id = 63, effect = "resistenergy"},
        [18] = {name = "Potion of Resistance", id = 49, effect = "resistice"},
        [19] = {name = "Potion of Resistance", id = 45, effect = "resistholy"},
        [20] = {name = "Potion of Resistance", id = 43, effect = "resistdeath"},
        [21] = {name = "Potion of Resistance", id = 62, effect = "resistphysical"},
        [22] = {name = "Potion of Absorption", id = 90, effect = "absorbfire"},
        [23] = {name = "Potion of Absorption", id = 44, effect = "absorbearth"},
        [24] = {name = "Potion of Absorption", id = 71, effect = "absorbenergy"},
        [25] = {name = "Potion of Absorption", id = 57, effect = "absorbice"},
        [26] = {name = "Potion of Absorption", id = 53, effect = "absorbholy"},
        [27] = {name = "Potion of Absorption", id = 51, effect = "absorbdeath"},
        [28] = {name = "Potion of Absorption", id = 70, effect = "absorbphysical"},
        [29] = {name = "Potion of Reflection", id = 98, effect = "reflectfire"},
        [39] = {name = "Potion of Reflection", id = 52, effect = "reflectearth"},
        [31] = {name = "Potion of Reflection", id = 79, effect = "reflectenergy"},
        [32] = {name = "Potion of Reflection", id = 65, effect = "reflectice"},
        [33] = {name = "Potion of Reflection", id = 61, effect = "reflectholy"},
        [34] = {name = "Potion of Reflection", id = 59, effect = "reflectdeath"},
        [35] = {name = "Potion of Reflection", id = 78, effect = "reflectphysical"},
        [36] = {name = "Potion of Deflection", id = 106, effect = "deflectfire"},
        [37] = {name = "Potion of Deflection", id = 60, effect = "deflectearth"},
        [38] = {name = "Potion of Deflection", id = 87, effect = "deflectenergy"},
        [39] = {name = "Potion of Deflection", id = 73, effect = "deflectice"},
        [40] = {name = "Potion of Deflection", id = 69, effect = "deflectholy"},
        [41] = {name = "Potion of Deflection", id = 67, effect = "deflectdeath"},
        [42] = {name = "Potion of Deflection", id = 86, effect = "deflectphysical"},
        [43] = {name = "Potion of Resistance", id = 91, effect = "resistall"},
        [44] = {name = "Potion of Absorption", id = 76, effect = "absorball"},
        [45] = {name = "Potion of Reflection", id = 77, effect = "reflectall"},
        [46] = {name = "Potion of Deflection", id = 94, effect = "deflectall"},
        [47] = {name = "Potion of Restore Soul", id = 102, effect = "restoresoul"},
        [48] = {name = "Potion of Regenerate Soul", id = 110, effect = "regensoul"},
        [49] = {name = "Potion of Waterbreathing", id = 89, effect = "drown"},
}

apotionids = {
        [58] = {name = "Potion of Restore Health", id = 1, effect = "restorehp"},
        [66] = {name = "Potion of Regenerate Health", id = 2, effect = "regenhp"},
        [38] = {name = "Potion of Increase Melee Skill", id = 4, effect = "meleeup"},
        [39] = {name = "Potion of Restore Mana", id = 6, effect = "restoremp"},
        [47] = {name = "Potion of Regenerate Mana", id = 7, effect = "regenmp"},
        [74] = {name = "Potion of Fortify Health", id = 8, effect = "maxhp"},
        [55] = {name = "Potion of Fortify Mana", id = 9, effect = "maxmp"},
        [37] = {name = "Potion of Speed", id = 10, effect = "speed"},
        [46] = {name = "Potion of Increase Fist Skill", id = 11, effect = "fistup"},
        [54] = {name = "Potion of Increase Distance Skill", id = 12, effect = "distup"},
        [61] = {name = "Potion of Increase Shielding Skill", id = 13, effect = "shieldup"},
        [41] = {name = "Potion of Increase Fishing Skill", id = 14, effect = "fishup"},
        [82] = {name = "Potion of Resistance", id = 15, effect = "resistfire"},
        [36] = {name = "Potion of Resistance", id = 16, effect = "resistearth"},
        [63] = {name = "Potion of Resistance", id = 17, effect = "resistenergy"},
        [49] = {name = "Potion of Resistance", id = 18, effect = "resistice"},
        [45] = {name = "Potion of Resistance", id = 19, effect = "resistholy"},
        [43] = {name = "Potion of Resistance", id = 20, effect = "resistdeath"},
        [62] = {name = "Potion of Resistance", id = 21, effect = "resistphysical"},
        [90] = {name = "Potion of Absorption", id = 22, effect = "absorbfire"},
        [44] = {name = "Potion of Absorption", id = 23, effect = "absorbearth"},
        [71] = {name = "Potion of Absorption", id = 24, effect = "absorbenergy"},
        [57] = {name = "Potion of Absorption", id = 25, effect = "absorbice"},
        [53] = {name = "Potion of Absorption", id = 26, effect = "absorbholy"},
        [51] = {name = "Potion of Absorption", id = 27, effect = "absorbdeath"},
        [70] = {name = "Potion of Absorption", id = 28, effect = "absorbphysical"},
        [98] = {name = "Potion of Reflection", id = 29, effect = "reflectfire"},
        [52] = {name = "Potion of Reflection", id = 30, effect = "reflectearth"},
        [79] = {name = "Potion of Reflection", id = 31, effect = "reflectenergy"},
        [65] = {name = "Potion of Reflection", id = 32, effect = "reflectice"},
        [61] = {name = "Potion of Reflection", id = 33, effect = "reflectholy"},
        [59] = {name = "Potion of Reflection", id = 34, effect = "reflectdeath"},
        [78] = {name = "Potion of Reflection", id = 35, effect = "reflectphysical"},
        [106] = {name = "Potion of Deflection", id = 36, effect = "deflectfire"},
        [60] = {name = "Potion of Deflection", id = 37, effect = "deflectearth"},
        [87] = {name = "Potion of Deflection", id = 38, effect = "deflectenergy"},
        [73] = {name = "Potion of Deflection", id = 39, effect = "deflectice"},
        [69] = {name = "Potion of Deflection", id = 40, effect = "deflectholy"},
        [67] = {name = "Potion of Deflection", id = 41, effect = "deflectdeath"},
        [86] = {name = "Potion of Deflection", id = 42, effect = "deflectphysical"},
        [91] = {name = "Potion of Resistance", id = 43, effect = "resistall"},
        [76] = {name = "Potion of Absorption", id = 44, effect = "absorball"},
        [77] = {name = "Potion of Reflection", id = 45, effect = "reflectall"},
        [94] = {name = "Potion of Deflection", id = 46, effect = "deflectall"},
        [102] = {name = "Potion of Restore Soul", id = 47, effect = "restoresoul"},
        [110] = {name = "Potion of Regenerate Soul", id = 48, effect = "regensoul"},
        [89] = {name = "Potion of Waterbreathing", id = 49, effect = "drown"},
}

apotency = {
        [0] = {prefix = ""},
        [1] = {prefix = "Minor"},
        [2] = {prefix = "Minor"},
        [3] = {prefix = "Strong"},
        [4] = {prefix = "Strong"},
        [5] = {prefix = "Powerful"},
        [6] = {prefix = "Powerful"},
        [7] = {prefix = "Major"},
        [8] = {prefix = "Major"},
        [9] = {prefix = "Great"},
        [10] = {prefix = "Great"},
}

function Player:hasIn(recipe)
        for i = 1, #arecipes[recipe].ingredients do
                if self:getItemCount(arecipes[recipe].ingredients[i].id) < arecipes[recipe].ingredients[i].count then
                        return false
                end
        end
        return true
end

function Player:decidePotion()
        local id = self:getGuid()
        local ing = {}
        local ingc = {}
        local pm = false
        local pmp = 0
        for i = 1, #bowl[id] do
                if not isInArray(ing, aingredients[bowl[id][i]].name) then
                        ing[#ing + 1] = aingredients[bowl[id][i]].name
                        ingc[aingredients[bowl[id][i]].name] = 1
                else
                        ingc[aingredients[bowl[id][i]].name] = ingc[aingredients[bowl[id][i]].name] + 1
                end
        end
        local cingc = 0
        for k, v in pairs(ingc) do
                cingc = cingc + 1
        end
        for i = 1, #arecipes do
                if pmp > 0 then
                        break
                end
                if #arecipes[i].ingredients == cingc then
                        for j = 1, #arecipes[i].ingredients do
                                if isInArray(ing, arecipes[i].ingredients[j].name) then
                                        if ingc[arecipes[i].ingredients[j].name] ~= arecipes[i].ingredients[j].count then
                                                pmp = 0
                                                break
                                        else
                                                pmp = i
                                        end
                                else
                                        pmp = 0
                                        break
                                end
                        end
                end
        end
        if pmp ~= 0 then
                pm = true
        end
        for i = 1, #arecipes do
                for j = 1, #bowl[id] do
                       
                end
        end
       
        local e = {} -- effects
        local n = {} -- effect counters
        local f = 0 -- final effect
        local pot = 1
        local dur = 0
        local ptemp = 0
       
        for i = 1, #bowl[id] do
                ptemp = ptemp + aingredients[bowl[id][i]].potency
        end
        local function round(num, idp)
                local mult = 10^(idp or 0)
                return math.floor(num * mult + 0.5) / mult
        end
        ptemp = round(ptemp / #bowl[id], 0)
       
        pot = math.max(pot, ptemp)
        for i = 1, #bowl[id] do
                for j = 1, 2 do
                        if aingredients[bowl[id][i]].effects[j] ~= "potency" and aingredients[bowl[id][i]].effects[j] ~= "duration" then
                                if not isInArray(e, aingredients[bowl[id][i]].effects[j]) then
                                        e[#e + 1] = aingredients[bowl[id][i]].effects[j]
                                        n[aeffects[aingredients[bowl[id][i]].effects[j]].id] = 1
                                else
                                        n[aeffects[aingredients[bowl[id][i]].effects[j]].id] = n[aeffects[aingredients[bowl[id][i]].effects[j]].id] + 1
                                end
                        else
                                if aingredients[bowl[id][i]].effects[j] == "potency" then
                                        if pot < 10 then
                                                pot = pot + aeffects[aingredients[bowl[id][i]].effects[j]].val
                                                if pot > 10 then
                                                        pot = 10
                                                end
                                        end
                                end
                                if aingredients[bowl[id][i]].effects[j] == "duration" then
                                        if dur < 60 then
                                                dur = dur + aeffects[aingredients[bowl[id][i]].effects[j]].val
                                        end
                                        if dur > 60 then
                                                dur = 60
                                        end
                                end
                        end
                end
        end
        local h = 0 -- highest
        local s = 0 -- spot of highest
        local t = {} -- ties
        local ts = {} -- spots of ties
        for k, v in pairs(n) do
                if n[k] > h then
                        h = n[k]
                        s = k
                       
                elseif n[k] == h then
                        t[#t + 1] = n[k]
                        ts[#ts + 1] = k
                end
                if #t > 0 then
                        for i = 1, #t do
                                if #t < i then
                                        break
                                end
                                if h > t[i] then
                                        table.remove(t, i)
                                        table.remove(ts, i)
                                end
                        end
                end
        end
        if #t > 0 then
                t[#t + 1] = h
                ts[#ts + 1] = s
                f = ts[math.random(1,#ts)]
        else
                f = s
        end
        local temp = 0
        for k, v in pairs(aeffects) do
                if aeffects[k].id == f then
                        temp = k
                end
        end
        if pm then
                if self:getStorageValue(arecipes[pmp].storage) ~= 1 then
                        self:setStorageValue(arecipes[pmp].storage, 1)
                        self:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the recipe for the " .. arecipes[pmp].name .. "!")
                end
                local pass = {arecipes[pmp], pot, dur, 1}
                return pass
        else
                local pass = {apotions[aeffects[temp].id], pot, dur, 2}
                return pass
        end
end

function Player:sendAlchemyWindow()
        local window = ModalWindow(modalId, "Alchemy", "Choose from the options below. You can create potions that you know recipes for, or try to combine ingredients to create something new.")
        local p = self:getGuid()
        if bowl[p] == nil then
                bowl[p] = {}
        end
        if recipe[p] == nil then
                recipe[p] = {}
        end
        window:addChoice(1, "Ingredients")
        window:addChoice(2, "Potions")

        window:addButton(1, "Enter")
        window:setDefaultEnterButton(1)
        window:addButton(2, "Exit")
        window:setDefaultEscapeButton(2)
        window:sendToPlayer(self)
        return true
end


function Player:sendIngredientWindow()
        local window = ModalWindow(modalId + 1, "Ingredients", "Add ingredients to the bowl or check the info for your ingredients.\nOnly ingredients you're carrying will appear here.\n")
        local temp = 0
        local p = self:getGuid()
        for i = 1, #aingredients do
                if self:getItemCount(aingredients[i].id) >= 1 then
                        temp = temp + 1
                end
        end
        if temp == 0 then
                window:setMessage(window:getMessage() .. "You have no usable ingredients.\n")
                window:setDefaultEnterButton(4)
        else
                window:addButton(1, "Info")
                window:setDefaultEnterButton(1)
                window:addButton(2, "Add")
               
        end
        if not bowl[p] then
                bowl[p] = {}
        end
        if #bowl[p] == 0 then
                window:setMessage(window:getMessage() .. "The bowl is empty\n")
        else
                window:setMessage(window:getMessage() .. "The bowl contains:\n")
                window:addButton(3, "Bowl")
        end
        for i = 1, #bowl[p] do
                window:setMessage(window:getMessage() .. aingredients[bowl[p][i]].name .. "\n")
        end
       
        for i = 1, #aingredients do
                if self:getItemCount(aingredients[i].id) then
                        local pc = self:getItemCount(aingredients[i].id)
                        local c = 0
                        for j = 1, #bowl[p] do
                                if aingredients[bowl[p][j]].id == aingredients[i].id then
                                        c = c + 1
                                end
                        end
                        if c > 0 then
                                pc = pc - c
                        end
                        if c > 0 or pc > 0 then
                                window:addChoice(i, aingredients[i].name .. " (" .. pc .. ")")
                        end
                end
        end
       
       
       
        window:addButton(4, "Back")
        window:setDefaultEscapeButton(4)
        window:sendToPlayer(self)
        return true
end

function Player:sendInfoWindow(choice)
        local window = ModalWindow(modalId + 2, aingredients[choice].name, "This ingredient has the following effects:\n")
        local choices = 0
        local temp = 0
        for i = 1, 2 do
                if self:getStorageValue(aingredients[choice].storages[i]) == 1 then
                        window:setMessage(window:getMessage() .. aeffects[aingredients[choice].effects[i]].fullname .. "\n")
                else
                        window:setMessage(window:getMessage() .. "Unknown\n")
                end
        end
        window:addButton(1, "Back")
        window:setDefaultEnterButton(1)
        window:setDefaultEscapeButton(1)
        window:sendToPlayer(self)
        return true
end

function Player:sendPotionWindow()
        local window = ModalWindow(modalId + 3, "Potion Recipes", "Choose from the recipes you know and view the requirements:\n")
        local temp = 0
        for i = 1, #arecipes do
                if self:getStorageValue(arecipes[i].storage) == 1 then
                        window:addChoice(i, arecipes[i].name)
                        temp = temp + 1
                end
        end
        if temp == 0 then
                window:setMessage(window:getMessage() .. "You do not know any recipes.\n")
                window:setDefaultEnterButton(2)
        else
                window:addButton(1, "Recipe")
                window:setDefaultEnterButton(1)
        end
        window:addButton(2, "Back")
        window:setDefaultEscapeButton(2)
        window:sendToPlayer(self)
        return true
end

function Player:sendPotionRecipeWindow(choice)
        local window = ModalWindow(modalId + 4, arecipes[choice].name, "To create this potion you need:\n")
        local temp = true
        local p = self:getGuid()
        recipe[p] = choice
        for i = 1, #arecipes[choice].ingredients do
                window:setMessage(window:getMessage() .. arecipes[choice].ingredients[i].count .. " " .. arecipes[choice].ingredients[i].name .. " (" .. self:getItemCount(arecipes[choice].ingredients[i].id) .. ")\n")
                if self:getItemCount(arecipes[choice].ingredients[i].id) < arecipes[choice].ingredients[i].count then
                        temp = false
                end
        end
        if temp then
                window:addButton(1, "Brew")
                window:setDefaultEnterButton(1)
        else
                window:setDefaultEnterButton(2)
        end
       
       
        window:addButton(2, "Back")
        window:setDefaultEscapeButton(2)
        window:sendToPlayer(self)
        return true
end

function Player:sendBowlWindow()
        local window = ModalWindow(modalId + 5, "Bowl", "The bowl contains the below items. You can remove items or try brewing a new potion.\n")
        local p = self:getGuid()
        window:addButton(3, "Back")
        window:setDefaultEscapeButton(3)
        if #bowl[p] > 0 then
                window:addButton(1, "Brew")
                window:addButton(2, "Remove")
                window:setDefaultEnterButton(1)
                for i = 1, #bowl[p] do
                        window:addChoice(i, aingredients[bowl[p][i]].name)
                end
        else
                window:setMessage("The bowl is empty.")
                window:setDefaultEnterButton(3)
        end
       
       
       
        window:sendToPlayer(self)
        return true
end

function Player:alchemyWindowChoice(windowId, buttonId, choiceId)
       
        if choiceId == 255 then
                choiceId = 1
        end
        if windowId == modalId then
                if buttonId == 1 then
                        if choiceId == 1 then
                                self:sendIngredientWindow()
                        elseif choiceId == 2 then
                                self:sendPotionWindow()
                        end
                       
                        return true
                elseif buttonId == 2 then
                        return false
                end
                return false
        end
        return false
end

function Player:ingredientWindowChoice(windowId, buttonId, choiceId)
        local p = self:getGuid()
        if choiceId == 255 then
                for i = 1, #aingredients do
                        if self:getItemCount(aingredients[i].id) >= 1 then
                                choiceId = i
                                break
                        end
                end
        end
        if windowId == modalId + 1 then
                if buttonId == 1 then
                        self:sendInfoWindow(choiceId)
                        return true
                elseif buttonId == 2 then
                        local pc = self:getItemCount(aingredients[choiceId].id)
                        local c = 0
                        for j = 1, #bowl[p] do
                                if aingredients[bowl[p][j]].id == aingredients[choiceId].id then
                                        c = c + 1
                                end
                        end
                        if c > 0 then
                                pc = pc - c
                        end
                        if pc > 0 then
                                bowl[p][#bowl[p] + 1] = choiceId
                        end
                        self:sendIngredientWindow()
                        return true
                elseif buttonId == 3 then
                        self:sendBowlWindow()
                        return true
                elseif buttonId == 4 then
                        self:sendAlchemyWindow()
                        return true
                end
                return false
        end
        return false
end


function Player:potionWindowChoice(windowId, buttonId, choiceId)
        if choiceId == 255 then
                for i = 1, #arecipes do
                        if self:getStorageValue(arecipes[i].storage) == 1 then
                                choiceId = i
                                break
                        end
                end
        end
        if windowId == modalId + 3 then
                if buttonId == 1 then
                        self:sendPotionRecipeWindow(choiceId)
                        return true
                elseif buttonId == 2 then
                        self:sendAlchemyWindow()
                        return true
                end
                return false
        end
        return false
end

function Player:potionRecipeWindowChoice(windowId, buttonId, choiceId)
        local p = self:getGuid()
        if choiceId == 255 then
                choiceId = 1
        end
        if windowId == modalId + 4 then
                if buttonId == 1 then
                        local r = recipe[p]
                        for i = 1, #arecipes[r].ingredients do
                                self:removeItem(arecipes[r].ingredients[i].id, arecipes[r].ingredients[i].count)
                        end
                        potion = self:addItem(2006, arecipes[r].id)
                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Effects:\n")
                        for i = 1, #arecipes[r].effects do
                                if i > 1 then
                                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "\n")
                                end
                                if arecipes[r].durations[i] > 0 then
                                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "[" .. aeffects[arecipes[r].effects[i]].fullname .. "]\n" .. aeffects[arecipes[r].effects[i]].label .. ": " .. arecipes[r].values[i] .. " | Duration: " .. arecipes[r].durations[i])
                                else
                                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "[" .. aeffects[arecipes[r].effects[i]].fullname .. "]\n" .. aeffects[arecipes[r].effects[i]].label .. ": " .. arecipes[r].values[i])
                                end
                        end
                        self:sendTextMessage(MESSAGE_INFO_DESCR, "You've brewed the " .. arecipes[r].name .. ".")
                        return self:hasIn(r) and self:sendPotionRecipeWindow(r) or self:sendPotionWindow()
                elseif buttonId == 2 then
                        self:sendPotionWindow()
                        return true
                end
                return false
        end
        return false
end

function Player:infoWindowChoice(windowId, buttonId, choiceId)
        if choiceId == 255 then
                choiceId = 1
        end
        if windowId == modalId + 2 then
                if buttonId == 1 then
                        self:sendIngredientWindow()
                        return true
                end
                return false
        end
        return false
end

function Player:bowlWindowChoice(windowId, buttonId, choiceId)
        if choiceId == 255 then
                choiceId = 1
        end
        if windowId == modalId + 5 then
                if buttonId == 1 then
                        local p = self:decidePotion()
                        local id = self:getGuid()
                        for i = 1, #bowl[id] do
                                if self:getStorageValue(aingredients[bowl[id][i]].storages[2]) ~= 1 then
                                        self:setStorageValue(aingredients[bowl[id][i]].storages[2], 1)
                                        self:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the effect " .. aeffects[aingredients[bowl[id][i]].effects[2]].fullname .. " from the " .. aingredients[bowl[id][i]].name .. "!")
                                end
                                self:removeItem(aingredients[bowl[id][i]].id, 1)
                        end
                       
                        local potion = self:addItem(2006, p[1].id)
                       
                        if p[4] == 2 then
                                potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Potency: " .. p[2] .. "\n")
                                if aeffects[p[1].effect].dur > 0 then
                                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. aeffects[p[1].effect].label .. ": " .. aeffects[p[1].effect].val + aeffects[p[1].effect].p * p[2] .. " | Duration: " .. aeffects[p[1].effect].dur + p[3])
                                else
                                        potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. aeffects[p[1].effect].label .. ": " .. aeffects[p[1].effect].val + aeffects[p[1].effect].p * p[2])
                                end
                        else
                                potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Effects:\n")
                                for i = 1, #p[1].effects do
                                        if i > 1 then
                                                potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "\n")
                                        end
                                        if p[1].durations[i] > 0 then
                                                potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "[" .. aeffects[p[1].effects[i]].fullname .. "]\n" .. aeffects[p[1].effects[i]].label .. ": " .. p[1].values[i] .. " | Duration: " .. p[1].durations[i])
                                        else
                                                potion:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, potion:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION) .. "[" .. aeffects[p[1].effects[i]].fullname .. "]\n" .. aeffects[p[1].effects[i]].label .. ": " .. p[1].values[i])
                                        end
                                end
                        end
                        self:sendTextMessage(MESSAGE_INFO_DESCR, "You've brewed the " .. p[1].name .. ".")
                        bowl[id] = {}
                        self:sendIngredientWindow()
                elseif buttonId == 2 then
                        local p = self:getGuid()
                        table.remove(bowl[p], choiceId)
                        self:sendBowlWindow()
                        return true
                elseif buttonId == 3 then
                        self:sendIngredientWindow()
                        return true
                end
        end
        return false
end

 



e em func.lua adicione isso


function Item:getEffects(thing)
        local effects = {}
        local values = {}
        local potency = 0
        local duration = 0
        local name = ""
        local description = thing:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
        local d = ""
        local p = ""
        local dur1, dur2 = string.find(description, "Duration: ")
        local pot1, pot2 = string.find(description, "Potency: ")
        local ty = 0
        if dur1 ~= nil and dur2 ~= nil then
                for l = 1, 5 do
                        if description:sub(dur2 + l, dur2 + l) ~= "\n" and description:sub(dur2 + l, dur2 + l) ~= " " then
                                d = d .. description:sub(dur2 + l, dur2 + l)
                        else
                                break
                        end
                end
        end
        if pot1 ~= nil and pot2 ~= nil then
                for l = 1, 5 do
                        if description:sub(pot2 + l, pot2 + l) ~= "\n" and description:sub(pot2 + l, pot2 + l) ~= " " then
                                p = p .. description:sub(pot2 + l, pot2 + l)
                        else
                                break
                        end
                end
        end
       
        for i, v in pairs(apotionids) do
                if thing:getFluidType() == i then
                        name = apotionids[thing:getFluidType()].name
                        ty = 1
                        local j, k = string.find(description, aeffects[apotionids[i].effect].label .. ": ")
                        local a = ""
                        if j ~= nil and k ~= nil then
                                for l = 1, 5 do
                                        if description:sub(k + l, k + l) ~= "\n" and description:sub(k + l, k + l) ~= " " then
                                                a = a .. description:sub(k + l, k + l)
                                        else
                                                break
                                        end
                                end
                        end
                       
                        if a ~= "" then
                                effects[#effects + 1] = apotionids[i].effect
                                values[#values + 1] = a
                        end
                end
        end
       
        for i = 1, #arecipes do
                if thing:getFluidType() == arecipes[i].id then
                        name = arecipes[i].name
                        ty = 2
                        for r = 1, #arecipes[i].effects do
                                local j, k = string.find(description, aeffects[arecipes[i].effects[r]].label .. ": ")
                                local a = ""
                                if j ~= nil and k ~= nil then
                                        for l = 1, 5 do
                                                if description:sub(k + l, k + l) ~= "\n" and description:sub(k + l, k + l) ~= " " then
                                                        a = a .. description:sub(k + l, k + l)
                                                else
                                                        break
                                                end
                                        end
                                end
                                if a ~= "" then
                                        effects[#effects + 1] = arecipes[i].effects[r]
                                        values[#values + 1] = a
                                end
                        end
                end
        end
       
        if d ~= "" then
                duration = d
        end
        if p ~= "" then
                potency = p
        end
        return {effects, values, duration, potency, name, ty}
end

function usePotion(player, effects)
        local hpregen = Condition(CONDITION_REGENERATION)
        hpregen:setParameter(CONDITION_PARAM_SUBID, 1)
        hpregen:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        hpregen:setParameter(CONDITION_PARAM_HEALTHTICKS, 3000)
        local mpregen = Condition(CONDITION_REGENERATION)
        mpregen:setParameter(CONDITION_PARAM_SUBID, 2)
        mpregen:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        mpregen:setParameter(CONDITION_PARAM_MANATICKS, 3000)
        local soulregen = Condition(CONDITION_REGENERATION)
        soulregen:setParameter(CONDITION_PARAM_SUBID, 12)
        soulregen:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        soulregen:setParameter(CONDITION_PARAM_SOULTICKS, 3000)
        local melee = Condition(CONDITION_ATTRIBUTES)
        melee:setParameter(CONDITION_PARAM_SUBID, 3)
        melee:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local dist = Condition(CONDITION_ATTRIBUTES)
        dist:setParameter(CONDITION_PARAM_SUBID, 4)
        dist:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local shield = Condition(CONDITION_ATTRIBUTES)
        shield:setParameter(CONDITION_PARAM_SUBID, 5)
        shield:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local fish = Condition(CONDITION_ATTRIBUTES)
        fish:setParameter(CONDITION_PARAM_SUBID, 6)
        fish:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local fist = Condition(CONDITION_ATTRIBUTES)
        fist:setParameter(CONDITION_PARAM_SUBID, 7)
        fist:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local resist = Condition(CONDITION_ATTRIBUTES)
        resist:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local speed = Condition(CONDITION_HASTE)
        speed:setParameter(CONDITION_PARAM_SUBID, 8)
        local maxhp = Condition(CONDITION_ATTRIBUTES)
        maxhp:setParameter(CONDITION_PARAM_SUBID, 9)
        maxhp:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local maxmp = Condition(CONDITION_ATTRIBUTES)
        maxmp:setParameter(CONDITION_PARAM_SUBID, 10)
        maxmp:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        local drown = Condition(CONDITION_ATTRIBUTES)
        drown:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
        drown:setParameter(CONDITION_PARAM_SUBID, 11)
        if not Player(player) then
                return false
        end
        for i = 1, #effects[1] do
                if effects[1][i] == "restorehp" then
                        player:addMana(effects[2][i])
                elseif effects[1][i] == "restoremp" then
                        player:addHealth(effects[2][i])
                elseif effects[1][i] == "restoresoul" then
                        player:addSoul(effects[2][i])
                elseif effects[1][i] == "regenhp" then
                        hpregen:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        hpregen:setParameter(CONDITION_PARAM_HEALTHGAIN, effects[2][i])
                        player:addCondition(hpregen)
                elseif effects[1][i] == "regenmp" then
                        mpregen:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        mpregen:setParameter(CONDITION_PARAM_MANAGAIN, effects[2][i])
                        player:addCondition(mpregen)
                elseif effects[1][i] == "regensoul" then
                        soulregen:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        soulregen:setParameter(CONDITION_PARAM_SOULGAIN, effects[2][i])
                        player:addCondition(soulregen)
                elseif effects[1][i] == "maxhp" then
                        maxhp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, effects[2][i])
                        maxhp:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(maxhp)
                elseif effects[1][i] == "maxmp" then
                        maxmp:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, effects[2][i])
                        maxmp:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(maxmp)
                elseif effects[1][i] == "speed" then
                        speed:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        speed:setParameter(CONDITION_PARAM_SPEED, player:getBaseSpeed() + effects[2][i])
                        player:addCondition(speed)
                elseif effects[1][i] == "drown" then
                        drown:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(drown)
                elseif effects[1][i] == "meleeup" then 
                        melee:setParameter(CONDITION_PARAM_SKILL_MELEE, effects[2][i])
                        melee:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(melee)
                elseif effects[1][i] == "fistup" then  
                        fist:setParameter(CONDITION_PARAM_SKILL_FIST, effects[2][i])
                        fist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(fist)
                elseif effects[1][i] == "distup" then  
                        dist:setParameter(CONDITION_PARAM_SKILL_DISTANCE, effects[2][i])
                        dist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(dist)
                elseif effects[1][i] == "shieldup" then
                        shield:setParameter(CONDITION_PARAM_SKILL_SHIELD, effects[2][i])
                        shield:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(shield)
                elseif effects[1][i] == "fishup" then  
                        fish:setParameter(CONDITION_PARAM_SKILL_FISHING, effects[2][i])
                        fish:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        player:addCondition(fish)
                elseif effects[1][i] == "resistfire" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 101)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistearth" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 102)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistenergy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 103)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistice" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 104)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistholy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 105)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistdeath" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 106)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistphysical" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 107)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "resistall" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 108)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectfire" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 109)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectearth" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 110)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectenergy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 111)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectice" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 112)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectholy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 113)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectdeath" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 114)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectphysical" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 115)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "reflectall" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 116)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectfire" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 117)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectearth" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 118)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectenergy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 119)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectice" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 120)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectholy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 121)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectdeath" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 122)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectphysical" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 123)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "deflectall" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 124)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbfire" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 125)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbearth" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 126)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbenergy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 127)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbice" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 128)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbholy" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 129)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbdeath" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 130)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorbphysical" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 131)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                elseif effects[1][i] == "absorball" then
                        resist:setParameter(CONDITION_PARAM_SUBID, 132)
                        resist:setParameter(CONDITION_PARAM_TICKS, effects[3] * 1000)
                        removeResists(player)
                        player:addCondition(resist)
                        player:setStorageValue(5, effects[2][i])
                end
        end
end

function removeResists(player)
        for i = 1, 32 do
                if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, i + 100) then
                        player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, i + 100)
                end
        end
end

 

 

 

** Edit - onLookInTrade corrigido.. sistema funcionando 100%

** Edit - algumas correções na escrita (eu estava com mt sono quando trouxe para cá o sistema)

Editado por DeCarvalho
Link para o comentário
Compartilhar em outros sites

Poxa né, 13 pessoas viram e tirando o Bruno que comentou pelo e curtiu mais ninguém fez.. chato isso né.. pode não ser meu mas acha que não da trabalho. fui la pedir pro cara para poder disponibilizar pois sei q tem gente que não entende inglês, fico aqui arrumando pra ficar bonito e organizado e nada.. assim nem dá vontade de trazer mais conteúdo.. :/ eu ia até postar o vídeo que fiz mostrando melhor o funcionamento mas assim.. nem..

 

 

Link para o comentário
Compartilhar em outros sites

Mas mesmo no cliente normal o modalwindow da um toque diferenciado.. além do que não é algo fixo.. você usa um item e o menu de 'craft' aparece.. certo que se houvesse um mod para otc seria interessante pois no old o modalwindow bloqueia a tela, e mod para otc não.

 

Mesmo não tendo mod para otc, usando o old.. é muito maneiro.. o sistema que ele fez não tem poção de ml, mesmo com pouco conhecimento procurei e sozinho consegui adicionar, errando e tentando :D há inumeras possibilidades de uso..

 

Para quem curte server RPG (futuramente estarei anunciando o meu) esse é um ótimo sistema

Link para o comentário
Compartilhar em outros sites

Cara como isso funciona? eu instalei aqui e não mudou nada o.O

 

Fera, bem la em cima é informado que são necessários dois items, um empty vial e um bowl with sacred water.. vc usa o empty vial no bowl with sacred water. é só prestar atenção no que ta escrito.

Link para o comentário
Compartilhar em outros sites

Eu fiz isso mas não foi. E não da erro.

Aparentemente eu tive o mesmo problema quando fui usar a primeira vez, eu criei um empty vial e não funcionava.. tente criar o item empty vial (id:2006) e use no bowl with sacred water (id:12289)

 

Link para o comentário
Compartilhar em outros sites

Consegui resolver auqi tava com um erro aqui, mas já resolvido.

Agora um outro detalhe:

Quando abre a janela e eu clico em "Potions" ele só fica vazio, mesmo eu criando várias poções, é normal?

Link para o comentário
Compartilhar em outros sites

Consegui resolver auqi tava com um erro aqui, mas já resolvido.

Agora um outro detalhe:

Quando abre a janela e eu clico em "Potions" ele só fica vazio, mesmo eu criando várias poções, é normal?

 

A gente traduz a parada toda e pensando em facilitar a coisa.. e a pessoa não lê :/

 

- Se os ingredientes na panela puderem ser usados para fabricar com base em uma pré-receita, o jogador fabrica a receita e acaba aprendendo como fabricar rapidamente direto da lista de poções. Se ele não souber a receita a poção irá produzir somente um efeito com a duração variável e potência (se aplicado)

Link para o comentário
Compartilhar em outros sites

 

A gente traduz a parada toda e pensando em facilitar a coisa.. e a pessoa não lê :/

 

- Se os ingredientes na panela puderem ser usados para fabricar com base em uma pré-receita, o jogador fabrica a receita e acaba aprendendo como fabricar rapidamente direto da lista de poções. Se ele não souber a receita a poção irá produzir somente um efeito com a duração variável e potência (se aplicado)

Jovem, eu fiz as receitas todas, colocando:

[1] = {name = "bonelord eye", id = 5898, count = 1},
[2] = {name = "honeycomb", id = 5902, count = 2}
Que é a de cura dobrada, porém não vai. Não da erro, nada.
Link para o comentário
Compartilhar em outros sites

 

Jovem, eu fiz as receitas todas, colocando:

[1] = {name = "bonelord eye", id = 5898, count = 1},
[2] = {name = "honeycomb", id = 5902, count = 2}
Que é a de cura dobrada, porém não vai. Não da erro, nada.

 

 

Aqui estão todas funcionando, até as que eu adicionei.. preste atenção ao adicionar o segundo honeycomb pois quando se adiciona o primeiro ele volta para o primeiro item.. se clicar seguidamente add ele adiciona 1 honeycomb e 1 bonelord eye.. vc tem que selecionar o honeycomb novamente antes de adicionar.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...