jeffaklumpen
Member
Hello!
I'm trying to create a boss room where the monsters and boss spawn only when a player enters the area. If there is no players in the area they should despawn. It works perfectly when there's 1 player online. If there's more players online however the script only works if all players are inside the area. If one player is outside it still despawns all the monsters inside.
I have the following script: (It's a global event that checks every 3 seconds)
I'm trying to create a boss room where the monsters and boss spawn only when a player enters the area. If there is no players in the area they should despawn. It works perfectly when there's 1 player online. If there's more players online however the script only works if all players are inside the area. If one player is outside it still despawns all the monsters inside.
I have the following script: (It's a global event that checks every 3 seconds)
Lua:
local from, to = {x = 31889, y = 31958, z = 8}, {x = 31991, y = 32019, z = 10}
function onThink(interval, lastExecution)
local tentaclepos1 = {x = 31934, y = 31982, z = 10, stackpos = 253}
local tentaclepos2 = {x = 31930, y = 31986, z = 10, stackpos = 253}
local tentaclepos3 = {x = 31939, y = 31987, z = 10, stackpos = 253}
local tentaclepos4 = {x = 31946, y = 31983, z = 10, stackpos = 253}
local tentaclepos5 = {x = 31935, y = 31990, z = 10, stackpos = 253}
local tentaclepos6 = {x = 31943, y = 31991, z = 10, stackpos = 253}
local tentaclepos7 = {x = 31938, y = 31995, z = 10, stackpos = 253}
local tentaclepos8 = {x = 31933, y = 31998, z = 10, stackpos = 253}
local tentaclepos9 = {x = 31946, y = 31996, z = 10, stackpos = 253}
local yogpos = {x = 31939, y = 31991, z = 10, stackpos = 253}
local tentacle1 = getThingfromPos(tentaclepos1).uid
local tentacle2 = getThingfromPos(tentaclepos2).uid
local tentacle3 = getThingfromPos(tentaclepos3).uid
local tentacle4 = getThingfromPos(tentaclepos4).uid
local tentacle5 = getThingfromPos(tentaclepos5).uid
local tentacle6 = getThingfromPos(tentaclepos6).uid
local tentacle7 = getThingfromPos(tentaclepos7).uid
local tentacle8 = getThingfromPos(tentaclepos8).uid
local tentacle9 = getThingfromPos(tentaclepos9).uid
local yog = getThingfromPos(yogpos).uid
for _, cid in ipairs(getPlayersOnline()) do
if not isInRange(getThingPosition(cid), from, to) and getGlobalStorageValue(43200) > -1 then
setGlobalStorageValue(43200, -1)
end
if not isInRange(getThingPosition(cid), from, to) and isMonster(yog) then
if isMonster(yog) then
doRemoveCreature(yog)
end
if isMonster(tentacle1) then
doRemoveCreature(tentacle1)
end
if isMonster(tentacle2) then
doRemoveCreature(tentacle2)
end
if isMonster(tentacle3) then
doRemoveCreature(tentacle3)
end
if isMonster(tentacle4) then
doRemoveCreature(tentacle4)
end
if isMonster(tentacle5) then
doRemoveCreature(tentacle5)
end
if isMonster(tentacle6) then
doRemoveCreature(tentacle6)
end
if isMonster(tentacle7) then
doRemoveCreature(tentacle7)
end
if isMonster(tentacle8) then
doRemoveCreature(tentacle8)
end
if isMonster(tentacle9) then
doRemoveCreature(tentacle9)
end
end
end
return TRUE
end
Last edited: