Merge remote-tracking branch 'origin/post-wipe-merge' into new-mob-ai

This commit is contained in:
2023-02-27 18:53:49 -06:00
49 changed files with 1467 additions and 1834 deletions
+1 -1
View File
@@ -872,7 +872,7 @@ public class City extends AbstractWorldObject {
if (playerObject == null)
continue;
if (!this.isLocationOnCityZone(playerObject.getLoc()))
if (!this.isLocationWithinSiegeBounds(playerObject.getLoc()))
continue;
player = (PlayerCharacter) playerObject;
+25 -27
View File
@@ -9,10 +9,13 @@
package engine.objects;
import engine.Enum;
import engine.Enum.TargetColor;
import engine.gameManager.ConfigManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import java.util.ArrayList;
import java.util.TreeMap;
@@ -330,12 +333,7 @@ public class Experience {
if (killer == null || mob == null)
return;
double xp = 0.0;
//Get the xp modifier for the world
float xpMod = MBServerStatics.EXP_RATE_MOD;
double grantedExperience = 0.0;
if (g != null) { // Do group EXP stuff
@@ -372,18 +370,18 @@ public class Experience {
}
// Process every player in the group getting XP
for (PlayerCharacter pc : giveEXPTo) {
if (pc.getLevel() >= MBServerStatics.LEVELCAP)
for (PlayerCharacter playerCharacter : giveEXPTo) {
if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP)
continue;
// Sets Max XP with server exp mod taken into account.
xp = (double) xpMod * maxXPPerKill(pc.getLevel());
grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(playerCharacter.getLevel());
// Adjust XP for Mob Level
xp *= getConMod(pc, mob);
grantedExperience *= getConMod(playerCharacter, mob);
// Process XP for this member
penalty = getGroupMemberPenalty(leadership, pc, giveEXPTo,
penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo,
highestLevel);
// Leadership Penalty Reduction
@@ -391,27 +389,27 @@ public class Experience {
penalty -= ((leadership) * 0.01) * penalty;
// Modify for hotzone
if (xp != 0)
if (grantedExperience != 0)
if (ZoneManager.inHotZone(mob.getLoc()))
xp *= MBServerStatics.HOT_EXP_RATE_MOD;
grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue());
// Check for 0 XP due to white mob, otherwise subtract penalty
// xp
if (xp == 0) {
xp = 1;
if (grantedExperience == 0) {
grantedExperience = 1;
} else {
xp -= (penalty * 0.01) * xp;
grantedExperience -= (penalty * 0.01) * grantedExperience;
// Errant Penalty Calculation
if (pc.getGuild().isEmptyGuild())
xp *= 0.6;
if (playerCharacter.getGuild().isEmptyGuild())
grantedExperience *= 0.6;
}
if (xp == 0)
xp = 1;
if (grantedExperience == 0)
grantedExperience = 1;
// Grant the player the EXP
pc.grantXP((int) Math.floor(xp));
playerCharacter.grantXP((int) Math.floor(grantedExperience));
}
} else { // Give EXP to a single character
@@ -422,20 +420,20 @@ public class Experience {
return;
// Get XP and adjust for Mob Level with world xp modifier taken into account
xp = (double) xpMod * maxXPPerKill(killer.getLevel());
xp *= getConMod(killer, mob);
grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(killer.getLevel());
grantedExperience *= getConMod(killer, mob);
// Modify for hotzone
if (ZoneManager.inHotZone(mob.getLoc()))
xp *= MBServerStatics.HOT_EXP_RATE_MOD;
grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue());
// Errant penalty
if (xp != 1)
if (grantedExperience != 1)
if (killer.getGuild().isEmptyGuild())
xp *= .6;
grantedExperience *= .6;
// Grant XP
killer.grantXP((int) Math.floor(xp));
killer.grantXP((int) Math.floor(grantedExperience));
}
}
}
+7 -10
View File
@@ -13,10 +13,7 @@ import engine.Enum;
import engine.Enum.ItemContainerType;
import engine.Enum.ItemType;
import engine.Enum.OwnerType;
import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.PowersManager;
import engine.gameManager.*;
import engine.net.ItemProductionManager;
import engine.net.ItemQueue;
import engine.net.client.ClientConnection;
@@ -202,7 +199,7 @@ public class ItemFactory {
// is used to determin whether or not an object has
// compelted rolling. The game object exists previously
// to this, not when 'compelte' is pressed.
long upgradeTime = System.currentTimeMillis() + (long)(time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER) ;
long upgradeTime = System.currentTimeMillis() + (long)(time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()));
DateTime dateTime = new DateTime();
dateTime = dateTime.withMillis(upgradeTime);
@@ -220,7 +217,7 @@ public class ItemFactory {
pi.setAmount(itemsToRoll);
pi.setRandom(false);
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER));
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
ItemProductionManager.send(produced);
return ml;
@@ -620,7 +617,7 @@ public class ItemFactory {
// is used to determin whether or not an object has
// compelted rolling. The game object exists previously
// to this, not when 'compelte' is pressed.
long upgradeTime = System.currentTimeMillis() + (long)(time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER) ;
long upgradeTime = System.currentTimeMillis() + (long)(time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())) ;
DateTime dateTime = new DateTime();
dateTime = dateTime.withMillis(upgradeTime);
@@ -637,7 +634,7 @@ public class ItemFactory {
pi.setProducedItemID(ml.getObjectUUID());
pi.setAmount(itemsToRoll);
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER));
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
ItemProductionManager.send(produced);
}catch(Exception e){
Logger.error(e);
@@ -906,7 +903,7 @@ public class ItemFactory {
// is used to determin whether or not an object has
// compelted rolling. The game object exists previously
// to this, not when 'compelte' is pressed.
long upgradeTime = System.currentTimeMillis() + (long)(time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER) ;
long upgradeTime = System.currentTimeMillis() + (long)(time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())) ;
DateTime dateTime = new DateTime();
dateTime = dateTime.withMillis(upgradeTime);
@@ -920,7 +917,7 @@ public class ItemFactory {
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(),vendor.getObjectUUID(),toRoll.getItemBaseID(),dateTime,true,prefix, suffix, toRoll.getCustomName(),playerID);
pi.setProducedItemID(toRoll.getObjectUUID());
pi.setAmount(itemsToRoll);
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * MBServerStatics.PRODUCTION_TIME_MULTIPLIER));
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));
ItemProductionManager.send(produced);
return toRoll;
}
+4 -1
View File
@@ -9,12 +9,15 @@
package engine.objects;
import engine.Enum;
import engine.Enum.ItemContainerType;
import engine.Enum.ItemType;
import engine.Enum.OwnerType;
import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
@@ -208,7 +211,7 @@ public class LootTable {
float chance = mlb.getChance() *.01f;
chance *= MBServerStatics.DROP_RATE_MOD;
chance *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue());
calculatedLootTable = mlb.getLootTableID();
+134 -144
View File
@@ -20,7 +20,10 @@ package engine.objects;
import engine.Enum;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.*;
import engine.gameManager.BuildingManager;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager;
import engine.net.ByteBufferWriter;
import engine.net.client.msg.ErrorPopupMsg;
import engine.server.MBServerStatics;
@@ -33,38 +36,34 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import static engine.gameManager.DbManager.*;
import static engine.gameManager.DbManager.MineQueries;
import static engine.gameManager.DbManager.getObject;
import static engine.math.FastMath.sqr;
public class Mine extends AbstractGameObject {
private String zoneName;
private Resource production;
public static ConcurrentHashMap<Mine, Integer> mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static ConcurrentHashMap<Integer, Mine> towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public boolean isActive = false;
private float latitude;
private float longitude;
private float altitude;
private Guild owningGuild;
public PlayerCharacter lastClaimer;
public boolean wasClaimed = false;
private int flags;
private int buildingID;
private Zone parentZone;
private MineProduction mineType;
//flags 1: never been claimed (make active).
// Not persisted to DB
public String guildName;
public GuildTag guildTag;
public String nationName;
public GuildTag nationTag;
public static ConcurrentHashMap<Mine, Integer> mineMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static ConcurrentHashMap<Integer, Mine> towerMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final String zoneName;
private Resource production;
private final float latitude;
private final float longitude;
private static long lastChange = System.currentTimeMillis();
//flags 1: never been claimed (make active).
private final float altitude;
private Guild owningGuild;
private int flags;
private int buildingID;
private final Zone parentZone;
private MineProduction mineType;
/**
* ResultSet Constructor
@@ -139,6 +138,7 @@ public class Mine extends AbstractGameObject {
}
}
public static void SendMineAttackMessage(Building mine) {
if (mine.getBlueprint() == null)
@@ -186,90 +186,10 @@ public class Mine extends AbstractGameObject {
* Getters
*/
public boolean changeProductionType(Resource resource) {
if (!this.validForMine(resource))
return false;
//update resource in database;
if (!MineQueries.CHANGE_RESOURCE(this, resource))
return false;
this.production = resource;
return true;
}
public MineProduction getMineType() {
return this.mineType;
}
public String getZoneName() {
return this.zoneName;
}
public Resource getProduction() {
return this.production;
}
public boolean getIsActive() {
return this.isActive;
}
public float getAltitude() {
return this.altitude;
}
public Guild getOwningGuild() {
if (this.owningGuild == null)
return Guild.getErrantGuild();
else
return this.owningGuild;
}
public int getFlags() {
return flags;
}
public void setFlags(int flags) {
this.flags = flags;
}
public Zone getParentZone() {
return parentZone;
}
public GuildTag getGuildTag() {
return guildTag;
}
public void setMineType(String type) {
this.mineType = MineProduction.getByName(type);
}
public void setActive(boolean isAc) {
this.isActive = isAc;
Building building = BuildingManager.getBuildingFromCache(this.buildingID);
if (building != null && !this.isActive)
building.isDeranking.compareAndSet(true, false);
}
public void setOwningGuild(Guild owningGuild) {
this.owningGuild = owningGuild;
}
public static Mine getMineFromTower(int towerID) {
return Mine.towerMap.get(towerID);
}
public boolean validForMine(Resource r) {
if (this.mineType == null)
return false;
return this.mineType.validForMine(r, this.isExpansion());
}
/*
* Serialization
*/
public static void serializeForClientMsg(Mine mine, ByteBufferWriter writer) {
writer.putInt(mine.getObjectType().ordinal());
writer.putInt(mine.getObjectUUID());
@@ -284,15 +204,15 @@ public class Mine extends AbstractGameObject {
// Errant mines are currently open. Set time to now.
LocalDateTime mineOpenTime = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
// Mine times are those of the nation not individual guild.
Guild mineNatonGuild = mine.getOwningGuild().getNation();
// Adjust the serialized mine time based upon whether
// the Guild's mine window has passed or not and if it was claimed.
// If a mine is active serialize current datetime irrespective
// of any claim.
// If a mine is active serialize current datetime irrespective
// of any claim.
if (mineNatonGuild.isEmptyGuild() == false && mine.isActive == false) {
@@ -321,20 +241,6 @@ public class Mine extends AbstractGameObject {
GuildTag._serializeForDisplay(mine.nationTag, writer);
}
public void serializeForMineProduction(ByteBufferWriter writer) {
writer.putInt(this.getObjectType().ordinal());
writer.putInt(this.getObjectUUID());
writer.putInt(this.getObjectUUID()); //actually a hash of mine
// writer.putInt(0x215C92BB); //this.unknown1);
writer.putString(this.mineType.name);
writer.putString(this.zoneName);
writer.putInt(this.production.hash);
writer.putInt(this.production.baseProduction);
writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here
writer.putInt(3600); //window in seconds
writer.putInt(this.isExpansion() ? this.mineType.xpacHash : this.mineType.hash);
}
public static ArrayList<Mine> getMinesForGuild(int guildID) {
ArrayList<Mine> mineList = new ArrayList<>();
@@ -343,20 +249,12 @@ public class Mine extends AbstractGameObject {
for (Mine mine : Mine.mineMap.keySet()) {
if (mine.owningGuild.getObjectUUID() == guildID &&
mine.isActive == false)
mine.isActive == false)
mineList.add(mine);
}
return mineList;
}
public static long getLastChange() {
return lastChange;
}
public static void setLastChange(long lastChange) {
Mine.lastChange = lastChange;
}
/*
* Database
*/
@@ -369,19 +267,6 @@ public class Mine extends AbstractGameObject {
return new ArrayList<>(mineMap.keySet());
}
@Override
public void updateDatabase() {
// TODO Create update logic.
}
public int getBuildingID() {
return buildingID;
}
public void setBuildingID(int buildingID) {
this.buildingID = buildingID;
}
public static boolean validateClaimer(PlayerCharacter playerCharacter) {
// Method validates that the claimer meets
@@ -407,7 +292,7 @@ public class Mine extends AbstractGameObject {
if (playerGuild.getNation().isEmptyGuild())
return false;
// Guild must own a city to hold a mine.
// Guild must own a city to hold a mine.
City guildCity = playerGuild.getOwnedCity();
@@ -433,7 +318,7 @@ public class Mine extends AbstractGameObject {
if (treeRank < 1)
return false;
if (guildUnderMineLimit(playerGuild.getNation(), treeRank) == false){
if (guildUnderMineLimit(playerGuild.getNation(), treeRank) == false) {
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Your nation cannot support another mine.");
return false;
}
@@ -450,11 +335,116 @@ public class Mine extends AbstractGameObject {
for (Guild guild : playerGuild.getSubGuildList())
mineCnt += Mine.getMinesForGuild(guild.getObjectUUID()).size();
if (mineCnt > tolRank)
return mineCnt <= tolRank;
}
public boolean changeProductionType(Resource resource) {
if (!this.validForMine(resource))
return false;
//update resource in database;
if (!MineQueries.CHANGE_RESOURCE(this, resource))
return false;
this.production = resource;
return true;
}
public MineProduction getMineType() {
return this.mineType;
}
public void setMineType(String type) {
this.mineType = MineProduction.getByName(type);
}
public String getZoneName() {
return this.zoneName;
}
public Resource getProduction() {
return this.production;
}
public boolean getIsActive() {
return this.isActive;
}
public float getAltitude() {
return this.altitude;
}
public Guild getOwningGuild() {
if (this.owningGuild == null)
return Guild.getErrantGuild();
else
return this.owningGuild;
}
public void setOwningGuild(Guild owningGuild) {
this.owningGuild = owningGuild;
}
/*
* Serialization
*/
public int getFlags() {
return flags;
}
public void setFlags(int flags) {
this.flags = flags;
}
public Zone getParentZone() {
return parentZone;
}
public GuildTag getGuildTag() {
return guildTag;
}
public void setActive(boolean isAc) {
this.isActive = isAc;
Building building = BuildingManager.getBuildingFromCache(this.buildingID);
if (building != null && !this.isActive)
building.isDeranking.compareAndSet(true, false);
}
public boolean validForMine(Resource r) {
if (this.mineType == null)
return false;
return this.mineType.validForMine(r, this.isExpansion());
}
public void serializeForMineProduction(ByteBufferWriter writer) {
writer.putInt(this.getObjectType().ordinal());
writer.putInt(this.getObjectUUID());
writer.putInt(this.getObjectUUID()); //actually a hash of mine
// writer.putInt(0x215C92BB); //this.unknown1);
writer.putString(this.mineType.name);
writer.putString(this.zoneName);
writer.putInt(this.production.hash);
writer.putInt(this.production.baseProduction);
writer.putInt(this.getModifiedProductionAmount()); //TODO calculate range penalty here
writer.putInt(3600); //window in seconds
writer.putInt(this.isExpansion() ? this.mineType.xpacHash : this.mineType.hash);
}
@Override
public void updateDatabase() {
// TODO Create update logic.
}
public int getBuildingID() {
return buildingID;
}
public void setBuildingID(int buildingID) {
this.buildingID = buildingID;
}
public void handleDestroyMine() {
if (!this.isActive)
@@ -465,7 +455,6 @@ public class Mine extends AbstractGameObject {
this.guildName = "";
this.nationName = "";
this.owningGuild = Guild.getErrantGuild();
Mine.setLastChange(System.currentTimeMillis());
this.lastClaimer = null;
this.wasClaimed = false;
@@ -513,6 +502,7 @@ public class Mine extends AbstractGameObject {
return true;
}
public boolean depositMineResources() {
if (this.owningGuild.isEmptyGuild())
+3 -6
View File
@@ -1508,17 +1508,14 @@ public class Mob extends AbstractIntelligenceAgent {
double gold = (ThreadLocalRandom.current().nextDouble() * (maxGold - minGold) + minGold);
//server specific gold multiplier
double goldMod = MBServerStatics.GOLD_RATE_MOD;
gold *= goldMod;
gold *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue());
//modify for hotzone
if (ZoneManager.inHotZone(mob.getLoc()))
gold *= MBServerStatics.HOT_GOLD_RATE_MOD;
gold *= MBServerStatics.GOLD_RATE_MOD;
gold *= Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue());
return (int) gold;
}
+1 -1
View File
@@ -2213,7 +2213,7 @@ public void dismissNecroPets() {
for (Effect eff : playerCharacter.getEffects().values()) {
if (eff.getPower() == null && otherPlayer)
continue;
if (eff.getPower().token == 429506619) // Oblivion's Caress
if (eff.getPower() != null && eff.getPower().token == 429506619) // Oblivion's Caress
continue;
if ( !eff.serializeForLoad(writer))
continue;
+17 -75
View File
@@ -1,13 +1,13 @@
package engine.objects;
import engine.Enum.RunegateType;
import engine.Enum;
import engine.Enum.PortalType;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.ConfigManager;
import engine.job.JobScheduler;
import engine.jobs.CloseGateJob;
import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.HashSet;
@@ -19,28 +19,20 @@ import java.util.HashSet;
public class Portal {
private boolean active;
private RunegateType sourceGateType;
private RunegateType portalType;
private RunegateType destinationGateType;
private final Vector3fImmutable portalLocation;
public Enum.PortalType portalType;
public Building sourceGate;
public Building targetGate;
public final Vector3fImmutable portalLocation;
private long lastActive = 0;
public Portal(RunegateType gateType, RunegateType portalType, RunegateType destinationGate) {
Building gateBuilding;
public Portal(Building sourceGate, PortalType portalType, Building targetGate) {
this.active = false;
this.sourceGateType = gateType;
this.destinationGateType = destinationGate;
this.sourceGate = sourceGate;
this.targetGate = targetGate;
this.portalType = portalType;
gateBuilding = this.sourceGateType.getGateBuilding();
if (gateBuilding == null) {
Logger.error("Gate building " + this.sourceGateType.getGateUUID() + " for " + this.sourceGateType.name() + " missing");
}
this.portalLocation = gateBuilding.getLoc().add(new Vector3fImmutable(portalType.getOffset().x, 6, portalType.getOffset().y));
this.portalLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y));
}
public boolean isActive() {
@@ -51,15 +43,12 @@ public class Portal {
public void deactivate() {
Building sourceBuilding;
// Remove effect bit from the runegate building, which turns off this
// portal type's particle effect
sourceBuilding = this.sourceGateType.getGateBuilding();
sourceBuilding.removeEffectBit(portalType.getEffectFlag());
sourceGate.removeEffectBit(portalType.effectFlag);
this.active = false;
sourceBuilding.updateEffects();
sourceGate.updateEffects();
}
public void activate(boolean autoClose) {
@@ -70,8 +59,8 @@ public class Portal {
// Apply effect bit to the runegate building, which turns on this
// portal type's particle effect
sourceBuilding = this.sourceGateType.getGateBuilding();
sourceBuilding.addEffectBit(portalType.getEffectFlag());
sourceGate.addEffectBit(portalType.effectFlag);
this.lastActive = System.currentTimeMillis();
this.active = true;
@@ -79,10 +68,10 @@ public class Portal {
// tries to send a dispatch.
if (ConfigManager.worldServer.isRunning == true)
sourceBuilding.updateEffects();
sourceGate.updateEffects();
if (autoClose == true) {
CloseGateJob cgj = new CloseGateJob(sourceBuilding, portalType);
CloseGateJob cgj = new CloseGateJob(sourceGate, portalType);
JobScheduler.getInstance().scheduleJob(cgj, MBServerStatics.RUNEGATE_CLOSE_TIME);
}
}
@@ -107,59 +96,12 @@ public class Portal {
if (player.getTimeStamp("lastMoveGate") < this.lastActive)
return;
Building gateBuilding;
gateBuilding = destinationGateType.getGateBuilding();
if (gateBuilding != null){
player.teleport(gateBuilding.getLoc());
player.teleport(targetGate.getLoc());
player.setSafeMode();
}
}
/**
* @return the sourceGateType
*/
public RunegateType getSourceGateType() {
return sourceGateType;
}
/**
* @param sourceGateType the sourceGateType to set
*/
public void setSourceGateType(RunegateType sourceGateType) {
this.sourceGateType = sourceGateType;
}
/**
* @return the portalType
*/
public RunegateType getPortalType() {
return portalType;
}
/**
* @param portalType the portalType to set
*/
public void setPortalType(RunegateType portalType) {
this.portalType = portalType;
}
/**
* @return the destinationGateType
*/
public RunegateType getDestinationGateType() {
return destinationGateType;
}
/**
* @param destinationGateType the destinationGateType to set
*/
public void setDestinationGateType(RunegateType destinationGateType) {
this.destinationGateType = destinationGateType;
}
/**
* @return the portalLocation
*/
+7 -16
View File
@@ -21,6 +21,7 @@ import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.awt.*;
import java.net.UnknownHostException;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -36,8 +37,9 @@ public class Realm {
// Internal class cache
private static ConcurrentHashMap<Integer, Realm> _realms = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public static ConcurrentHashMap<Integer, Realm> _realms = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public Color mapColor;
private final float mapR; //Red color
private final float mapG; //Green color
private final float mapB; //Blue color
@@ -63,7 +65,7 @@ public class Realm {
private final int stretchY;
private final int locX;
private final int locY;
private final int realmID;
public final int realmID;
private final HashSet<Integer> cities = new HashSet<>();
private String hash;
@@ -72,6 +74,7 @@ public class Realm {
*/
public Realm(ResultSet rs) throws SQLException, UnknownHostException {
this.mapColor = new Color(rs.getInt("mapColor"));
this.mapR = rs.getFloat("mapR");
this.mapG = rs.getFloat("mapG");
this.mapB = rs.getFloat("mapB");
@@ -200,20 +203,8 @@ public class Realm {
public static void configureAllRealms() {
Realm serverRealm;
int realmID;
for (Enum.RealmType realmType : Enum.RealmType.values()) {
realmID = realmType.getRealmID();
// Don't serialize seafloor
if (realmID == 0)
continue;
serverRealm = Realm.getRealm(realmID);
serverRealm.configure();
for (Realm realm : Realm._realms.values()) {
realm.configure();
}
}
+42 -142
View File
@@ -1,61 +1,56 @@
package engine.objects;
import engine.Enum.RunegateType;
import engine.gameManager.BuildingManager;
import engine.Enum;
import engine.Enum.PortalType;
import engine.gameManager.DbManager;
import engine.net.ByteBufferWriter;
import java.util.ArrayList;
import java.util.HashMap;
/* Runegates are tied to particular buildings at
* bootstrap. They aren't tighly coupled, with
* the Runegate merely toggling effect bits on it's
* parent building.
* bootstrap derived from the Portal creation.
* This is only to enable the toggling of effect
* bits when traveler is used.
*/
public class Runegate {
// Runegate class Instance variables
private static final Runegate[] _runegates = new Runegate[9];
public static HashMap<Integer, Runegate> _runegates = new HashMap<>();
private final Portal[] _portals;
private final RunegateType gateType;
public Portal[] _portals;
public Building gateBuilding;
private Runegate(RunegateType gateType) {
private Runegate(Building gateBuilding) {
this._portals = new Portal[8];
this.gateType = gateType;
this.gateBuilding = gateBuilding;
// Each Runegate has a different destination
// for each portal opened.
configureGatePortals();
// Load portals for this runegate portals from the database
configurePortals();
// Chaos, Khar and Oblivion are on by default
_portals[RunegateType.CHAOS.ordinal()].activate(false);
_portals[RunegateType.OBLIV.ordinal()].activate(false);
_portals[RunegateType.MERCHANT.ordinal()].activate(false);
_portals[Enum.PortalType.CHAOS.ordinal()].activate(false);
_portals[Enum.PortalType.OBLIV.ordinal()].activate(false);
_portals[Enum.PortalType.MERCHANT.ordinal()].activate(false);
}
public void activatePortal(RunegateType gateType) {
public void activatePortal(Enum.PortalType portalType) {
this._portals[gateType.ordinal()].activate(true);
this._portals[portalType.ordinal()].activate(true);
}
public void deactivatePortal(RunegateType gateType) {
public void deactivatePortal(Enum.PortalType portalType) {
this._portals[gateType.ordinal()].deactivate();
this._portals[portalType.ordinal()].deactivate();
}
public RunegateType getGateType() {
return this.gateType;
}
public static Runegate[] getRunegates() {
return Runegate._runegates;
}
public Portal[] getPortals() {
@@ -74,18 +69,31 @@ public class Runegate {
public static void loadAllRunegates() {
for (RunegateType runegateType : RunegateType.values()) {
_runegates[runegateType.ordinal()] = new Runegate(runegateType);
}
ArrayList<Integer> gateList;
gateList = DbManager.RunegateQueries.GET_RUNEGATE_LIST();
for (int gateID : gateList) {
Building gateBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateID);
Runegate runegate = new Runegate(gateBuilding);
_runegates.put(gateID, runegate);
}
}
public void configurePortals() {
ArrayList<Portal> portalList = DbManager.RunegateQueries.GET_PORTAL_LIST(this.gateBuilding.getObjectUUID());
for (Portal portal : portalList) {
this._portals[portal.portalType.ordinal()] = portal;
}
}
public void _serializeForEnterWorld(ByteBufferWriter writer) {
Building gateBuilding;
gateBuilding = BuildingManager.getBuilding(this.gateType.getGateUUID());
writer.putInt(gateBuilding.getObjectType().ordinal());
writer.putInt(gateBuilding.getObjectUUID());
writer.putString(gateBuilding.getParentZone().getName());
@@ -94,114 +102,6 @@ public class Runegate {
writer.putFloat(gateBuilding.getLoc().getLong());
}
private void configureGatePortals() {
// Source gate type, portal type and destination gate type;
switch (this.gateType) {
case EARTH:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.FIRE, RunegateType.FORBID);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case AIR:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.AIR, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.AIR, RunegateType.AIR, RunegateType.FORBID);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.AIR, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.AIR, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.AIR, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.AIR, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.AIR, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.AIR, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case FIRE:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.FIRE, RunegateType.FORBID);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case WATER:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.WATER, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.WATER, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.WATER, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.WATER, RunegateType.WATER, RunegateType.FORBID);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.WATER, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.WATER, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.WATER, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.WATER, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case SPIRIT:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.SPIRIT, RunegateType.FORBID);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case CHAOS:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.CHAOS, RunegateType.MERCHANT);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case OBLIV:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.OBLIV, RunegateType.MERCHANT);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case MERCHANT:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.MERCHANT, RunegateType.FORBID);
break;
case FORBID:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
}
}
public static ArrayList<String> GetAllOpenGateIDStrings(){
ArrayList<String> openGateIDStrings = new ArrayList<>();
+4 -3
View File
@@ -23,6 +23,7 @@ import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
@@ -50,8 +51,8 @@ public class Zone extends AbstractGameObject {
private boolean isNPCCity = false;
private boolean isPlayerCity = false;
private String hash;
private int minLvl;
private int maxLvl;
public int minLvl;
public int maxLvl;
private float worldAltitude = 0;
@@ -59,7 +60,7 @@ public class Zone extends AbstractGameObject {
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
public boolean hasBeenHotzone = false;
/**
* ResultSet Constructor
*/