• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Scripter Zbizu / Free scripting service

Status
Not open for further replies.

Sopago

Member
Joined
Dec 15, 2020
Messages
32
Reaction score
11
GitHub
Sopago
Hi, thanks for this.

Version: TFS 1.3
Client: 10.98

Creating npc next to player
-To create npc you need item X and item Y (ids) together in your bp
-Npc can give X Money or Y Experience(can only choose one)
-After giving what you chose npc dissapears
-Only player who create npc can talk to him
-After you get reward the item dissapear from bp.
-Cant use item to create npc if he is already created by me, items become inactive during the time he is created.

Thanks in advance.
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,631
Solutions
126
Reaction score
2,016
Nah, it's engine bug. Freshly generated variant just makes it ignore cast direction.

2 attempts were made:
Code:
    local p = creature:getPosition()
    combat2:execute(creature, {type = 2, pos = {x = p.x, y = p.y, z = p.z, stackpos = p.stackpos}})

and

Code:
    local p = creature:getPosition()
    combat2:execute(creature, Variant(creature, p))
Post automatically merged:

Ok. Now I see why the support for legacy combat functions wasn't dropped yet.

Here's an example of working spell(revscriptsys mod):

Code:
local area1 = {
    {0, 1, 0},
    {0, 1, 0},
    {0, 3, 0}
}

local area2 = {
    {1, 1, 1},
    {1, 1, 1},
    {1, 1, 1},
    {0, 0, 0},
    {0, 0, 0},
    {0, 2, 0}
}

local area2_full = createCombatArea(area2)

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(area1))
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
  
local spell = Spell(SPELL_INSTANT)
spell:name("jutsu my ass")
spell:words("jutsu my ass")
spell:id(220)
spell:level(20)
spell:magicLevel(5)
spell:needDirection(true)
spell:isAggressive(true)
spell:vocation("sorcerer;true", "master sorcerer")

local function castSpell(creatureId)
    local player = Player(creatureId)
    if not player then
        return
    end
  
    local level = player:getLevel()
    local ninjutsu = player:getMagicLevel()
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
  

    local pos = player:getPosition()
    pos:getNextPosition(player:getDirection())

    doAreaCombatHealth(creatureId, COMBAT_FIREDAMAGE, pos, area2_full, min, max, CONST_ME_MORTAREA)
end

function spell.onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(castSpell, 100, creature:getId())
    return true
end

spell:register()

@poe6man3

if anyone needs more examples of target/area combat with delays, see here (scroll to pastebin link):
Why are you passing creature to variant? Variant is either creature id, position, thing or string

 
OP
OP
zbizu

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,217
Solutions
25
Reaction score
2,416
Location
Poland
GitHub
Zbizu
I messed reverting the code after trying something else. Previously I tried Variant(pos), but I kept getting weird results.

The centerPos of combatArea is in front of the player btw so you also have to call getNextPosition when you want to make a new Variant object.
full code (finished):
Code:
local area1 = {
    {0, 1, 0},
    {0, 1, 0},
    {0, 3, 0}
}

local area2 = {
    {1, 1, 1},
    {1, 1, 1},
    {1, 1, 1},
    {0, 0, 0},
    {0, 0, 0},
    {0, 2, 0}
}

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(area1))
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onGetFormulaValues(player, level, ninjutsu)
    local min = (level / 5) + (ninjutsu * 1.6) + 9
    local max = (level / 5) + (ninjutsu * 3.2) + 19
    return -min, -max
end

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat2:setArea(createCombatArea(area2))
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local spell = Spell(SPELL_INSTANT)
spell:name("jutsu my ass")
spell:words("jutsu my ass")
spell:id(220)
spell:level(20)
spell:magicLevel(5)
spell:needDirection(true)
spell:isAggressive(true)
spell:vocation("sorcerer;true", "master sorcerer")

local function castSpell(creatureId)
	local player = Player(creatureId)
	if not player then
		return
	end
	
	local level = player:getLevel()
	local ninjutsu = player:getMagicLevel()
	local min = (level / 5) + (ninjutsu * 1.6) + 9
	local max = (level / 5) + (ninjutsu * 3.2) + 19
	

	local pos = player:getPosition()
	pos:getNextPosition(player:getDirection())

	combat2:execute(player, Variant(pos))
end

function spell.onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(castSpell, 2000, creature:getId())
    return true
end

spell:register()
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,508
Solutions
260
Reaction score
4,443

Landera

Veteran OT User
Joined
Nov 24, 2011
Messages
886
Solutions
1
Reaction score
288
Bringing back the oldskool guildmaster npc :)

For 1.3 tfs
 

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,113
Solutions
26
Reaction score
600
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi @zbizu

I wonder if would be a good request a remake of this old system

There's a detail on the request, I would like that the carpet follows an specific route when the player is in traveling and being translated.
carpet.png

This feature would be in replacement of the talkaction commands. When the carpet ends the route, it stays and wait for a next onMoveIn event to occur. The next event should be the carpet "traveling back" following the same route. I attached the map with and without carpets. Anything else that is needed i'll do (setting up the coordinates too).

Regards and thanks!
 

Attachments

Hammer

New Member
Joined
Jun 29, 2009
Messages
11
Reaction score
1
u can transform to revscript this script pls
 

Attachments

  • dreamscarLevers.lua
    12.5 KB · Views: 4 · VirusTotal

303878

New Member
Joined
Apr 4, 2015
Messages
6
Reaction score
1
can you make an entire tibia ot server for me? I'll pay you ofc
 

3zequi3l

New Member
Joined
Jan 14, 2021
Messages
5
Reaction score
0
Location
México
Hello good evening, according to the Tibiaface Slot system, it can be modified so that it appears what attributes to put on the item? please... here I leave the script:

Lua:
--------------------------
-- Creaditos: [Adm] SevuOT de tibiaface.com
-- Nota: este sistema fue creado con la intension de regalarles algo en navidad! feliz navidad!
-- Version: 1.0
-- RECOMENDACIONES: > Si no sabe de lua o scripts, mejor no tocar mucho el script, es delicado a cambios brutos <

-- Objetos con el cual podras añadirle slots a otros objeos
-- Tambien puedes añadir esta funcionalidad a mas de un objeto, solo añadiendo una coma y seguido de la nueva ID
-- Ejemplo: local addSlotItems = { 2160, 2452 }
local addSlotItems = { 42028 }
local slotAction = Action()
local creatureEvent = CreatureEvent()

-- Libreria para la funcionalidad del sistema
local Attr = {}
Attr.__index = Attr
Attr.init = function(slot)
    local attr = {}
    setmetatable(attr, Attr)
    attr.name = slot.name
    attr.value = slot.value
    attr.percent = slot.percent
    return attr
end
setmetatable(Attr, {
    __call = function(_, ...) return Attr.init(...) end,
    __eq = function(a, b) return a.name == b.name and a.value == b.value and a.percent == b.percent end
})

local slotLib = {}
slotLib.maxSlots = 3 -- max 10, more get a errors
slotLib.baseSubids = 90
slotLib.cache = {}

slotLib.attributes = {
    { name = "Club", values = { 1, 2 }, percent = false },
    { name = "Sword", values = { 1, 2 }, percent = false },
    { name = "Axe", values = { 1, 2 }, percent = false },
    { name = "Distance", values = { 1, 2 }, percent = false },
    { name = "Shield", values = { 1, 2 }, percent = false },
    { name = "Fishing", values = { 1, 2 }, percent = false },
    { name = "MagicLevel", values = { 1, 2 }, percent = false },
    { name = "CriticalChance", values = { 1, 2 }, percent = false },
    { name = "CriticalAmount", values = { 1, 2 }, percent = false },
    { name = "LifeLeechChance", values = { 1, 2 }, percent = false },
    { name = "LifeLeechAmount", values = { 1, 2 }, percent = false },
    { name = "ManaLeechChance", values = { 1, 2 }, percent = false },
    { name = "ManaLeechAmount", values = { 1, 2 }, percent = false },
    { name = "Speed", values = { 1, 2 }, percent = false },
    { name = "HealthGain", values = { 1, 2 }, percent = false },
    { name = "ManaGain", values = { 1, 2 }, percent = false }
}

slotLib.conditions = {
    ["Club"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CLUB },
    ["Sword"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_SWORD },
    ["Axe"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_AXE },
    ["Distance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_DISTANCE },
    ["Shield"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_SHIELD },
    ["Fishing"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_FISHING },
    ["MagicLevel"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_STAT_MAGICPOINTS },
    ["CriticalChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE },
    ["CriticalAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE },
    ["LifeLeechChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE },
    ["LifeLeechAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT },
    ["ManaLeechChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE },
    ["ManaLeechAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT },
    ["Speed"] = { Type = CONDITION_SPEED, Attr = CONDITION_PARAM_SPEED },
    ["HealthGain"] = { Type = CONDITION_REGENERATION, Attr = CONDITION_PARAM_HEALTHGAIN },
    ["ManaGain"] = { Type = CONDITION_REGENERATION, Attr = CONDITION_PARAM_MANAGAIN }
}

slotLib.addItemSlot = function(item)
    local slots = slotLib.getItemSlots(item)
    local replace = #slots >= slotLib.maxSlots
    local slot = slotLib.attributes[math.random(1, #slotLib.attributes)]
    if slot then
        local slotIndex = not replace and #slots + 1 or math.random(1, slotLib.maxSlots)
        local newvalue = slot.values[math.random(1, #slot.values)]
        local oldvalue = replace and slots[slotIndex].value or newvalue
        slots[slotIndex] = {
            name = slot.name,
            value = not slot.percent and newvalue,
            valuePercent = slot.percent and newvalue
        }
        slotLib.setItemSlots(item, slots)
        return newvalue >= oldvalue
    end
end

slotLib.getItemSlots = function(item)
    local slots = {}
    for slot in string.gmatch(Item.getDescription(item), "(%[.-%])") do
        local name = string.match(slot, "%[(%a+)%p")
        local value = tonumber(string.match(slot, "%p(%d+)%]"))
        local valuePercent = tonumber(string.match(slot, "%p(%d+)%%+%]"))
        slots[#slots + 1] = {
            name = name,
            value = value,
            valuePercent = valuePercent
        }
    end
    return slots
end

slotLib.setItemSlots = function(item, slots)
    local description = ItemType.getDescription(ItemType(Item.getId(item))) or ""
    for _, slot in pairs(slots) do
        description = string.format("%s[%s+%u%s]%s", description, slot.name, slot.value or slot.valuePercent, slot.valuePercent and "%" or "", _ == #slots and "" or "\n")
    end
    return Item.setAttribute(item, ITEM_ATTRIBUTE_DESCRIPTION, description)
end

slotLib.autoDetection = function(playerId)
    local player = Player(playerId)
    if player then
        if not slotLib.cache[playerId] then
            slotLib.cache[playerId] = {}
        end
        for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(slot)
            if item then
                local slots = slotLib.getItemSlots(item)
                slotLib.onSlotEquip(player, slots, slot)
                if #slots < slotLib.maxSlots then
                    for index = #slots+1, slotLib.maxSlots do
                        local subid = slotLib.baseSubids + slot + (CONST_SLOT_AMMO * index)
                        player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
                        player:removeCondition(CONDITION_SPEED, CONDITIONID_DEFAULT, subid, true)
                        player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, subid, true)
                    end
                end
            else
                for index = 1, slotLib.maxSlots do
                    local subid = slotLib.baseSubids + slot + (CONST_SLOT_AMMO * index)
                    player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
                    player:removeCondition(CONDITION_SPEED, CONDITIONID_DEFAULT, subid, true)
                    player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, subid, true)
                end
            end
        end
        addEvent(slotLib.autoDetection, 100, playerId)
    else
        slotLib.cache[playerId] = nil
    end
end

slotLib.onSlotEquip = function(player, slots, slotIndex)
    for index, slot in pairs(slots) do
        local attr = Attr(slot)
        local subid = slotLib.baseSubids + slotIndex + (CONST_SLOT_AMMO * index)
        if not slotLib.cache[player.uid][subid] or slotLib.cache[player.uid][subid] ~= attr then
            if slotLib.cache[player.uid][subid] and slotLib.cache[player.uid][subid] ~= attr then
                player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
                player:removeCondition(CONDITION_SPEED, CONDITIONID_DEFAULT, subid, true)
                player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, subid, true)
            end
            local info = slotLib.conditions[attr.name]
            if info then
                local condition = Condition(info.Type, CONDITIONID_DEFAULT)
                if condition then
                    condition:setParameter(info.Attr, attr.value)
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(CONDITION_PARAM_SUBID, subid)
                    player:addCondition(condition)
                    slotLib.cache[player.uid][subid] = attr
                end
            end
        end
    end
end

slotLib.isUpgradeable = function(item)
    local it = ItemType(item.itemid)
    return it:getArmor() >= 1 or it:getDefense() >= 1 or it:getAttack() >= 1 or it:getExtraDefense() >= 1 or it:getShootRange() >= 1 or it:getWeaponType() >= 1
end

function slotAction.onUse(player, item, fromPos, target, toPos, isHotkey)
    if not target or not target:isItem() then
        return player:sendCancelMessage("Sorry not possible, only work on items.")
    end
    if not slotLib.isUpgradeable(target) then
        return player:sendCancelMessage("Sorry not possible, this item cannot update slots.")
    end
    local greatz = slotLib.addItemSlot(target)
    target:getPosition():sendMagicEffect(greatz and CONST_ME_FIREWORK_RED or CONST_ME_FIREWORK_BLUE)
    player:say(greatz and "Perfect!" or "Bad!")
    return true
end

slotAction:id(addSlotItems[1])
slotAction:register()

function creatureEvent.onLogin(player)
    slotLib.autoDetection(player.uid)
    return true
end

creatureEvent:register()
 
Status
Not open for further replies.
Top