Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CONFIG!
- local effectOnCaster = {151, 0, 0}
- local effectOnTarget = {151, 0, 0}
- local delay = 5 -- in seconds
- local otherWorlds = {
- [1] = {centerPos = {x = 854, y = 214, z = 7}, sizeOfTeleportArea = {2, 2}},
- [2] = {centerPos = {x = 838, y = 239, z = 7}, sizeOfTeleportArea = {2, 2}},
- [3] = {centerPos = {x = 900, y = 212, z = 7}, sizeOfTeleportArea = {2, 2}},
- [4] = {centerPos = {x = 882, y = 240, z = 7}, sizeOfTeleportArea = {2, 2}}
- }
- --END OF CONFIG!
- local condition = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(condition, CONDITION_PARAM_TICKS, delay * 1000)
- setConditionParam(condition, CONDITION_PARAM_SUBID, 167)
- setConditionParam(condition, CONDITION_PARAM_INCREASE_COMBAT, 20, COMBAT_PHYSICALDAMAGE)
- local condition = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(condition, CONDITION_PARAM_TICKS, delay * 1000)
- setConditionParam(condition, CONDITION_PARAM_SUBID, 171)
- local lastPosition = {}
- local typeOfWorld = {}
- local function doSendModifedMagicEffectByPos(position, var)
- doSendMagicEffect({x = position.x + var[2], y = position.y + var[3], z = position.z}, var[1])
- end
- local function doSendModifedMagicEffect(cid, var)
- doSendModifedMagicEffectByPos(getThingPos(cid), var)
- end
- local function getPosition(pos, size)
- local position = {x = pos.x + math.random(-size[1], size[1]), y = pos.y + math.random(-size[2], size[2]), z = pos.z}
- if not isWalkablefloor(position) then
- return getPosition(pos, size)
- end
- return position
- end
- local function teleportTo(target, id)
- local pos = getThingPos(target)
- local it = getTileInfo(pos)
- if it.protection or it.nopvp or it.pvp then
- return false
- end
- lastPosition[target] = pos
- local var = otherWorlds[id]
- doTeleportThing(target, getPosition(var.centerPos, var.sizeOfTeleportArea), true)
- doSendModifedMagicEffect(target, effectOnTarget)
- addEvent(function()
- if isCreature(target) then
- doTeleportThing(target, lastPosition[target], true)
- end
- end, delay * 1000)
- end
- function onCastSpell(cid, var, iconId, spellLevel)
- if typeOfWorld[cid] then
- return doPlayerSendCancel(cid, 'You can\'t use this spell.') and false
- end
- local target = getCreatureTarget(cid)
- if not isCreature(target) or getCreatureCondition(target, CONDITION_ATTRIBUTES, 169) then
- return false
- end
- if not isPlayer(target) then
- return false
- end
- if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 171) or getCreatureCondition(target, CONDITION_ATTRIBUTES, 171) then
- return false
- end
- local id = math.random(#otherWorlds)
- typeOfWorld[cid] = id
- teleportTo(target, id)
- doAddCondition(cid, condition)
- teleportTo(cid, id)
- doSendModifedMagicEffect(cid, effectOnCaster)
- addEvent(function() typeOfWorld[cid] = nil end, delay * 1000)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement