KA

Potion de Pokemon Certa quantidade de HP [Resolvido]

Por kamus9629, 10 de mar. de 2020 em Scripts

20
3.5k
kamus9629K
10 de março de 2020 às 20:05

Potion de Pokemon Certa quantidade de HP 

RESOLVIDO PELO @Yan18  Procure abaixo ?

Editado Maio 1 por kamus9629

3 semanas depois...
Yan OliveiraY
26 de março de 2020 às 15:49
Em 10/03/2020 em 20:05, kamus9629 disse:
Versão do Servidor:
Tipo de Script: actions
Código:
  Ocultar conteúdo

function doHealOverTime(cid, div, turn, effect)                     --alterado v1.6 peguem o script todo!!
if not isCreature(cid) then return true end

if turn <= 0 or (getCreatureHealth(cid) == getCreatureMaxHealth(cid)) or getPlayerStorageValue(cid, 173) <= 0 then 
   setPlayerStorageValue(cid, 173, -1)
   return true 
end

local d = div / 10000
local amount = math.floor(getCreatureMaxHealth(cid) * d)
doCreatureAddHealth(cid, amount)
if math.floor(turn/10) == turn/10 then
   doSendMagicEffect(getThingPos(cid), effect)
end
addEvent(doHealOverTime, 100, cid, div, turn - 1, effect)
end

local potions = {
[1456] = {effect = 13, div = 235}, --super potion
[1451] = {effect = 13, div = 330}, --great potion              
[384] = {effect = 12, div = 550}, --ultra potion
[385] = {effect = 14, div = 750}, --hyper potion
[392] = {effect = 14, div = 900}, --full restore
[667] = {effect = 14, div = 1200}, --full restore
[668] = {effect = 14, div = 1350}, --full restore
[669] = {effect = 14, div = 1600}, --full restore
[670] = {effect = 14, div = 1710}, --full restore
[671] = {effect = 14, div = 2280}, --full restore
}

function onUse(cid, item, frompos, item2, topos)
local pid = getThingFromPosWithProtect(topos)

if not isSummon(pid) or getCreatureMaster(pid) ~= cid then
return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!")
end

if getCreatureHealth(pid) == getCreatureMaxHealth(pid) then
return doPlayerSendCancel(cid, "This pokemon is already at full health.")
end

if getPlayerStorageValue(pid, 173) >= 1 then
return doPlayerSendCancel(cid, "This pokemon is already under effects of potions.")
end

if getPlayerStorageValue(cid, 52481) >= 1 then
return doPlayerSendCancel(cid, "You can't do that while a duel.")
end

if getPlayerStorageValue(cid, 990) >= 1 then
   doPlayerSendCancel(cid, "You can't use rpotion during gym battles.")
   return true
end

doCreatureSay(cid, "".. getCreatureName(pid)..", take this potion!", TALKTYPE_MONSTER)
doSendMagicEffect(getThingPos(pid), 0)
setPlayerStorageValue(pid, 173, 1)
doRemoveItem(item.uid, 1)

local a = potions[item.itemid]
doHealOverTime(pid, a.div, 100, a.effect)

return true
end

Alguem poderia fazer esse codigo pramin para que o pokemon receba o HP por numero nao por porcentagem 

Você não especificou a quantidade exata que quer, então substitua o código por esse:

 

local hp_quantidade = 50000 -- COLOQUEI AQUI A QUANTIDADE DE HP

function doHealOverTime(cid, div, turn, effect)                     --alterado v1.6 peguem o script todo!!
if not isCreature(cid) then return true end

if turn <= 0 or (getCreatureHealth(cid) == getCreatureMaxHealth(cid)) or getPlayerStorageValue(cid, 173) <= 0 then 
   setPlayerStorageValue(cid, 173, -1)
   return true 
end

local hp = math.floor(hp_quantidade)
doCreatureAddHealth(cid, hp)

if math.floor(turn/10) == turn/10 then
   doSendMagicEffect(getThingPos(cid), effect)
end
addEvent(doHealOverTime, 100, cid, div, turn - 1, effect)
end

local potions = {
[1456] = {effect = 13, div = 235}, --super potion
[1451] = {effect = 13, div = 330}, --great potion              
[384] = {effect = 12, div = 550}, --ultra potion
[385] = {effect = 14, div = 750}, --hyper potion
[392] = {effect = 14, div = 900}, --full restore
[667] = {effect = 14, div = 1200}, --full restore
[668] = {effect = 14, div = 1350}, --full restore
[669] = {effect = 14, div = 1600}, --full restore
[670] = {effect = 14, div = 1710}, --full restore
[671] = {effect = 14, div = 2280}, --full restore
}

function onUse(cid, item, frompos, item2, topos)
local pid = getThingFromPosWithProtect(topos)

if not isSummon(pid) or getCreatureMaster(pid) ~= cid then
return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!")
end

if getCreatureHealth(pid) == getCreatureMaxHealth(pid) then
return doPlayerSendCancel(cid, "This pokemon is already at full health.")
end

if getPlayerStorageValue(pid, 173) >= 1 then
return doPlayerSendCancel(cid, "This pokemon is already under effects of potions.")
end

if getPlayerStorageValue(cid, 52481) >= 1 then
return doPlayerSendCancel(cid, "You can't do that while a duel.")
end

if getPlayerStorageValue(cid, 990) >= 1 then
   doPlayerSendCancel(cid, "You can't use rpotion during gym battles.")
   return true
end

doCreatureSay(cid, "".. getCreatureName(pid)..", take this potion!", TALKTYPE_MONSTER)
doSendMagicEffect(getThingPos(pid), 0)
setPlayerStorageValue(pid, 173, 1)
doRemoveItem(item.uid, 1)

local a = potions[item.itemid]
doHealOverTime(pid, a.div, 100, a.effect)

return true
end

E na primeira linha na variável hp_quantidade troque o valor pelo desejado.

 

Teste e me fale.

kamus9629K
26 de março de 2020 às 15:51

vlw parceiro @Yan18

Yan OliveiraY
26 de março de 2020 às 16:54
1 hora atrás, kamus9629 disse:

vlw parceiro @Yan18

Mas testou? Deu certo?

kamus9629K
26 de março de 2020 às 16:55
Agora, Yan18 disse:

Mas testou? Deu certo?

tentei ainda nao porque estou tentando copilar soucer otclient que ta fazendo distancia effect buga no game 

1 mês depois...
kamus9629K
24 de abril de 2020 às 20:19

@Yan18 desculpe a dermora mano tipo vou explicar  eu queria que cada item dava um HP diferente mais eu acho que esse serve mais vou ter que cria 50 item action diferente para mais vlw vou testar agora

 

eu testei esse codigo agora 20:30 mais ele nao ta dando so a quantidade do HP ele ta enchendo HP TODO

Editado Abril 24 por kamus9629

Yan OliveiraY
30 de abril de 2020 às 01:42
Melhor resposta
Em 24/04/2020 em 20:19, kamus9629 disse:

@Yan18 desculpe a dermora mano tipo vou explicar  eu queria que cada item dava um HP diferente mais eu acho que esse serve mais vou ter que cria 50 item action diferente para mais vlw vou testar agora

 

eu testei esse codigo agora 20:30 mais ele nao ta dando so a quantidade do HP ele ta enchendo HP TODO

Opa, foi bobeira minha, mas eu refiz o código, testei e agora está funcionando:

-- REFEITO POR YAN18 PARA RESTAURAR VIDA POR VALOR CONSTANTE --

function doHealOverTime(cid, hp, effect)                  
if not isCreature(cid) then 
	return true 
end

doSendMagicEffect(getThingPos(cid), effect)	
doCreatureAddHealth(cid, math.floor(hp))
end

local potions = {
[1456] = {effect = 13, hp = 50000}, -- super potion
[1451] = {effect = 13, hp = 50000}, -- great potion              
[384] = {effect = 12, hp = 50000}, -- ultra potion
[385] = {effect = 14, hp = 50000}, -- hyper potion
[392] = {effect = 14, hp = 50000}, -- full restore
[667] = {effect = 14, hp = 50000}, -- full restore
[668] = {effect = 14, hp = 50000}, -- full restore
[669] = {effect = 14, hp = 50000}, -- full restore
[670] = {effect = 14, hp = 50000}, -- full restore
[671] = {effect = 14, hp = 50000}, -- full restore
}

