SK
dúvida

Potions

Por SkyDarkyes, 25 de set. de 2013 em Scripts

resolvido
49
6.7k
25 de setembro de 2013 às 18:48

Depois eu coloco o id

netinhossdN
25 de setembro de 2013 às 19:02

ok Maelisie ^^

LuckOakeL
25 de setembro de 2013 às 19:26

Fiz uns ajustes no script:

 

 

 

local removeOnUse = true -- Remover a poção ao usar? (true / false)
local usableOnTarget = true -- Você pode healar outras pessoas? (true / false)
local splashable = false -- Dá pra jogar o líquido da poção no chão? (true / false)
local realAnimation = false -- Se true, o texto do heal só será visível para player que estiverem a 1x1 sqm de distância (true / false)
local giveEmptyVial = true -- Dar a garrafa da potion vazia para o player ao usar? (true / false)
local healthMultiplier = 1.0 -- Multiplicador da health que a potion adiciona
local mamaMultiplier = 1.0 -- Multiplicador da mana que a potion adiciona
local POTIONS = { -- [id] = {empty_id, {hp, mp}, splash_subtype},
        [2150] = {empty = 7478, stats = {5000, 5000}, splash = 2}, -- health potion
        [2151] = {empty = 7478, stats = {20000, 20000}, splash = 2}, -- health strong potion
        [2144] = {empty = 7478, stats = {5000, 5000}, splash = 7}, -- strong mana potion
        [2149] = {empty = 7478, stats = {15000, 15000}, splash = 7}, -- great mana potion
}
 
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local potion = POTIONS[item.itemid]
    if not potion then return true end
    
    if not isPlayer(itemEx.uid) or not usableOnTarget and cid ~= itemEx.uid then
        if not splashable then return true end
        if toPosition.x == CONTAINER_POSITION then
            toPosition = getThingPos(item.uid)
        end
        doDecayItem(doCreateItem(2016, potion.splash, toPosition))
        doTransformItem(item.uid, potion.empty)
        return true 
    end 
    if hasCondition(cid, CONDITION_EXHAUST_HEAL) then 
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true
    elseif potion.level and getPlayerLevel(cid) < potion.level and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) then
        doCreatureSay(itemEx.uid, "Only players of level "..(potion.level).." or above may drink this fluid.", TALKTYPE_MONSTER) return true 
    end
    
    local stats = potion.stats
    doCreatureAddHealth(itemEx.uid, stats[1] * manaMultiplier)
    doPlayerAddMana(itemEx.uid, stats[2] * manaMultiplier)
    doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
    
    if not realAnimation then
        doCreatureSay(itemEx.uid, "I feel better!", TALKTYPE_MONSTER)
    else
        for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
            if isPlayer(tid) then
                doCreatureSay(itemEx.uid, "I feel better!", TALKTYPE_MONSTER, false, tid)
            end
        end
    end
    
    doAddCondition(cid, exhaust)
    if removeOnUse then
        doRemoveItem(item.uid, 1)
    end
    if giveEmptyVial and potion.empty and potion.empty > 0 then
        doPlayerAddItem(cid, potion.empty, 1)
    end
    return true
end

 

 

 

Configure aqui:

local removeOnUse = true -- Remover a poção ao usar? (true / false)
local usableOnTarget = true -- Você pode healar outras pessoas? (true / false)
local splashable = false -- Dá pra jogar o líquido da poção no chão? (true / false)
local realAnimation = false -- Se true, o texto do heal só será visível para player que estiverem a 1x1 sqm de distância (true / false)
local giveEmptyVial = true -- Dar a garrafa da potion vazia para o player ao usar? (true / false)
local healthMultiplier = 1.0 -- Multiplicador da health que a potion adiciona
local mamaMultiplier = 1.0 -- Multiplicador da mana que a potion adiciona
local POTIONS = { -- [id] = {empty_id, {hp, mp}, splash_subtype},
        [2150] = {empty = 7478, stats = {5000, 5000}, splash = 2}, -- health potion
        [2151] = {empty = 7478, stats = {20000, 20000}, splash = 2}, -- health strong potion
        [2144] = {empty = 7478, stats = {5000, 5000}, splash = 7}, -- strong mana potion
        [2149] = {empty = 7478, stats = {15000, 15000}, splash = 7}, -- great mana potion
}

