• 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+ Destroy Field, Animate dead - Not working.

absorc

Ask-her
Joined
Oct 7, 2013
Messages
57
Reaction score
4
Location
Sweden
Hey guys

I am currently trying to find errors on the server I am planning on using in the future.

Atm I am using RealOTX 7.72 TFS 1.3 by mattyx14.
Now the problems I've encountered so far is that destroy field or animate dead are not working.

When I am trying to use Destroy field nothing happens and this is the error code i get:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/support/destroy_field_rune.lua:onCastSpell
data/spells/scripts/support/destroy_field_rune.lua:3: attempt to call global 'getAllCreatures' (a nil value)
stack traceback:
        [C]: in function 'getAllCreatures'
        data/spells/scripts/support/destroy_field_rune.lua:3: in function <data/spells/scripts/support/destroy_field_rune.lua:1>
This is my destroyfield.lua
Lua:
function onCastSpell(cid, var)
    local position = variantToPosition(var)
    local creaturesSize = #getAllCreatures(position)
    local stackSize = getTileStackItemsSize(position) + creaturesSize
    local itemsTable = {}
    local removed = false

    if stackSize > 0 then
        for i=1,stackSize do
            position.stackpos = i
            itemsTable[i] = getTileThingByPos(position)
        end
    end

    if #itemsTable > 0 then
        for k, item in pairs(itemsTable) do
            if isInArray(FIELDS, item.itemid) then
                doRemoveItem(item.uid)
                removed = true
            end
        end
    end

    if removed then
        doSendMagicEffect(position, CONST_ME_POFF)
        return true
    end

    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    return false
end

And when I am trying to use animate dead rune, then the dead corpse disappears but there is no skeleton spawning, I recieve this error in my console:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/support/animate_dead_rune.lua:onCastSpell
data/spells/scripts/support/animate_dead_rune.lua:7: attempt to call global 'doPlayerSummonCreature' (a nil value)
stack traceback:
        [C]: in function 'doPlayerSummonCreature'
        data/spells/scripts/support/animate_dead_rune.lua:7: in function <data/spells/scripts/support/animate_dead_rune.lua:1>
This is my animate dead.lua:
Lua:
local function doTargetCorpse(cid, pos)
    local getPos = pos
    getPos.stackpos = 255
    corpse = getThingfromPos(getPos)
    if(corpse.uid > 0 and isCreature(corpse.uid) == false and isInArray(CORPSES, corpse.itemid) ) then
        doRemoveItem(corpse.uid)
        doPlayerSummonCreature(cid, "Skeleton", pos)
        doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
        return LUA_NO_ERROR
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return LUA_ERROR
end

function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if(pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0) then
        return doTargetCorpse(cid, pos)
    end

    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return LUA_ERROR
end
This is my global.lua:
Lua:
dofile('data/lib/lib.lua')

NOT_MOVEABLE_ACTION = 8000
PARTY_PROTECTION = 1 -- Set to 0 to disable.
ADVANCED_SECURE_MODE = 1 -- Set to 0 to disable.

STORAGEVALUE_PROMOTION = 30018

ropeSpots = {384, 418}

doors = {[1209] = 1211, [1210] = 1211, [1212] = 1214, [1213] = 1214, [1219] = 1220, [1221] = 1222, [1231] = 1233, [1232] = 1233, [1234] = 1236, [1235] = 1236, [1237] = 1238, [1239] = 1240, [1249] = 1251, [1250] = 1251, [1252] = 1254, [1253] = 1254, [1539] = 1540, [1541] = 1542, [3535] = 3537, [3536] = 3537, [3538] = 3539, [3544] = 3546, [3545] = 3546, [3547] = 3548, [4913] = 4915, [4914] = 4915, [4916] = 4918, [4917] = 4918, [5082] = 5083, [5084] = 5085}
verticalOpenDoors = {1211, 1220, 1224, 1228, 1233, 1238, 1242, 1246, 1251, 1256, 1260, 1540, 3546, 3548, 3550, 3552, 4915, 5083}
horizontalOpenDoors = {1214, 1222, 1226, 1230, 1236, 1240, 1244, 1248, 1254, 1258, 1262, 1542, 3537, 3539, 3541, 3543, 4918, 5085}
openSpecialDoors = {1224, 1226, 1228, 1230, 1242, 1244, 1246, 1248, 1256, 1258, 1260, 1262, 3541, 3543, 3550, 3552}
questDoors = {1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551}
levelDoors = {1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549}
keys = {2086, 2087, 2088, 2089, 2090, 2091, 2092}

function getDistanceBetween(firstPosition, secondPosition)
    local xDif = math.abs(firstPosition.x - secondPosition.x)
    local yDif = math.abs(firstPosition.y - secondPosition.y)
    local posDif = math.max(xDif, yDif)
    if firstPosition.z ~= secondPosition.z then
        posDif = posDif + 15
    end
    return posDif
end

function getFormattedWorldTime()
    local worldTime = getWorldTime()
    local hours = math.floor(worldTime / 60)

    local minutes = worldTime % 60
    if minutes < 10 then
        minutes = '0' .. minutes
    end
    return hours .. ':' .. minutes
end

