Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CONFIG!
- local effectOnCaster = {176, 1, -1}
- local effectOnTarget = {176, 1, -1}
- local exhaustedSpell = {}
- local delay = 10 -- in seconds
- local exhausted = 10 -- in seconds
- local placeArea = {
- [1] = createCombatArea({
- {0, 0, 1, 1, 1, 0, 0},
- {0, 1, 1, 1, 1, 1, 0},
- {1, 1, 1, 1, 1, 1, 1},
- {1, 1, 1, 3, 1, 1, 1},
- {1, 1, 1, 1, 1, 1, 1},
- {0, 1, 1, 1, 1, 1, 0},
- {0, 0, 1, 1, 1, 0, 0}
- }),
- [2] = createCombatArea({{3}})
- }
- local otherWorlds = {
- [1] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}},
- [2] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}},
- [3] = {centerPos = {x = 1379, y = 1313, z = 7}, sizeOfTeleportArea = {4, 4}}
- }
- --END OF CONFIG!
- local lastPosition = {}
- local typeOfWorld = {}
- local function getPosition(pos, size, n)
- local _pos = {x = pos.x + math.random(-size[1], size[1]), y = pos.y + math.random(-size[2], size[2]), z = pos.z}
- if not isWalkable(_pos, true, true, true) then
- return n < 20 and getPosition(pos, size, n + 1)
- end
- return _pos
- end
- local function teleportTo(cid, target, owner)
- if not isCreature(target) then
- return false
- end
- lastPosition[target] = getThingPos(target)
- local _table = otherWorlds[typeOfWorld[cid] or 1]
- doTeleportThing(target, getPosition(_table.centerPos, _table.sizeOfTeleportArea, 0), true)
- doSendModifedMagicEffect(target, effectOnTarget)
- addEvent(function()
- doTeleportThing(target, (lastPosition[target] or getPlayerMasterPos(cid)), true)
- lastPosition[target] = nil
- if owner then
- typeOfWorld[cid] = nil
- end
- end, delay * 1000)
- end
- function _onTileCombat(cid, pos, iconId, spellLevel)
- local target = getTopCreature(pos).uid
- if not isPlayer(target) then
- return false
- end
- teleportTo(cid, target)
- end
- function onTileCombat1(cid, pos)
- return _onTileCombat(cid, pos, iconId, spellLevel)
- end
- function onTileCombat2(cid, pos)
- return _onTileCombat(cid, pos, iconId, spellLevel)
- end
- local combats = {}
- for i = 1, 2 do
- combats[i] = createCombatObject()
- setCombatParam(combats[i], COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
- setCombatParam(combats[i], COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
- setCombatFormula(combats[i], COMBAT_FORMULA_LEVELMAGIC, -1.0, -3450, -1.1, -3460)
- setCombatCallback(combats[i], CALLBACK_PARAM_TARGETTILE, 'onTileCombat' .. i)
- setCombatArea(combats[i], placeArea[i])
- end
- function onCastSpell(cid, var, iconId, spellLevel)
- if typeOfWorld[cid] then
- return doPlayerSendCancel(cid, 'You can\'t use this spell.') and false
- end
- typeOfWorld[cid] = math.random(#otherWorlds)
- teleportTo(cid, cid, true)
- doCombat(cid, combats[(isPlayer(getCreatureTarget(cid)) and 2 or 1)], var)
- return doSendModifedMagicEffect(cid, effectOnCaster)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement