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

Spell [TFS 1.2] Teleport back spell

kingsley666

Active Member
Joined
Jul 24, 2011
Messages
151
Reaction score
32
Location
Venezuela
Hello OtLand.

I just made my first spell and i want to share with you, hope you can give some feedbacks. :)

TFS I used: 1.2

As the title say, the spell teleport you to the back of your target with some restrictions.

The following images are for reference:

Facing the monster:

GyVThfq.png


You don't need to be facing the monster, the spells works validating the distance of 2 sqm from the mosnter/player, also you need to be attacking the enemy.

EkOlP23.png


Then if you are close enough it will teleport you to the back of the monster and will set your direction the same as the target.

QbG6vV8.png


EGT2GUx.png


You could use it for a dagger or rogue vocation, followed by a spell to attack from back :p.

Installation:

spells/spells.xml
Lua:
    <instant group="attack" spellid="122" name="Back Port" words="backstab" lvl="40" mana="20" prem="0" range="2" casterTargetOrDirection="1" needlearn="0" blockwalls="1" cooldown="2000" groupcooldown="2000" script="support/back_port.lua">

        <vocation name="Paladin" />
        <vocation name="Royal Paladin" />
    </instant>

spells/scripts/attack/back_port.lua
Lua:
function onCastSpell(creature, variant)
    local north = 0
    local south = 2
    local east = 1
    local west = 3

    local creaturePosition = creature:getPosition()
    local creatureDirection = creature:getDirection()
   
    if creature:getTarget() ~= nil then
        enemy = creature:getTarget()
        targetPosition = enemy:getPosition()
        enemyDirection = enemy:getDirection()
    else
        creature:sendCancelMessage("You need to select a target.")
        creaturePosition:sendMagicEffect(CONST_ME_POFF)
        return false       
    end   


    if enemyDirection == north then
        targetPosition.y = targetPosition.y + 1
    elseif enemyDirection == south then
        targetPosition.y = targetPosition.y - 1
    elseif enemyDirection == east then
        targetPosition.x = targetPosition.x - 1
    else
        targetPosition.x = targetPosition.x + 1
    end   
       
    creature:teleportTo(targetPosition)
    creature:setDirection(enemyDirection)
    creaturePosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    creaturePosition = creature:getPosition()
    creaturePosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    return false

end

Hope i helped you, enjoy.
 
You need check if player can teleport to this position.
Exemple, what will occours if have a wall, door or other thing in back of the target?

What will happen if the target is in the red square and the player is in the blue square and uses the magic?

Furthermore, you are to be congratulated! as the topic was revived from 2018, I believe you have evolved even further
 
Back
Top