Editado Setembro 25 por LuckOake

25 de setembro de 2013 às 19:35

Como fasso para healar a mana e vida,posta uma tag ai k

LuckOakeL
25 de setembro de 2013 às 19:39

Tag:

<action itemid="xxxx;yyyy" script="potions.lua"/>

No lugar de xxxx e yyyy, mude pro ID das poções. Você também pode adicionar mais IDs colocando ; (ponto e vírgula). Exemplo: 1213;8491;4891;5543

 

E no script você configura aqui:

local POTIONS = { -- [id] = {empty_id, {hp, mp}, splash_subtype},
        [2150] = {empty = 7478, stats = {5000, 5000}, splash = 2}, -- health potion
        [2151] = {empty = 7478, stats = {20000, 20000}, splash = 2}, -- health strong potion
        [2144] = {empty = 7478, stats = {5000, 5000}, splash = 7}, -- strong mana potion
        [2149] = {empty = 7478, stats = {15000, 15000}, splash = 7}, -- great mana potion
}

Todo id que você colocar na tag você também deve colocar aqui.

 

Modelo: [id] = {empty = empty_id, stats = {hp, mp}, splash = splash_subtype},

id = id da poção
empty_id = id da vial vazia
{hp, mp} = {vida, mana}
splash = subtype, só modifique se você souber o que está fazendo.

Só ir adicionando.

Editado Setembro 25 por LuckOake

25 de setembro de 2013 às 19:43

Nnn a tag eu ja sabia,queria sabe como add {hp, mp} = {vida, mana}

LuckOakeL
25 de setembro de 2013 às 19:45

Tá completamente explicado no meu post anterior.

 

Releia.

25 de setembro de 2013 às 19:46

Entendi man,mas deixa queto,acho que não vai ter geito

LuckOakeL
25 de setembro de 2013 às 19:47

Ué, por que não?

 

Seu objetivo não era adicionar vida e mana ao mesmo tempo? O script que postei faz isso. Não entendi qual o problema.

Editado Setembro 25 por LuckOake

25 de setembro de 2013 às 19:49

Sim,mas ai no caso está para todos os potions,e eu queria que fosse apenas para os que escolhesse

LuckOakeL
25 de setembro de 2013 às 19:52

Ah, no seu script original dava pra fazer isso sem problemas.

 

Era só modificar a tabela, de exemplo a health potion:

[2150] = {empty = 7478, splash = 2, health = {5000, 5000}}, -- health potion 

Era só colocar assim:

[2150] = {empty = 7478, splash = 2, health = {5000, 5000}, mana = {5000, 5000}}, -- health potion 

Ou seja, só adicionar um "mana = {min, max}" alí.

25 de setembro de 2013 às 19:53

Oxe pq nao falo antes kkkk,desculpa ai luck,limite rep

 

Mais uma coisa,quando uso potion,aparece uma fala,porem em laranja,queria que aparecesse igual uma magia,tipo em amarelo,no default

Editado Setembro 25 por SkyDarkyes

LuckOakeL
25 de setembro de 2013 às 19:59

Modifique aqui:

doCreatureSay(itemEx.uid, "I feel better!", TALKTYPE_ORANGE_1)

Coloque assim:

doCreatureSay(itemEx.uid, "I feel better!")

E modifique aqui:

doCreatureSay(itemEx.uid, "I feel better!", TALKTYPE_ORANGE_1, false, tid)

Coloque assim:

doCreatureSay(itemEx.uid, "I feel better!", TALKTYPE_SAY, false, tid)
25 de setembro de 2013 às 20:27

Outra duvida,tem como colocar exasted?

LuckOakeL
25 de setembro de 2013 às 20:28

Já tem exhausted. Só se lembre de testar com players.