Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function placeSpawnRandom(fromPositon, toPosition, monsterName, ammount, hasCall, storage, value, removestorage, sharedHP, event, message)
- for _x = fromPositon.x, toPosition.x do
- for _y = fromPositon.y, toPosition.y do
- for _z = fromPositon.z, toPosition.z do
- local tile = Tile(Position(_x,_y,_z))
- if not removestorage then
- if tile and tile:getTopCreature() and tile:getTopCreature():isMonster() and tile:getTopCreature():getName() == monsterName then
- tile:getTopCreature():remove()
- end
- else
- if tile and tile:getTopCreature() and tile:getTopCreature():isMonster() and tile:getTopCreature():getStorageValue(storage) == value then
- tile:getTopCreature():remove()
- end
- end
- end
- end
- end
- if ammount and ammount > 0 then
- local summoned = 0
- local tm = os.time()
- repeat
- local tile = false
- -- repeat
- local position = {x = math.random(fromPositon.x, toPosition.x), y = math.random(fromPositon.y, toPosition.y), z = math.random(fromPositon.z, toPosition.z)}
- -- tile = Tile(position)
- -- passando = tile and #tile:getItems() <= 0
- -- until (passando == true)
- local monster = Game.createMonster(monsterName, position)
- if monster then
- summoned = summoned + 1
- -- setando o primeiro spawn
- monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
- if(hasCall) then
- monster:setStorage(storage, value)
- if sharedHP then
- monster:beginSharedLife(tm)
- monster:registerEvent("sharedLife")
- end
- if event then
- monster:registerEvent(event)
- end
- local function SendMessage(mit, message)
- if not Monster(mit) then
- return false
- end
- Monster(mit):say(message, TALKTYPE_MONSTER_SAY)
- end
- if message then
- addEvent(SendMessage, 200,monster:getId(), message)
- end
- end
- end
- until (summoned == ammount)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement