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

Help Use X Item in Monster

Hell Hazor

New Member
Joined
Jun 9, 2009
Messages
11
Reaction score
0
Hello people good night! I come to ask for your help after several attempts.

I want to create an item, as if it were a "rune", and when using this rune on the monster, I would be teleported to an X location.

it is possible?

I use Nekiro tfs 1.5
 
data/scripts

Lua:
local config = {
    runeName = "Teleport Rune",
    runeId = 2275,
    level = 100, -- Level to use the rune
    magicLevel = 5, -- Magic level to use the rune
    cooldown = 1, -- Cooldown before you can use the rune again (seconds)
    magicEffect = CONST_ME_MAGIC_BLUE, -- Effect on target
    position = Position(1000, 1000, 7), -- Location to get teleported to
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, config.magicEffect)
combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local rune = Spell(SPELL_RUNE)

function rune.onCastSpell(creature, variant, isHotkey)
    local target = Creature(variant:getNumber())
    if target == creature then
        creature:sendCancelMessage("You can not use this rune on yourself.")
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    creature:teleportTo(config.position)
    creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return combat:execute(creature, variant)
end

rune:name(config.runeName)
rune:runeId(config.runeId)
rune:level(config.level)
rune:magicLevel(config.magicLevel)
rune:id(220)
rune:group("support")
rune:cooldown(config.cooldown * 1000)
rune:groupCooldown(2000)
rune:needTarget(true)
rune:isAggressive(false)
rune:allowFarUse(true)
rune:vocation("sorcerer")
rune:register()
 
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- If the 'monsterName' variable has the name of a specific monster, then the rune will only work for that particular monster.
    -- If the 'monsterName' variable is empty, then the rune will work for any monster.
    local monsterName = ""

    if monsterName ~= "" then
        if not target:isMonster() or target:getName():lower() ~= monsterName:lower() then
            player:sendCancelMessage("You can only use this item on the specified monster.")
            return true
        end
    elseif not target:isMonster() then
        player:sendCancelMessage("You can only use this item on monsters.")
        return true
    end

    local destination = {x = 100, y = 200, z = 7}

    player:teleportTo(destination)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have been teleported.")
    item:remove(1)

    return true
end
 
Back
Top