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

Lua Xikini's Free Scripting Service TFS 1.3

Status
Not open for further replies.

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
Please request
actions / creatureevents / globalevents / npcs / movements / talkactions

Do not request
spells / weapons / monsters / source editing / database queries

My goal of this thread is to learn TFS 1.3 scripting.

------------------------------------
Support

If you have an issue with one of my scripts, I will attempt to help you, but not in this thread.
Make a thread in the support board.
Ensure to follow all rules of the support board.
Without all neccesary information it's impossible to help you.

------------------------------------
I will only be scripting for TFS 1.3

Not TFS 1.1 / 1.2
Not OTServBR / OTX
and certainly not TFS 0.4

When requesting a script, don't ask for "this script I saw on super popular OT".

I don't care where the idea came from.
I don't want to see a video of the script in action.

I'm here to learn how to script better.
Just describe what the script is supposed to do, and I'll try to make it.

Any script that I make in response to a request from this thread will be shared publically, here, in this thread.

I'm not going to make anything in private, so post your request in this thread only.
Please, for the love of god, don't pm me asking to make a script.
I will actually add you to my ignore list if you do that.
--------------

Anyways!

Thanks for coming by and checking the thread out.
If you think there is a better way to script something, feel free to let me know.
I'm here to learn.

Cheers,

Xikini

----

Completed Scripts

DPS Dummy -> using RevScripts
!playerinfo character name -> using RevScripts
Positional Text talkaction -> using RevScripts
||--> Updated version that can use text & effects
Vocational Item Bonus's -> using RevScripts
||--> Updated version with easier config.
Simple damge buff potion -> using Revscripts
Kill monster in specific area, remove stone for x seconds -> using RevScripts
Training Room Teleporter -> using RevScripts
Lever that removes/adds/transforms objects or ground tiles -> using RevScripts
Loot from monster goes into single backpack, no matter how much loot there is.
Extra loot in monsters, based on chance and tier list -> using RevScripts
||--> Updated version that allows specific monsters to have their own loot table
Random Item chest that disappears after use, and respawns after x time -> using RevScripts
Multiple players required to open passageway.
Monster Arena Lever (x amount of waves, complete all waves, teleport appears) -> using RevScripts
Daily Boosted Creatures (experience & loot chance of items)
||--> Updated main file of boosted creatures, so that it triggers at midnight, instead of when the server starts up.
Reward Chest - Extremely simple. -> using Revscripts
Simple Npc that can sell an item, via text.

----

Extremely useful libs that I use quite often.

data/lib/core/player.lua
Give player items by table

data/lib/core/container.lua
getContainerFreeSlots

----

To-Do List

Shalaby - Player death counter. (Movement and talkaction)
Shalaby - Npc kill monster task, with item reward.
Shalaby - Boss respawn after x time.

-------

Last spot I've read messages
 
Last edited:
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
could you make two scripts for tfs 1.3 please. ?

if lever is used remove a wall. If it's used again add wall, but checking if a corpse , person or item is in there ( on the sqm where the wall will be created or added. if that is the case push the player, item, corpse, magic field 1 sqm back.

the second script works very similar but consists on;

if lever is used remove x roof or floor id. if a player or an item, corpse monster.. is standing on the sqm that will be removed when the lever is being used, they should fall down. if there is an magic field when the on the floor when the lever it used it should disappear. if the lever is used again add the roof / or floor id again


thanks in advance
Made it into 1 script.

bandicam-2020-08-30-05-46-27-309.gif

data\scripts\ onUse_leverActions.lua
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
    
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
    
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}

    [45001] = {"object", "add", Position(94, 93, 7), 1026, "south"},
    [45002] = {"object", "remove", Position(96, 93, 7), 1026, "south"},
    [45003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
    
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [45004] = {"floor", "add", Position(100, 93, 7), 406},
    [45005] = {"floor", "remove", Position(102, 93, 7), 406},
    [45006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [45007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}

local relocateDirections = {
    ["north"] = {0, -1},
    ["east"]  = {1, 0},
    ["south"] = {0, 1},
    ["west"]  = {-1, 0},
}

local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

local leverActions = Action()

function leverActions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item_id = item.itemid
    local index = config[item.actionid]
    local tile = Tile(index[3])
    
    -- add
    if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
        if index[1] == "object" then
            local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, true)
            Game.createItem(index[4], 1, index[3])
        elseif index[1] == "floor" then
            Game.createTile(index[3], true)
            Game.createItem(index[4], 1, index[3])
        end
        
    -- remove
    elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
        if index[1] == "object" then
            local object = tile:getItemById(index[4])
            object:remove()
        elseif index[1] == "floor" then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
            tile:getGround():remove()
        end
        
    -- replace
    elseif index[2] == "replace" then
        local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
        local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])            
        object:transform(index[4][transformTo])
        if index[1] == "floor" and index[5][transformTo] == true then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
        end
        
    end
    
    item:transform(item_id == levers.left and levers.right or levers.left)
    return true
