mirror of
https://github.com/araxiaonline/Arena-Fight-Script.git
synced 2026-06-13 02:32:21 -04:00
Update FighterGuildServer.lua
This commit is contained in:
@@ -2,6 +2,9 @@ local AIO = AIO or require("AIO")
|
||||
|
||||
local FighterGuildHandlers = AIO.AddHandlers("FighterGuildServer", {})
|
||||
|
||||
print("Fighters Guild Loaded")
|
||||
|
||||
|
||||
-- Define bosses directly (with difficulty levels, points, and spawn info)
|
||||
local bosses = {
|
||||
-- Custom Bosses
|
||||
@@ -101,12 +104,32 @@ local rewardX, rewardY, rewardZ, rewardOrientation = 2204.453125, -4794.402344,
|
||||
|
||||
-- BRAWL SYSTEM INTEGRATION: Queue and timer variables
|
||||
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 currentFighter = nil -- Currently fighting player
|
||||
local currentBoss = nil -- Currently spawned boss
|
||||
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
|
||||
local function StartNextInQueue()
|
||||
if #queue > 0 then
|
||||
@@ -134,10 +157,8 @@ local function TookTooLong(eventId, delay, calls, player)
|
||||
player:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
|
||||
player:RemoveAura(timerAura)
|
||||
|
||||
-- Clean up boss if still alive
|
||||
if currentBoss and currentBoss:IsInWorld() then
|
||||
currentBoss:DespawnOrUnsummon(1000)
|
||||
end
|
||||
-- Clean up ALL creatures in arena
|
||||
CleanupArena()
|
||||
|
||||
-- Move to next player
|
||||
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)
|
||||
if currentBoss then
|
||||
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)
|
||||
else
|
||||
player:SendBroadcastMessage("Failed to spawn boss. NPC ID: " .. bossInfo.id)
|
||||
@@ -207,10 +228,8 @@ local function OnPlayerDeath(event, creature, victim)
|
||||
victim:RemoveAura(timerAura)
|
||||
victim:SendBroadcastMessage("You were defeated! Better luck next time.")
|
||||
|
||||
-- Despawn boss
|
||||
if currentBoss and currentBoss:IsInWorld() then
|
||||
currentBoss:DespawnOrUnsummon(3000)
|
||||
end
|
||||
-- Clean up ALL creatures in arena (boss + minions)
|
||||
CleanupArena()
|
||||
|
||||
-- Teleport to reward area (no rewards though)
|
||||
victim:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
|
||||
@@ -242,6 +261,9 @@ local function OnBossDefeated(event, creature, killer)
|
||||
|
||||
killer:RemoveAura(timerAura)
|
||||
|
||||
-- Clean up ALL creatures in arena (boss + any remaining minions)
|
||||
CleanupArena()
|
||||
|
||||
-- Teleport the player back to the reward location
|
||||
if bossInfo then
|
||||
killer:Teleport(mapId, rewardX, rewardY, rewardZ, rewardOrientation)
|
||||
@@ -270,10 +292,8 @@ local function OnPlayerLogout(event, player)
|
||||
PlayerDeathEvent = nil
|
||||
end
|
||||
|
||||
-- Clean up boss
|
||||
if currentBoss and currentBoss:IsInWorld() then
|
||||
currentBoss:DespawnOrUnsummon(1000)
|
||||
end
|
||||
-- Clean up ALL creatures in arena
|
||||
CleanupArena()
|
||||
|
||||
-- Update character position in database to prevent getting stuck
|
||||
local guid = tostring(player:GetGUID())
|
||||
|
||||
Reference in New Issue
Block a user