Lua Script Error: [Spell Interface]
data/spells/scripts/attack/sudden death.luanCastSpell
data/spells/scripts/attack/sudden death.lua:16: attempt to index local 'tile' (a nil value)
stack traceback:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1.38 + maglevel * 6.70)
max = -(level * 1.74 + maglevel * 7.34)
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant, isHotkey)
local position = variant:getPosition()
local tile = Tile(position)
if tile:getTopCreature() then
return combat:execute(creature, variant)
end
i have this error:
by code from link and I can't solve it in any way
creature:sendCancelMessage(RETURNVALUE_CANONLYUSETHISRUNEONCREATURES)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
needtarget="1"
needtarget="0"
Have you even tried?this does not give the desired effect. You can shoot anywhere and only want to shoot at monsters and players
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1.38 + maglevel * 6.70)
max = -(level * 1.74 + maglevel * 7.34)
return min, max
end
combat:setFormula(COMBAT_PHYSICALDAMAGE, -1.38, -1.74, 6.70, 7.34)
function onCastSpell(creature, var, isHotkey)
local targetTile = Tile(var:getPosition())
if targetTile then
local topCreature = targetTile:getTopCreature()
if topCreature and not topCreature:isPlayer() then
return combat:execute(creature, var)
else
creature:sendCancelMessage("You can only use this rune on creatures.")
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
return false
end
needtarget="1"
needtarget="0"
not work for me. in console no errors but no shoot.The script has been corrected here...
Lua:local combat = Combat() combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA) combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH) function onGetFormulaValues(cid, level, maglevel) min = -(level * 1.38 + maglevel * 6.70) max = -(level * 1.74 + maglevel * 7.34) return min, max end combat:setFormula(COMBAT_PHYSICALDAMAGE, -1.38, -1.74, 6.70, 7.34) function onCastSpell(creature, var, isHotkey) local targetTile = Tile(var:getPosition()) if targetTile then local topCreature = targetTile:getTopCreature() if topCreature and not topCreature:isPlayer() then return combat:execute(creature, var) else creature:sendCancelMessage("You can only use this rune on creatures.") creature:getPosition():sendMagicEffect(CONST_ME_POFF) end end return false end
spells.xml
change toLua:needtarget="1"
Lua:needtarget="0"
Done, okay
I was reloading spells so much that's why SD stopped shooting. I have tfs 1.2. I think the problem is:Did you use the command /reload spells? Or did you restart the server? What's your TFS version? It's been tested here and is functioning normally.
I was reloading spells so much that's why SD stopped shooting. I have tfs 1.2. I think the problem is:
Tile(var:getPosition())
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
function onGetFormulaValues(player, level, magicLevel)
local min = (level / 5) + (magicLevel * 4.3) + 32
local max = (level / 5) + (magicLevel * 7.4) + 48
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant, isHotkey)
local position = variant:getPosition()
local tile = Tile(position)
if tile:getTopCreature() then
return combat:execute(creature, variant)
end
creature:sendCancelMessage(RETURNVALUE_CANONLYUSETHISRUNEONCREATURES)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
Here, the target is already set to either the monster or the player, both of which I included in the script. I tested it, and it's working well. Please try running my script again!if topCreature and not topCreature:isPlayer() then