Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. function placeSpawnRandom(fromPositon, toPosition, monsterName, ammount, hasCall, storage, value, removestorage, sharedHP, event, message)
  2.     for _x = fromPositon.x, toPosition.x do
  3.         for _y = fromPositon.y, toPosition.y do
  4.             for _z = fromPositon.z, toPosition.z do
  5.                 local tile = Tile(Position(_x,_y,_z))
  6.                 if not removestorage then
  7.                     if tile and tile:getTopCreature() and tile:getTopCreature():isMonster() and tile:getTopCreature():getName() == monsterName then
  8.                         tile:getTopCreature():remove()
  9.                     end
  10.                 else
  11.                     if tile and tile:getTopCreature() and tile:getTopCreature():isMonster() and tile:getTopCreature():getStorageValue(storage) == value then
  12.                         tile:getTopCreature():remove()
  13.                     end
  14.                 end
  15.             end
  16.         end
  17.     end
  18.         if ammount and ammount > 0 then
  19.             local summoned = 0
  20.             local tm = os.time()
  21.             repeat
  22.                 local tile = false
  23.                 -- repeat
  24.                     local position = {x = math.random(fromPositon.x, toPosition.x), y = math.random(fromPositon.y, toPosition.y), z = math.random(fromPositon.z, toPosition.z)}
  25.                     -- tile = Tile(position)
  26.                     -- passando = tile and #tile:getItems() <= 0
  27.                 -- until (passando == true)
  28.                 local monster = Game.createMonster(monsterName, position)
  29.                 if monster then
  30.                     summoned = summoned + 1
  31.                     -- setando o primeiro spawn
  32.                     monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  33.                     if(hasCall) then
  34.                         monster:setStorage(storage, value)
  35.                         if sharedHP then
  36.                             monster:beginSharedLife(tm)
  37.                             monster:registerEvent("sharedLife")
  38.                         end
  39.                         if event then
  40.                             monster:registerEvent(event)
  41.                         end
  42.                         local function SendMessage(mit, message)
  43.                             if not Monster(mit) then
  44.                                 return false
  45.                             end
  46.                             Monster(mit):say(message, TALKTYPE_MONSTER_SAY)
  47.                         end
  48.                         if message then
  49.                             addEvent(SendMessage, 200,monster:getId(), message)
  50.                         end
  51.                     end
  52.                 end
  53.             until (summoned == ammount)
  54.         end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement