From 49ca340b36afddc429181613e8a8112a1be27014 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 13 Mar 2025 20:42:28 -0500 Subject: [PATCH] hellgates maybe? --- src/engine/gameManager/HellgateManager.java | 212 ++++++++++++++++++ src/engine/gameManager/SimulationManager.java | 7 + src/engine/objects/AbstractGameObject.java | 2 +- src/engine/objects/Hellgate.java | 41 ++++ src/engine/objects/Mob.java | 2 +- 5 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 src/engine/gameManager/HellgateManager.java create mode 100644 src/engine/objects/Hellgate.java diff --git a/src/engine/gameManager/HellgateManager.java b/src/engine/gameManager/HellgateManager.java new file mode 100644 index 00000000..5d00b80e --- /dev/null +++ b/src/engine/gameManager/HellgateManager.java @@ -0,0 +1,212 @@ +package engine.gameManager; + +import engine.Enum; +import engine.InterestManagement.InterestManager; +import engine.InterestManagement.WorldGrid; +import engine.math.Vector3fImmutable; +import engine.mobileAI.MobAI; +import engine.net.DispatchMessage; +import engine.net.client.msg.chat.ChatSystemMsg; +import engine.objects.Guild; +import engine.objects.Hellgate; +import engine.objects.Mob; +import engine.objects.Resists; +import engine.server.MBServerStatics; + +import java.util.ArrayList; + +public class HellgateManager { + public static ArrayList hellgates; + public static void Reset(Hellgate hellgate){ + for(Mob mob : hellgate.mobs){ + mob.respawn(); + LootManager.GenerateStrongholdLoot(mob,false,false); + } + for(Mob mob : hellgate.mini_bosses){ + mob.respawn(); + LootManager.GenerateStrongholdLoot(mob,true,false); + } + hellgate.boss.respawn(); + LootManager.GenerateStrongholdLoot(hellgate.boss,false,true); + } + + public static void Spawn(Hellgate hellgate){ + int offsetUID = 1; + //create mobs + for(Vector3fImmutable loc : getMobSpawns(hellgate)){ + Vector3fImmutable realLoc = hellgate.parent.getLoc().add(loc); + Mob mob = CreateHellgateMiniBoss(); + if(mob == null) + continue; + mob.setResists(new Resists("Elite")); + mob.spawnTime = 1000000000; + mob.BehaviourType = Enum.MobBehaviourType.Aggro; + mob.setLoc(realLoc); + mob.healthMax = 12500; + mob.setHealth(mob.healthMax); + mob.maxDamageHandOne = 1550; + mob.minDamageHandOne = 750; + mob.atrHandOne = 1800; + mob.defenseRating = 2200; + mob.setFirstName("Hellgate Commander"); + WorldGrid.addObject(mob,realLoc.x,realLoc.z); + InterestManager.setObjectDirty(mob); + WorldGrid.updateObject(mob); + LootManager.GenerateStrongholdLoot(mob,true,false); + hellgate.mini_bosses.add(mob); + mob.setObjectUUID(mob.getObjectUUID() - (10000 + offsetUID)); + offsetUID++; + for(int i = 0; i < 5; i++){ + Mob minion = CreateHellgateMob(); + if(minion == null) + continue; + Vector3fImmutable offset = Vector3fImmutable.getRandomPointOnCircle(realLoc,32f); + minion.setLoc(offset); + minion.setResists(new Resists("Elite")); + minion.spawnTime = 1000000000; + minion.BehaviourType = Enum.MobBehaviourType.Aggro; + minion.setLoc(realLoc); + minion.healthMax = 7500; + minion.setHealth(minion.healthMax); + minion.maxDamageHandOne = 1550; + minion.minDamageHandOne = 750; + minion.atrHandOne = 1800; + minion.defenseRating = 2200; + minion.setFirstName("Hellgate Commander"); + WorldGrid.addObject(minion,offset.x,offset.z); + InterestManager.setObjectDirty(minion); + WorldGrid.updateObject(minion); + LootManager.GenerateStrongholdLoot(minion,false,false); + hellgate.mobs.add(minion); + minion.setObjectUUID(minion.getObjectUUID() - (10000 + offsetUID)); + offsetUID++; + } + } + + //spawn boss + Mob mob = CreateHellgateBoss(); + if(mob == null) + return; + mob.setLoc(hellgate.parent.getLoc()); + mob.spawnTime = 1000000000; + mob.setResists(new Resists("Elite")); + WorldGrid.addObject(mob,hellgate.parent.getLoc().x,hellgate.parent.getLoc().z); + InterestManager.setObjectDirty(mob); + WorldGrid.updateObject(mob); + LootManager.GenerateStrongholdLoot(mob,false,true); + hellgate.boss = mob; + mob.setObjectUUID(mob.getObjectUUID() - (10000 + offsetUID)); + offsetUID++; + } + + public static Mob CreateHellgateMob(){ + int soldierID = 14161; + Mob mob = null; + mob = createHellgateMob(soldierID,Vector3fImmutable.ZERO,"Hellgate Minion",75); + mob.equipmentSetID = 7545; + return mob; + } + + public static Mob CreateHellgateMiniBoss(){ + int miniBossID = 14180; + Mob mob = null; + mob = createHellgateMob(miniBossID,Vector3fImmutable.ZERO,"Hellgate Commander",75); + mob.equipmentSetID = 7816; + return mob; + } + + public static Mob CreateHellgateBoss(){ + int bossID = 2018; + Mob mob = null; + mob = createHellgateMob(bossID,Vector3fImmutable.ZERO,"Demonic Lord-Commander",85); + mob.equipmentSetID = 0; + return mob; + } + + public static ArrayList getMobSpawns(Hellgate hellgate){ + ArrayList offsets = new ArrayList<>(); + offsets.add(new Vector3fImmutable(128,0,0)); + offsets.add(new Vector3fImmutable(256,0,0)); + offsets.add(new Vector3fImmutable(384,0,0)); + offsets.add(new Vector3fImmutable(512,0,0)); + offsets.add(new Vector3fImmutable(-128,0,0)); + offsets.add(new Vector3fImmutable(-256,0,0)); + offsets.add(new Vector3fImmutable(-384,0,0)); + offsets.add(new Vector3fImmutable(-512,0,0)); + offsets.add(new Vector3fImmutable(0, 0, 128)); + offsets.add(new Vector3fImmutable(0, 0, 256)); + offsets.add(new Vector3fImmutable(0, 0, 384)); + offsets.add(new Vector3fImmutable(0, 0, 512)); + offsets.add(new Vector3fImmutable(0, 0, -128)); + offsets.add(new Vector3fImmutable(0, 0, -256)); + offsets.add(new Vector3fImmutable(0, 0, -384)); + offsets.add(new Vector3fImmutable(0, 0, -512)); + return offsets; + } + + public static Mob createHellgateMob(int loadID, Vector3fImmutable spawn, String pirateName, int level) { + + // Create a new Mob instance + Mob mobWithoutID = new Mob(pirateName, "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, (short) 1, 0, false, false, false, spawn, spawn, Vector3fImmutable.ZERO, (short) 1, (short) 1, (short) 1, Guild.getErrantGuild(), (byte) 0, loadID, true, null, null, 0); + + // Check if mobBase is null + if (mobWithoutID.mobBase == null) + return null; + + // Set mob level + mobWithoutID.level = (short) level; + + // Set the parent zone and parentZoneID + mobWithoutID.parentZone = null; + mobWithoutID.parentZoneID = 0; + + // Avoid database actions and directly return the created mobWithoutID + mobWithoutID.setObjectTypeMask(MBServerStatics.MASK_MOB | mobWithoutID.getTypeMasks()); + + return mobWithoutID; + } + + public static void pulseHellgates(){ + if(HellgateManager.hellgates == null){ + HellgateManager.hellgates = new ArrayList<>(); + Hellgate hellgate = new Hellgate(993); + HellgateManager.hellgates.add(hellgate); + return; + } + + //handle MobAI controller + for(Hellgate hellgate : HellgateManager.hellgates){ + for(Mob mob : hellgate.mobs){ + MobAI.DetermineAction(mob); + } + for(Mob mob : hellgate.mini_bosses){ + MobAI.DetermineAction(mob); + } + MobAI.DetermineAction(hellgate.boss); + + //check if boss has been defeated + if(!hellgate.boss.isAlive() && hellgate.completionTime == 0L){ + hellgate.completionTime = System.currentTimeMillis(); + for(Mob mob : hellgate.mobs){ + mob.killCharacter("Hellgate Over"); + mob.despawn(); + } + for(Mob mob : hellgate.mini_bosses){ + mob.killCharacter("Hellgate Over"); + mob.despawn(); + } + return; + } + + //reset hellgate on 15 minute intervals + if(!hellgate.boss.isAlive() && hellgate.completionTime != 0L && hellgate.completionTime + MBServerStatics.FIFTEEN_MINUTES < System.currentTimeMillis()){ + Reset(hellgate); + ChatSystemMsg chatMsg = new ChatSystemMsg(null, "Citadel Ruins Hellgate Has Begun!"); + chatMsg.setMessageType(10); + chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); + DispatchMessage.dispatchMsgToAll(chatMsg); + return; + } + } + } +} diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 189c9f5a..62022cc0 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -130,6 +130,13 @@ public enum SimulationManager { } + try{ + HellgateManager.pulseHellgates(); + }catch(Exception e){ + Logger.error("Failed to pulse hellgates"); + Logger.error(e.getMessage()); + } + SimulationManager.executionTime = Duration.between(startTime, Instant.now()); if (executionTime.compareTo(executionMax) > 0) diff --git a/src/engine/objects/AbstractGameObject.java b/src/engine/objects/AbstractGameObject.java index b105cf14..d3ed684b 100644 --- a/src/engine/objects/AbstractGameObject.java +++ b/src/engine/objects/AbstractGameObject.java @@ -169,7 +169,7 @@ public abstract class AbstractGameObject { return this.objectUUID; } - protected void setObjectUUID(int objectUUID) { + public void setObjectUUID(int objectUUID) { this.objectUUID = objectUUID; } diff --git a/src/engine/objects/Hellgate.java b/src/engine/objects/Hellgate.java new file mode 100644 index 00000000..7cecd982 --- /dev/null +++ b/src/engine/objects/Hellgate.java @@ -0,0 +1,41 @@ +package engine.objects; + +import engine.gameManager.HellgateManager; +import engine.gameManager.ZoneManager; +import engine.math.Vector3fImmutable; +import org.pmw.tinylog.Logger; + +import java.util.ArrayList; + +public class Hellgate { + public Zone parent; + public ArrayList entrances; + public ArrayList mobs; + public ArrayList mini_bosses; + public Mob boss; + + public Long completionTime; + + public Hellgate(Integer zoneID){ + Zone parentZone = ZoneManager.getZoneByUUID(zoneID); + if(parentZone == null){ + Logger.error("Failed To Spawn Hellgate"); + return; + } + this.parent = parentZone; + this.entrances = new ArrayList<>(); + entrances.add(ZoneManager.getZoneByUUID(994).getLoc()); + entrances.add(ZoneManager.getZoneByUUID(996).getLoc()); + entrances.add(ZoneManager.getZoneByUUID(997).getLoc()); + entrances.add(ZoneManager.getZoneByUUID(998).getLoc()); + this.mobs = new ArrayList<>(); + this.mini_bosses = new ArrayList<>(); + this.completionTime = 0L; + this.init(); + } + + public void init(){ + HellgateManager.Spawn(this); + } + +} diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d097aec9..31dab8b4 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -87,7 +87,7 @@ public class Mob extends AbstractIntelligenceAgent { protected int loadID; protected float spawnRadius; //used by static mobs - protected int parentZoneID; + public int parentZoneID; protected float statLat; protected float statLon; protected float statAlt;