Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- warp = {
- storage_ini = 60000,
- gates = {}
- }
- function warp:new(name, pos, mana, level, id, storage)
- if self:getWarpById(id) then
- return self:getWarpById(id)
- end
- local object = {id = id or #self.gates + 1, name = name, pos = pos, mana = mana, level = level}
- object.storage = storage or self.storage_ini + object.id
- setmetatable(object, {__index = self})
- self.gates[object.id] = {}
- setmetatable(self.gates[object.id], {__index = object})
- return object
- end
- function warp:getWarpById(id)
- return self.gates[id]
- end
- function warp:getGates()
- return self.gates
- end
- local looks = {[0] = 1, [1] = 2, [2] = 3, [3] = 0}
- local function girar(uid, atual, warp, sx)
- if isCreature(uid) then
- if sx == 1 and atual == 10 then
- doSendMagicEffect(getThingPos(uid), 2)
- doTeleportThing(uid, warp.pos)
- doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been warped to ".. warp.name .. ".")
- doSendMagicEffect(warp.pos, 10)
- end
- doCreatureSetLookDirection(uid, looks[getCreatureLookDirection(uid)])
- if atual ~= 10 then
- if sx == 1 then
- addEvent(girar, 1200 - atual * 200, uid, atual + 1, warp, sx)
- else
- addEvent(girar, atual * 50 , uid, atual + 1, warp, sx)
- end
- elseif sx == 1 then
- addEvent(girar, 1200 - atual * 200, uid, 1, warp, 2)
- else
- mayNotMove(uid, false)
- end
- end
- end
- function warp:Warp(uid)
- local p = getThingPos(uid)
- if getPlayerLevel(uid) < self.level then
- return doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not able to open ".. self.name .. "'s gate at this level.")
- elseif getCreatureMana(uid) < self.mana then
- return doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, "Your magic power is not enough to open ".. self.name .. "'s gate.")
- elseif p.x == self.pos.x and p.y == self.pos.y and p.z == self.pos.z then
- return doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, "You already are on ".. self.name .. ".")
- end
- doCreatureAddMana(uid, -self.mana)
- mayNotMove(uid, true)
- doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, "The magic portal is absorbing your body...")
- girar(uid, 1, self, 1)
- return true
- end
- warp:new("Asgard", {x = 857, y = 964, z = 7}, 1200, 15)
- warp:new("Alidria", {x = 881, y = 1030, z = 7}, 20, 150)
- warp:new("Badien", {x = 873, y = 977, z = 7}, 70, 170)
- warp:new("Kahften", {x = 833, y = 958, z = 7}, 0, 0)
- warp:new("Rasgon", {x = 861, y = 980, z = 7}, 50, 15)
- warp:new("Tamriel", {x = 866, y = 964, z = 6}, 9500, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement