Using TFS: 1.2
This is how i would like to modify it.
1. Make it 10% chance per 2 hour to respawn (boss)
2. If boss is not killed per 1hour it will be deleted with broadcast (i have this function already but its not convenient because it will delete everything around even if player will stand close so you will be kicked to.
Or it would be great instead of deleting it if monster is not killed do not spawn another boss if that first boss is not killed to avoid couple spawns.
3. Last think if its possible to give exp reward if they deal some dmg to that boss because its not really good to use share exp function on such event like this. So it would be nice to see if everyone would get the same amount exp.
I'll explain how my script works now.
So every 20:00 boss randomly between Test LvL 1, Test LvL 2 will be spawned, it will choose one of them to spawn if boss is not killed it will delete that boss with broadcast but as you can see it will delete players to if they stand next to that monster
This is how i would like to modify it.
1. Make it 10% chance per 2 hour to respawn (boss)
2. If boss is not killed per 1hour it will be deleted with broadcast (i have this function already but its not convenient because it will delete everything around even if player will stand close so you will be kicked to.
Or it would be great instead of deleting it if monster is not killed do not spawn another boss if that first boss is not killed to avoid couple spawns.
3. Last think if its possible to give exp reward if they deal some dmg to that boss because its not really good to use share exp function on such event like this. So it would be nice to see if everyone would get the same amount exp.
I'll explain how my script works now.
Lua:
local bosses = {
{bossName = "Test LvL 1", bossPosition = Position(315, 179, 7)},
{bossName = "Test LvL 2", bossPosition = Position(315, 179, 7)}
}
Bosses = {}
function spawnBoss()
if #Bosses >= #bosses then
for i = #Bosses, 1, -1 do
Bosses[i] = nil
end
end
local creature = bosses[math.random(#bosses)]
if isInArray(Bosses, creature.bossName) then
-- print('>> attempt to spawn '..creature.bossName..' again.')
creature = spawnBoss() -- recursive, call again if name exist
else
-- update the global Bosses table with the creature name if it does not exist
table.insert(Bosses, creature.bossName)
end
-- return the local table's return value
return creature
end
local function removeBoss()
local center = Position(315, 179, 7)
local radius = 10
local monsters = Game.getSpectators(center, false, false, radius, radius, radius, radius)
if monsters == nil then
return false
end
if #monsters < 0 then
return false
end
for i = 1, #monsters do
monster = Creature(monsters[i])
monster:remove()
end
broadcastMessage("1 Hour passed and you was not able to defeat the daily boss!", MESSAGE_EVENT_ADVANCE)
return true
end
function onTime(interval)
local rand = spawnBoss()
local monster = Game.createMonster(rand.bossName, rand.bossPosition)
if not monster then
print('>> Failed to spawn '..rand.bossName..'.')
return true
end
print('>> The boss: ' ..monster:getName() .. ' spawn.')
broadcastMessage("Daily boss have been spawned infront of temple!.", MESSAGE_EVENT_ADVANCE)
return true
end
addEvent(removeBoss, 3600000)
Code:
<globalevent name="SpawnBoss" time="20:00:00" script="spawn.lua" />
So every 20:00 boss randomly between Test LvL 1, Test LvL 2 will be spawned, it will choose one of them to spawn if boss is not killed it will delete that boss with broadcast but as you can see it will delete players to if they stand next to that monster