Update FighterGuildServer.lua

This commit is contained in:
Manmadedrummer
2025-12-13 17:38:32 -05:00
parent 963e55eea2
commit d8ec3d7a05

View File

@@ -2,6 +2,9 @@ local AIO = AIO or require("AIO")
local FighterGuildHandlers = AIO.AddHandlers("FighterGuildServer", {}) local FighterGuildHandlers = AIO.AddHandlers("FighterGuildServer", {})
print("Fighters Guild Loaded")
-- Define bosses directly (with difficulty levels, points, and spawn info) -- Define bosses directly (with difficulty levels, points, and spawn info)
local bosses = { local bosses = {
-- Custom Bosses -- Custom Bosses
@@ -101,12 +104,32 @@ local rewardX, rewardY, rewardZ, rewardOrientation = 2204.453125, -4794.402344,
-- BRAWL SYSTEM INTEGRATION: Queue and timer variables -- BRAWL SYSTEM INTEGRATION: Queue and timer variables
local queue = {} -- Queue of waiting players local queue = {} -- Queue of waiting players
local maxTime = 120000 -- 2 minutes in milliseconds local maxTime = 300000 -- 5 minutes in milliseconds
local timerAura = 707474 -- Timer visual aura local timerAura = 707474 -- Timer visual aura
local currentFighter = nil -- Currently fighting player local currentFighter = nil -- Currently fighting player
local currentBoss = nil -- Currently spawned boss local currentBoss = nil -- Currently spawned boss
local PlayerDeathEvent = nil -- Event ID for tracking local PlayerDeathEvent = nil -- Event ID for tracking
-- Arena cleanup radius (will despawn ALL creatures within this range of boss spawn point)
local arenaCleanupRadius = 100 -- Adjust this if your arena is bigger/smaller
-- Function to despawn all creatures in the arena area
local function CleanupArena()
if currentBoss and currentBoss:IsInWorld() then
-- Get all creatures near the boss spawn point
local creaturesInArena = currentBoss:GetCreaturesInRange(arenaCleanupRadius, 0)
for _, creature in pairs(creaturesInArena) do
if creature and creature:IsInWorld() and not creature:IsPlayer() then
creature:DespawnOrUnsummon(500)
end
end
-- Also despawn the main boss
currentBoss:DespawnOrUnsummon(500)
end
end
-- Function to get the next player in queue -- Function to get the next player in queue
local function StartNextInQueue() local function StartNextInQueue()
if #queue > 0 then if #queue > 0 then
@@ -134,10 +157,8 @@ local function TookTooLong(eventId, delay, calls, player)
player:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation) player:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
player:RemoveAura(timerAura) player:RemoveAura(timerAura)
-- Clean up boss if still alive -- Clean up ALL creatures in arena
if currentBoss and currentBoss:IsInWorld() then CleanupArena()
currentBoss:DespawnOrUnsummon(1000)
end
-- Move to next player -- Move to next player
player:RegisterEvent(StartNextInQueue, 10000, 1) player:RegisterEvent(StartNextInQueue, 10000, 1)
@@ -179,9 +200,9 @@ function FighterGuildHandlers.StartFight(player, bossId)
currentBoss = player:SpawnCreature(bossInfo.id, bossSpawnX, bossSpawnY, bossSpawnZ, bossOrientation, 2, maxTime) currentBoss = player:SpawnCreature(bossInfo.id, bossSpawnX, bossSpawnY, bossSpawnZ, bossOrientation, 2, maxTime)
if currentBoss then if currentBoss then
currentBoss:SetLevel(bossInfo.level or 80) currentBoss:SetLevel(bossInfo.level or 80)
player:SendBroadcastMessage("Boss spawned: " .. bossInfo.name .. " - You have 2 minutes!") player:SendBroadcastMessage("Boss spawned: " .. bossInfo.name .. " - You have 5 minutes!")
-- Register timeout event (2 minutes) -- Register timeout event (5 minutes)
PlayerDeathEvent = player:RegisterEvent(TookTooLong, maxTime, 1) PlayerDeathEvent = player:RegisterEvent(TookTooLong, maxTime, 1)
else else
player:SendBroadcastMessage("Failed to spawn boss. NPC ID: " .. bossInfo.id) player:SendBroadcastMessage("Failed to spawn boss. NPC ID: " .. bossInfo.id)
@@ -207,10 +228,8 @@ local function OnPlayerDeath(event, creature, victim)
victim:RemoveAura(timerAura) victim:RemoveAura(timerAura)
victim:SendBroadcastMessage("You were defeated! Better luck next time.") victim:SendBroadcastMessage("You were defeated! Better luck next time.")
-- Despawn boss -- Clean up ALL creatures in arena (boss + minions)
if currentBoss and currentBoss:IsInWorld() then CleanupArena()
currentBoss:DespawnOrUnsummon(3000)
end
-- Teleport to reward area (no rewards though) -- Teleport to reward area (no rewards though)
victim:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation) victim:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
@@ -242,6 +261,9 @@ local function OnBossDefeated(event, creature, killer)
killer:RemoveAura(timerAura) killer:RemoveAura(timerAura)
-- Clean up ALL creatures in arena (boss + any remaining minions)
CleanupArena()
-- Teleport the player back to the reward location -- Teleport the player back to the reward location
if bossInfo then if bossInfo then
killer:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation) killer:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
@@ -270,10 +292,8 @@ local function OnPlayerLogout(event, player)
PlayerDeathEvent = nil PlayerDeathEvent = nil
end end
-- Clean up boss -- Clean up ALL creatures in arena
if currentBoss and currentBoss:IsInWorld() then CleanupArena()
currentBoss:DespawnOrUnsummon(1000)
end
-- Update character position in database to prevent getting stuck -- Update character position in database to prevent getting stuck
local guid = tostring(player:GetGUID()) local guid = tostring(player:GetGUID())