• 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+ shoot sd/hmm on invisible creature + invisible creatures not sending const_me_magicblue effect

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
994
Solutions
6
Reaction score
168
Location
Nowhere
Hi

I use tfs 1.4-1.5 protocol 8.6

have two problems. the first one is that i cannot shoot runes like ex: sd, hmm on invisible creature
changed this:
Lua:
function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

to this
Code:
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
but doesn't works, also i noticed that invisible mosnters does not sends blueshimmerffect when they turn invisible or meanwhile they are invisible.

any ideas how i could fix these problems pls?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Stalker" nameDescription="a stalker" race="blood" experience="90" speed="260" raceId="72">
    <health now="120" max="120" />
    <look type="128" head="97" body="116" legs="95" feet="95" corpse="6080" />
    <targetchange interval="4000" chance="10" />
    <targetstrategy nearest="70" weakest="10" mostdamage="10" random="10" />
<flags>
        <flag summonable="0" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="0" />
        <flag canpushitems="1" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="90" />
        <flag runonhealth="0" />
        <flag canwalkonenergy="0" />
        <flag canwalkonfire="0" />
        <flag canwalkonpoison="0" />
    </flags>
    <attacks>
        <attack name="melee" interval="2000" min="0" max="-70" />
        <attack name="lifedrain" interval="1000" chance="15" range="1" min="-20" max="-30">
            <attribute key="areaEffect" value="redshimmer" />
        </attack>
    </attacks>
    <defenses armor="14" defense="14">
        <defense name="invisible" interval="2000" chance="30" duration="15000">
            <attribute key="areaEffect" value="blueshimmer" />
        </defense>
    </defenses>
    <elements>
        <element deathPercent="5" />
        <element physicalPercent="-20" />
        <element holyPercent="-5" />
    </elements>
    <immunities>
        <immunity invisible="1" />
        <immunity lifedrain="1" />
    </immunities>
    <loot>
        <item id="2148" name="gold coin" chance="13123" countmax="8" />
        <item id="2410" name="throwing knife" chance="11116" countmax="2" />
        <item id="2260" name="blank rune" chance="8811" />
        <item id="2511" name="brass shield" chance="5617" />
        <item id="2478" name="brass legs" chance="3531" />
        <item id="12430" name="miraculum" chance="1543" />
        <item id="2425" name="obsidian lance" chance="1198" />
        <item id="2412" name="katana" chance="519" />
    </loot>
</monster>
 
Solution
Actually, I just saw it now... it's already fixed and tested, okay... both players and monsters are working normally.

Lua:
function onCastSpell(creature, var, isHotkey)
    local targetTile = Tile(var:getPosition())
    if targetTile then
        local topCreature = targetTile:getTopCreature()
        if topCreature then
            return combat:execute(creature, var)
        end
    end
    creature:sendCancelMessage("You can only use this rune on creatures.")
    creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
end
try!!
sd.
Lua:
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 then
            return combat:execute(creature, var)
        end
    end
    creature:sendCancelMessage("You can only use this rune on creatures.")
    creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
end
Afterward, go to spells.xml and look for this line, change it to 0.

Lua:
needtarget="1"
change to.
Lua:
needtarget="0"
 
Last edited:
try!!
sd.
Lua:
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
Afterward, go to spells.xml and look for this line, change it to 0.

Lua:
needtarget="1"
change to.
Lua:
needtarget="0"
worked

but how should i do with explsoion rune? because if i don't aim in monster i could not use that rune how to get it working for this case? @Mateus Robeerto
 
try!!
sd.
Lua:
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
Afterward, go to spells.xml and look for this line, change it to 0.

Lua:
needtarget="1"
change to.
Lua:
needtarget="0"
@johnsamir
@Mateus Robeerto

This is not the correct answer. Think about it. If he targets a player with this SD/HMM, then the script will return “You can only use this rune on creatures,” because your script only works with non-player creatures.

correct rune code for SD/HMM/UH/LMM/IH/Antidote Rune and others target runes:
Lua:
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

Also, the only problem with the original script is that it doesn’t change the needtarget part.

Correct change in xml from each rune that you changed the script to the above:
XML:
needtarget="0"


For AREA runes:
For explosion runes, you don’t need to make any changes to the original script. This is because explosion, gfb, and other runes are AREA runes, not target runes like SD or HMM, and they already inflict damage on invisible creatures.
 
Last edited:
Actually, I just saw it now... it's already fixed and tested, okay... both players and monsters are working normally.

Lua:
function onCastSpell(creature, var, isHotkey)
    local targetTile = Tile(var:getPosition())
    if targetTile then
        local topCreature = targetTile:getTopCreature()
        if topCreature then
            return combat:execute(creature, var)
        end
    end
    creature:sendCancelMessage("You can only use this rune on creatures.")
    creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    return false
end
 
Solution
thank you guys works i've made a new thread with an issue relted to invisible mosnters
@Mateus Robeerto @mano368
hope you guys could help me pls
 
Back
Top