• 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+ TFS 1.3 Statues of Fortune

Viduy

Member
Joined
Oct 5, 2011
Messages
25
Reaction score
14
Hey guys!

Probably such script has been done already, but couldn't find it :D maybe someone can link me to it!
But the idea is that there's a statue that when you use it, it will reward you an item(s) at random. And every time you use the statue it will disappear, and appear at a different location.

there are 3 different statues and I want it to change randomly between the 3, so it's not always the same looking statue.

so the breakthrough:
Use statue > You have been rewarded (itemname) > Statue disappears > Statue appears at a different random location

already got 30 co-ords written out where the statue can re-spawn, just need the script writing out as I'm sh%t at it :D also I want people to be able to do it over and over and over again.

Thank you!
22.png
 
something like this?
 
something like this?
This could be edited to grant items instead of buffs.
 
Possibly...? :D but rather than adding them in map editor, I'd rather have the script adding one statue to one of the 30 possible locations, then it despawns and respawns it at 2nd location after use :D but I'll look into that script with shrines :)
 
Hey guys!

Probably such script has been done already, but couldn't find it :D maybe someone can link me to it!
But the idea is that there's a statue that when you use it, it will reward you an item(s) at random. And every time you use the statue it will disappear, and appear at a different location.

there are 3 different statues and I want it to change randomly between the 3, so it's not always the same looking statue.

so the breakthrough:
Use statue > You have been rewarded (itemname) > Statue disappears > Statue appears at a different random location

already got 30 co-ords written out where the statue can re-spawn, just need the script writing out as I'm sh%t at it :D also I want people to be able to do it over and over and over again.

Thank you!
View attachment 62457

Lua:
-- <action actionid="XXXX" script="script.lua" />
local config = {
    [1000] = {
        items = {
            -- {itemid, count, chance}
            {2190, 1},
            {2490, 1},
            {2494, 1, 50},
        },
        positions = {
            -- possible position of the statue
            Position(524, 546, 6),
            Position(527, 546, 6),
        },
        toItemId = 5074 -- item to which it will be transformed
    },
    [1001] = {
        items = {
            {5792, 1},
            {2050, 1},
            {7429, 1, 50},
        },
        positions = {
            Position(520, 547, 6),
            Position(520, 548, 6),
        },
        toItemId = 5075
    },
    [1002] = {
        items = {
            {5792, 1},
            {2050, 1},
            {7429, 1, 50},
        },
        positions = {
            Position(524, 550, 6),
        },
        toItemId = 5075
    },
}

local function tabletostring(table)
    local str = ''
    for a, b in ipairs(table) do
        str = str .. (#table > 1 and (#table - 1 > a and b .. ', ' or #table - 1 == a and b .. ' and ' or #table == a and b) or #table == 1 and b)
    end
    return str
end

function Player.rewardItems(self, items, bp)
    local bp = bp or 1999
    local backpack = self:addItem(bp, 1)
    for i, v in ipairs(items) do
        local item, count = v[1], v[2]
        if ItemType(item):isStackable() then
            backpack:addItem(item, count)
        else
            for i = 1, count do
                backpack:addItem(item, 1)
            end
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local possibleStatue = {}
    for index, value in pairs(config) do
        table.insert(possibleStatue, index)
    end

    local oldActionId = item.actionid
    local newActionId = possibleStatue[math.random(#possibleStatue)]
    while(not newActionId or newActionId == oldActionId) do
        if newActionId ~= oldActionId then
            break
        end
        newActionId = possibleStatue[math.random(#possibleStatue)]
    end

    local oldStatue = config[oldActionId]
    local newStatue = config[newActionId]
    local oldPosition = item:getPosition()
    local newPosition = newStatue.positions[math.random(#newStatue.positions)]
    while(newPosition == oldPosition) do
        if newPosition ~= oldPosition then
            break
        end
        newPosition = newStatue.positions[math.random(#newStatue.positions)]
    end

    item:remove()
    oldPosition:sendMagicEffect(CONST_ME_POFF)
    newPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)

    local items_list, items_name = {}, {}
    for index, value in ipairs(oldStatue.items) do
        if not value[3] or math.random(100) <= value[3] then
            table.insert(items_list, {value[1], value[2]})
            table.insert(items_name, value[2] .. ' ' .. ItemType(value[1]):getName())
        end
    end

    local bp = {1998, 1999, 2000, 2001, 2002, 2003, 2004} -- random bp
    player:rewardItems(items_list, bp[math.random(#bp)])
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been rewarded: " .. tabletostring(items_name) .. ". Statue appears at a different random location.")


    local newItem = Game.createItem(newStatue.toItemId, 1, newPosition)
    newItem:setAttribute("aid", newActionId)
    return true
end

You just have to place a statue in remers with the corresponding actionId
 
Last edited:
Back
Top