Browse Source

Initial Stronghold Push

lakebane-strongholds
FatBoy-DOTC 6 months ago
parent
commit
9f591b166b
  1. 23
      src/engine/gameManager/LootManager.java
  2. 4
      src/engine/objects/Building.java
  3. 32
      src/engine/objects/ItemBase.java
  4. 102
      src/engine/objects/Mine.java
  5. 21
      src/engine/objects/Resists.java
  6. 20
      src/engine/workthreads/HalfHourlyJobThread.java

23
src/engine/gameManager/LootManager.java

@ -663,4 +663,27 @@ public enum LootManager { @@ -663,4 +663,27 @@ public enum LootManager {
}
}
public static void GenerateStrongholdLoot(Mob mob, boolean commander){
mob.getCharItemManager().clearInventory();
int multiplier = 1;
if(commander)
multiplier = 2;
int high = 500000;
int low = 125000;
int gold = ThreadLocalRandom.current().nextInt(low, high + 1) * multiplier;
if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold);
mob.getCharItemManager().addItemToInventory(goldAmount);
}
for(int i = 0; i < 3 * multiplier; i++){
DropPresent(mob);
}
}
}

4
src/engine/objects/Building.java

@ -821,6 +821,10 @@ public class Building extends AbstractWorldObject { @@ -821,6 +821,10 @@ public class Building extends AbstractWorldObject {
return this.meshScale;
}
public void setMeshScale(Vector3f scale) {
this.meshScale = scale;
}
public final int getMeshUUID() {
return this.meshUUID;
}

32
src/engine/objects/ItemBase.java

@ -220,16 +220,28 @@ public class ItemBase { @@ -220,16 +220,28 @@ public class ItemBase {
AnniverseryGifts.add(971008);
AnniverseryGifts.add(971009);
AnniverseryGifts.add(971010);
//AnniverseryGifts.add(5101000);
//AnniverseryGifts.add(5101020);
//AnniverseryGifts.add(5101100);
//AnniverseryGifts.add(5101120);
//AnniverseryGifts.add(5101040);
//AnniverseryGifts.add(5101140);
//AnniverseryGifts.add(5101060);
//AnniverseryGifts.add(5101080);
AnniverseryGifts.add(5101000);
AnniverseryGifts.add(5101020);
AnniverseryGifts.add(5101100);
AnniverseryGifts.add(5101120);
AnniverseryGifts.add(5101040);
AnniverseryGifts.add(5101140);
AnniverseryGifts.add(5101060);
AnniverseryGifts.add(5101080);
//fate peddler presents
AnniverseryGifts.add(971012);
AnniverseryGifts.add(971013);
AnniverseryGifts.add(971014);
AnniverseryGifts.add(971015);
AnniverseryGifts.add(971016);
AnniverseryGifts.add(971017);
AnniverseryGifts.add(971018);
AnniverseryGifts.add(971019);
AnniverseryGifts.add(971020);
AnniverseryGifts.add(971021);
AnniverseryGifts.add(971022);
AnniverseryGifts.add(971023);
}
public static int getDiscPrice(int uuid) {

102
src/engine/objects/Mine.java

@ -10,8 +10,11 @@ @@ -10,8 +10,11 @@
package engine.objects;
import engine.Enum;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.*;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter;
import engine.net.client.msg.ErrorPopupMsg;
import engine.server.MBServerStatics;
@ -58,6 +61,11 @@ public class Mine extends AbstractGameObject { @@ -58,6 +61,11 @@ public class Mine extends AbstractGameObject {
public final HashSet<Integer> _playerMemory = new HashSet<>();
public ArrayList<PlayerCharacter> affectedPlayers = new ArrayList<>();
//stronghold stuff
public boolean isStronghold = false;
public ArrayList<Mob> strongholdMobs;
public HashMap<Integer,Integer> oldBuildings;
/**
* ResultSet Constructor
*/
@ -180,9 +188,15 @@ public class Mine extends AbstractGameObject { @@ -180,9 +188,15 @@ public class Mine extends AbstractGameObject {
writer.putInt(mine.getObjectType().ordinal());
writer.putInt(mine.getObjectUUID());
writer.putInt(mine.getObjectUUID()); //actually a hash of mine
writer.putString(mine.mineType.name);
if(mine.isStronghold){
writer.putString("STRONGHOLD");
writer.putString("");
}else {
writer.putString(mine.mineType.name);
writer.putString(mine.capSize + " Man ");
}
//writer.putString(mine.zoneName + " " + mine.capSize + " Man ");
writer.putString(mine.capSize + " Man ");
writer.putInt(mine.production.hash);
writer.putInt(mine.production.baseProduction);
writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here
@ -637,4 +651,88 @@ public class Mine extends AbstractGameObject { @@ -637,4 +651,88 @@ public class Mine extends AbstractGameObject {
_playerMemory.removeAll(toRemove);
}
public void StartStronghold(){
//remove buildings
Building tower = BuildingManager.getBuilding(this.buildingID);
if(tower == null)
return;
this.isStronghold = true;
this.strongholdMobs = new ArrayList<>();
this.oldBuildings = new HashMap<>();
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
for(Building building : mineZone.zoneBuildingSet){
oldBuildings.put(building.getObjectUUID(),building.meshUUID);
building.setMeshUUID(407650);
building.setMeshScale(new Vector3f(0,0,0));
}
//update tower to become stronghold mesh
tower.setMeshScale(new Vector3f(2,2,2));
tower.setMeshUUID(5001500);
//create elite mobs
for(int i = 0; i < 15; i++){
Mob guard = Mob.createMob(14315, Vector3fImmutable.getRandomPointOnCircle(tower.loc,30),Guild.getErrantGuild(),true,mineZone,null,0, "Elite",65);
if(guard != null){
guard.setResists(new Resists("Elite"));
guard.healthMax *= 2;
guard.setHealth(guard.healthMax);
guard.spawnTime = 1000000000;
guard.runAfterLoad();
InterestManager.setObjectDirty(guard);
this.strongholdMobs.add(guard);
LootManager.GenerateStrongholdLoot(guard,false);
}
}
//create stronghold commander
Mob commander = Mob.createMob(14315, Vector3fImmutable.getRandomPointOnCircle(tower.loc,30),Guild.getErrantGuild(),true,mineZone,null,0, "Commander",75);
if(commander != null){
commander.setResists(new Resists("Elite"));
commander.healthMax *= 2;
commander.setHealth(commander.healthMax);
commander.spawnTime = 1000000000;
commander.runAfterLoad();
InterestManager.setObjectDirty(commander);
this.strongholdMobs.add(commander);
LootManager.GenerateStrongholdLoot(commander,true);
}
this.setActive(true);
tower.setProtectionState(Enum.ProtectionState.PROTECTED);
}
public void EndStronghold(){
//restore the buildings
Building tower = BuildingManager.getBuilding(this.buildingID);
if(tower == null)
return;
this.isStronghold = false;
//get rid of the mobs
for(Mob mob : this.strongholdMobs) {
mob.despawn();
mob.removeFromCache();
}
//restore the buildings
Zone mineZone = ZoneManager.findSmallestZone(tower.loc);
for(Building building : mineZone.zoneBuildingSet){
if(this.oldBuildings.containsKey(building.getObjectUUID())) {
building.setMeshUUID(this.oldBuildings.get(building.getObjectUUID()));
building.setMeshScale(new Vector3f(1, 1, 1));
}
}
//update tower to become Mine Tower again
tower.setMeshScale(new Vector3f(1,1,1));
tower.setMeshUUID(1500100);
this.setActive(false);
tower.setProtectionState(Enum.ProtectionState.NPC);
}
}

21
src/engine/objects/Resists.java

@ -49,6 +49,9 @@ public class Resists { @@ -49,6 +49,9 @@ public class Resists {
case "Dropper":
setDropperResists();
break;
case "Elite":
setEliteResists();
break;
default:
setGenericResists();
break;
@ -252,6 +255,24 @@ public class Resists { @@ -252,6 +255,24 @@ public class Resists {
this.immuneTo.put(DamageType.Siege, true);
}
public final void setEliteResists() {
this.immuneToAll = false;
this.resists.put(DamageType.Slash, 75f);
this.resists.put(DamageType.Crush, 75f);
this.resists.put(DamageType.Pierce, 75f);
this.resists.put(DamageType.Magic, 75f);
this.resists.put(DamageType.Bleed, 75f);
this.resists.put(DamageType.Poison, 75f);
this.resists.put(DamageType.Mental, 75f);
this.resists.put(DamageType.Holy, 75f);
this.resists.put(DamageType.Unholy, 75f);
this.resists.put(DamageType.Lightning, 75f);
this.resists.put(DamageType.Fire, 75f);
this.resists.put(DamageType.Cold, 75f);
this.resists.put(DamageType.Healing, 0f);
this.immuneTo.put(DamageType.Siege, true);
}
/**
* Create generic resists
*/

20
src/engine/workthreads/HalfHourlyJobThread.java

@ -24,6 +24,7 @@ import org.pmw.tinylog.Logger; @@ -24,6 +24,7 @@ import org.pmw.tinylog.Logger;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import static engine.server.MBServerStatics.MINE_LATE_WINDOW;
@ -43,6 +44,9 @@ public class HalfHourlyJobThread implements Runnable { @@ -43,6 +44,9 @@ public class HalfHourlyJobThread implements Runnable {
for (Mine mine : mines) {
try {
if(mine.isStronghold)
mine.EndStronghold();
//handle mines opening on server reboot weird time interval
if(LocalDateTime.now().isAfter(LocalDateTime.now().withHour(mine.openHour).withMinute(mine.openMinute))) {
if (LocalDateTime.now().isBefore(LocalDateTime.now().withHour(mine.openHour).withMinute(mine.openMinute).plusMinutes(30))) {
@ -67,9 +71,25 @@ public class HalfHourlyJobThread implements Runnable { @@ -67,9 +71,25 @@ public class HalfHourlyJobThread implements Runnable {
Logger.error("mineID: " + mine.getObjectUUID(), e.toString());
}
}
//process stronghold
int count = 0;
while(count < 2){
int random = ThreadLocalRandom.current().nextInt(1,mines.size()) - 1;
Mine mine = mines.get(random);
if(mine != null){
if(!mine.isActive){
mine.StartStronghold();
count ++;
}
}
}
} catch (Exception e) {
Logger.error(e.toString());
}
}
public static void mineWindowOpen(Mine mine) {

Loading…
Cancel
Save