Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FlyingMounts = {65} -- Mounts in this table are going to force fly when mounting/dismounting.
- PvpRestrictions = "high" -- You can set 3 different types of pvp restrictions
- -- None:
- ---- Nothing will be done, the players can attack each other anytime while flying.
- -- Medium:
- -- The players can attack each other while flying, but they cant start flying if they already have pz and they will have a huge interval (configurable) to go up and down. The interval is only applied to the people with PZ locked.
- -- High:
- ---- Players can't attack each other while flying at all and they cant start flying as in medium. This could be abused to escape from pks as you can't be attacked by them while flying.
- ChangeFloorInterval = 2 -- seconds
- ChangeFloorIntervalPZ = 10 -- seconds, only in medium restriction.
- function Position:createFlyFloor()
- local toTile = Tile(self)
- if not toTile or not toTile:getItems() or not toTile:getGround() then
- doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
- Game.createItem(460, 1, self)
- end
- end
- function Tile:hasValidGround()
- local ground = self:getGround()
- local nilitem = self:getItemById(460)
- if ground and not nilitem then
- return true
- end
- return false
- end
- function Player:activateFly()
- self:setStorageValue(16400, 1)
- self:registerEvent("FlyEvent")
- return true
- end
- function Player:deactivateFly()
- local can, floor = self:canDeactivateFly()
- local pos = self:getPosition()
- if can then
- local curtile = Tile(pos)
- local itemfloor = curtile:getItemById(460)
- if itemfloor then
- itemfloor:remove()
- end
- self:setStorageValue(16400, -1)
- self:unregisterEvent("FlyEvent")
- if pos.z ~= floor then
- pos.z = floor
- self:teleportTo(pos)
- pos:sendMagicEffect(CONST_ME_TELEPORT)
- end
- end
- return can
- end
- function Player:isFlying()
- return self:getStorageValue(16400) == 1
- end
- function Player:canDeactivateFly()
- local pos = self:getPosition()
- for z = pos.z, 15 do
- local tmp = Tile(pos.x, pos.y, z)
- if tmp and tmp:hasValidGround() then
- if self:canFlyDown(z) then
- return true, z
- else
- return false
- end
- end
- end
- return false
- end
- function Player:canFlyUp()
- local pos = self:getPosition()
- local tmp = Tile(pos.x, pos.y, pos.z-1)
- if tmp and tmp:hasValidGround() then
- return false
- end
- return true
- end
- function Player:canFlyDown(floor)
- local pos = self:getPosition()
- local tmp = Tile(pos)
- if floor and floor == pos.z then
- return true
- end
- if tmp:hasValidGround() then
- return false
- end
- tmp = Tile(pos.x, pos.y, floor or pos.z+1)
- if tmp and (tmp:getHouse() or tmp:hasFlag(TILESTATE_PROTECTIONZONE) or tmp:hasFlag(TILESTATE_FLOORCHANGE) or tmp:hasFlag(TILESTATE_BLOCKSOLID)) then
- return false
- end
- return true
- end
- function Player:flyUp()
- if self:isFlying() then
- if self:canFlyUp() then
- local pos = self:getPosition()
- local tile = Tile(pos)
- local itemfloor = tile:getItemById(460)
- if itemfloor then
- itemfloor:remove()
- end
- pos.z = pos.z-1
- pos:createFlyFloor()
- self:teleportTo(pos)
- pos:sendMagicEffect(CONST_ME_TELEPORT)
- return true
- end
- return false
- else
- self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are not flying.")
- end
- end
- function Player:flyDown()
- if self:isFlying() then
- if self:canFlyDown() then
- local pos = self:getPosition()
- local tile = Tile(pos)
- local itemfloor = tile:getItemById(460)
- if itemfloor then
- itemfloor:remove()
- end
- pos.z = pos.z+1
- pos:createFlyFloor()
- self:teleportTo(pos)
- pos:sendMagicEffect(CONST_ME_TELEPORT)
- return true
- end
- return false
- else
- self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are not flying.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement