diff --git a/src/engine/gameManager/HotzoneManager.java b/src/engine/gameManager/HotzoneManager.java new file mode 100644 index 00000000..21cfb02a --- /dev/null +++ b/src/engine/gameManager/HotzoneManager.java @@ -0,0 +1,61 @@ +package engine.gameManager; + +import engine.Enum; +import engine.InterestManagement.WorldGrid; +import engine.net.DispatchMessage; +import engine.net.client.msg.chat.ChatSystemMsg; +import engine.objects.Guild; +import engine.objects.Mob; +import engine.objects.Zone; +import org.pmw.tinylog.Logger; + +import java.util.Random; + +public class HotzoneManager { + + public static Mob hotzoneMob = null; + public static void SelectRandomHotzone(){ + if(hotzoneMob != null){ + hotzoneMob.killCharacter("Hotzone Over"); + } + Random random = new Random(); + Zone newHotzone = null; + while (newHotzone == null || newHotzone.getObjectUUID() == 931 || newHotzone.getObjectUUID() == 913) + newHotzone = (Zone) ZoneManager.macroZones.toArray()[random.nextInt(ZoneManager.macroZones.size())]; + ZoneManager.setHotZone(newHotzone); + int R8UUId = 0; + switch(random.nextInt(5)) { + case 1: + R8UUId = 14152; + break; + case 2: + R8UUId = 14179; + break; + case 3: + R8UUId = 14180; + break; + case 4: + R8UUId = 14220; + break; + default: + R8UUId = 14319; + break; + } + Mob created = Mob.createMob(R8UUId,newHotzone.getLoc(), Guild.getErrantGuild(),true,newHotzone,null,0,"",85); + if(created == null){ + Logger.error("Failed To Generate Hotzone R8 Mob"); + return; + } + ChatSystemMsg chatMsg = new ChatSystemMsg(null, created.getFirstName() + " has spawned in " + newHotzone.getName() + ". Glory and riches await adventurers who dare defeat it!"); + chatMsg.setMessageType(10); + chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); + DispatchMessage.dispatchMsgToAll(chatMsg); + + created.bindLoc = newHotzone.getLoc(); + created.runAfterLoad(); + WorldGrid.addObject(created,created.bindLoc.x,created.bindLoc.z); + created.teleport(created.bindLoc); + hotzoneMob = created; + HellgateManager.SpecialLootHandler(created,true,true); + } +} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index fd9ed067..389d39dc 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -534,6 +534,9 @@ public class WorldServer { printThreads(); Logger.info("Threads Running:"); + Logger.info("Starting Hotzone..."); + HotzoneManager.SelectRandomHotzone(); + return true; } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 93751791..24f374bc 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -36,6 +36,7 @@ public class HourlyJobThread implements Runnable { ConcurrentHashMap map = DbManager.getMap(Enum.GameObjectType.City); + HotzoneManager.SelectRandomHotzone(); if (map != null) { for (AbstractGameObject ago : map.values()) {