function onUse(cid, item, frompos, item2, topos)
local pid = getThingFromPosWithProtect(topos)

if not isSummon(pid) or getCreatureMaster(pid) ~= cid then
	return doPlayerSendCancel(cid, "You can only use potions on your own Pokemons!")
end

if getCreatureHealth(pid) == getCreatureMaxHealth(pid) then
	return doPlayerSendCancel(cid, "This pokemon is already at full health.")
end

if getPlayerStorageValue(pid, 173) >= 1 then
	setPlayerStorageValue(pid, 173, -1)
end

if getPlayerStorageValue(cid, 52481) >= 1 then
	return doPlayerSendCancel(cid, "You can't do that while a duel.")
end

if getPlayerStorageValue(cid, 990) >= 1 then
   doPlayerSendCancel(cid, "You can't use potion during gym battles.")
   return true
end

doCreatureSay(cid, "".. getCreatureName(pid)..", take this potion!", TALKTYPE_MONSTER)
doSendMagicEffect(getThingPos(pid), 0)
setPlayerStorageValue(pid, 173, 1)
doRemoveItem(item.uid, 1)

local a = potions[item.itemid]
doHealOverTime(pid, a.hp, a.effect)
doPlayerSendCancel(cid, "Your monsters recovered " ..a.hp.. " of HP.")

return true
end

Ai para configurar o HP, você precisa mudar os valores na variável hp de cada potion (item) na tabela potions onde está 50000 para todos.

kamus9629K
01 de maio de 2020 às 21:55

@Yan18 ae yan eu testei aqui ainda ta heal tudo Video Do heal

heal item.rar

Editado Maio 1 por kamus9629

Yan OliveiraY
01 de maio de 2020 às 22:02
5 minutos atrás, kamus9629 disse:

@Yan18 ae yan eu testei aqui ainda ta heal tudo

Está healando tudo se não mudou o valor ali do hp que falei, deixei 50000 só de teste, pode ser que os monstros que está usando a potion tenham menos de 50000 de vida. Eu testei aqui e está curando pelo tanto que você define. 

kamus9629K
01 de maio de 2020 às 22:08
10 minutos atrás, Yan18 disse:

Está healando tudo se não mudou o valor ali do hp que falei, deixei 50000 só de teste, pode ser que os monstros que está usando a potion tenham menos de 50000 de vida. Eu testei aqui e está curando pelo tanto que você define. 

[384] = {effect = 12, hp = 550}, -- ultra potion eu tambem mandei o videoheal item.rar video

Editado Maio 1 por kamus9629

Yan OliveiraY
01 de maio de 2020 às 22:22
9 minutos atrás, kamus9629 disse:

[384] = {effect = 12, hp = 550}, -- ultra potion eu tambem mandei o videoheal item.rar video

Eu vi o vídeo, mas você não está usando o script que eu fiz, pois quando usou a potion nem apareceu a mensagem que coloquei.

 

Tirei até uma print do teste que fiz novamente aqui, olha como cura o tanto que eu coloco e exibe a mensagem;

 

image.thumb.png.12c6aa46e07a630ac99ddf80e2334e9b.png

kamus9629K
01 de maio de 2020 às 23:16

@Yan18

Primeiro me desculpe pelo tempo perdido segundo vlw me ajudou bastante

Yan OliveiraY
01 de maio de 2020 às 23:18
Agora, kamus9629 disse:

@Yan18

Primeiro me desculpe pelo tempo perdido segundo vlw me ajudou bastante

De nada, que isso! Você tinha esquecido de salvar o script que fiz?

kamus9629K
01 de maio de 2020 às 23:20


tinha esquecido de mudar no action.lua tinha replica de outro codigo la eu posso coloca o codigo La em cima na postagem com seus creditos ? ou voce cria um topico e eu posto la em cima 

Editado Maio 1 por kamus9629

Yan OliveiraY
01 de maio de 2020 às 23:22
Agora, kamus9629 disse:


tinha esquecido de mudar no action.lua tinha replica de outro codigo la eu posso coloca o codigo La em cima na postagem com seus creditos ?

Acontece, tibia é tudo nos mínimos detalhes rsrs.

 

Mas, você fala aqui no post? É melhor eleger como melhor resposta o post que postei o código, porque assim quem precisar futuramente já identifica facilmente.