5 changed files with 262 additions and 2 deletions
@ -0,0 +1,212 @@
@@ -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<Hellgate> 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<Vector3fImmutable> getMobSpawns(Hellgate hellgate){ |
||||
ArrayList<Vector3fImmutable> 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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -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<Vector3fImmutable> entrances; |
||||
public ArrayList<Mob> mobs; |
||||
public ArrayList<Mob> 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); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue