Jump to content
  • 0

Question

eu estou tendo dificuldade em fazer a spell só gastar mana longe dos ids

 

eu n sei direito como funciona o else

nesse caso só q ele só gasta mana nesse caso \/

 

function onCastSpell(cid, var)

local pos = getPlayerPosition(cid)

doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)

local position, match = getCreaturePosition(cid)

for x = (position.x - 3), (position.x + 3) do

for y = (position.y - 3), (position.y + 3) do

local tmp = {x = x, y = y, z = position.z}

if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then

doCreatureAddMana(cid, 1)

else

doCreatureAddMana(cid, -1)

return doCombat(cid, combat, var)

end

end

return doCombat(cid, combat, var)

end

 

 

acho melhor colocar pra gastar mana por aqui

em vez de gastar pelo xml

Edited by rohfagundes
Link to comment
https://xtibia.com/forum/topic/206146-ajuda-nessa-spell-aqui-x/
Share on other sites

13 answers to this question

Recommended Posts

  • 0

não intendi uq vc quer

 

Abraço

 

seguinte

 

if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then

doCreatureAddMana(cid, 1)

else

doCreatureAddMana(cid, -1)

 

queria q se ele estivese perto dos ids ele ganha 1 de mana

se n ele perde 1 de mana

 

o problema é q n sei muito bem como fazer isso

e ele só ta perdendo

  • 0

cara o seu script estava necessitando de um 'end' simplesmente o adicionei veja se vai funcionar

 

function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

  • 0

cara o seu script estava necessitando de um 'end' simplesmente o adicionei veja se vai funcionar

 

function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

 

Sim faltava um end, mas tambem falta a variaval

if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then

essa parte precisaria de uma variavel que se chame local WATER_TILES.

 

 

Nao testei mas testa ai =o

 

 

 

 

[size=4]local agua = {1111, 2222, 3333}-- configure o id dos tiles de water[/size]
function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(agua, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

Edited by Gears
  • 0

cara o seu script estava necessitando de um 'end' simplesmente o adicionei veja se vai funcionar

 

function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

 

n é por causa disso

eu ja tinha tentado antes

 

 

pera vou postar o script inteiro '-'

 

 

 

 

edit: ta ai o script da spell inteiro

 

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)

setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, -35, 0, -55)

local area = createCombatArea({

{0, 0, 0},

{1, 1, 1},

{1, 2, 1},

{1, 1, 1},

{0, 0, 0}

})

setCombatArea(combat, area)

 

local WATER_TILES = {1370,1371,1372,1773,9466,1378, 4718, 6628, 6630, 4664, 5739, 4614, 4615, 4616, 4617, 4618, 4619, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

 

function onCastSpell(cid, var)

local pos = getPlayerPosition(cid)

doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)

local position, match = getCreaturePosition(cid)

for x = (position.x - 3), (position.x + 3) do

for y = (position.y - 3), (position.y + 3) do

local tmp = {x = x, y = y, z = position.z}

if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then

doCreatureAddMana(cid, 1)

else

doCreatureAddMana(cid, -1)

return doCombat(cid, combat, var)

end

end

return doCombat(cid, combat, var)

end

end

 

Edited by rohfagundes
  • 0

@Rohfagundes, testa ai :)

 

 

local WATER_TILES = {1370,1371,1372,1773,9466,1378, 4718, 6628, 6630, 4664, 5739, 4614, 4615, 4616, 4617, 4618, 4619, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, -35, 0, -55)
local area = createCombatArea({
{0, 0, 0},
{1, 1, 1},
{1, 2, 1},
{1, 1, 1},
{0, 0, 0}
})
setCombatArea(combat, area)
function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

  • 0

@Rohfagundes, testa ai :)

 

 

local WATER_TILES = {1370,1371,1372,1773,9466,1378, 4718, 6628, 6630, 4664, 5739, 4614, 4615, 4616, 4617, 4618, 4619, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, -35, 0, -55)
local area = createCombatArea({
{0, 0, 0},
{1, 1, 1},
{1, 2, 1},
{1, 1, 1},
{0, 0, 0}
})
setCombatArea(combat, area)
function onCastSpell(cid, var)
local pos = getPlayerPosition(cid)
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)
local position, match = getCreaturePosition(cid)
for x = (position.x - 3), (position.x + 3) do
for y = (position.y - 3), (position.y + 3) do
local tmp = {x = x, y = y, z = position.z}
if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
doCreatureAddMana(cid, 1)
else
doCreatureAddMana(cid, -1)
return doCombat(cid, combat, var)
end
end
return doCombat(cid, combat, var)
end
end

 

o problema continua

é como se ele ignora-se a posiçao do player em relaçao a agua

ou

o problema ta nessa parte

 

if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then

doCreatureAddMana(cid, 1)

else

doCreatureAddMana(cid, -1)

 

pq sempre tira 1 de mana perto dos ids ou n

  • 0

<instant name="Water Circle" words="w-circle" lvl="1" exhaustion="2000" prem="0" range="0" needlearn="0" needtarget="0" blockwalls="1" aggressive="1" event="script" value="water/water circle.lua">

<vocation name="Water"/>

</instant>

  • 0

Pode ser também que a speel esteja errada, peguei 1 spell qualquer aqui testa ai :)

 

Nao entendi mt bem essa spell sua então peguei 1 spell e edita pra que ela só seja usada dentro da agua, o resto vc adapta :)

 



local WATER_TILES = {1370,1371,1372,1773,9466,1378, 4718, 6628, 6630, 4664, 5739, 4614, 4615, 4616, 4617, 4618, 4619, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}
local mana = 1
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 1500, 1500, 1500, 1500)

local arr = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
  if not isInArray(WATER_TILES, getThingfromPos(pos)) then
         return doPlayerSendTextMessage(cid, 20, "Vc não pode usar essa magia fora da agua.")
  end

  • 0

tenta assim..

 

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, -35, 0, -55)
local area = createCombatArea({
{0, 0, 0},
{1, 1, 1},
{1, 2, 1},
{1, 1, 1},
{0, 0, 0}
})
setCombatArea(combat, area)

local WATER_TILES = {1370,1371,1372,1773,9466,1378, 4718, 6628, 6630, 4664, 5739, 4614, 4615, 4616, 4617, 4618, 4619, 4608, 4609, 4610, 4611, 4612, 4613, 7236, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4665, 4666, 4820, 4821, 4822, 4823, 4824, 4825}

function onCastSpell(cid, var)
local pos, found = getPlayerPosition(cid), false
doSendMagicEffect({x = pos.x+1, y = pos.y+1, z = pos.z}, 87)

for x = (pos.x - 3), (pos.x + 3) do
   for y = (pos.y - 3), (pos.y + 3) do
    local tmp = {x = x, y = y, z = pos.z, stackpos = 0}
    if isInArray(WATER_TILES, getTileThingByPos(tmp).itemid) then
	   found = true
	   break
    end
   end
end
if found then
  doPlayerAddMana(cid, 1)
else
  doPlayerAddMana(cid, -1)
end
return doCombat(cid, combat, var)
end

 

×
×
  • Create New...