• 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!

Destroy field rune not working when elemental fields are above non-walkeable objects (i.e chests)

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
I'm using Othire 1.0 and a server 7.4 style, with otclient 7.72.
When i want to use a destroy field rune on a poison field that is above a non-walkeable object, i can't do it.

For example, in the senja castle, poison fields are supposed to spawn above those chest, however i am not able as a player to get rid of them using destroy field rune.

It says "There is not enough room" because it's basically like using a rune against a wall. I recall i was able to do it back in the 7.4 days.

Can someone confirm this theory, and if so, try to help me out?

Here is the rune code:


Lua:
local function doRemoveField(cid, pos)
    pos.stackpos = 254
    local field = getThingfromPos(pos)
    local playerPos = getPlayerPosition(cid)

    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end

    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    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 doRemoveField(cid, pos)
    end

    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
 
Solution
I disabled the rune in the .lua and spells.xml, and added the itemid action to actions.xml, then made the lua into the actions folder with the code you suggested me.
This is the output when using the rune:

Lua:
item found is not a field item?


Lua Script Error: [Action Interface]
data/actions/scripts/destroy_field_rune.lua:onUse


attempt to index a nil value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/actions/scripts/destroy_field_rune.lua:11: in function <data/actions/scripts/destroy_field_rune.lua:1>
Without being able to see more othire source code, I'm not sure how to remove charges from the rune
Lua:
local FIELDS =...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,354
Solutions
350
Reaction score
3,465
I'm using Othire 1.0 and a server 7.4 style, with otclient 7.72.
When i want to use a destroy field rune on a poison field that is above a non-walkeable object, i can't do it.

For example, in the senja castle, poison fields are supposed to spawn above those chest, however i am not able as a player to get rid of them using destroy field rune.

It says "There is not enough room" because it's basically like using a rune against a wall. I recall i was able to do it back in the 7.4 days.

Can someone confirm this theory, and if so, try to help me out?

Here is the rune code:


Lua:
local function doRemoveField(cid, pos)
    pos.stackpos = 254
    local field = getThingfromPos(pos)
    local playerPos = getPlayerPosition(cid)

    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end

    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    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 doRemoveField(cid, pos)
    end

    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
Weird issue.

My only idea is to recursively check through the tile and find the top item, then check if it's a field item or not, instead of relying on the source's stackpos 254

So yeah, try this.
Lua:
local function doRemoveField(cid, pos)
    local field
    for i = 0, 255 do
        pos.stackpos = i
        field = getThingfromPos(pos)
        if field.itemid == 0 then
            pos.stackpos = i - 1
            field = getThingfromPos(pos)
            break
        end
    end
    local playerPos = getPlayerPosition(cid)
    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end
   
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    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 doRemoveField(cid, pos)
    end
   
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
 
OP
T

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
Weird issue.

My only idea is to recursively check through the tile and find the top item, then check if it's a field item or not, instead of relying on the source's stackpos 254

So yeah, try this.
Lua:
local function doRemoveField(cid, pos)
    local field
    for i = 0, 255 do
        pos.stackpos = i
        field = getThingfromPos(pos)
        if field.itemid == 0 then
            pos.stackpos = i - 1
            field = getThingfromPos(pos)
            break
        end
    end
    local playerPos = getPlayerPosition(cid)
    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end
  
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    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 doRemoveField(cid, pos)
    end
  
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
Didn't work, still the same behaviour u.u.
Post automatically merged:

You're wrong. It wasn't possible.
If that is the case i would leave it as it is. Btw, did those chest with the poison fields spawned like that back then? or is it a custom mapping someone added?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,354
Solutions
350
Reaction score
3,465
Didn't work, still the same behaviour u.u.
hmm.

Okay, let's ignore my changes for now then.. and add some prints.
Find out exactly what's happening.

