• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ cant shoot with SD to invisible monsters

Tubeshop

Member
Joined
Nov 23, 2023
Messages
173
Reaction score
19
changing to needtarget="0" for SD helps, but I don't want to do it because then you can shoot SD everywhere and it is unnatural. How to make SD shoot invisible monsters like Warlock?
 
 
i have this error:

Lua Script Error: [Spell Interface]
data/spells/scripts/attack/sudden death.lua:eek:nCastSpell
data/spells/scripts/attack/sudden death.lua:16: attempt to index local 'tile' (a nil value)
stack traceback:


by code from link and I can't solve it in any way

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

creature:sendCancelMessage(RETURNVALUE_CANONLYUSETHISRUNEONCREATURES)
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
 
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
Lua:
needtarget="1"
change to
Lua:
needtarget="0"

Done, okay :)
 
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
Lua:
needtarget="1"
change to
Lua:
needtarget="0"

Done, okay :)
not work for me. in console no errors but no shoot.
 
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())

The solution to this problem is to both change the onCastSpell function as above and also changing needtarget to "0". Then, after combining those two steps this error disappears, and you can shoot runes at invisible monsters, and not "anywhere" like gfb, unless you are using some old or shitty distro. But my guess is you did somethign wrong, or didn't follow those two steps.

This is tested and working fine on 1.4.2
Lua:
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
sd.gif
 
Last edited:
No its no work perfecly. Now i cant shoot from player to player.

need replace:
if topCreature and not topCreature:isPlayer() then
to
if topCreature then
 
No its no work perfecly. Now i cant shoot from player to player.

need replace:
if topCreature and not topCreature:isPlayer() then
to
if topCreature then
Dude, just use the script I have provided, I am 100% sure you didnt try it, and used only the other one. Ehh...

sd3.gif
 
Back
Top