Advertisement
Guest User

Untitled

a guest
May 27th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. --CONFIG!
  2. local effectOnCaster = {176, 1, -1}
  3. local effectOnTarget = {176, 1, -1}
  4. local exhaustedSpell = {}
  5. local delay = 10 -- in seconds
  6. local exhausted = 10 -- in seconds
  7. local placeArea = {
  8. [1] = createCombatArea({
  9. {0, 0, 1, 1, 1, 0, 0},
  10. {0, 1, 1, 1, 1, 1, 0},
  11. {1, 1, 1, 1, 1, 1, 1},
  12. {1, 1, 1, 3, 1, 1, 1},
  13. {1, 1, 1, 1, 1, 1, 1},
  14. {0, 1, 1, 1, 1, 1, 0},
  15. {0, 0, 1, 1, 1, 0, 0}
  16. }),
  17. [2] = createCombatArea({{3}})
  18. }
  19.  
  20. local otherWorlds = {
  21. [1] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}},
  22. [2] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}},
  23. [3] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}}
  24. }
  25.  
  26. --END OF CONFIG!
  27.  
  28. local lastPosition = {}
  29. local typeOfWorld = {}
  30.  
  31. local function getPosition(pos, size, n)
  32. local _pos = {x = pos.x + math.random(-size[1], size[1]), y = pos.y + math.random(-size[2], size[2]), z = pos.z}
  33. if not isWalkable(_pos, true, true, true) then
  34. return n < 20 and getPosition(pos, size, n + 1)
  35. end
  36.  
  37. return _pos
  38. end
  39.  
  40. local function teleportTo(cid, target, owner)
  41. if not isCreature(target) then
  42. return false
  43. end
  44. lastPosition[target] = getThingPos(target)
  45.  
  46. local _table = otherWorlds[typeOfWorld[cid] or 1]
  47. doTeleportThing(target, getPosition(_table.centerPos, _table.sizeOfTeleportArea, 0), true)
  48. doSendModifedMagicEffect(target, effectOnTarget)
  49.  
  50. addEvent(function()
  51. doTeleportThing(target, (lastPosition[target] or getPlayerMasterPos(cid)), true)
  52. lastPosition[target] = nil
  53. if owner then
  54. typeOfWorld[cid] = nil
  55. end
  56. end, delay * 1000)
  57. end
  58.  
  59. function _onTileCombat(cid, pos, iconId, spellLevel)
  60. local target = getTopCreature(pos).uid
  61. if not isPlayer(target) then
  62. return false
  63. end
  64.  
  65. teleportTo(cid, target)
  66. end
  67.  
  68. function onTileCombat1(cid, pos)
  69. return _onTileCombat(cid, pos, iconId, spellLevel)
  70. end
  71.  
  72. function onTileCombat2(cid, pos)
  73. return _onTileCombat(cid, pos, iconId, spellLevel)
  74. end
  75.  
  76. local combats = {}
  77. for i = 1, 2 do
  78. combats[i] = createCombatObject()
  79. setCombatParam(combats[i], COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
  80. setCombatParam(combats[i], COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
  81. setCombatFormula(combats[i], COMBAT_FORMULA_LEVELMAGIC, -1.0, -3450, -1.1, -3460)
  82. setCombatCallback(combats[i], CALLBACK_PARAM_TARGETTILE, 'onTileCombat' .. i)
  83. setCombatArea(combats[i], placeArea[i])
  84. end
  85.  
  86. function onCastSpell(cid, var, iconId, spellLevel)
  87. if typeOfWorld[cid] then
  88. return doPlayerSendCancel(cid, 'You can\'t use this spell.') and false
  89. end
  90.  
  91. typeOfWorld[cid] = math.random(#otherWorlds)
  92. teleportTo(cid, cid, true)
  93.  
  94. doCombat(cid, combats[(isPlayer(getCreatureTarget(cid)) and 2 or 1)], var)
  95. return doSendModifedMagicEffect(cid, effectOnCaster)
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement