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

how do i do Tfs 1.2 Anni Style quests?

oshrigames

Active Member
Joined
Nov 9, 2012
Messages
222
Reaction score
47
Location
israel
hello,

ive been stuck at this one issue for the past 2-3 months..
i want to make 4 sets of weapon quests at levels 30, 60, 80 and 120.
have the chest quests just like anni where you can choose and pick only one reward of the entire lot.
35781
i used to do it mainly by the Reme map editor with Action ID: 2000, and uniqueID: same number in all chests..
put the item in the chest (black squares).
problem with TLS 1.2 is that is that the code is seems to be different and it's get error of duplicate ID and only one chest will work.

i did add Action - Advanced quest chests 1.x (https://otland.net/threads/advanced-quest-chests-1-x.249678/) but i manage to make only mounts work for me..
i also tried [How-to] Quests (https://otland.net/threads/how-to-quests.148708/)

but and adjust the few lines of code to fit to tfs 1.2 still not working :C.

i use this script for my system.lua:

Lua:
local specialQuests = {
    [2215] = NoSpecialQuests,
}

local questsExperience = {
    [2217] = 1 -- dummy values
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = specialQuests[item.actionid]
    if not storage then
        storage = item.uid
        if storage > 65535 then
            return false
        end
    end

    if player:getStorageValue(storage) > 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.')
        return true
    end

    local items, reward = {}
    local size = item:isContainer() and item:getSize() or 0
    if size == 0 then
        reward = item:clone()
    else
        local container = Container(item.uid)
        for i = 0, container:getSize() - 1 do
            items[#items + 1] = container:getItem(i):clone()
        end
    end

    size = #items
    if size == 1 then
        reward = items[1]:clone()
    end

    local result = ''
    if reward then
        local ret = ItemType(reward.itemid)
        if ret:isRune() then
            result = ret:getArticle() .. ' ' ..  ret:getName() .. ' (' .. reward.type .. ' charges)'
        elseif ret:isStackable() and reward:getCount() > 1 then
            result = reward:getCount() .. ' ' .. ret:getPluralName()
        elseif ret:getArticle() ~= '' then
            result = ret:getArticle() .. ' ' .. ret:getName()
        else
            result = ret:getName()
        end
    else
        if size > 20 then
            reward = Game.createItem(item.itemid, 1)
        elseif size > 8 then
            reward = Game.createItem(1988, 1)
        else
            reward = Game.createItem(1987, 1)
        end

        for i = 1, size do
            local tmp = items[i]
            if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then
                print('[Warning] QuestSystem:', 'Could not add quest reward to container')
            end
        end
        local ret = ItemType(reward.itemid)
        result = ret:getArticle() .. ' ' .. ret:getName()
    end

    if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
        local weight = reward:getWeight()
        if player:getFreeCapacity() < weight then
            player:sendCancelMessage(string.format('You have found %s weighing %.2f oz. You have no capacity.', result, (weight / 100)))
        else
            player:sendCancelMessage('You have found ' .. result .. ', but you have no room to take it.')
        end
        return true
    end

    if questsExperience[storage] then
        player:addExperience(questsExperience[storage], true)
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. result .. '.')
    player:setStorageValue(storage, 1)
    return true
end

so if i try Action ID: 2215 (from system.lua), and uniqueID: same number in all cheasts non of the chests with the uniqueID working.
i'm more of a mapper myself than a scripter :c

i use theforgottenserver-v1.2-win64
protocol 10.98

if you need any more info please ask ill provide all i can..
PS: normal quests work witohut any issue.

35782
 
Solution
i rememer i did test "using all different unique id's and the same action id. "
it spawn corpes, walls, doors and such.

also, i will gve your system a try once i'm home.
from first glance i have no idea how to implement it to my action.xml

like that? :x
<action uniqueid="30015" script="quests/annihilator.lua" /> (<==== this the original i had)
<action uniqueid="2000" script="quests/annihilator_chest.lua.lua" />
You will add same action id to all chests and register that aid in actions.xml:
XML:
<action actionid="2000" script="quests/annihilator_chest.lua.lua" />

Then each chest will have a different unique id which needs to be added in the rewards array:
Lua:
local rewards = {
    [1] = {chest_uid = 2001, reward_id =...
hello,

ive been stuck at this one issue for the past 2-3 months..
i want to make 4 sets of weapon quests at levels 30, 60, 80 and 120.
have the chest quests just like anni where you can choose and pick only one reward of the entire lot.
View attachment 35781
i used to do it mainly by the Reme map editor with Action ID: 2000, and uniqueID: same number in all chests..
put the item in the chest (black squares).
problem with TLS 1.2 is that is that the code is seems to be different and it's get error of duplicate ID and only one chest will work.

i did add Action - Advanced quest chests 1.x (https://otland.net/threads/advanced-quest-chests-1-x.249678/) but i manage to make only mounts work for me..
i also tried [How-to] Quests (https://otland.net/threads/how-to-quests.148708/)

but and adjust the few lines of code to fit to tfs 1.2 still not working :C.

i use this script for my system.lua:

Lua:
local specialQuests = {
    [2215] = NoSpecialQuests,
}

local questsExperience = {
    [2217] = 1 -- dummy values
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = specialQuests[item.actionid]
    if not storage then
        storage = item.uid
        if storage > 65535 then
            return false
        end
    end

    if player:getStorageValue(storage) > 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.')
        return true
    end

    local items, reward = {}
    local size = item:isContainer() and item:getSize() or 0
    if size == 0 then
        reward = item:clone()
    else
        local container = Container(item.uid)
        for i = 0, container:getSize() - 1 do
            items[#items + 1] = container:getItem(i):clone()
        end
    end

    size = #items
    if size == 1 then
        reward = items[1]:clone()
    end

    local result = ''
    if reward then
        local ret = ItemType(reward.itemid)
        if ret:isRune() then
            result = ret:getArticle() .. ' ' ..  ret:getName() .. ' (' .. reward.type .. ' charges)'
        elseif ret:isStackable() and reward:getCount() > 1 then
            result = reward:getCount() .. ' ' .. ret:getPluralName()
        elseif ret:getArticle() ~= '' then
            result = ret:getArticle() .. ' ' .. ret:getName()
        else
            result = ret:getName()
        end
    else
        if size > 20 then
            reward = Game.createItem(item.itemid, 1)
        elseif size > 8 then
            reward = Game.createItem(1988, 1)
        else
            reward = Game.createItem(1987, 1)
        end

        for i = 1, size do
            local tmp = items[i]
            if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then
                print('[Warning] QuestSystem:', 'Could not add quest reward to container')
            end
        end
        local ret = ItemType(reward.itemid)
        result = ret:getArticle() .. ' ' .. ret:getName()
    end

    if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
        local weight = reward:getWeight()
        if player:getFreeCapacity() < weight then
            player:sendCancelMessage(string.format('You have found %s weighing %.2f oz. You have no capacity.', result, (weight / 100)))
        else
            player:sendCancelMessage('You have found ' .. result .. ', but you have no room to take it.')
        end
        return true
    end

    if questsExperience[storage] then
        player:addExperience(questsExperience[storage], true)
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. result .. '.')
    player:setStorageValue(storage, 1)
    return true
end

so if i try Action ID: 2215 (from system.lua), and uniqueID: same number in all cheasts non of the chests with the uniqueID working.
i'm more of a mapper myself than a scripter :c

i use theforgottenserver-v1.2-win64
protocol 10.98

if you need any more info please ask ill provide all i can..
PS: normal quests work witohut any issue.

View attachment 35782
You should be using all different unique id's and the same action id.

You can use the annihilator_chest.lua I have in this thread, and you can add more tables inside the rewards table to work for your system:
Action - [TFS 1.3] Advanced Annihilator System (https://otland.net/threads/tfs-1-3-advanced-annihilator-system.263342/)
 
i rememer i did test "using all different unique id's and the same action id. "
it spawn corpes, walls, doors and such.

also, i will gve your system a try once i'm home.
from first glance i have no idea how to implement it to my action.xml

like that? :x
<action uniqueid="30015" script="quests/annihilator.lua" /> (<==== this the original i had)
<action uniqueid="2000" script="quests/annihilator_chest.lua.lua" />
 
i rememer i did test "using all different unique id's and the same action id. "
it spawn corpes, walls, doors and such.

also, i will gve your system a try once i'm home.
from first glance i have no idea how to implement it to my action.xml

like that? :x
<action uniqueid="30015" script="quests/annihilator.lua" /> (<==== this the original i had)
<action uniqueid="2000" script="quests/annihilator_chest.lua.lua" />
You will add same action id to all chests and register that aid in actions.xml:
XML:
<action actionid="2000" script="quests/annihilator_chest.lua.lua" />

Then each chest will have a different unique id which needs to be added in the rewards array:
Lua:
local rewards = {
    [1] = {chest_uid = 2001, reward_id = 2494, reward_count = 1},
    [2] = {chest_uid = 2002, reward_id = 2400, reward_count = 1},
    [3] = {chest_uid = 2003, reward_id = 2431, reward_count = 1},
    [4] = {chest_uid = 2004, reward_id = 2421, reward_count = 1}
}

Here you can add as many tables in this rewards table for more rewards as long as you use a different unique id for each.
 
Solution
Back
Top