Jump to content
×
×
  • Create New...
  • 0

Potion de Pokemon Certa Porcentagem HP


Question

Versão do Servidor: TFS - 1.0
Tipo de Script: actions
Código:
 
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 = {
[12347] = {effect = 14, hp = 120}, --super potion
[12348] = {effect = 14, hp = 300}, --great potion              
[12346] = {effect = 14, hp = 800}, --ultra potion
[12345] = {effect = 14, hp = 2000}, --hyper potion
[7588] = {effect = 14, hp = 6000}, -- 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

Eu quero uma poção que cura uma porcentagem de exemplo
que cura o pokémon de 10.000, mas que cura por segundo de 1000. até atingir 10.000

 

 

 

Link to post
Share on other sites
  • Answers 34
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

Sobre erro, é porque eu escrevi errado o nome da função, digitei uma letra errada, troque o código por esse:   local function HealPerTurn(cid, health, effect, seconds, time) local duration =

Sim, eu entendi o que você quer. É estranho, pois eu testei aqui e está funcionando normal. Troque o código por esse:   local function HealPerTurn(cid, health, effect, time, seconds) local du

Você precisa explicar melhor, pois quando falou que está usando infinito, eu entendi que a cura estava sendo infinita, e não o uso. E sim, realmente esqueci de remover o item.   Sobre esse e

Posted Images

Recommended Posts

  • 0
Agora, KaboFlow disse:

 

[06/04/2021 22:42:12] [Error - Action Interface] 
[06/04/2021 22:42:12] In a timer event called from: 
[06/04/2021 22:42:12] data/actions/scripts/potion/Potion2021.lua:onUse
[06/04/2021 22:42:12] Description: 
[06/04/2021 22:42:12] (luaGetCreatureMaxHealth) Creature not found

[06/04/2021 22:42:12] [Error - Action Interface] 
[06/04/2021 22:42:12] In a timer event called from: 
[06/04/2021 22:42:12] data/actions/scripts/potion/Potion2021.lua:onUse
[06/04/2021 22:42:12] Description: 
[06/04/2021 22:42:12] (luaDoPlayerSendCancel) Player not found

Quando esse erro acontece? Ao puxar o pokémon quando está realizando a cura?

Link to post
Share on other sites
  • 0
Em 06/04/2021 em 22:43, Yan18 disse:

Quando esse erro acontece? Ao puxar o pokémon quando está realizando a cura?

 

 

[01/05/2021 11:27:33] [Error - Action Interface] 
[01/05/2021 11:27:33] data/actions/scripts/potion.lua:onUse
[01/05/2021 11:27:33] Description: 
[01/05/2021 11:27:33] data/actions/scripts/potion.lua:30: attempt to call global 'getThingFromPosWithProtect' (a nil value)
[01/05/2021 11:27:33] stack traceback:
[01/05/2021 11:27:33]     data/actions/scripts/potion.lua:30: in function <data/actions/scripts/potion.lua:29>

 

 

ache outra mais tenhe error...

 

 

Spoiler

function doHealOverTime(cid, heal, 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 onPokeHealthChange(getCreatureMaster(cid))
elseif getCreatureHealth(cid) + heal/10 >= getCreatureMaxHealth(cid) then
   doSendAnimatedText(getThingPos(cid), "+"..getCreatureMaxHealth(cid) - getCreatureHealth(cid), 65)
   doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
   doSendMagicEffect(getThingPos(cid), 12)
   return onPokeHealthChange(getCreatureMaster(cid))
end

doSendAnimatedText(getThingPos(cid), "+"..heal/10, 65)
doCreatureAddHealth(cid, heal/10)
doSendMagicEffect(getThingPos(cid), 12)
onPokeHealthChange(getCreatureMaster(cid))
addEvent(doHealOverTime, 1000, cid, heal, turn - 1, effect)
end

local potions = {
[2272] = {health = 400, animate = "SMALL POT", collor = 140},
[2274] = {health = 1500, animate = "GREAT POT", collor = 140},       
[2271] = {health = 4000, animate = "ULTRA POT", collor = 140},
[2270] = {health = 10000, animate = "HYPER POT", collor = 140},
[7588] = {health = 30000, animate = "ULTIMATE POT", collor = 140},
}

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
 
doCreatureSay(cid, "".. getCreatureName(pid)..", take this potion!", TALKTYPE_SAY)
doSendAnimatedText(getThingPos(pid), potions[item.itemid].animate, potions[item.itemid].collor)
setPlayerStorageValue(pid, 173, 1)
doRemoveItem(item.uid, 1)

doHealOverTime(pid, potions[item.itemid].health, 10, 12)

return true
end

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now