• 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 (WoW) Teleport to Temple spell with cast time and cooldown!

MarkSmartRemark

Lua-Noob in Training :D
Joined
Jan 27, 2010
Messages
139
Reaction score
3
Hi guys,

Theres alot of teleport/createportal scripts out there that do cool things but im practicing scripting some WoW-like spells and tried to come up w something that i havent seen yet w help from andu.

What it does is the following

-When player casts spell he begins to cast and channel energy to create a portal for him and friends to be able to get to their hometowns.
- If hes in combat he cannot cast the spell. If he enters combat while casting (someone pks or monster comes in screen) the spell will be cancelled.
-The spell will also cancel if he moves or changes direction. (He needs to concentrate to make the portal so leave him the f*ck alone o_O)
-There will be an arrow warning people at the hometown position that players are arriving!
-Lastly, it has a pretty easy config for effects cast time etc...


The spell has one last issues before its 100% complete.
  1. I would like to add a party feature. Right now i know how to make it check if player is in a party. but i do not know how to make it check if the player is in the player who made the teleports party. So if im in another party, i can go in the teleport that you created. I want it to have a bit of a team-feel.


Once again, main credits to Andu for giving me the cast time and pointers to most of the spell!

Code:
-- >>Script by Tabz!<< --
--{Credits: Spell Mechanics by Andu; Helped from Zyntax}

--.::.CONFIG.::.--
local config = {
    channeling_time = 10.0,              --- Duration of Cast Time.
    dist_eff = CONST_ANI_SMALLHOLY,      --- Cast time Distance Effect.
    cancel_eff = CONST_ME_POFF,         --- Effect if spell is canceled.
    tp_duration = 30,                    --- Duration of Teleport before it vanishes.
    cooldown = 60,                       --- Cooldown time for this spell (Exhaustion)? [seconds]
    cd_storage = 107,                    --- Cooldown StorageID    -- Cancel Effect. 
    distanceEffects = {                  --- Cast Time Distance Effects Config.
        [1] = {from = {x = 0, y = 2}},
        [2] = {from = {x = 1, y = 2}},
        [3] = {from = {x = 2, y = 1}},
        [4] = {from = {x = 2, y = 0}},
        [5] = {from = {x = 2, y = -1}},
        [6] = {from = {x = 1, y = -2}},
        [7] = {from = {x = 0, y = -2}},
        [8] = {from = {x = -1, y = -2}},
        [9] = {from = {x = -2, y = -1}},
        [10] = {from = {x = -2, y = 0}},
        [11] = {from = {x = -2, y = 1}},
        [12] = {from = {x = -1, y = 2}}
    }
}

local function deleteTeleport(cpos)
local teleport = getTileItemById(cpos, 1387)
if(teleport.uid > 0) then
doRemoveItem(teleport.uid)
end
return true
end

local check = 0
local v = config.distanceEffects
local function distanceShoot(cid, oldPos, oldDir, nvar)
    local cpos = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z, stackpos=1}
    local newPos = getCreaturePosition(cid)
    local newDir = getCreatureLookDirection(cid)
    if isCreature(cid) == true then
        local pos = getCreaturePosition(cid)
        if oldDir == newDir and oldPos.x == newPos.x and oldPos.y == newPos.y and oldPos.z == newPos.z and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
            if check > #v then
                for x = 1, config.tp_duration do
                    local n = config.tp_duration - x
                    addEvent(doSendAnimatedText, x * 1000, cpos, n > 0 and tostring(n), TEXTCOLOR_DARKRED)
                    addEvent(doSendAnimatedText, 15000, cpos, "Org Port!", TEXTCOLOR_DARKRED)
                    addEvent(doSendAnimatedText, 30000, cpos, "Closed!", TEXTCOLOR_DARKRED)
                end
                doCreateTeleport(1387, getTownTemplePosition(getPlayerTown(cid)), cpos)
                doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), 55)
                doSendMagicEffect(pos, 3)
                doSendMagicEffect(pos, 49)
            else
                doSendDistanceShoot({x = pos.x + v[check].from.x, y = pos.y + v[check].from.y, z = pos.z}, pos, config.dist_eff)
                addEvent(distanceShoot, (config.channeling_time * 1000 / (#v)), cid, oldPos, getCreatureLookDirection(cid))
            end
            check = check + 1
        else
            check = #v
            doSendMagicEffect(pos, config.cancel_eff)
        end
    end
end

function onCastSpell(cid, var)
    if exhaustion.check(cid, config.cd_storage) then
doPlayerSendCancel(cid, "Your Portal spell still has "..exhaustion.get(cid, config.cd_storage).." seconds on cooldown.")
return false
end
    local cpos = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z, stackpos=1}
    local nvar = var
    check = 1
    addEvent(distanceShoot, (config.channeling_time * 1000 / (#v)), cid, getCreaturePosition(cid), getCreatureLookDirection(cid), nvar)
    exhaustion.set(cid, config.cd_storage, config.cooldown)
    addEvent(deleteTeleport, (((config.tp_duration+config.channeling_time)+1)*1000), cpos)
    return true
end

EDIT: Updated and Added Teleport Removal and some animated texts.
 
Last edited:
Local getPlayerPosition(cid)
Local createtp = getPlayerPosition(cid)

Then do this

Code:
local teleport = getTileItemById(createtp, 1387)
 
couldn't really check it, but try it anyway (spelling errors may occur!)

Code:
-- >>Script by Tabz!<< --
--{Credits: Spell Mechanics by Andu!}

--.::.CONFIG.::.--
local config = {
  channeling_time = 2.0,  --- Duration of Cast Time.
  dist_eff = CONST_ANI_SMALLHOLY,  --- Cast time Distance Effect.
  cancel_eff = CONST_ME_POFF,  --- Effect if spell is canceled.
  tp_duration = 30,  --- Duration of Teleport before it vanishes.
  cooldown = 15,  --- Cooldown time for this spell (Exhaustion)? [seconds]
  cd_storage = 107,  --- Cooldown StorageID  -- Cancel Effect.  
  distanceEffects = {  --- Cast Time Distance Effects Config.
  [1] = {from = {x = 0, y = 2}},
  [2] = {from = {x = 1, y = 2}},
  [3] = {from = {x = 2, y = 1}},
  [4] = {from = {x = 2, y = 0}},
  [5] = {from = {x = 2, y = -1}},
  [6] = {from = {x = 1, y = -2}},
  [7] = {from = {x = 0, y = -2}},
  [8] = {from = {x = -1, y = -2}},
  [9] = {from = {x = -2, y = -1}},
  [10] = {from = {x = -2, y = 0}},
  [11] = {from = {x = -2, y = 1}},
  [12] = {from = {x = -1, y = 2}}
  }
}


local function deleteTeleport(cpos)
local teleport = getTileItemById(cpos, 1387)
if(teleport.uid > 0) then
doRemoveItem(teleport.uid)
end
return true
end

local check = 0
local v = config.distanceEffects
local function distanceShoot(cid, oldPos, oldDir, nvar,cpos)
  local newPos = getCreaturePosition(cid)
  local newDir = getCreatureLookDirection(cid)
  if isCreature(cid) == true then
  local pos = getCreaturePosition(cid)
  if oldDir == newDir and oldPos.x == newPos.x and oldPos.y == newPos.y and oldPos.z == newPos.z and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
  if check > #v then
  doCreateTeleport(1387, getTownTemplePosition(getPlayerTown(cid)), cpos)
  doSendMagicEffect(getTownTemplePosition(getPlayerTown(cid)), 55)
  doSendMagicEffect(pos, 3)
  doSendMagicEffect(pos, 49)
  else
  doSendDistanceShoot({x = pos.x + v[check].from.x, y = pos.y + v[check].from.y, z = pos.z}, pos, config.dist_eff)
  addEvent(distanceShoot, (config.channeling_time * 1000 / (#v)), cid, oldPos, getCreatureLookDirection(cid))
  end
  check = check + 1
  else
  check = #v
  doSendMagicEffect(pos, config.cancel_eff)
  end
  end
end

function onCastSpell(cid, var)
  if exhaustion.check(cid, config.cd_storage) then
doPlayerSendCancel(cid, "Your Portal spell still has "..exhaustion.get(cid, config.cd_storage).." seconds on cooldown.")
return false
end
  local nvar = var
  check = 1
   local cpos = {x=getCreaturePosition(cid).x, y=getCreaturePosition(cid).y, z=getCreaturePosition(cid).z, stackpos=1}
  addEvent(distanceShoot, (config.channeling_time * 1000 / (#v)), cid, getCreaturePosition(cid), getCreatureLookDirection(cid), nvar,cpos)
  exhaustion.set(cid, config.cd_storage, config.cooldown)
  addEvent(deleteTeleport, (config.tp_duration*1000), cpos)
  return true
end
 
For the party try.
For i =1 #getPartyMembers(cid) do
Setstorage(getPartyMembers(cid),storage,1)
And make a movment script to check
I am on phone atm so sorry
 
For the party try.
For i =1 #getPartyMembers(cid) do
Setstorage(getPartyMembers(cid),storage,1)
And make a movment script to check
I am on phone atm so sorry

tried playing around with it, couldnt get it to work properly sorry : /
 
In spells, you can also see it by looking at the prefix (Spell) and the function onCastSpell.
 
Fair warning for anyone using this.

Tested on 1.2

If a player cast this spell in the destination point (lets say temple) it will freeze and crash server. (you are basically making a loop :p)

A workaround is to set aggressive="1" to avoid casts in PZ (obviously make the destiny a PZ)
 
Fair warning for anyone using this.

Tested on 1.2

If a player cast this spell in the destination point (lets say temple) it will freeze and crash server. (you are basically making a loop :p)

A workaround is to set aggressive="1" to avoid casts in PZ (obviously make the destiny a PZ)

Tested on tfs 1.2? What do you mean? This script is made for 0.3/4. ?
 
Tested on tfs 1.2? What do you mean? This script is made for 0.3/4. ?

I mean that casting the spell in the destination SQM from the TP you create will crash the server.

This was using TFS 1.2
 
Back
Top