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

Desintegrate rune...

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Notes: Not very useful, but try to have one in your backpack if you are in a PvP world because it may help save you from a PK trap. You need to stand next to the item(s) you want to desintegrate. It will desintegrate an entire square (it will not desintegrate any dead human body, but it will desintegrate monster bodies). Also, please note it will not work in protection zones. Also note that using this rune will prevent you from entering protection zone for a while (a.k.a. PZ-locked).

Lua:
local function doRemoveObject(cid, pos)
        pos.stackpos = 255
        local object = getThingFromPos(pos)
        if(object.uid > 65535 and not isCreature(object.uid) and isMovable(object.uid) and object.actionid == 0 and not getTileInfo(pos).protection) then
                doRemoveItem(object.uid)
                doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
                return true
        end

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

function onCastSpell(cid, var)
        local pos = variantToPosition(var)
        if(pos.x == CONTAINER_POSITION) then
                pos = getThingPos(cid)
        end

        if(pos.x ~= 0 and pos.y ~= 0) then
                return doRemoveObject(cid, pos)
        end

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

Could someone make it like RL?

Thanks :)
 
Cyko:
Code:
if not isInArray(thing, donotdeletetheseids)
?

btw http://otfans.net/showthread.php?t=144930 (not tested)

or change
Code:
if(object.uid > 65535 and not isCreature(object.uid) and isMovable(object.uid)  and object.actionid == 0 and not  getTileInfo(pos).protection) then
                doRemoveItem(object.uid)
                doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
                return true
        end
to
Code:
if(object.uid > 65535 and not isCreature(object.uid) and isMovable(object.uid)  and object.actionid == 0 and not  getTileInfo(pos).protection)and not isInArray(object.itemid, somearray) then
                doRemoveItem(object.uid)
                doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
                return true
        end
and at begining add somearray={id1, id2, id3 etc}
and checking all stackpos should be done by loop I think
 
Last edited:
well, if it checks if item is movable etc it SHOULD be ok(if you go from highest stackpos , if some item lower in stack is deleted the higher gets new stackpos?)
 
well, if it checks if item is movable etc it SHOULD be ok(if you go from highest stackpos , if some item lower in stack is deleted the higher gets new stackpos?)
exactly how i wanted to do it! (and i did)

Code:
local function doRemoveObject(cid, pos)
	pos.stackpos = 1
	local i = 0
	if not isMoveable(getThingfromPos(pos).uid) then
		pos.stackpos = pos.stackpos + 1
	end
	while isMoveable(getThingfromPos(pos).uid) do
		local v = getThingfromPos(pos)
		if v.uid > 65535 and v.actionid == 0 then
			doRemoveItem(v.uid)
			i = i + 1
		end
		if not isMoveable(getThingfromPos(pos).uid) then
			pos.stackpos = pos.stackpos + 1
		end
	end

	if i > 0 then
		doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
		return LUA_NO_ERROR
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getPlayerPosition(cid), 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 and not getTileInfo(pos).protection and not isCreature(getTopCreature(pos).uid)) then
		return doRemoveObject(cid, pos)
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	return LUA_ERROR
end
 
exactly how i wanted to do it! (and i did)

Code:
local function doRemoveObject(cid, pos)
	pos.stackpos = 1
	local i = 0
	if not isMoveable(getThingfromPos(pos).uid) then
		pos.stackpos = pos.stackpos + 1
	end
	while isMoveable(getThingfromPos(pos).uid) do
		local v = getThingfromPos(pos)
		if v.uid > 65535 and v.actionid == 0 then
			doRemoveItem(v.uid)
			i = i + 1
		end
		if not isMoveable(getThingfromPos(pos).uid) then
			pos.stackpos = pos.stackpos + 1
		end
	end

	if i > 0 then
		doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
		return LUA_NO_ERROR
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getPlayerPosition(cid), 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 and not getTileInfo(pos).protection and not isCreature(getTopCreature(pos).uid)) then
		return doRemoveObject(cid, pos)
	end

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

Thanks, it works... It removes a entire square... Thanks a lot, repped.
 
no wait, i'm trying to make unremovable items (human corpses)

Issue: It doesn't work if there are 2 unmoveable items in a row.
 
Last edited:
ok, made some progress:

0.2:
Code:
local unremovable = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
local function isRemovable(v)
	return type(v) == "table" and v.uid > 65535 and v.actionid == 0 and isMoveable(v.uid) == TRUE and isInArray(unremovable, v.itemid) == FALSE and isCreature(v.uid) == FALSE or false
end

local function findFirstRemovable(pos)
	while getThingfromPos(pos).uid > 0 do
		if isRemovable(getThingfromPos(pos)) then
			return pos.stackpos
		end
		pos.stackpos = pos.stackpos + 1
	end
end
local function doRemoveObject(cid, pos)
	pos.stackpos = 1
	local i, first = 0, getThingfromPos(pos)
	if not isRemovable(first) then
		local k = findFirstRemovable(pos)
		if type(k) == "number" then
			pos.stackpos = k
		end
	end
	while isRemovable(getThingfromPos(pos)) do
		doRemoveItem(getThingfromPos(pos).uid)
		i = i + 1
		if not isRemovable(getThingfromPos(pos)) then
			local k = findFirstRemovable(pos)
			if type(k) == "number" then
				pos.stackpos = k
			end
		end
	end

	if i > 0 then
		doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
		return LUA_NO_ERROR
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getThingPos(cid), 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 and getTilePzInfo(pos) == FALSE) then
		return doRemoveObject(cid, pos)
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	return LUA_ERROR
end
0.3:
Code:
local unremovable = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
local function isRemovable(v)
	return type(v) == "table" and v.uid > 65535 and v.actionid == 0 and isMoveable(v.uid) and not isInArray(unremovable, v.itemid) and not isCreature(v.uid) or false
end

local function findFirstRemovable(pos)
	while getThingfromPos(pos).uid > 0 do
		if isRemovable(getThingfromPos(pos)) then
			return pos.stackpos
		end
		pos.stackpos = pos.stackpos + 1
	end
end
local function doRemoveObject(cid, pos)
	pos.stackpos = 1
	local i, first = 0, getThingfromPos(pos)
	if not isRemovable(first) then
		local k = findFirstRemovable(pos)
		if type(k) == "number" then
			pos.stackpos = k
		end
	end
	while isRemovable(getThingfromPos(pos)) do
		doRemoveItem(getThingfromPos(pos).uid)
		i = i + 1
		if not isRemovable(getThingfromPos(pos)) then
			local k = findFirstRemovable(pos)
			if type(k) == "number" then
				pos.stackpos = k
			end
		end
	end

	if i > 0 then
		doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
		return LUA_NO_ERROR
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getThingPos(cid), 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 and not getTileInfo(pos).protection) then
		return doRemoveObject(cid, pos)
	end

	doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	return LUA_ERROR
end
 
Last edited:
Your last update works fine, it removes human bodys, but it doesnt matter xD
I haven't tested the 0.3 one, but 0.2 version doesn't remove human bodies. Also, you're probably using wrong corpse IDs, i specified the correct ones in the table.
 
You can either correct the ID's in source (const.h) or add your current (wrong) corpse IDs into the array.

I am not responsible for any infinite loops caused by using this script - it's not been verified as safe.
 
Back
Top