end

for k, v in pairs(config) do
    leverActions:aid(k)
end
leverActions:register()
 

Moody

New Member
Joined
Feb 8, 2020
Messages
46
Reaction score
3
i have very many bosses with big loot list can you help me make onkill or any script so it split and randomize half loot in bag or backpack of my choose? i have many many like this and to add bag one after one will take so long
backpack of my choose go in monsters loot not in my containers
 
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
i have very many bosses with big loot list can you help me make onkill or any script so it split and randomize half loot in bag or backpack of my choose? i have many many like this and to add bag one after one will take so long
backpack of my choose go in monsters loot not in my containers
Honestly, I don't really understand what exactly you want. xD
But, this change to the loot drop will force all of the items to go into a never-ending backpack.

bandicam-2020-08-31-00-29-26-832.gif

data\events\scripts\monster.lua

replace your function, with this one.
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        local backpack = corpse:addItem(1988)
        for i = 1, #monsterLoot do
            if backpack:getEmptySlots() == 1 then
                backpack = backpack:addItem(1988)
            end
            local item = backpack:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_LOOT, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_LOOT, text)
        end
    end
end
 

Diarreamental

Well-Known Member
Joined
Jul 6, 2015
Messages
364
Reaction score
65
Made it into 1 script.

View attachment 49400

data\scripts\ onUse_leverActions.lua
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
   
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
   
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}

    [45001] = {"object", "add", Position(94, 93, 7), 1026, "south"},
    [45002] = {"object", "remove", Position(96, 93, 7), 1026, "south"},
    [45003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
   
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [45004] = {"floor", "add", Position(100, 93, 7), 406},
    [45005] = {"floor", "remove", Position(102, 93, 7), 406},
    [45006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [45007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}

local relocateDirections = {
    ["north"] = {0, -1},
    ["east"]  = {1, 0},
    ["south"] = {0, 1},
    ["west"]  = {-1, 0},
}

local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

local leverActions = Action()

function leverActions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item_id = item.itemid
    local index = config[item.actionid]
    local tile = Tile(index[3])
   
    -- add
    if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
        if index[1] == "object" then
            local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, true)
            Game.createItem(index[4], 1, index[3])
        elseif index[1] == "floor" then
            Game.createTile(index[3], true)
            Game.createItem(index[4], 1, index[3])
        end
       
    -- remove
    elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
        if index[1] == "object" then
            local object = tile:getItemById(index[4])
            object:remove()
        elseif index[1] == "floor" then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
            tile:getGround():remove()
        end
       
    -- replace
    elseif index[2] == "replace" then
        local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
        local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])           
        object:transform(index[4][transformTo])
        if index[1] == "floor" and index[5][transformTo] == true then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
        end
       
    end
   
    item:transform(item_id == levers.left and levers.right or levers.left)
    return true
end

for k, v in pairs(config) do
    leverActions:aid(k)
end
leverActions:register()
incredible thanks you so much @Xikini
Post automatically merged:

Made it into 1 script.

View attachment 49400

data\scripts\ onUse_leverActions.lua
Lua:
--[[
    "object" -> anything that is not a floor tile.
    "floor" floor tiles (roof/ground/hole)
   
    "add" / "remove" -> tells the script what to do when lever is on the left. (after it flops, it will do the opposite)
    "replace" -> transforms an item into another item, instead of adding/removing
   
]]--