Use on the chest, and check the console.
Lua:
local function doRemoveField(cid, pos)
    pos.stackpos = 254
    local field = getThingfromPos(pos)
    local playerPos = getPlayerPosition(cid)

    print("uid = " .. field.uid)
    print("itemid = " .. field.itemid)
    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        print("Field item found.")
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end

    print("item found is not a field item?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    return LUA_ERROR
end

function onCastSpell(cid, var)
    print("--------")
    local pos = variantToPosition(var)
    print("x = " .. pos.x .. ", y = "  .. pos.y .. ", z = " .. pos.z .. "")
    if(pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0) then
        print("remove field..")
        return doRemoveField(cid, pos)
    end

    print("invalid position?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
 
OP
T

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
hmm.

Okay, let's ignore my changes for now then.. and add some prints.
Find out exactly what's happening.

Use on the chest, and check the console.
Lua:
local function doRemoveField(cid, pos)
    pos.stackpos = 254
    local field = getThingfromPos(pos)
    local playerPos = getPlayerPosition(cid)

    print("uid = " .. field.uid)
    print("itemid = " .. field.itemid)
    if(field.uid > 0 and isInArray(FIELDS, field.itemid) == TRUE) then
        print("Field item found.")
        doRemoveItem(field.uid)
        doSendMagicEffect(pos, CONST_ME_POFF)
        return LUA_NO_ERROR
    end

    print("item found is not a field item?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(playerPos, CONST_ME_POFF)
    return LUA_ERROR
end

function onCastSpell(cid, var)
    print("--------")
    local pos = variantToPosition(var)
    print("x = " .. pos.x .. ", y = "  .. pos.y .. ", z = " .. pos.z .. "")
    if(pos.x ~= 0 and pos.y ~= 0 and pos.z ~= 0) then
        print("remove field..")
        return doRemoveField(cid, pos)
    end

    print("invalid position?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end
When i used the rune in the chest, i just got the same error (There is not enough room), however, when i use it in a normal elemental field, i got this on server console:
x = 32181, y = 31631, z = 8
remove field..
uid = 70006
itemid = 1491
Field item found.
Post automatically merged:

No, there were no chests. Only a lever under fire field that opened the magic wall.
Thank you :)
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,354
Solutions
350
Reaction score
3,465
When i used the rune in the chest, i just got the same error (There is not enough room), however, when i use it in a normal elemental field, i got this on server console:
x = 32181, y = 31631, z = 8
remove field..
uid = 70006
itemid = 1491
Field item found.
Post automatically merged:


Thank you :)
That's... extremely annoying.

Since it's not a combat rune, can we move it into actions.xml instead?

Disable the spell version of the rune, and add the itemid into actions.xml

Then, use this as the script
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.uid > 0 and isInArray(FIELDS, itemEx.itemid) == TRUE then
        print("Field item found.")
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return LUA_NO_ERROR
    end
   
    print("item found is not a field item?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end

--
Edit..

There was some mistakes in the code. I fixed them, please re-copy and try again
 
OP
T

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
That's... extremely annoying.

Since it's not a combat rune, can we move it into actions.xml instead?

Disable the spell version of the rune, and add the itemid into actions.xml

Then, use this as the script
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.uid > 0 and isInArray(FIELDS, itemEx.itemid) == TRUE then
        print("Field item found.")
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return LUA_NO_ERROR
    end
  
    print("item found is not a field item?")
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
    return LUA_ERROR
end

--
Edit..

There was some mistakes in the code. I fixed them, please re-copy and try again

I disabled the rune in the .lua and spells.xml, and added the itemid action to actions.xml, then made the lua into the actions folder with the code you suggested me.
This is the output when using the rune:

Lua:
item found is not a field item?


Lua Script Error: [Action Interface]
data/actions/scripts/destroy_field_rune.lua:onUse


attempt to index a nil value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/actions/scripts/destroy_field_rune.lua:11: in function <data/actions/scripts/destroy_field_rune.lua:1>
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,354
Solutions
350
Reaction score
3,465
I disabled the rune in the .lua and spells.xml, and added the itemid action to actions.xml, then made the lua into the actions folder with the code you suggested me.
This is the output when using the rune:

Lua:
item found is not a field item?


Lua Script Error: [Action Interface]
data/actions/scripts/destroy_field_rune.lua:onUse


attempt to index a nil value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/actions/scripts/destroy_field_rune.lua:11: in function <data/actions/scripts/destroy_field_rune.lua:1>
Without being able to see more othire source code, I'm not sure how to remove charges from the rune
Lua:
local FIELDS = {1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1500,1501,1502,1503,1504}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isInArray(FIELDS, itemEx.itemid) == TRUE then
        doRemoveItem(itemEx.uid, 1)
        doRemoveItem(item.uid, 1) -- removes entire item, not just charges
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        return LUA_NO_ERROR
    end
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return LUA_ERROR
end
 
Solution

Silba

7.6+ is not oldschool
Premium User
Joined
Aug 22, 2013
Messages
226
Solutions
1
Reaction score
151
Worked, although the charges are the only issue because the rune dissapear no matter what charges does it have, it removes the fields above the chests.
Lua:
doChangeTypeItem(item.uid,item.type-1)
or
doChangeTypeItem(itemEx.uid,item.type-1)

I'm not using othire anymore but both of these were used in my action 'rune' scripts. I'm not sure which one applies here.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,354
Solutions
350
Reaction score
3,465
Lua:
doChangeTypeItem(item.uid,item.type-1)
or
doChangeTypeItem(itemEx.uid,item.type-1)

I'm not using othire anymore but both of these were used in my action 'rune' scripts. I'm not sure which one applies here.
It would be doChangeTypeItem(item.uid, item.type-1) in this case, since item is the item being used, and itemEx is the item we're attempting to use it on.
 
OP
T

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
Yes, that one worked.

So you should add to actions.xml this line:

Code:
<action itemid="2261" script="destroy_field_rune.lua" allowfaruse="1"/>

Then create the destroy_field_rune.lua into the folder of actions items like this :)


Code:
local FIELDS = {1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1500,1501,1502,1503,1504}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if isInArray(FIELDS, itemEx.itemid) == TRUE and getPlayerMagicLevel(cid) >= 3 then
        doRemoveItem(itemEx.uid, 1)
        doChangeTypeItem(item.uid, item.type-1)
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return LUA_NO_ERROR
    end
    doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    return LUA_ERROR
end

You also might want to remove/edit from spells.xml the script from the destroy field rune line, from this:

Code:
<rune name="adito grav" id="2261" maglv="3" range="4" blocktype="solid" aggressive="0" charges="3" script="support/destroy_field_rune.lua"/>

Into this

Code:
<rune name="adito grav" id="2261" maglv="3" range="4" blocktype="solid" aggressive="0" charges="3" />

And finally add to functions.lua this function:


Lua:
function getPlayerMagicLevel(cid)
    local MagicLevel = db.storeQuery('SELECT `maglevel` FROM `players` WHERE `id`=' .. db.escapeString(getPlayerGUID(cid))..";")
    local Maglevel = result.getDataInt(MagicLevel, "maglevel")
    result.free(MagicLevel)
    return Maglevel
end

Note: It's not returning "You do not have enough magic level", instead only "Sorry it's not possible". Also you can use this rune as long as nothing blocks the item path and is in your screen, instead of the 4 sqm distance limit that you are able to use it normally.
 
Last edited:

kay

Legendary OT User
Joined
Apr 23, 2013
Messages
828
Solutions
9
Reaction score
1,049
Location
32316,31942,7
YouTube
TibiantisOnline
Also you can use this rune as long as nothing blocks the item path and is in your screen, instead of the 4 sqm distance limit that you are able to use it normally.
That's not normally. There was no 4 squares limit, it worked like every other rune.
Also to specify what I posted earlier, because I didn't make it clear enough: I meant you couldn't use destroy field rune on chests (or field runes in general), but you could still aim other runes on it, such as gfb etc.
 
OP
T

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
146
Solutions
5
Reaction score
44
Location
Santiago, Chile.
That's not normally. There was no 4 squares limit, it worked like every other rune.
Also to specify what I posted earlier, because I didn't make it clear enough: I meant you couldn't use destroy field rune on chests (or field runes in general), but you could still aim other runes on it, such as gfb etc.
Thank you. In othire by default that rune have 4 sqm distance defined in the spells, any clue why?
 
Top