• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Problem undead legion spell tfs 1.2

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
Hello guys,
someone here can help me with my spell problem?

This spell is not working correctly, currently the spell only works if my character is on top of the dead creature corpse (same tile) and appear only 1 skeleton... (does nothing with the others bodies around) of my character.

and is not doing a magic in area, how would it be correctly...

How can I fix this spell?

My spells.xml configuration

XML:
    <instant name="Undead Legion" words="exana mas mort" lvl="30" mana="300" prem="1" aggressive="1" needlearn="1" script="spells/undead legion.lua">
        <vocation name="Druid" />
        <vocation name="Elder Druid" />
    </instant>


My spell script.
Undead Legion.lua


LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))

local humanBodies = {
    4240, 4241, 4247, 4248
}

function onCastSpell(creature, variant)
    local position = Variant.getPosition(variant)
    local tile = Tile(position)
    if tile then
        local corpse = tile:getTopDownItem()
        if corpse then
            local itemType = corpse:getType()
            if not table.contains(humanBodies, itemType:getId()) then
                if itemType:isCorpse() and itemType:isMovable() then
                    local monster = Game.createMonster("Skeleton", position)
                    if monster then
                        corpse:remove()
                        monster:setMaster(creature)
                        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
                        return true
                    end
                end
            end
        end
    end

    creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    return false
end
 
Hello guys,
someone here can help me with my spell problem?

This spell is not working correctly, currently the spell only works if my character is on top of the dead creature corpse (same tile) and appear only 1 skeleton... (does nothing with the others bodies around) of my character.

and is not doing a magic in area, how would it be correctly...

How can I fix this spell?

My spells.xml configuration

XML:
    <instant name="Undead Legion" words="exana mas mort" lvl="30" mana="300" prem="1" aggressive="1" needlearn="1" script="spells/undead legion.lua">
        <vocation name="Druid" />
        <vocation name="Elder Druid" />
    </instant>


My spell script.
Undead Legion.lua


LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))

local humanBodies = {
    4240, 4241, 4247, 4248
}

function onCastSpell(creature, variant)
    local position = Variant.getPosition(variant)
    local tile = Tile(position)
    if tile then
        local corpse = tile:getTopDownItem()
        if corpse then
            local itemType = corpse:getType()
            if not table.contains(humanBodies, itemType:getId()) then
                if itemType:isCorpse() and itemType:isMovable() then
                    local monster = Game.createMonster("Skeleton", position)
                    if monster then
                        corpse:remove()
                        monster:setMaster(creature)
                        position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
                        return true
                    end
                end
            end
        end
    end

    creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
    return false
end
I can see the issue, but I don't know enough about spells or TFS 1.0+ to fix it for you.

Basically you are calling 'position' from var (most likely the player position, or maybe the position in front?), but you aren't looping through the 5x5 area that the combat portion is using.
So you need to find a way to use each tile in the area that is being created.

I'm sure there is some pre-built function to do that.. but otherwise you could go and make your own table, that you can loop through using the player position as a guide.

pseudo code..
Code:
local table = {
   {1, 0},
   {0, 0},
   {-1, 0} -- et cetera
}
for i = 1, #table do
    position = Position(x + table[1], y + table[2], z)
    -- check for corpse, et cetera
end
 
not tfs 1.2, but it works on my tfs 1.2 server.

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

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

function onTargetCorpse(cid, pos)
    local getPos = pos
    getPos.stackpos = 255
    corpse = getThingfromPos(getPos)
    if(corpse.uid > 0 and isCorpse(corpse.uid) and isMoveable(corpse.uid) and getPlayerSkullType(cid) ~= 5) then
       

    local summon = Game.createMonster("Skeleton", pos, true)
        if summon then
            doRemoveItem(corpse.uid)
            cid:addSummon(summon)
            pos:sendMagicEffect(CONST_ME_MAGIC_BLUE)
        end
        return false
    end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetCorpse")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Back
Top