Ir para conteúdo
  • 0

spell usadar perto de tal lugar n gasta mana


rohfagundes

Pergunta

7 respostass a esta questão

Posts Recomendados

  • 0

Vou pegar a magia Ice Strike como exemplo:

 


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)

local WATER_TILES = {}

function onCastSpell(cid, var)
       local position, match = getCreaturePosition(cid)
       for x = (position.x - 1), (position.x + 1) do
               for y = (position.y - 1), (position.y + 1) do
                       local tmp = {x = x, y = y, z = position.z}
                       if isInArray(WATER_TILES, getThingFromPos(tmp).itemid) then
                               doCreatureAddMana(cid, getInstantSpellInfo("Ice Strike").mana)
                               return doCombat(cid, combat, var)
                       end
               end
       end
       return doCombat(cid, combat, var)
end

 

Só adicionar em WATER_TILES todos os ids de tiles de água.

Editado por Oneshot
Link para o comentário
Compartilhar em outros sites

  • 0

n aparece nenhum erro

aqui

mas continua gastando mana

 

essa ai seria pra n gastar a mana né?

 

e como pode ser a outra q só vai dar pra usar perto desses ids?

 

 

 

 

ta ai o jeito q coloquei

 

 

 

local function doPushCreature(target, cid)

if target > 0 then

if not isNpc(target) then

local position = getThingPosition(cid)

local fromPosition = getThingPosition(target)

local x = ((fromPosition.x - position.x) < 0 and -1 or ((fromPosition.x - position.x) == 0 and 0 or 1))

local y = ((fromPosition.y - position.y) < 0 and -1 or ((fromPosition.y - position.y) == 0 and 0 or 1))

local toPosition = {x = fromPosition.x + x, y = fromPosition.y + y, z = fromPosition.z}

if doTileQueryAdd(target, toPosition) == 1 and getTileInfo(toPosition).house == false then

doTeleportThing(target, toPosition, true)

end

end

end

end

local spell = {}

spell.config = {

[5] = {

damageType = 1,

areaEffect = 1,

area = {

{0, 0, 1, 1, 1, 0, 0},

{0, 1, 0, 0, 0, 1, 0},

{1, 0, 0, 0, 0, 0, 1},

{1, 0, 0, 2, 0, 0, 1},

{1, 0, 0, 0, 0, 0, 1},

{0, 1, 0, 0, 0, 1, 0},

{0, 0, 1, 1, 1, 0, 0}

}

},

[4] = {

damageType = 1,

areaEffect = 1,

area = {

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 2, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0}

}

},

[3] = {

damageType = 1,

areaEffect = 1,

area = {

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 1, 1, 1, 0, 0},

{0, 1, 0, 0, 0, 1, 0},

{0, 1, 0, 2, 0, 1, 0},

{0, 1, 0, 0, 0, 1, 0},

{0, 0, 1, 1, 1, 0, 0},

{0, 0, 0, 0, 0, 0, 0}

}

},

[2] = {

damageType = 1,

areaEffect = 1,

area = {

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 2, 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] = {

damageType = 1,

areaEffect = 1,

area = {

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 1, 1, 1, 0, 0},

{0, 0, 1, 2, 1, 0, 0},

{0, 0, 1, 1, 1, 0, 0},

{0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0}

}

}

}

 

spell.combats = {}

for _, config in ipairs(spell.config) do

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, config.damageType)

setCombatParam(combat, COMBAT_PARAM_EFFECT, config.areaEffect)

setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, -10, 0, -22)

function onTargetCreature(cid, target)

doPushCreature(target, cid)

end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

setCombatArea(combat, createCombatArea(config.area))

table.insert(spell.combats, combat)

end

 

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 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

match = true

break

end

end

 

if match then

break

end

end

 

if match then

doCreatureAddMana(cid, getInstantSpellInfo("Water Spin").mana)

end

for n = 1, #spell.combats do

addEvent(doCombat, (n * 150) - 150, cid, spell.combats[n], var)

end

return true

end

 

 

Editado por rohfagundes
Link para o comentário
Compartilhar em outros sites

  • 0

experimenta no lugar de:

 

doCreatureAddMana(cid, getInstantSpellInfo("Water Spin").mana)

 

usar addEvent, assim:

 

addEvent(doCreatureAddMana, 1, cid, getInstantSpellInfo("Water Spin").mana)

 

porque a mana só é gasta depois do return true, então se você testar com mana full, vai gastar mana

 

pra não permitir que use a magia caso não esteja perto dos itens, é só fazer:

 

if not match then return false end

 

resumindo, troca essa parte:

 

if match then
doCreatureAddMana(cid, getInstantSpellInfo("Water Spin").mana)
end

 

por essa:

 

if match then
   addEvent(doCreatureAddMana, 1, cid, getInstantSpellInfo("Water Spin").mana)
else
   doPlayerSendCancel(cid, "Alguma mensagem de erro!")
   return false
end

Link para o comentário
Compartilhar em outros sites

  • 0

fiz assim

só q agora só da dano quando gasta a mana

 

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

if match then

addEvent(doCreatureAddMana, 1, cid, getInstantSpellInfo("Water Circle").mana)

else

doPlayerSendCancel(cid, "Alguma mensagem de erro!")

return FALSE

end

return doCombat(cid, combat, var)

end

end

end

return doCombat(cid, combat, var)

end

Link para o comentário
Compartilhar em outros sites

  • 0
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), false
   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
		    match = true
		    break
	    end
    end
   end

   if match then
    addEvent(doCreatureAddMana, 1, cid, getInstantSpellInfo("Water Circle").mana)
   else
    doPlayerSendCancel(cid, "Alguma mensagem de erro!")
   return FALSE
   end

return doCombat(cid, combat, var)
end

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...