Advertisement
jdrecarp

Advanced Kill Boss Portal

Aug 6th, 2019
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. local portalId, t = 1387,
  2. {
  3.     ["demon"] = {
  4.         message = "You killed a Demon!",
  5.         config = {
  6.             createPos = {x = 100, y = 100, z = 7},
  7.             toPos = {x = 100, y = 100, z = 7},
  8.             portalTime = 5, --minutes
  9.             storage = 123
  10.         }
  11.     },
  12.     ["orshabaal"] = {
  13.         message = "You have defeated Orshabaal!",
  14.         config = {
  15.             createPos = {}, --NOTE: You may use empty brackets to create the portal where the monster dies.
  16.             toPos = {x = 100, y = 100, z = 7},
  17.             portalTime = 1, --minutes
  18.             storage = 123
  19.         }
  20.     }
  21. }
  22.  
  23. local function removePortal(position)
  24.     local portal = Tile(position):getItemById(portalId)
  25.     if portal then
  26.         portal:remove()
  27.     end
  28. end
  29.  
  30. function onKill(creature, target)
  31.     if not target:isMonster() or target:getMaster() then
  32.         return true
  33.     end
  34.    
  35.     local player = Player(cid)
  36.     local k = t[target:getName():lower()]
  37.     if not k then
  38.         return true
  39.     end
  40.    
  41.     local pos, cPos = target:getPosition()
  42.     if type(k.config.createPos) == 'table' then
  43.         if next(k.config.createPos) == nil then
  44.             cPos = pos
  45.         else
  46.             cPos = k.config.createPos
  47.         end
  48.     end
  49.  
  50.     local item = Game.createItem(portalId, 1, cPos)
  51.     if item:isTeleport() then
  52.         item:setDestination(k.config.toPos)
  53.     end
  54.  
  55.     for i, damage in pairs(target:getDamageMap()) do
  56.         local p = Player(i)
  57.         if p then
  58.             if p.getStorageValue(k.config.storage) < 1 then
  59.                 p:setStorageValue(k.config.storage, 1)
  60.             end
  61.         end
  62.     end
  63.  
  64.     local pt = k.config.portalTime
  65.     player:sendTextMessage(MESSAGE_INFO_DESCR, k.message .. " You have " .. pt .. " " .. (pt > 1 and "minutes" or "minute") .. " to escape!")
  66.     addEvent(removePortal, k.config.portalTime * 60 * 1000, cPos)
  67.     return true
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement