Public Repository for the Magicbane Shadowbane Emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
8.6 KiB

4 months ago
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.bindLoc = realLoc;
4 months ago
mob.healthMax = 12500;
mob.setHealth(mob.healthMax);
mob.maxDamageHandOne = 1550;
mob.minDamageHandOne = 750;
mob.atrHandOne = 1800;
mob.defenseRating = 2200;
mob.setFirstName("Hellgate Commander");
InterestManager.setObjectDirty(mob);
WorldGrid.addObject(mob,realLoc.x,realLoc.z);
4 months ago
WorldGrid.updateObject(mob);
mob.runAfterLoad();
4 months ago
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.bindLoc = offset;
4 months ago
minion.setResists(new Resists("Elite"));
minion.spawnTime = 1000000000;
minion.BehaviourType = Enum.MobBehaviourType.Aggro;
minion.healthMax = 7500;
minion.setHealth(minion.healthMax);
minion.maxDamageHandOne = 1550;
minion.minDamageHandOne = 750;
minion.atrHandOne = 1800;
minion.defenseRating = 2200;
minion.setFirstName("Hellgate Soldier");
4 months ago
WorldGrid.addObject(minion,offset.x,offset.z);
InterestManager.setObjectDirty(minion);
WorldGrid.updateObject(minion);
minion.runAfterLoad();
4 months ago
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.bindLoc = hellgate.parent.getLoc();
4 months ago
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);
mob.runAfterLoad();
4 months ago
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;
mobWithoutID.bindLoc = spawn;
4 months ago
// Set the parent zone and parentZoneID
mobWithoutID.parentZone = ZoneManager.getZoneByUUID(993);
mobWithoutID.parentZoneID = 993;
4 months ago
// 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.isEmpty()){
4 months ago
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;
}
}
}
}