Jump to content

Potion System - Igual PxG


Noninhouh

Recommended Posts

Bom, vim trazer a vocês o sistema de potion igual ao da pxg...

Gostaria de falar que peguei esse sistema do servidor PDA e so mudei umas coisinhas pra ele healar o pokemon do mesmo jeito que o da pxg

 

Actions/scripts/potion.lua:

 

 

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 = {
[12347] = {health = 400, animate = "SMALL POT", collor = 140},
[12348] = {health = 1500, animate = "GREAT POT", collor = 140},       
[12346] = {health = 4000, animate = "ULTRA POT", collor = 140},
[12345] = {health = 10000, animate = "HYPER POT", collor = 140},
[12344] = {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

 

 

 

 

Actions/actions.xml:

 

 

<action itemid="12344-12348" event="script" value="potion.lua" allowfaruse="1" blockwalls="1"/>

 

 

 

OBS: Consertem os id's dos items e as cores do animated text.

 

 

Creditos:

Slicer, Brun123, eu e qm ajudo fazer o sistema original do PDA

Edited by Noninhouh
Link to comment
Share on other sites

  • 6 years later...
  • 8 months later...
Em 25/03/2014 em 12:12, Noninhouh disse:

Bom, vim trazer a vocês o sistema de potion igual ao da pxg...

Gostaria de falar que peguei esse sistema do servidor PDA e so mudei umas coisinhas pra ele healar o pokemon do mesmo jeito que o da pxg

 

Actions/scripts/potion.lua:

 

  Ocultar conteúdo

 



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 = {
[12347] = {health = 400, animate = "SMALL POT", collor = 140},
[12348] = {health = 1500, animate = "GREAT POT", collor = 140},       
[12346] = {health = 4000, animate = "ULTRA POT", collor = 140},
[12345] = {health = 10000, animate = "HYPER POT", collor = 140},
[12344] = {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

 

 

 

 

Actions/actions.xml:

 

  Ocultar conteúdo

 



<action itemid="12344-12348" event="script" value="potion.lua" allowfaruse="1" blockwalls="1"/>

 

 

 

OBS: Consertem os id's dos items e as cores do animated text.

 

 

Creditos:

Slicer, Brun123, eu e qm ajudo fazer o sistema original do PDA

 

 

 

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

Link to comment
Share on other sites

×
×
  • Create New...