JE

[Resolvido] Held Item

Por jeanflamengo, 30 de mar. de 2014 em Resolvidos

854
pda
8.54
held
held item
resolvido
28
5k
jeanflamengoJ
30 de março de 2014 às 02:37

preciso de ajuda nessa função

 

 

 

function doRegenerateWithHeld(cid,sid)
local ball = getPlayerSlotItem(cid, 8) or getPlayerSlotItem(getCreatureMaster(cid), 8)
if isSummon(sid) then
if isPlayer(cid) and #getCreatureSummons(cid) > 0 then
if isCreature(sid) and getItemAttribute(ball.uid, "regenheld") == 1 and getCreatureHealth(sid) < getCreatureMaxHealth(sid) then
addEvent(function() doCreatureAddHealth(sid,1000) doSendAnimatedText(getThingPos(sid), "+1000", 30) end, 0)
end
end
addEvent(doRegenerateWithHeld, 1000, cid, sid)
end
end

ela eh do held item de regen porem ele heala mesmo estando de battle e eu queria que so curasse quando estivesse sem battle e.e
30 de março de 2014 às 04:01


function doRegenerateWithHeld(cid,sid)

local ball = getPlayerSlotItem(cid, 8) or getPlayerSlotItem(getCreatureMaster(cid), 8)

 

 

if getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then

return false

end

 

if isSummon(sid) then

if isPlayer(cid) and #getCreatureSummons(cid) > 0 then

if isCreature(sid) and getItemAttribute(ball.uid, "regenheld") == 1 and getCreatureHealth(sid) < getCreatureMaxHealth(sid) then

addEvent(function() doCreatureAddHealth(sid,1000) doSendAnimatedText(getThingPos(sid), "+1000", 30) end, 0)

end

end

addEvent(doRegenerateWithHeld, 1000, cid, sid)

end

end

jeanflamengoJ
30 de março de 2014 às 04:44

vlw mais continua curando quando esta de battle

SlicerS
30 de março de 2014 às 10:51

 

function doRegenerateWithHeld(cid,sid)
   if not isSummon(sid) or not isPlayer(cid) then
      return
   elseif getCreatureCondition(cid, CONDITION_INFIGHT) or getCreatureCondition(sid, CONDITION_INFIGHT) then
      addEvent(doRegenerateWithHeld, 1000, cid, sid)
      return
   end
   
   local ball = getPlayerSlotItem(cid, 8)
   
   if ball.uid > 1 and getItemAttribute(ball.uid, "regenheld") == 1 and getCreatureHealth(sid) < getCreatureMaxHealth(sid) then
      doCreatureAddHealth(sid,1000)
      doSendAnimatedText(getThingPos(sid), "+1000", 30)
   end
   addEvent(doRegenerateWithHeld, 1000, cid, sid)
end
jeanflamengoJ
30 de março de 2014 às 13:38

vlw slicer mais ainda tah curando de battle

 

vo passar tudo que eu tiver aqui sobre o regen

 

 

exp2.0

 

 

------------------------- X-REGENERATION -----------------------------
if isSummon(attacker) and isSummon(cid) and isPlayer(getCreatureMaster(cid)) and (getPlayerStorageValue(getCreatureMaster(cid), 637501) <= 0) and (getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "regenheld") == 1) then
addEvent(doRegenerateWithHeld, 0, cid)
end

some functions

function doRegenerateWithHeld(cid,sid)
if not isSummon(sid) or not isPlayer(cid) then
return
elseif getCreatureCondition(cid, CONDITION_INFIGHT) or getCreatureCondition(sid, CONDITION_INFIGHT) then
addEvent(doRegenerateWithHeld, 1000, cid, sid)
return
end

local ball = getPlayerSlotItem(cid, 8)

if ball.uid > 1 and getItemAttribute(ball.uid, "regenheld") == 1 and getCreatureHealth(sid) < getCreatureMaxHealth(sid) then
doCreatureAddHealth(sid,1000)
doSendAnimatedText(getThingPos(sid), "+1000", 30)
end
addEvent(doRegenerateWithHeld, 1000, cid, sid)
end

SlicerS
30 de março de 2014 às 14:05

1* pq tu usa addEvent se vai usar tempo 0? u,U

2* o script nem era pra ta curando... tas passando soh o summon como parametro pra funçao...

 

o certo eh usar...

doRegenerateWithHeld(getCreatureMaster(cid), cid)

3* esse teu IF ae ta errado neh? o held eh pra curar quando ataca ou quando eh atacado? pq 1* tu faz 2 verificaçoes no CID e depois faz uma no ATTACKER... n sei bem como funciona esses held itens da pxg mas n vejo muito sentido nisso...

Editado Março 30 por Slicer

jeanflamengoJ
30 de março de 2014 às 14:16

@slicer tpw o regen na pxg cura quando o poke esta sem battle mais se de repente ele pegar battle para de curar

SlicerS
30 de março de 2014 às 14:40

