• 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,835
Solutions
585
Reaction score
5,431
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:
I made it for generic physical damage, I think.
I say just use it as-is. lol

Its not working for my crossbow.

Lua:
local firecrossbow = 5390
local fire_percent = 10
local fire_damage = {}


local weapon = Weapon(WEAPON_DISTANCE)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 28)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0)

function onGetFormulaValues(player, skill, attack, factor)
    local min = 0
    local max = getMaxWeaponDamage(player:getLevel(), skill, (attack * GLOBAL_vocationMultipliers[player:getVocation():getId()].distDamage), factor)
    local damage = normal_random_range(min, max)
    fire_damage[player:getId()] = math.floor(((damage / 100) * fire_percent) + 0.5)
    local target = player:getTarget()
    damage, effect = target:calculateDamageAfterArmorandDefence(damage)
    target:getPosition():sendMagicEffect(effect)
    return -damage, -damage
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


local combat_fire = Combat()
combat_fire:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)

function onGetFormulaValues(player, skill, attack, factor)
    local fireDamage = fire_damage[player:getId()]
    fire_damage[player:getId()] = nil
    return -fireDamage, -fireDamage
end

combat_fire:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


function weapon.onUseWeapon(player, variant)
    if player:getSkull() == SKULL_BLACK then
        return false
    end

    combat:execute(player, variant)
    combat_fire:execute(player, variant)
    return true
end

weapon:id(firecrossbow)
weapon:register()


It is working for lets say an fire spear, but its not working for bows/crossbows.
 
As requested, can put every element up to 10%.

View attachment 82075

data/scripts/delikeramRequest.lua
Lua:
local amuletItemId = 2173
local maximumUpgradePercent = 10

local protectionItems = {
--    [1111] = {protectionType = "physical", percent = 0.5},
    [8303] = {protectionType = "energy", percent = 0.5},
--    [1111] = {protectionType = "earth", percent = 0.5},
--    [1111] = {protectionType = "fire", percent = 0.5},
    [8302] = {protectionType = "ice", percent = 0.5},
--    [1111] = {protectionType = "holy", percent = 0.5},
--    [1111] = {protectionType = "death", percent = 0.5}
}

-- END OF CONFIG

local protectionTypes = {
    ["physical"] = COMBAT_PHYSICALDAMAGE,
    ["energy"] = COMBAT_ENERGYDAMAGE,
    ["earth"] = COMBAT_EARTHDAMAGE,
    ["fire"] = COMBAT_FIREDAMAGE,
    ["ice"] = COMBAT_ICEDAMAGE,
    ["holy"] = COMBAT_HOLYDAMAGE,
    ["death"] = COMBAT_DEATHDAMAGE
}

local combatTypes = {
    [COMBAT_PHYSICALDAMAGE] = "physical",
    [COMBAT_ENERGYDAMAGE] = "energy",
    [COMBAT_EARTHDAMAGE] = "earth",
    [COMBAT_FIREDAMAGE] = "fire",
    [COMBAT_ICEDAMAGE] = "ice",
    [COMBAT_HOLYDAMAGE] = "holy",
    [COMBAT_DEATHDAMAGE] = "death"
}


local function setProtectionDescription(item)
    local text = ""
    local isMaxUpgraded = true
    local order = {"physical", "energy", "earth", "fire", "ice", "holy", "death"}
    for _, element in ipairs(order) do
        local attributeValue = item:getCustomAttribute(element) or 0
        if attributeValue > 0 then
            if text ~= "" then
                text = text .. ", "
            end
            text = text .. element .. " +" .. attributeValue .. "%"
        end
        if attributeValue ~= maximumUpgradePercent then
            isMaxUpgraded = false
        end
    end
    if isMaxUpgraded then
        text = "[Additional Protections: All Damage Types +" .. maximumUpgradePercent .. "%]"
    else
        text = "[Additional Protections: " .. text .. "]"
    end
    item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, text)
end

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    if target:getId() ~= amuletItemId then
        target:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
   
    local itemId = item:getId()
    local attributeValue = target:getCustomAttribute(protectionItems[itemId].protectionType) or 0
   
    if attributeValue >= maximumUpgradePercent then
        target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        return true
    end
   
    target:setCustomAttribute(protectionItems[itemId].protectionType, math.min(attributeValue + protectionItems[itemId].percent, maximumUpgradePercent))
    target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    setProtectionDescription(target)
    item:remove(1)
    return true
end

for itemId, _ in pairs(protectionItems) do
    action:id(itemId)
end
action:register()


local function damageCalculator(player, primaryDamage, primaryType, secondaryDamage, secondaryType)
    local slotItem = player:getSlotItem(CONST_SLOT_NECKLACE)
    if slotItem then
        if combatTypes[primaryType] then
            local reductionPecent = slotItem:getCustomAttribute(combatTypes[primaryType]) or 0
            if reductionPecent > 0 then
                primaryDamage = primaryDamage - (primaryDamage * (reductionPecent / 100))
            end
        end
        if combatTypes[secondaryType] then
            local reductionPecent = slotItem:getCustomAttribute(combatTypes[secondaryType]) or 0
            if reductionPecent > 0 then
                secondaryDamage = secondaryDamage - (secondaryDamage * (reductionPecent / 100))
            end
        end
    end
    return primaryDamage, secondaryDamage
end


local healthChange = CreatureEvent("onHealthChange_protectionAmulet")

function healthChange.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    primaryDamage, secondaryDamage = damageCalculator(creature, primaryDamage, primaryType, secondaryDamage, secondaryType)
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

healthChange:register()


local manaChange = CreatureEvent("onManaChange_protectionAmulet")

function manaChange.onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    primaryDamage, secondaryDamage = damageCalculator(creature, primaryDamage, primaryType, secondaryDamage, secondaryType)
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaChange:register()


local creatureevent = CreatureEvent("example")

function creatureevent.onLogin(player)
    player:registerEvent("onHealthChange_protectionAmulet")
    player:registerEvent("onManaChange_protectionAmulet")
    return true
end

creatureevent:register()
Would it be possible to do it the other way around or almost the same? instead of protection I would like to increase the damage, regardless of the item, that is: using the upgrade stone on any weapon/wand would increase its damage by x% for each stone used... please and thank you xD
 
Back
Top