local levers = {left = 1945, right = 1946}
local config = {
-- [actionid] = {"object", "add", position, itemid, relocate_direction}
-- [actionid] = {"object", "remove", position, itemid, relocate_direction}
-- [actionid] = {"object", "replace", position, {itemid_from, itemid_to}}

    [45001] = {"object", "add", Position(94, 93, 7), 1026, "south"},
    [45002] = {"object", "remove", Position(96, 93, 7), 1026, "south"},
    [45003] = {"object", "replace", Position(98, 93, 7), {1026, 1050}},
   
-- [actionid] = {"floor", "add", position, itemid}
-- [actionid] = {"floor", "remove", position, itemid}
-- [actionid] = {"floor", "replace", position, {itemid_from, itemid_to}, {relocate_from, relocate_to}}

    [45004] = {"floor", "add", Position(100, 93, 7), 406},
    [45005] = {"floor", "remove", Position(102, 93, 7), 406},
    [45006] = {"floor", "replace", Position(104, 93, 7), {406, 407}, {false, false}},
    [45007] = {"floor", "replace", Position(106, 93, 6), {461, 462}, {false, true}}, -- true means YES do relocate.
}

local relocateDirections = {
    ["north"] = {0, -1},
    ["east"]  = {1, 0},
    ["south"] = {0, 1},
    ["west"]  = {-1, 0},
}

local function transposeFields(fromPosition, toPosition, transpose)
    local tile = Tile(fromPosition)
    if tile then
        local items = tile:getItems()
        if items then
            for i, item in ipairs(items) do
                if transpose == true then
                    item:moveTo(toPosition)
                else
                    item:remove()
                end
            end
        end
    end
end

local leverActions = Action()

function leverActions.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local item_id = item.itemid
    local index = config[item.actionid]
    local tile = Tile(index[3])
   
    -- add
    if index[2] == "add" and item_id == levers.left or index[2] == "remove" and item_id == levers.right then
        if index[1] == "object" then
            local relocatePosition = Position(index[3].x + relocateDirections[index[5]][1], index[3].y + relocateDirections[index[5]][2], index[3].z)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, true)
            Game.createItem(index[4], 1, index[3])
        elseif index[1] == "floor" then
            Game.createTile(index[3], true)
            Game.createItem(index[4], 1, index[3])
        end
       
    -- remove
    elseif index[2] == "remove" and item_id == levers.left or index[2] == "add" and item_id == levers.right then
        if index[1] == "object" then
            local object = tile:getItemById(index[4])
            object:remove()
        elseif index[1] == "floor" then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
            tile:getGround():remove()
        end
       
    -- replace
    elseif index[2] == "replace" then
        local transformTo = tile:getItemCountById(index[4][1]) > 0 and 2 or 1
        local object = tile:getItemById(transformTo == 2 and index[4][1] or index[4][2])           
        object:transform(index[4][transformTo])
        if index[1] == "floor" and index[5][transformTo] == true then
            local relocatePosition = Position(index[3].x, index[3].y, index[3].z + 1)
            tile:relocateTo(relocatePosition)
            transposeFields(index[3], relocatePosition, false)
        end
       
    end
   
    item:transform(item_id == levers.left and levers.right or levers.left)
    return true
end

for k, v in pairs(config) do
    leverActions:aid(k)
end
leverActions:register()
Code:
Lua Script Error: [Test Interface]
data/actions/scripts/thais/triangle_tower.lua
LuaScriptInterface::luaCreateAction(). Actions can only be registered in the Scripts interface.
stack traceback:
        [C]: in function 'Action'
        data/actions/scripts/thais/triangle_tower.lua:55: in main chunk

Lua Script Error: [Test Interface]
data/actions/scripts/thais/triangle_tower.lua
data/actions/scripts/thais/triangle_tower.lua:57: attempt to index local 'leverActions' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        data/actions/scripts/thais/triangle_tower.lua:57: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/thais/triangle_tower.lua

what's wrong?
 
Last edited:

Diarreamental

Well-Known Member
Joined
Jul 6, 2015
Messages
364
Reaction score
65
Take a look at where you've installed the script, compared to where I installed it.
my bad
Loading lua scripts
["scripts"]
triangle_tower_switch_near_temple.lua [loaded]
Loading monsters
Post automatically merged:

i got errors in console
@Xikini
Lua:
Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\Desktop-OT\TFS772 1.3\data\scripts\triangle_tower_switch_near_temple.lua:callback
...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: attempt to index local 'object' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:78: in function <...2 1.3\data\scripts\triangle_tower_switch_near_temple.lua:57>
 
Last edited:
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
I've updated the main post for these issues which keep popping up.
Support

If you have an issue with one of my scripts, I will attempt to help you, but not in this thread.
Make a thread in the support board.
Ensure to follow all rules of the support board.
Without all neccesary information it's impossible to help you.
It's impossible to help you guys without seeing the modifications you've made to the script.
i got errors in console
In your case, it's almost guaranteed to be an issue with the table, as it is a fairly complex table.

As always, please post a support thread, and feel free to @Xikini
 

Eiffel

EternumOT Mapper/Designer
Joined
Nov 17, 2008
Messages
255
Reaction score
118
Location
Bakersfield, CA
How about a script that does the following:

A GM or Admin can use a command such as:

!monsterchase creature, amount, duration

This will broadcast a message serverwide with "A monster chase has begun! Kill (Amount) (Creature)s before the time runs out! Timer: (Duration) minutes"

and would broadcast an update every 10 minutes with the top 5 players. (If there is more than 5 people tied, choose 5 from the same list at random)
the updates would end once the event ends. Each player will see their own personal counter in their chat log with every kill updating their total.

Creature would be the name of the creature
Amount would be the amount of that creature that needs to be killed for the event to end and reward a winner
Duration would be how long (in minutes) the event runs for

If the amount isn't reached, the person with the highest amount killed wins. If there is a tie, the person with the lowest level wins. Kills cannot be shared in a party and is only awarded to the person who deals the highest amount of damage to the creature.

The event ends when 1 person hits the amount or whenever the time runs out, whichever is first.


Example:

GM Eiffel: !monsterchase Demon, 200, 60

Broadcast: "A monster chase has begun! Kill 200 Demons before the time runs out! Timer: 60 minutes"

5 minutes pass

Broadcast: "Current Leader: Player1 with 15 Demons killed!"
Broadcast: "Player2 with 12 Demons killed!"
Broadcast: "Player3 with 10 Demons killed!"
Broadcast: "Player4 with 8 Demons killed!"
Broadcast: "Player5 with 6 Demons killed!"

Player1 finishes the goal before 10 minutes before the timer runs out.

Broadcast: "Player1 wins this monster chase! They have slain 200 Demons with 10 minutes left!
 

Roni123

Hardstyle Never Die < 3 !!!
Joined
Aug 31, 2010
Messages
147
Reaction score
11
Location
Gorzów Wielkopolski
Honestly, I don't really understand what exactly you want. xD
But, this change to the loot drop will force all of the items to go into a never-ending backpack.

View attachment 49428

data\events\scripts\monster.lua

replace your function, with this one.
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        local backpack = corpse:addItem(1988)
        for i = 1, #monsterLoot do
            if backpack:getEmptySlots() == 1 then
                backpack = backpack:addItem(1988)
            end
            local item = backpack:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_LOOT, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_LOOT, text)
        end
    end
end
Good Morning,

Dear Xikini,

Can you share your loot display script ? I have TFS 1.2 and got only loot channel but I want to show loot on display when loot channel are closed but loot display/channel should be used only for premium people.

And 2nd request are script too on TFS 1.2 while ppl make 8 lvl and choose they vocation then old EQ going to replacement on new one depending on vocation.

Thanks in advance !
 
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
Additional unique drop system: (not sure if can be done in pure lua but most likely yes, if no just scrap that idea ;p)

  • After killing monster it will roll additional item with possibility to not roll additional item from this system.
  • Possibility to add different sets of items in tiers for each monster
  • First rolling Tier of the item from 1 to x where 1 is the rarest
  • After rolling the tier it will roll items from the tier list thet got choosen ( items also got different % to chance to drop, and also only 1 item can be choosen )
  • After all of this send message to player that he just got additional tier x drop
  • This additional item can be inside the corpse or give to the player container its whatever u would prefer
Done! :)

text and effects are toggleable on/off, for each tier.

bandicam-2020-09-01-07-36-40-114.gif

Register in specific monsters, use
Lua:
<script>
    <event name="onDeath_randomItemDrops" />
</script>

Register in all monsters..
Make sure that onSpawn is enabled="1" inside data\events\events.xml
data\events\scripts\monster.lua
inside function onSpawn, add
Lua:
self:registerEvent("onDeath_randomItemDrops")
data\scripts\ onDeath_randomItemDrops.lua
Lua:
local config = {
    chance = 2500, -- chance out of 10000. 2500 = 25% of an additional item dropping in monsters.
    tiers = {
        -- A random number is rolled between 1 to 10000.
        -- If the number is between or equal to these numbers, that tier is selected.
    
        -- [chance_lower, chance_higher] = {tier = {"text", enabled?}, effect = {effect, enabled?}}
        [{  1,  5000}] = { tier = {"normal", true}, effect = {CONST_ME_SOUND_WHITE, true}, itemList = {
                {2148, 1, 1, 10000},
                {2148, 2, 2, 5000}, -- {itemid, amount_min, amount_max, chance} -- chance out of 10000.
                {2148, 3, 3, 5000}
            }
        },
        [{5001,  8500}] = { tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {
                {2152, 1, 1, 10000},
                {2152, 2, 2, 5000}, -- note; DO NOT SET amount_min, amount_max higher then 1, if that item is not stackable.
                {2152, 3, 3, 5000}
            }
        },
        [{8501,  9500}] = { tier = {"epic", true}, effect = {CONST_ME_SOUND_BLUE, true}, itemList = {
                {2160, 1, 1, 10000},
                {2160, 2, 2, 5000}, -- note; Even though a reward tier has been selected, if all item chances fail to reward an item, it's possible that a player will not receive any item.
                {2160, 3, 3, 5000}  -- for that reason, I suggest that at least 1 item's chance is set to 10000, so that a player is garenteed to receive an item.
            }
        },
        [{9501, 10000}] = { tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {
                {6500, 1, 1, 10000},
                {6500, 2, 2, 5000},
                {6500, 3, 3, 5000}
            }
        }
    }
}

local creatureevent = CreatureEvent("onDeath_randomItemDrops")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    -- check if corpse item has available space to receive an additional item.
    if corpse:getEmptySlots() > 0 then
        -- check if an additional item will drop.
        if math.random(10000) > config.chance then
            return true
        end
        -- choose a tier.
        local rand = math.random(10000)
        for chance, index in pairs(config.tiers) do
            if chance[1] <= rand and chance[2] >= rand then
                -- create loot list.
                local rewardItems = {}
                for i = 1, #index.itemList do
                    if math.random(10000) <= index.itemList[i][4] then
                        rewardItems[#rewardItems + 1] = i
                    end
                end
                -- give a random item, if there are any to give.
                if rewardItems[1] then
                    rand = math.random(#rewardItems)
                    corpse:addItem(index.itemList[rand][1], math.random(index.itemList[rand][2], index.itemList[rand][3]))
                    if index.tier[2] == true then
                        creature:say(index.tier[1], TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
                    end
                    if index.effect[2] == true then
                        local position = creature:getPosition()
                        for i = 1, 4 do
                            addEvent(function() position:sendMagicEffect(index.effect[1]) end, (i - 1) * 500)
                        end
                    end
                end
                return true
            end
        end
    end
    return true
end

creatureevent:register()
 
Last edited:
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,668
Solutions
405
Reaction score
3,781
@BulawOw

Sorry for missing a crucial portion of your script.
Possibility to add different sets of items in tiers for each monster

Here is an updated version of the script to allow for this.
Lua:
local config = {
    ["rat"] = {
        chance = 2500, -- chance out of 10000. 2500 = 25% of an additional item dropping in monsters.
        tiers = {
            -- A random number is rolled between 1 to 10000.
            -- If the number is between or equal to these numbers, that tier is selected.
            
            -- [chance_lower, chance_higher] = {tier = {"text", enabled?}, effect = {effect, enabled?}}
            [{  1,  5000}] = { tier = {"normal", true}, effect = {CONST_ME_SOUND_WHITE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- {itemid, amount_min, amount_max, chance} -- chance out of 10000.
                    {2160, 3, 3, 5000}
                }
            },
            [{5001,  8500}] = { tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- note; DO NOT SET amount_min, amount_max higher then 1, if that item is not stackable.
                    {2160, 3, 3, 5000}
                }
            },
            [{8501,  9500}] = { tier = {"epic", true}, effect = {CONST_ME_SOUND_BLUE, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000}, -- note; Even though a reward tier has been selected, if all item chances fail to reward an item, it's possible that a player will not receive any item.
                    {2160, 3, 3, 5000}  -- for that reason, I suggest that at least 1 item's chance is set to 10000, so that a player is garenteed to receive an item.
                }
            },
            [{9501, 10000}] = { tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {
                    {2160, 1, 1, 10000},
                    {2160, 2, 2, 5000},
                    {2160, 3, 3, 5000}
                }
            }
        }
    },
    ["cave rat"] = {
        chance = 2500, tiers = {
            [{   1,  5000}] = {tier = {"normal", true},    effect = {CONST_ME_SOUND_WHITE, true},  itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{5001,  8500}] = {tier = {"enchanted", true}, effect = {CONST_ME_SOUND_PURPLE, true}, itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{8501,  9500}] = {tier = {"epic", true},      effect = {CONST_ME_SOUND_BLUE, true},   itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }},
            [{9501, 10000}] = {tier = {"legendary", true}, effect = {CONST_ME_SOUND_YELLOW, true}, itemList = {{6500, 1, 1, 10000}, {6500, 2, 2, 5000}, {6500, 3, 3, 5000} }}
        }
    },
}

local creatureevent = CreatureEvent("onDeath_randomItemDrops")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    local monster = config[creature:getName():lower()]
    -- check if monster is in table
    if monster then
        -- check if corpse item has available space to receive an additional item.
        if corpse:getEmptySlots() > 0 then
            -- check if an additional item will drop.
            if math.random(10000) > monster.chance then
                return true
            end
            -- choose a tier.
            local rand = math.random(10000)
            for chance, index in pairs(monster.tiers) do
                if chance[1] <= rand and chance[2] >= rand then
                    -- create loot list.
                    local rewardItems = {}
                    for i = 1, #index.itemList do
                        if math.random(10000) <= index.itemList[i][4] then
                            rewardItems[#rewardItems + 1] = i
                        end
                    end
                    -- give a random item, if there are any to give.
                    if rewardItems[1] then
                        rand = math.random(#rewardItems)
                        corpse:addItem(index.itemList[rand][1], math.random(index.itemList[rand][2], index.itemList[rand][3]))
                        if index.tier[2] == true then
                            creature:say(index.tier[1], TALKTYPE_MONSTER_SAY, false, nil, creature:getPosition())
                        end
                        if index.effect[2] == true then
                            local position = creature:getPosition()
                            for i = 1, 4 do
                                addEvent(function() position:sendMagicEffect(index.effect[1]) end, (i - 1) * 500)
                            end
                        end
                    end
                    return true
                end
            end
        end
    end
    return true
end

creatureevent:register()
 

mimsol

New Member
Joined
Mar 18, 2020
Messages
83
Reaction score
2
Hey whats about a Reborn System that multiplie dmg hp mana per rebirth maybe its possible without source edits
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,784
Solutions
35
Reaction score
989
Location
Germany
Hey whats about a Reborn System that multiplie dmg hp mana per rebirth maybe its possible without source edits
as i know its possible for hp and mp but not for dmg at all
or...
You using custom spells damage formulas based on rebirth
but there alredy exists reborn system for tfs 1.2 ( I think its working for tfs 1.3 aswell )
 

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
159
Solutions
2
Reaction score
33
Location
Egypt
Can u make a script if there's 3 players step in 3 different SQM positons they open a gate like stone and the gate wait for 4 second then it goes gone. 2nd a script to how many dies u died like if you step in portal it teleport u and it send a text message with monster say gives u how much u died like you have died "number of times plus using this command !hmdies".
3rd script a npc gives u an items if you killed 2 different monsters, 1 monster for 200 times and the other monster for 20 time.
4th script a monster spawn in some area every 7 hours.
Did you forget me ?😂
 

miguelshta

Member
Joined
Mar 21, 2009
Messages
295
Solutions
1
Reaction score
10
Location
Toronto, Canada
@Xikini can you do
1.- action
critical imbuement stone < adds 15% criticalchance and 20% criticaldmg
mana leech imbuement stone < adds 100% mana leech chance and 5% mana leech
2.- npc that sell these stones for 1000 silver tokens

XML:
my variables for crit and mana leech are:

manaleechchance = 100%
manaleechamount = 5%

criticalhitamount = 20%
criticalhitchance = 15%
in advance thank you! :D
 
Status
Not open for further replies.
Top