sim isso eu intendi... soh q tpw, assim q tu tira o poke da ball ja começa a curar? pq tu diz q n eh pra ta em battle, mas coloca pra ativar a funçao no exp.lua, q eh executado quando o poke leva um hit...

 

achu melhor esperar alguem q saiba como esse sistema funciona kk' faz + de 1 ano q n entro nem no forum da pxg ;p

TechrlzT
30 de março de 2014 às 14:48

Veja se esta do jeito que você quer:

function doRegenerateWithHeld(cid,sid)
local ball = getPlayerSlotItem(cid, 8) or getPlayerSlotItem(getCreatureMaster(cid), 8)
if isSummon(sid) then
if isPlayer(cid) and #getCreatureSummons(cid) > 0 then
if isCreature(sid) and getItemAttribute(ball.uid, "regenheld") == 1 and getCreatureHealth(sid) < getCreatureMaxHealth(sid) and getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE then
addEvent(function() doCreatureAddHealth(sid,1000) doSendAnimatedText(getThingPos(sid), "+1000", 30) end, 0)
end
end
addEvent(doRegenerateWithHeld, 1000, cid, sid)
 end  
 end

Editado Março 30 por Techrlz

jeanflamengoJ
30 de março de 2014 às 15:38

@slicer eh assim se poke nao estiver com o hp full e nao estiver com battle ele fica curando vida mais se der o sinal de battle automaticamente para de curar mais se sumir o battle ai volta euhheehue (mó doiderah )


@tech esse jeito que tu passo ae esta na base do serve so que tbm cura estando de battle

Editado Março 30 por jeanflamengo

TechrlzT
30 de março de 2014 às 15:52

Eu coloquei uma condição de infight , mesmo assim ele continua curando?

jeanflamengoJ
30 de março de 2014 às 16:08

@tech sim

SlicerS
30 de março de 2014 às 16:10

estranhu neh? tava pensando aki... sera q eh pq ta no exp.lua e dai ele executa antes do poke levar dano em si, fazendo assim ele curar a 1x soh? -pq dai o player pode estar sem battle ainda-

 

@topic

tenta usar oq eu postei ali e dai la no exp.lua tu usa...

addEvent(doRegenerateWithHeld, 150, getCreatureMaster(cid), cid)
jeanflamengoJ
30 de março de 2014 às 16:49

@slicer tentei aqui so que tpw para de healar msmo estando sem battle e so heala quando o player solta o poke, se o player fika clickando pra soltar e puxar o poke toda hora heala 1k uhehuehee

gabrielbsalesG
30 de março de 2014 às 18:02
Melhor resposta

Jean, faz assim, apaga a parte do exp2.lua.

No some functions.lua substitui a função por essa:

 

 

function doRegenerateWithHeld(cid,sid)
regenerando = {}
local ball = getPlayerSlotItem(cid, 8) or getPlayerSlotItem(getCreatureMaster(cid), 8)
if isSummon(sid) then
if isPlayer(cid) and #getCreatureSummons(cid) > 0 then
if isCreature(sid) and getCreatureHealth(sid) < getCreatureMaxHealth(sid) and getItemAttribute(ball.uid, "regenheld") == 1 then
if getCreatureCondition(cid, CONDITION_INFIGHT) or getCreatureCondition(sid, CONDITION_INFIGHT) then return true end
addEvent(function() doCreatureAddHealth(sid,1000) doSendAnimatedText(getThingPos(sid), "+1000", 30) regenerando = 1 end, 0)
end
end
addEvent(doRegenerateWithHeld, 1000, cid, sid)
 end  
 end

 

 

 

No goback.lua ao inves de:

    addEvent(doRegenerateWithHeld, 0, getCreatureMaster(pk), pk)

deixe assim:

if not getCreatureCondition(cid, CONDITION_INFIGHT) then
    addEvent(doRegenerateWithHeld, 0, getCreatureMaster(pk), pk)
    end

Vai em login.lua e em baixo de:

registerCreatureEvent(cid, "LookSystem")

Adicione:

registerCreatureEvent(cid, "Xregen")

Crie um arquivo.lua com nome de Regeneration e dentro bota isso:

function onThink(cid, interval)
if isPlayer(cid) and #getCreatureSummons(cid) >= 1 then
 if getCreatureHealth(getCreatureSummons(cid)[1]) == getCreatureMaxHealth(getCreatureSummons(cid)[1]) then
 regenerando = 0
 end
if not getCreatureCondition(cid, CONDITION_INFIGHT) then
if getCreatureHealth(getCreatureSummons(cid)[1]) < getCreatureMaxHealth(getCreatureSummons(cid)[1]) then
if (getPlayerStorageValue(cid, 637501) <= 0) and getItemAttribute(getPlayerSlotItem(cid, 8).uid, "regenheld") == 1 then
if regenerando == 0 then
doRegenerateWithHeld(cid, getCreatureSummons(cid)[1])
end
end
end
end
end
end

No creaturescripts.xml adiciona essa tag:

<event type="think" name="Xregen" event="script" value="Regeneration.lua"/>

Pronto, tem o tuto na minha assinatura \/