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

Action improved obsidian knife TFS 1.2

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
Hello, as I didn't found an obsidian knife script which matched my expectations I made one on my own.
I has the following features:
Code:
sculpting piece of marble rock
sculpting ice cubes
skinning monsters
skinning fresh corpses only if you are the owner

Here is the script. I tested it on my standard 1.2 TFS server
Lua:
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893

local config = {
    [3090] = {chance = 6, product = MINOTAUR_LEATHER, toCorpse = 3091}, -- Minotaur
    [5969] = {chance = 6, product = MINOTAUR_LEATHER, toCorpse = 3091, owner = true},
    [2866] = {chance = 7, product = MINOTAUR_LEATHER, toCorpse = 2867}, -- Minotaur Mage
    [5981] = {chance = 7, product = MINOTAUR_LEATHER, toCorpse = 2867, owner = true},
    [2871] = {chance = 6, product = MINOTAUR_LEATHER, toCorpse = 2872}, -- Minotaur Archer
    [5982] = {chance = 6, product = MINOTAUR_LEATHER, toCorpse = 2872, owner = true},
    [2876] = {chance = 7, product = MINOTAUR_LEATHER, toCorpse = 2877}, -- Minotaur Guard
    [5983] = {chance = 7, product = MINOTAUR_LEATHER, toCorpse = 2877, owner = true},
    [3104] = {chance = 10, product = GREEN_DRAGON_LEATHER, toCorpse = 3105}, -- Dragon
    [5973] = {chance = 10, product = GREEN_DRAGON_LEATHER, toCorpse = 3105, owner = true},
    [2881] = {chance = 20, product = RED_DRAGON_LEATHER, toCorpse = 2882}, -- Dragon Lord
    [5984] = {chance = 20, product = RED_DRAGON_LEATHER, toCorpse = 2882, owner = true},
    [2931] = {chance = 22, product = BEHEMOTH_FANG, toCorpse = 2932}, -- Behemoth
    [5999] = {chance = 22, product = BEHEMOTH_FANG, toCorpse = 2932, owner = true},
    [4256] = {chance = 14, product = LIZARD_LEATHER, toCorpse = 4257}, -- Lizard Templar
    [4251] = {chance = 14, product = LIZARD_LEATHER, toCorpse = 4257, owner = true},
    [4259] = {chance = 10, product = LIZARD_LEATHER, toCorpse = 4260}, -- Lizard Sentinel
    [6040] = {chance = 10, product = LIZARD_LEATHER, toCorpse = 4260, owner = true},
    [4262] = {chance = 20, product = LIZARD_LEATHER, toCorpse = 4263}, -- Lizard Snakecharmer
    [6041] = {chance = 20, product = LIZARD_LEATHER, toCorpse = 4263, owner = true},
    [3031] = {chance = 10, product = HARDENED_BONE, toCorpse = 3032}, -- Bonebeast
    [6030] = {chance = 10, product = HARDENED_BONE, toCorpse = 3032, owner = true}
}

local sculpting =
{
    [7441] = {randsize = 31, newid = 7442},
    [7442] = {randsize = 19, newid = 7444},
    [7444] = {randsize = 10, newid = 7445},
    [7445] = {randsize = 7, newid = 7446},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local skinnedObject = target:getId()
    if toPosition.x == CONTAINER_POSITION then
        toPosition = player:getPosition()
    end
   
    -- Sculpting (Piece of Marble Rock)
    if skinnedObject == 11343 then
        local value = math.random(1,1000)
        local playerName = player:getName(cid)
        if value <= 625 then -- Broke
            target:remove()
            player:say("Your attempt at shaping that marble rock failed miserably.", TALKTYPE_MONSTER_SAY)
        elseif value <= 890 then -- Rough
            target:transform(11344)
            target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This shoddy work was made by " .. playerName .. ".")
        elseif value <= 990 then -- Marble
            target:transform(11345)
            target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This little figurine made by " .. playerName .. " has some room for improvement.")
        elseif value <= 1000 then -- Beautiful
            target:transform(11346)
            target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This little figurine of Tibiasula was masterfully sculpted by " .. playerName .. ".")
        end
        toPosition:sendMagicEffect(CONST_ME_HITAREA)
    end
   
    -- Sculpting (Ice Cube)
    local iceCube = sculpting[skinnedObject]
    if(iceCube) then
        if(math.random(1,100) <= iceCube.randsize) then
            target:transform(iceCube.newid)
        else
            target:remove()
            player:say("The attempt at sculpting failed miserably.", TALKTYPE_MONSTER_SAY)
        end
        toPosition:sendMagicEffect(CONST_ME_HITAREA)
        return true
    end
   
    -- Skinning
    local monster = config[skinnedObject]
    if(not(monster)) then
        return false
    else
        if monster.owner == true then
            local owner = target:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER)
            if owner ~= 0 and owner ~= player:getId() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are not the owner.")
                return true
            end
        end
        if math.random(1,100) <= monster.chance then
            player:addItem(monster.product, 1)
            toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
        else
            toPosition:sendMagicEffect(CONST_ME_BLOCKHIT)
        end
        target:transform(monster.toCorpse)
        target:decay()
        return true
    end
end
 
Here is the script from orts, I think you're missing a few corpses in your script.
Lua:
local config = {
    [5908] = {
        -- Minotaurs
        [2830] = {value = 25000, newItem = 5878},
        [2871] = {value = 25000, newItem = 5878},
        [2866] = {value = 25000, newItem = 5878},
        [2876] = {value = 25000, newItem = 5878},
        [3090] = {value = 25000, newItem = 5878},
        [23463] = {value = 25000, newItem = 5878},
        [23467] = {value = 25000, newItem = 5878},
        [23471] = {value = 25000, newItem = 5878},

        -- Low Class Lizards
        [4259] = {value = 25000, newItem = 5876},
        [4262] = {value = 25000, newItem = 5876},
        [4256] = {value = 25000, newItem = 5876},

        -- High Class Lizards
        [11288] = {value = 25000, newItem = 5876},
        [11280] = {value = 25000, newItem = 5876},
        [11272] = {value = 25000, newItem = 5876},
        [11284] = {value = 25000, newItem = 5876},

        -- Dragons
        [3104] = {value = 25000, newItem = 5877},
        [2844] = {value = 25000, newItem = 5877},

        -- Dragon Lords
        [2881] = {value = 25000, newItem = 5948},

        -- Behemoths
        [2931] = {value = 35000, newItem = 5893},

        -- Bone Beasts
        [3031] = {value = 25000, newItem = 5925},

        -- The Mutated Pumpkin
        [8961] = { { value = 5000, newItem = 7487 }, { value = 10000, newItem = 7737 }, { value = 20000, 6492 }, { value = 30000, newItem = 8860 }, { value = 45000, newItem = 2683 }, { value = 60000, newItem = 2096 }, { value = 90000, newItem = 9005, amount = 50 } },

        -- Marble
        [11343] = { {value = 10000, newItem = 11345, desc = "This shoddy work was made by |PLAYERNAME|." }, {value = 35000, newItem = 11345, desc = "This little figurine made by |PLAYERNAME| has some room for improvement." }, { value = 60000, newItem = 11346, desc = "This little figurine of Tibiasula was masterfully sculpted by |PLAYERNAME|." } },

        -- Ice Cube
        [7441] = {value = 25000, newItem = 7442},
        [7442] = {value = 25000, newItem = 7444},
        [7444] = {value = 25000, newItem = 7445},
        [7445] = {value = 25000, newItem = 7446},
    },
    [5942] = {
        -- Demon
        [2916] = {value = 25000, newItem = 5906},

        -- Vampires
        [2956] = {value = 25000, newItem = 5905},
        [9654] = {value = 25000, newItem = 5905, after = 9658},
        [8938] = {value = 25000, newItem = 5905},
        [21275] = {value = 25000, newItem= 5905}
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local skin = config[item.itemid][target.itemid]

    -- Wrath of the emperor quest
    if item.itemid == 5908 and target.itemid == 12295 then
        target:transform(12287)
        player:say("You carve a solid bowl of the chunk of wood.", TALKTYPE_MONSTER_SAY)
    -- An Interest In Botany Quest
    elseif item.itemid == 5908 and target.itemid == 11691 and player:getItemCount(12655) > 0 and player:getStorageValue(Storage.TibiaTales.AnInterestInBotany) == 1 then
        player:say("The plant feels cold but dry and very soft. You streak the plant gently with your knife and put a fragment in the almanach.", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(Storage.TibiaTales.AnInterestInBotany, 2)
    elseif item.itemid == 5908 and target.itemid == 11653 and player:getItemCount(12655) > 0 and player:getStorageValue(Storage.TibiaTales.AnInterestInBotany) == 2 then
        player:say("You cut a leaf from a branch and put it in the almanach. It smells strangely sweet and awfully bitter at the same time.", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(Storage.TibiaTales.AnInterestInBotany, 3)
    end

    if not skin then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    local random, effect, transform = math.random(1, 100000), CONST_ME_MAGIC_GREEN, true
    if type(skin[1]) == 'table' then
        local added = false
        local _skin
        for i = 1, #skin do
            _skin = skin[i]
            if random <= _skin.value then
                if target.itemid == 11343 then
                    effect = CONST_ME_ICEAREA
                    local gobletItem = player:addItem(_skin.newItem, _skin.amount or 1)
                    if gobletItem then
                        gobletItem:setDescription(_skin.desc:gsub('|PLAYERNAME|', player:getName()))
                    end
                    added = true
                elseif isInArray({7441, 7442, 7444, 7445}, target.itemid) then
                    player:addItem(_skin.newItem, _skin.amount or 1)
                    effect = CONST_ME_HITAREA
                    added = true
                else
                    player:addItem(_skin.newItem, _skin.amount or 1)
                    added = true
                end
                break
            end
        end

        if not added and target.itemid == 8961 then
            effect = CONST_ME_POFF
            transform = false
        end
    elseif random <= skin.value then
        if target.itemid == 11343 then
            effect = CONST_ME_ICEAREA
            local gobletItem = player:addItem(skin.newItem, skin.amount or 1)
            if gobletItem then
                gobletItem:setDescription(skin.desc:gsub('|PLAYERNAME|', player:getName()))
            end
        elseif isInArray({7441, 7442, 7444, 7445}, target.itemid) then
            if skin.newItem == 7446 then
                player:addAchievement('Ice Sculptor')
            end
            player:addItem(skin.newItem, skin.amount or 1)
            effect = CONST_ME_HITAREA
        else
            player:addItem(skin.newItem, skin.amount or 1)
        end
    else
        if isInArray({7441, 7442, 7444, 7445}, target.itemid) then
            player:say('The attempt of sculpting failed miserably.', TALKTYPE_MONSTER_SAY)
            effect = CONST_ME_HITAREA
        else
            effect = CONST_ME_POFF
        end
    end

    toPosition:sendMagicEffect(effect)
    if transform then
        target:transform(skin.after or target.itemid + 1)
    end

    return true
end
 
Back
Top