table.contains = function(array, value)
    for _, targetColumn in pairs(array) do
        if targetColumn == value then
            return true
        end
    end
    return false
end

string.split = function(str, sep)
    local res = {}
    for v in str:gmatch("([^" .. sep .. "]+)") do
        res[#res + 1] = v
    end
    return res
end

string.trim = function(str)
    return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end
If I failed to express my errors or if there is something more I can add to make it easier for anybody to help just let me know.

Thanks in advance
//Absorc
 
Last edited:
Animate Dead
Lua:
local function doTargetCorpse(cid, pos)
    local getPos = pos
    getPos.stackpos = 255
    corpse = getThingfromPos(getPos)
    if(corpse.uid > 0 and isCreature(corpse.uid) == false and isInArray(CORPSES, corpse.itemid) ) then
        doRemoveItem(corpse.uid)
        local creature = doCreateMonster(cid, "Skeleton", pos)
        doConvinceCreature(cid, creature)
        doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
        return LUA_NO_ERROR
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return LUA_ERROR
end
function onCastSpell(cid, var)
    local pos = variantToPosition(var)
    if(pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0) then
        return doTargetCorpse(cid, pos)
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    return LUA_ERROR
end
 
I checked TFS 1.3 sources for the function but it doesn't exist however i did find a getAllCreatures in another source. You can add the version to your sources although you might have to make some code adjustments. I really can't tell at this point because i am not home to review the code in it's entirety.

opentibia-xx/otserv

opentibia-xx/otserv

opentibia-xx/otserv
 
@Ascuas Funkeln Thank you for your effort but it gave me just another error:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/support/animate_dead_rune.lua:onCastSpell
data/spells/scripts/support/animate_dead_rune.lua:7: attempt to call global 'doCreateMonster' (a nil value)
stack traceback:
        [C]: in function 'doCreateMonster'
        data/spells/scripts/support/animate_dead_rune.lua:7: in function <data/spells/scripts/support/animate_dead_rune.lua:1>
@bayview Hopefully I won't need to make code adjustments. I'm just not that good.
@Peonso Thank you! For now it fixed both destroyfield and animate dead. If I encounter more problems I'll just check out the default scripts. Thx once again.
 
Hey again guys.
Instead of making a new thread I'll post another problem I encountered and haven't been able to solve by myself so far.

So, I have this NPC in the temple that is supposed to heal you when you are bad and to deny you help if you have more than 40hp and if the players condition is stable (no fire, poision or electricity dmg).
The keywords in the .xml file triggers her but the word heal won't work. So it's something in the .lua file that is wrong.
I'll post both the .xml and .lua file so that you guy's can take a look.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alia" script="healer_tibra.lua" walkinterval="1000" access="3" floorchange="0">
    <health now="100" max="100"/>
    <look type="138" head="58" body="95" legs="93" feet="76" addons="0"/>
    <parameters>
      
        <parameter key="message_greet" value="Welcome in the name of the gods, pilgrim |PLAYERNAME|!"/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|. May the gods be with you to guard and guide you, my child!"/>
      
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="gods;monsters;job;name;ferumbras;excalibug;" />
        <parameter key="keyword_reply1" value="The gods of good guard us and guide us, the gods of evil want to destroy us and steal our souls!" />
        <parameter key="keyword_reply2" value="Remind Not everything you call monster is evil to the core!" />
        <parameter key="keyword_reply3" value="I am a priest of the great pantheon." />
        <parameter key="keyword_reply4" value="My name is Tibra. Your soul tells me that you are |PLAYERNAME|." />
        <parameter key="keyword_reply5" value="The fallen one should be mourned, not feared." />
        <parameter key="keyword_reply6" value="The mythical blade was hidden in ancient times. Its said that powerful wards protect it." />
      
        <parameter key="module_shop" value="1"/>
        <parameter key="shop_buyable" value="" />
        <parameter key="shop_sellable" value="" />
    </parameters>
</npc>

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg)

    if(cid ~= npcHandler.focus) then
        return false
    end
  
    if msgcontains(msg, 'heal') then
        if hasCondition(cid, CONDITION_FIRE) == TRUE then
            npcHandler:say('You are burning. I will help you.')
            doRemoveCondition(cid, CONDITION_FIRE)
            doSendMagicEffect(getCreaturePosition(cid), 14)
        elseif hasCondition(cid, CONDITION_POISON) == TRUE then
            npcHandler:say('You are poisoned. I will help you.')
            doRemoveCondition(cid, CONDITION_POISON)
            doSendMagicEffect(getCreaturePosition(cid), 13)
        elseif getCreatureHealth(cid) < 65 then
            npcHandler:say('You are looking really bad. Let me heal your wounds.')
            doCreatureAddHealth(cid, 65 - getCreatureHealth(cid))
            doSendMagicEffect(getCreaturePosition(cid), 12)
        else
            npcHandler:say('You aren\'t looking that bad. Sorry, I need my powers for cases more severe than yours.')
        end
        return TRUE
    end
end
function onThink()                         npcHandler:onThink() end
-- OTServ event handling functions end
npcHandler:addModule(FocusModule:new())

Thanks in advance

//Absorc
 
Seems that you have some scripts not made for 1.3, those aren't 1.x versions of TFS functions.
 
Back
Top