Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement monster respawn in Grimvale #2228

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions data-otservbr-global/raids/darashia/tyrn.xml

This file was deleted.

6 changes: 0 additions & 6 deletions data-otservbr-global/raids/roshamuul/mawhawk.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
local raidSchedule = {
["Tuesday"] = {
["16:00"] = { raidName = "Midnight Panther" },
},
["Wednesday"] = {
["12:00"] = { raidName = "Draptor" },
},
["Thursday"] = {
["19:00"] = { raidName = "Undead Cavebear" },
},
["Friday"] = {
["06:00"] = { raidName = "Titanica" },
},
["Saturday"] = {
["20:00"] = { raidName = "Draptor" },
},
["Sunday"] = {
["15:00"] = { raidName = "Midnight Panther" },
["13:00"] = { raidName = "Orc Backpack" },
},
["31/10"] = {
["16:00"] = { raidName = "Halloween Hare" },
},
}

local spawnRaidsEvent = GlobalEvent("SpawnRaidsEvent")

function spawnRaidsEvent.onThink(interval, lastExecution, thinkInterval)
local currentDayOfWeek, currentDate = os.date("%A"), getRealDate()
local raidsToSpawn = {}

if raidSchedule[currentDayOfWeek] then
raidsToSpawn[#raidsToSpawn + 1] = raidSchedule[currentDayOfWeek]
end

if raidSchedule[currentDate] then
raidsToSpawn[#raidsToSpawn + 1] = raidSchedule[currentDate]
end

if #raidsToSpawn > 0 then
for i = 1, #raidsToSpawn do
local currentRaidSchedule = raidsToSpawn[i][getRealTime()]
if currentRaidSchedule and not currentRaidSchedule.alreadyExecuted then
Game.startRaid(currentRaidSchedule.raidName)
currentRaidSchedule.alreadyExecuted = true
end
end
end
return true
end

spawnRaidsEvent:interval(60000)
spawnRaidsEvent:register()

This file was deleted.

18 changes: 0 additions & 18 deletions data-otservbr-global/scripts/globalevents/spawn/mawhawk.lua

This file was deleted.

65 changes: 0 additions & 65 deletions data-otservbr-global/scripts/globalevents/spawn/raids.lua

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions data-otservbr-global/scripts/globalevents/spawn/tyrn.lua

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local grimvaleConfig = {
position = { fromPosition = Position(33330, 31670, 7), toPosition = Position(33350, 31690, 7) },
spawnDay = 13,
}

local function createRandomMonster(position, availableMonsters)
local tile = Tile(position)
if not tile or tile:getItemById(486) or tile:hasProperty(CONST_PROP_BLOCKSOLID) or tile:getTopCreature() then
return false
end

local monsterName = availableMonsters[math.random(#availableMonsters)]
local monster = Game.createMonster(monsterName, position)
if monster then
monster:setSpawnPosition()
monster:remove()
end
return true
end

local function spawnMonsters(monstersToSpawn)
for x = grimvaleConfig.position.fromPosition.x, grimvaleConfig.position.toPosition.x do
for y = grimvaleConfig.position.fromPosition.y, grimvaleConfig.position.toPosition.y do
if math.random(1000) >= 983 then
if createRandomMonster(Position(x, y, 7), monstersToSpawn) then
return
end
end
end
end
end

local grimvaleRespawnEvent = GlobalEvent("GrimvaleRespawnEvent")

function grimvaleRespawnEvent.onStartup()
spawnMonsters(grimvaleConfig.spawnDay == tonumber(os.date("%d")) and { "wereboar", "werebadger" } or { "bandit", "badger", "blue butterfly", "yellow butterfly" })
return true
end

grimvaleRespawnEvent:register()
Loading