fix parchment room quest demons spawning:

https://github.com/TwistedScorpio/Nostalrius/issues/18
This commit is contained in:
ErikasKontenis 2019-12-30 16:41:03 +02:00
parent c46ab0d012
commit 0364ba62ed
2 changed files with 41 additions and 9 deletions

View File

@ -55,6 +55,17 @@ function Game.isPlayerThere(position)
return false return false
end end
function Game.isMonsterThere(position, monsterName)
local tile = Tile(position)
local creatures = tile:getCreatures()
for _, creature in ipairs(creatures) do
if creature:isMonster() and creature:getName():lower() == monsterName:lower() then
return creature
end
end
return nil
end
function Game.broadcastMessage(message, messageType) function Game.broadcastMessage(message, messageType)
if messageType == nil then if messageType == nil then
messageType = MESSAGE_STATUS_WARNING messageType = MESSAGE_STATUS_WARNING

View File

@ -1,10 +1,31 @@
function onRemoveItem(item, tileitem, position) function onRemoveItem(item, tileitem, position)
doRelocate({x = 33336, y = 31954, z = 15},{x = 33060, y = 31623, z = 15}) local demonsInRoomCount = 0;
doRelocate({x = 33340, y = 31954, z = 15},{x = 33066, y = 31623, z = 15}) local spectators = Game.getSpectators(Position(33063, 31624, 15), false, false, 20, 20, 20, 20)
doRelocate({x = 33340, y = 31958, z = 15},{x = 33066, y = 31627, z = 15}) for i = 1, #spectators do
doRelocate({x = 33336, y = 31958, z = 15},{x = 33060, y = 31627, z = 15}) local creature = spectators[i]
Game.sendMagicEffect({x = 33060, y = 31622, z = 15}, 14) if creature:getName():lower() == "demon" then
Game.sendMagicEffect({x = 33066, y = 31622, z = 15}, 14) demonsInRoomCount = demonsInRoomCount + 1
Game.sendMagicEffect({x = 33066, y = 31628, z = 15}, 14) end
Game.sendMagicEffect({x = 33060, y = 31628, z = 15}, 14) end
if (demonsInRoomCount <= 1) then
local demon1 = Game.isMonsterThere({x = 33336, y = 31954, z = 15}, "Demon")
local demon2 = Game.isMonsterThere({x = 33340, y = 31954, z = 15}, "Demon")
local demon3 = Game.isMonsterThere({x = 33340, y = 31958, z = 15}, "Demon")
local demon4 = Game.isMonsterThere({x = 33336, y = 31958, z = 15}, "Demon")
if demon1 ~= nil and demon2 ~= nil and demon3 ~= nil and demon4 ~= nil then
demon1:addHealth(-demon1:getMaxHealth())
demon2:addHealth(-demon2:getMaxHealth())
demon3:addHealth(-demon3:getMaxHealth())
demon4:addHealth(-demon4:getMaxHealth())
Game.createMonster("Demon", {x = 33060, y = 31623, z = 15})
Game.createMonster("Demon", {x = 33066, y = 31623, z = 15})
Game.createMonster("Demon", {x = 33066, y = 31627, z = 15})
Game.createMonster("Demon", {x = 33060, y = 31627, z = 15})
Game.sendMagicEffect({x = 33060, y = 31622, z = 15}, 14)
Game.sendMagicEffect({x = 33066, y = 31622, z = 15}, 14)
Game.sendMagicEffect({x = 33066, y = 31628, z = 15}, 14)
Game.sendMagicEffect({x = 33060, y = 31628, z = 15}, 14)
end
end
end end