• 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.4.2

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,928
Solutions
589
Reaction score
5,586
Request whatever you want, within reason.

Please do not request for things that require source editing or database queries.

------------------------------------
If I've reacted to your post, it means I've read it. 👍😍🤣😲🙁😡🤔😉

------------------------------------
Completed Requests

A boss that randomly creates effects on tiles, that when stepped on, gives the player increased damage/mitigation to that boss.
Kill monster and gain X% extra loot chance or Y% extra experience for Z minutes
A pack of 6 useful simple scripts.
-> (1) Simple quest npc
-> (2,3,4,5) use levers in specific order / stand with 4 players / use 4 objects / place items -> to open wall
-> (6) use lever to add/remove/replace objects
Wave type spell, with multiple effects
-> Same spell, but with default combat system
House market system. (owner places price on blackboard and object on the ground, other players buy with a lever)
Respawn System (closest anchor (like darks souls bonfire) / tavern / temple)
Vocation Death Protection (protect the noobs!)
Spell that shows area it will damage, before it strikes.
RAID SYSTEM - rebuilt in Lua, with some more features.
Modal Window - Teleport Item with saving/deleting of positions
Show top 3 Online Players (outfit, name, level) (as monsters, in set positions)
onLook function showing kill count of player.
Modal Window - Use Item -> choose reward.
Talkaction - !backpacks - to buy backpacks (or single items) anywhere. uses bank & current money on players
Quest/Event? Turn a bunch of objects with a monster, spawn portal.
Spawn Monsters, after they've all been killed, give global increased experience/loot in specific area's
Evolving Weapons - Kill X amount of specific creatures, evolve weapon and gain extra damage to those creatures.
Random Portals spawn at XX:XX time(s). (can exit 'off' portals, if you have the storage.)
Monster that adjusts speed based on target
Monster that increases damage output based on # of players nearby
Experience recovery Item. Die -> Use Item -> gain % of lost experience
Character Snapshot - Keeps track of all skills & level, for resetting later.
Fire Dagger - Physical Damage Melee Weapon, with % added damage
Players in specific level ranges don't lose skills/loot/experience, when they die.
Multiclient Limit Check - with admin account not being counted towards limit
Capacity Increasing Items
Upgradeable Protection Amulet - 10% to all elements
-> upgrade amulet, but for all items.
onKill - give reward to all players who dealt damage
-> example: give reward based on damage contribution
Quest Book - Record your quest progress into a book.
Stat System, using modal windows
Holy Tible (POI) - Require Item to use teleport tiles
Item Upgrade System
Skill Stages
-> individual stages for each skill type
-> talkaction to check rates (by @Extrodus)
Random Reward Item - gives different rewards based on vocation
Bounty Hunter System
NPC & Player Walk System (Follow Nodes to destination)
Health/Mana gain permanent - limited use items

------------------------------------
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 necessary information it's impossible to help you.

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

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.

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 publicly, 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
---------

P.S.
I've been doing free scripting service's on/off for awhile.
And if you want to see the previous threads, go check them here.

 
Last edited by a moderator:
teleport player to temple instead of log out would be possible to ask? this way players don't get it's backpack closed
don't need anything else, just that is not for an war server want it for an rpg server, it's tediuous to have to re open everything after death so would like to ask for this script if it woould be posible. thanks
As far as I know, this is only possible if you simulate the death via script.

I kind of explained it here, but it's too complicated for me.
 
For example: you are hunting with your team in... dragons (example) when they attack you, suddenly they hit you with critical damage and the critical damage animation appears.
check it out:
Put it into data/scripts
LUA:
local critical_monsters = {
    ["dragon"] = {multiplier = 2.0, chance = 5}, -- 2x dmg, 5% chance
    ["make sure the monster names are lowercase"] = {multiplier = 2.0, chance = 5}
}


local healthChange = CreatureEvent("onHealthChange_Critical_Monsters")

function healthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healthChange:register()

local manaChange = CreatureEvent("onManaChange_Critical_Monsters")

function manaChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaChange:register()


local creatureevent = CreatureEvent("onLogin_Critical_Monsters")

function creatureevent.onLogin(player)
    player:registerEvent("onHealthChange_Critical_Monsters")
    player:registerEvent("onManaChange_Critical_Monsters")
    return true
end

creatureevent:register()
 
Last edited:
For example: you are hunting with your team in... dragons (example) when they attack you, suddenly they hit you with critical damage and the critical damage animation appears.
check it out:
Just add the new attack to the monster, and set animation to critical hit, which is 173. No need to create anything more than that

XML:
<attack name="ice" interval="2000" chance="10" range="7" radius="1" target="1" min="-10" max="-30">
    <attribute key="areaEffect" value="173" />
</attack>
 
Just add the new attack to the monster, and set animation to critical hit, which is 173. No need to create anything more than that

XML:
<attack name="ice" interval="2000" chance="10" range="7" radius="1" target="1" min="-10" max="-30">
    <attribute key="areaEffect" value="173" />
</attack>
Good alternative, all depends on what the requester wants.

For an individual creature/boss on a specific attack, this is much better.
However, if you want multiple creatures and all their attacks/spells, I would go with the onHealthChange as it's much less work.
 
Good alternative, all depends on what the requester wants.

For an individual creature/boss on a specific attack, this is much better.
However, if you want multiple creatures and all their attacks/spells, I would go with the onHealthChange as it's much less work.

Right, if you need the critical hit to affect every attack of the monster, then the script is obviously a way to go. I wonder if the script provided by @Xikini would also affect monsters healing?

I guess would be good to add
LUA:
if primaryType == COMBAT_HEALING then
   return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Good alternative, all depends on what the requester wants.

For an individual creature/boss on a specific attack, this is much better.
However, if you want multiple creatures and all their attacks/spells, I would go with the onHealthChange as it's much less work.
Good point. Should do onManaChange as well, since there is magical attacks, and mana shield. lol

Right, if you need the critical hit to affect every attack of the monster, then the script is obviously a way to go. I wonder if the script provided by @Xikini would also affect monsters healing?

I guess would be good to add
LUA:
if primaryType == COMBAT_HEALING then
   return primaryDamage, primaryType, secondaryDamage, secondaryType
end

Technically yes..
But what monsters are casting healing onto players?
 
Good point. Should do onManaChange as well, since there is magical attacks, and mana shield. lol



Technically yes..
But what monsters are casting healing onto players?
They are healing themselves. You are checking if attacker:isMonster(), but not checking if the target is player. That made me wonder, if the monster would trigger it's healing spell, it is still considered an attacker, but doesn't check who it targets. Isn't it like that? I'm just thinking out loud :P
 
They are healing themselves. You are checking if attacker:isMonster(), but not checking if the target is player. That made me wonder, if the monster would trigger it's healing spell, it is still considered an attacker, but doesn't check who it targets. Isn't it like that? I'm just thinking out loud :P
The onHealthChange is only registered to players (via onLogin), so creature in this instance can only ever be the player. xP
 
View attachment 81824

data/lib/core/core.lua -- add
LUA:
dofile('data/lib/core/xikiniCustomFunctions.lua')
data/lib/core/xikiniCustomFunctions.lua -- add
LUA:
--[[ quick reference of events

    CREATURE_EVENT_NONE
    CREATURE_EVENT_LOGIN
    CREATURE_EVENT_LOGOUT
    CREATURE_EVENT_THINK
    CREATURE_EVENT_PREPAREDEATH
    CREATURE_EVENT_DEATH
    CREATURE_EVENT_KILL
    CREATURE_EVENT_ADVANCE
    CREATURE_EVENT_MODALWINDOW
    CREATURE_EVENT_TEXTEDIT
    CREATURE_EVENT_HEALTHCHANGE
    CREATURE_EVENT_MANACHANGE
    CREATURE_EVENT_EXTENDED_OPCODE
]]--

function Player:hasEvent(type, name)
    for k, v in pairs(self:getEvents(type)) do
        if v == name then
            return true
        end
    end
    return false
end

data/scripts/onUse_RemoveSaveTeleport.lua
LUA:
local teleportItemId = 11134

local config = {
    modalWindow = {
        id = 1000,
        title = "Teleport-Pos",
        message = "Choose a position to teleport",
        eventText = "ModalWindow_RemoveSaveTeleport",
        buttons = {
            {text = "Remove"},
            {text = "Save"},
            {text = "Teleport", defaultEnterButton = true},
            {text = "Cancel", defaultEscapeButton = true},
        }
    },
    teleport = {
        {45026, 45027, 45028}, -- these are storageKeys
        {45029, 45030, 45031},
        {45032, 45033, 45034}  -- add as many as you want. just make sure all the storages are unused, and unique
    }
}

local function createTeleportWindow(playerId)
    local player = Player(playerId)
    if not player then
        return
    end

    if player:hasEvent(CREATURE_EVENT_MODALWINDOW, config.modalWindow.eventText) then
        player:unregisterEvent(config.modalWindow.eventText)
    end
    player:registerEvent(config.modalWindow.eventText)
   
    local modalWindow = ModalWindow(config.modalWindow.id, config.modalWindow.title, config.modalWindow.message)
   
    for id, button in ipairs(config.modalWindow.buttons) do
        modalWindow:addButton(id, button.text)
        if button.defaultEscapeButton then
            modalWindow:setDefaultEscapeButton(id)
        elseif button.defaultEnterButton then
            modalWindow:setDefaultEnterButton(id)
        end
    end       

    for id, v in ipairs(config.teleport) do
        local x = player:getStorageValue(v[1])
        local y = player:getStorageValue(v[2])
        local z = player:getStorageValue(v[3])
        local text = x ~= -1 and string.format("Position(%s, %s, %s)", x, y, z) or "No position saved."
        modalWindow:addChoice(id, text)
    end
   
    modalWindow:hasPriority()
    modalWindow:sendToPlayer(player)
end


local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    createTeleportWindow(player:getId())
    return true
end

action:id(teleportItemId)
action:register()


local creatureevent = CreatureEvent(config.modalWindow.eventText)

function creatureevent.onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:unregisterEvent(config.modalWindow.eventText)
   
    if modalWindowId == config.modalWindow.id then
        local buttonChoice = config.modalWindow.buttons[buttonId].text
       
        if buttonChoice == "Teleport" then
            local x = player:getStorageValue(config.teleport[choiceId][1])
            local y = player:getStorageValue(config.teleport[choiceId][2])
            local z = player:getStorageValue(config.teleport[choiceId][3])
            if x ~= -1 then
                local position = Position(x, y, z)
                player:teleportTo(position)
                position:sendMagicEffect(CONST_ME_TELEPORT)
            end
        elseif buttonChoice == "Save" then
            local playerPosition = player:getPosition()
            player:setStorageValue(config.teleport[choiceId][1], playerPosition.x)
            player:setStorageValue(config.teleport[choiceId][2], playerPosition.y)
            player:setStorageValue(config.teleport[choiceId][3], playerPosition.z)
           
        elseif buttonChoice == "Remove" then
            player:setStorageValue(config.teleport[choiceId][1], -1)
            player:setStorageValue(config.teleport[choiceId][2], -1)
            player:setStorageValue(config.teleport[choiceId][3], -1)
        else
            -- "Cancel" button
            return true
        end
       
        addEvent(createTeleportWindow, 0, player:getId())
    end
    return true
end

creatureevent:register()
Post automatically merged:


Unfortunately I've learned that all 'frag' information is stored in the database, with no default functions to manipulate it.

So, this falls under database queries and will not be scripted.

Nice I like it
 
Put it into data/scripts
LUA:
local critical_monsters = {
    ["dragon"] = {multiplier = 2.0, chance = 50}, -- 2x dmg, 5% chance
    ["make sure the monster names are lowercase"] = {multiplier = 2.0, chance = 5}
}


local healthChange = CreatureEvent("onHealthChange_Critical_Monsters")

function healthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healthChange:register()

local manaChange = CreatureEvent("onManaChange_Critical_Monsters")

function manaChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaChange:register()


local creatureevent = CreatureEvent("onLogin_Critical_Monsters")

function creatureevent.onLogin(player)
    player:registerEvent("onHealthChange_Critical_Monsters")
    player:registerEvent("onManaChange_Critical_Monsters")
    return true
end

creatureevent:register()
you're amazing bro!! it works perfectly
Post automatically merged:

Put it into data/scripts
LUA:
local critical_monsters = {
    ["dragon"] = {multiplier = 2.0, chance = 5}, -- 2x dmg, 5% chance
    ["make sure the monster names are lowercase"] = {multiplier = 2.0, chance = 5}
}


local healthChange = CreatureEvent("onHealthChange_Critical_Monsters")

function healthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healthChange:register()

local manaChange = CreatureEvent("onManaChange_Critical_Monsters")

function manaChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker:isMonster() then
        local critMonster = critical_monsters[attacker:getName():lower()]
        if critMonster then
            if math.random(100) <= critMonster.chance then
                primaryDamage = primaryDamage * critMonster.multiplier
                secondaryDamage = secondaryDamage * critMonster.multiplier
                creature:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaChange:register()


local creatureevent = CreatureEvent("onLogin_Critical_Monsters")

function creatureevent.onLogin(player)
    player:registerEvent("onHealthChange_Critical_Monsters")
    player:registerEvent("onManaChange_Critical_Monsters")
    return true
end

creatureevent:register()

Sin título.jpg
a error appaers xd
 
Last edited:
you're amazing bro!! it works perfectly
Post automatically merged:



View attachment 84554
a error appaers xd
change (x2 in script)
LUA:
if attacker:isMonster() then
to
LUA:
if attacker and attacker:isMonster() then

or just go and recopy script from above. I edited it with the fix.
 
Back
Top