Guest User

Untitled

a guest
Aug 23rd, 2019
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --CONFIG!
  2. local effectOnCaster = {151, 0, 0}
  3. local effectOnTarget = {151, 0, 0}
  4. local delay = 5 -- in seconds
  5.  
  6. local otherWorlds = {
  7. [1] = {centerPos = {x = 854, y = 214, z = 7}, sizeOfTeleportArea = {2, 2}},
  8. [2] = {centerPos = {x = 838, y = 239, z = 7}, sizeOfTeleportArea = {2, 2}},
  9. [3] = {centerPos = {x = 900, y = 212, z = 7}, sizeOfTeleportArea = {2, 2}},
  10. [4] = {centerPos = {x = 882, y = 240, z = 7}, sizeOfTeleportArea = {2, 2}}
  11. }
  12.  
  13. --END OF CONFIG!
  14.  
  15. local condition = createConditionObject(CONDITION_ATTRIBUTES)
  16. setConditionParam(condition, CONDITION_PARAM_TICKS, delay * 1000)
  17. setConditionParam(condition, CONDITION_PARAM_SUBID, 167)
  18. setConditionParam(condition, CONDITION_PARAM_INCREASE_COMBAT, 20, COMBAT_PHYSICALDAMAGE)
  19.  
  20. local condition = createConditionObject(CONDITION_ATTRIBUTES)
  21. setConditionParam(condition, CONDITION_PARAM_TICKS, delay * 1000)
  22. setConditionParam(condition, CONDITION_PARAM_SUBID, 171)
  23.  
  24. local lastPosition = {}
  25. local typeOfWorld = {}
  26.  
  27. local function doSendModifedMagicEffectByPos(position, var)
  28. doSendMagicEffect({x = position.x + var[2], y = position.y + var[3], z = position.z}, var[1])
  29. end
  30.  
  31. local function doSendModifedMagicEffect(cid, var)
  32. doSendModifedMagicEffectByPos(getThingPos(cid), var)
  33. end
  34.  
  35. local function getPosition(pos, size)
  36. local position = {x = pos.x + math.random(-size[1], size[1]), y = pos.y + math.random(-size[2], size[2]), z = pos.z}
  37. if not isWalkablefloor(position) then
  38. return getPosition(pos, size)
  39. end
  40.  
  41. return position
  42. end
  43.  
  44. local function teleportTo(target, id)
  45. local pos = getThingPos(target)
  46.  
  47. local it = getTileInfo(pos)
  48. if it.protection or it.nopvp or it.pvp then
  49. return false
  50. end
  51.  
  52. lastPosition[target] = pos
  53.  
  54. local var = otherWorlds[id]
  55. doTeleportThing(target, getPosition(var.centerPos, var.sizeOfTeleportArea), true)
  56. doSendModifedMagicEffect(target, effectOnTarget)
  57.  
  58. addEvent(function()
  59. if isCreature(target) then
  60. doTeleportThing(target, lastPosition[target], true)
  61. end
  62. end, delay * 1000)
  63. end
  64.  
  65. function onCastSpell(cid, var, iconId, spellLevel)
  66. if typeOfWorld[cid] then
  67. return doPlayerSendCancel(cid, 'You can\'t use this spell.') and false
  68. end
  69.  
  70. local target = getCreatureTarget(cid)
  71. if not isCreature(target) or getCreatureCondition(target, CONDITION_ATTRIBUTES, 169) then
  72. return false
  73. end
  74.  
  75. if not isPlayer(target) then
  76. return false
  77. end
  78.  
  79. if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 171) or getCreatureCondition(target, CONDITION_ATTRIBUTES, 171) then
  80. return false
  81. end
  82.  
  83. local id = math.random(#otherWorlds)
  84. typeOfWorld[cid] = id
  85.  
  86. teleportTo(target, id)
  87.  
  88. doAddCondition(cid, condition)
  89. teleportTo(cid, id)
  90. doSendModifedMagicEffect(cid, effectOnCaster)
  91. addEvent(function() typeOfWorld[cid] = nil end, delay * 1000)
  92. return true
  93. end
RAW Paste Data