forked from MagicBane/Server
Merge branch 'lakebane-zerg' into lakebane-master
# Conflicts: # src/engine/InterestManagement/InterestManager.java # src/engine/gameManager/SimulationManager.java # src/engine/mobileAI/MobAI.java # src/engine/objects/CharacterItemManager.java # src/engine/objects/Mine.java # src/engine/objects/PlayerCharacter.java
This commit is contained in:
@@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
public int contractUUID;
|
||||
public Contract contract;
|
||||
|
||||
protected String firstName;
|
||||
protected String lastName;
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
protected short statStrCurrent;
|
||||
protected short statDexCurrent;
|
||||
protected short statConCurrent;
|
||||
@@ -117,16 +117,33 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
protected boolean movingUp = false;
|
||||
private float desiredAltitude = 0;
|
||||
private long takeOffTime = 0;
|
||||
private float hateValue = 0;
|
||||
private long lastHateUpdate = 0;
|
||||
private boolean collided = false;
|
||||
private byte aoecntr = 0;
|
||||
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
|
||||
public AbstractCharacter() {
|
||||
super();
|
||||
this.firstName = "";
|
||||
this.lastName = "";
|
||||
|
||||
this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.statStrCurrent = (short) 0;
|
||||
this.statDexCurrent = (short) 0;
|
||||
this.statConCurrent = (short) 0;
|
||||
this.statIntCurrent = (short) 0;
|
||||
this.statSpiCurrent = (short) 0;
|
||||
|
||||
this.unusedStatPoints = (short) 0;
|
||||
|
||||
this.level = (short) 0; // TODO get this from MobsBase later
|
||||
this.exp = 1;
|
||||
this.walkMode = true;
|
||||
this.bindLoc = Vector3fImmutable.ZERO;
|
||||
this.faceDir = Vector3fImmutable.ZERO;
|
||||
|
||||
this.runningTrains = (byte) 0;
|
||||
|
||||
this.skills = new ConcurrentHashMap<>();
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
this.initializeCharacter();
|
||||
|
||||
}
|
||||
@@ -214,8 +231,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +273,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,8 +304,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,9 +353,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.powers = new ConcurrentHashMap<>();
|
||||
|
||||
this.initializeCharacter();
|
||||
|
||||
// Dangerous to use THIS in a constructor!!!
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
}
|
||||
|
||||
public static int getBankCapacity() {
|
||||
@@ -1758,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.inBuildingID = inBuildingID;
|
||||
}
|
||||
|
||||
public float getHateValue() {
|
||||
if (this.hateValue <= 0) {
|
||||
this.hateValue = 0;
|
||||
return hateValue;
|
||||
}
|
||||
|
||||
if (this.lastHateUpdate == 0) {
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
return this.hateValue;
|
||||
}
|
||||
long duration = System.currentTimeMillis() - this.lastHateUpdate;
|
||||
//convert duration to seconds and multiply Hate Delimiter.
|
||||
float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER;
|
||||
this.hateValue -= modAmount;
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
return this.hateValue;
|
||||
}
|
||||
|
||||
public void setHateValue(float hateValue) {
|
||||
this.lastHateUpdate = System.currentTimeMillis();
|
||||
this.hateValue = hateValue;
|
||||
}
|
||||
|
||||
public int getInFloorID() {
|
||||
return inFloorID;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import ch.claude_martin.enumbitset.EnumBitSet;
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ModType;
|
||||
@@ -31,7 +32,20 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
protected Vector3fImmutable lastBindLoc;
|
||||
public boolean assist = false;
|
||||
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
|
||||
public boolean isPlayerGuard = false;
|
||||
public AbstractCharacter guardCaptain;
|
||||
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
;
|
||||
public Enum.MobBehaviourType behaviourType;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||
public int lastPatrolPointIndex = 0;
|
||||
public long stopPatrolTime = 0;
|
||||
public City guardedCity;
|
||||
|
||||
public AbstractIntelligenceAgent() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
@@ -87,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
this.agentType = Enum.AIAgentType.CHARMED;
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob)) {
|
||||
((Mob) this).setOwner(owner);
|
||||
|
||||
((Mob) this).guardCaptain = owner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,14 +125,6 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public PlayerCharacter getOwner() {
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob))
|
||||
return this.getOwner();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean getSafeZone() {
|
||||
|
||||
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
|
||||
@@ -158,7 +165,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
|
||||
//clear owner
|
||||
|
||||
PlayerCharacter owner = this.getOwner();
|
||||
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
|
||||
|
||||
//close pet window
|
||||
|
||||
@@ -174,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
owner.setPet(null);
|
||||
|
||||
if (this.getObjectType().equals(GameObjectType.Mob))
|
||||
((Mob) this).setOwner(null);
|
||||
((Mob) this).guardCaptain = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
|
||||
Mob mob = (Mob) this;
|
||||
if (mob.isSiege()) {
|
||||
if (mob.isPet()) {
|
||||
PlayerCharacter petOwner = mob.getOwner();
|
||||
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain;
|
||||
if (petOwner != null && source.equals(EffectSourceType.Effect)) {
|
||||
petOwner.dismissPet();
|
||||
return;
|
||||
|
||||
@@ -167,10 +167,7 @@ public class Blueprint {
|
||||
// based upon the building's current rank
|
||||
|
||||
public static int getNpcMaintCost(int rank) {
|
||||
int maintCost = Integer.MAX_VALUE;
|
||||
|
||||
maintCost = (9730 * rank) + 1890;
|
||||
|
||||
int maintCost = 0;
|
||||
return maintCost;
|
||||
}
|
||||
|
||||
@@ -313,10 +310,10 @@ public class Blueprint {
|
||||
|
||||
// Early exit for buildings with single or no slots
|
||||
|
||||
if (this.maxSlots <= 1)
|
||||
if (this.maxSlots <= 1 && this.buildingGroup.equals(BuildingGroup.TOL) == false)
|
||||
return maxSlots;
|
||||
|
||||
if (this.maxRank == 1 && currentRank == 1)
|
||||
if (this.maxRank == 1 && currentRank == 1&& this.buildingGroup.equals(BuildingGroup.TOL) == false)
|
||||
return getMaxSlots();
|
||||
|
||||
switch (currentRank) {
|
||||
@@ -328,20 +325,22 @@ public class Blueprint {
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
availableSlots = 2;
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
availableSlots = 3;
|
||||
break;
|
||||
case 8:
|
||||
availableSlots = 1;
|
||||
availableSlots = 3;
|
||||
break;
|
||||
default:
|
||||
availableSlots = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if(this.buildingGroup.equals(BuildingGroup.TOL)){
|
||||
availableSlots += 1;
|
||||
}
|
||||
return availableSlots;
|
||||
}
|
||||
|
||||
@@ -609,17 +608,10 @@ public class Blueprint {
|
||||
|
||||
switch (this.buildingGroup) {
|
||||
case TOL:
|
||||
case BARRACK:
|
||||
maintCost = (61500 * rank) + 19500;
|
||||
break;
|
||||
case SPIRE:
|
||||
maintCost = (4800 * rank) + 1200;
|
||||
maintCost = 3000000;
|
||||
break;
|
||||
default:
|
||||
if (maxRank == 1)
|
||||
maintCost = 22500;
|
||||
else
|
||||
maintCost = (15900 * rank) + 3300;
|
||||
maintCost = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1244,13 +1244,33 @@ public class CharacterItemManager {
|
||||
|
||||
return false;
|
||||
}
|
||||
if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
boolean added = false;
|
||||
for(Item item : this.getInventory()){
|
||||
if(item.getItemBaseID() == i.getItemBaseID()){
|
||||
if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) {
|
||||
item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems());
|
||||
updateInventory();
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!added){
|
||||
this.inventory.add(i);
|
||||
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
|
||||
|
||||
this.inventory.add(i);
|
||||
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
|
||||
ItemBase ib = i.getItemBase();
|
||||
if (ib != null)
|
||||
this.inventoryWeight += ib.getWeight();
|
||||
}
|
||||
}else {
|
||||
this.inventory.add(i);
|
||||
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
|
||||
|
||||
ItemBase ib = i.getItemBase();
|
||||
if (ib != null)
|
||||
this.inventoryWeight += ib.getWeight();
|
||||
ItemBase ib = i.getItemBase();
|
||||
if (ib != null)
|
||||
this.inventoryWeight += ib.getWeight();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2095,7 +2115,7 @@ public class CharacterItemManager {
|
||||
if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) {
|
||||
PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
|
||||
int newWeight = this.getCarriedWeight() + weight;
|
||||
return newWeight <= pc.getInventoryCapacity();
|
||||
return newWeight <= (int) pc.statStrBase * 3;
|
||||
} else if (this.absCharacter.getObjectType() == GameObjectType.NPC) {
|
||||
int newWeight = this.getCarriedWeight() + weight;
|
||||
return newWeight <= 1900 + (this.absCharacter.getLevel() * 3);
|
||||
@@ -2128,7 +2148,7 @@ public class CharacterItemManager {
|
||||
tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight();
|
||||
tradeWeight = tradeWeight - this.getTradingWeight();
|
||||
|
||||
return tradeWeight <= playerCharacter.getInventoryCapacity();
|
||||
return tradeWeight <= (int) playerCharacter.statStrBase * 3;
|
||||
}
|
||||
|
||||
public boolean hasRoomBank(short weight) {
|
||||
@@ -2432,9 +2452,9 @@ public class CharacterItemManager {
|
||||
if (item == null || amount < 1 || amount > 5)
|
||||
return;
|
||||
|
||||
//dont damage items when dieing in safezone
|
||||
if(ZoneManager.findSmallestZone(this.absCharacter.getLoc()).getSafeZone() == 0)
|
||||
if(ZoneManager.findSmallestZone(this.getOwner().loc).getSafeZone() == 1){
|
||||
return;
|
||||
}
|
||||
|
||||
//verify the item is equipped by this player
|
||||
int slot = item.getEquipSlot();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Contract extends AbstractGameObject {
|
||||
public int inventorySet = 0;
|
||||
private int vendorID;
|
||||
private boolean isTrainer;
|
||||
private VendorDialog vendorDialog;
|
||||
public VendorDialog vendorDialog;
|
||||
private ArrayList<Integer> npcMenuOptions = new ArrayList<>();
|
||||
private ArrayList<Integer> npcModTypeTable = new ArrayList<>();
|
||||
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
||||
|
||||
@@ -730,32 +730,29 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
public boolean canSubAGuild(Guild toSub) {
|
||||
|
||||
boolean canSub;
|
||||
|
||||
boolean canSubToNation;
|
||||
boolean canAcceptSub;
|
||||
if (this.equals(toSub))
|
||||
return false;
|
||||
switch (this.guildState) {
|
||||
case Nation:
|
||||
case Sovereign:
|
||||
canSub = true;
|
||||
canAcceptSub = true;
|
||||
break;
|
||||
default:
|
||||
canSub = false;
|
||||
canAcceptSub = false;
|
||||
}
|
||||
|
||||
switch (toSub.guildState) {
|
||||
case Errant:
|
||||
case Sovereign:
|
||||
canSub = true;
|
||||
canSubToNation = true;
|
||||
break;
|
||||
default:
|
||||
canSub = false;
|
||||
canSubToNation = false;
|
||||
}
|
||||
City nationCap = City.getCity(nation.cityUUID);
|
||||
if (nation.getSubGuildList().size() >= nationCap.getRank()) {
|
||||
canSub = false;
|
||||
}
|
||||
return canSub;
|
||||
|
||||
return canAcceptSub && canSubToNation;
|
||||
}
|
||||
|
||||
public int getRealmsOwnedFlag() {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Item extends AbstractWorldObject {
|
||||
private ArrayList<EnchantmentBase> enchants = new ArrayList<>();
|
||||
private long dateToUpgrade;
|
||||
private String customName = "";
|
||||
private int magicValue;
|
||||
public int magicValue;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
@@ -889,6 +889,8 @@ public class Item extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean isCanDestroy() {
|
||||
if(this.getItemBaseID() == 7)//gold
|
||||
return false;
|
||||
return canDestroy;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import engine.Enum.DamageType;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.Enum.ItemType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.LootManager;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -914,4 +915,8 @@ public class ItemBase {
|
||||
public void setAutoID(boolean autoID) {
|
||||
this.autoID = autoID;
|
||||
}
|
||||
|
||||
public boolean isVorg(){
|
||||
return LootManager.vorg_ha_uuids.contains(this.uuid) || LootManager.vorg_ma_uuids.contains(this.uuid) || LootManager.vorg_la_uuids.contains(this.uuid) || LootManager.vorg_cloth_uuids.contains(this.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,7 +707,7 @@ public class ItemFactory {
|
||||
|
||||
if (rollPrefix < 80) {
|
||||
|
||||
int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false);
|
||||
int randomPrefix = LootManager.TableRoll(vendor.getLevel());
|
||||
prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix);
|
||||
|
||||
if (prefixEntry != null)
|
||||
@@ -722,7 +722,7 @@ public class ItemFactory {
|
||||
|
||||
if (rollSuffix < 80 || prefixEntry == null) {
|
||||
|
||||
int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false);
|
||||
int randomSuffix = LootManager.TableRoll(vendor.getLevel());
|
||||
suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix);
|
||||
|
||||
if (suffixEntry != null)
|
||||
|
||||
@@ -21,9 +21,7 @@ import java.net.UnknownHostException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static engine.gameManager.DbManager.MineQueries;
|
||||
@@ -32,7 +30,6 @@ import static engine.math.FastMath.sqr;
|
||||
|
||||
public class Mine extends AbstractGameObject {
|
||||
|
||||
public final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
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;
|
||||
@@ -51,6 +48,13 @@ public class Mine extends AbstractGameObject {
|
||||
private int buildingID;
|
||||
private MineProduction mineType;
|
||||
|
||||
public int capSize;
|
||||
|
||||
public final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
public final HashMap<Integer,Long> _recentMemory = new HashMap<>();
|
||||
HashMap<Guild,ArrayList<Integer>> dividedPlayers;
|
||||
public Integer totalPlayers;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -91,6 +95,19 @@ public class Mine extends AbstractGameObject {
|
||||
this.production = Resource.valueOf(rs.getString("mine_resource"));
|
||||
this.lastClaimer = null;
|
||||
|
||||
//int capRoll = ThreadLocalRandom.current().nextInt(0,100);
|
||||
//if(capRoll >= 0 && capRoll <= 33){
|
||||
this.capSize = 5;
|
||||
//}
|
||||
//if(capRoll >= 34 && capRoll <= 66){
|
||||
// this.capSize = 10;
|
||||
//}
|
||||
//if(capRoll >= 67 && capRoll <= 100){
|
||||
// this.capSize = 20;
|
||||
//}
|
||||
Building mineTower = BuildingManager.getBuilding(this.buildingID);
|
||||
mineTower.setMaxHitPoints(5000 * this.capSize);
|
||||
mineTower.setCurrentHitPoints((float)5000 * this.capSize);
|
||||
}
|
||||
|
||||
public static void releaseMineClaims(PlayerCharacter playerCharacter) {
|
||||
@@ -165,7 +182,7 @@ public class Mine extends AbstractGameObject {
|
||||
writer.putInt(mine.getObjectUUID());
|
||||
writer.putInt(mine.getObjectUUID()); //actually a hash of mine
|
||||
writer.putString(mine.mineType.name);
|
||||
writer.putString(mine.zoneName);
|
||||
writer.putString(mine.zoneName + " {" + mine.capSize + " Man}");
|
||||
writer.putInt(mine.production.hash);
|
||||
writer.putInt(mine.production.baseProduction);
|
||||
writer.putInt(mine.getModifiedProductionAmount()); //TODO calculate range penalty here
|
||||
@@ -577,13 +594,12 @@ public class Mine extends AbstractGameObject {
|
||||
public void onEnter() {
|
||||
|
||||
HashSet<AbstractWorldObject> currentPlayers;
|
||||
HashSet<Integer> currentMemory;
|
||||
PlayerCharacter player;
|
||||
|
||||
// Gather current list of players within the zone bounds
|
||||
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc, Enum.CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER);
|
||||
currentMemory = new HashSet<>();
|
||||
Building tower = BuildingManager.getBuildingFromCache(this.buildingID);
|
||||
currentPlayers = WorldGrid.getObjectsInRangePartial(tower.loc, Enum.CityBoundsType.GRID.extents, MBServerStatics.MASK_PLAYER);
|
||||
boolean updated = false;
|
||||
|
||||
for (AbstractWorldObject playerObject : currentPlayers) {
|
||||
|
||||
@@ -591,9 +607,10 @@ public class Mine extends AbstractGameObject {
|
||||
continue;
|
||||
|
||||
player = (PlayerCharacter) playerObject;
|
||||
currentMemory.add(player.getObjectUUID());
|
||||
|
||||
// Player is already in our memory
|
||||
if (_recentMemory.containsKey(player.getObjectUUID()))
|
||||
_recentMemory.remove(player.getObjectUUID());
|
||||
|
||||
if (_playerMemory.contains(player.getObjectUUID()))
|
||||
continue;
|
||||
@@ -601,24 +618,60 @@ public class Mine extends AbstractGameObject {
|
||||
// Add player to our city's memory
|
||||
|
||||
_playerMemory.add(player.getObjectUUID());
|
||||
updated = true;
|
||||
|
||||
// ***For debugging
|
||||
// Logger.info("PlayerMemory for ", this.getCityName() + ": " + _playerMemory.size());
|
||||
}
|
||||
this.totalPlayers = this._playerMemory.size();
|
||||
try {
|
||||
onExit(currentMemory);
|
||||
if(onExit(currentPlayers)){
|
||||
updated = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
PowersManager.applyZergBuff(this);
|
||||
this.dividedPlayers = new HashMap<>();
|
||||
for(Integer playerID : this._playerMemory){
|
||||
player = PlayerCharacter.getFromCache(playerID);
|
||||
Guild nation = player.getGuild().getNation(); Guild entry;
|
||||
if(this.dividedPlayers.containsKey(nation)){
|
||||
this.dividedPlayers.get(nation).add(playerID);
|
||||
}else{
|
||||
ArrayList<Integer> newEntry = new ArrayList<>();
|
||||
newEntry.add(playerID);
|
||||
this.dividedPlayers.put(nation,newEntry);
|
||||
}
|
||||
}
|
||||
if(updated == true){
|
||||
for(Integer playerID : this._playerMemory){
|
||||
player = PlayerCharacter.getFromCache(playerID);
|
||||
if(this.dividedPlayers.containsKey(player.getGuild().getNation())){
|
||||
int count = this.dividedPlayers.get(player.getGuild().getNation()).size();
|
||||
switch(this.capSize){
|
||||
case 5:
|
||||
player.ZergMultiplier = ZergManager.getMultiplier5Man(count);
|
||||
break;
|
||||
case 10:
|
||||
player.ZergMultiplier = ZergManager.getMultiplier10Man(count);
|
||||
break;
|
||||
case 20:
|
||||
player.ZergMultiplier = ZergManager.getMultiplier20Man(count);
|
||||
break;
|
||||
}
|
||||
} else{
|
||||
player.ZergMultiplier = 1.0f; //something went wrong reset to default until next cycle
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void onExit(HashSet<Integer> currentMemory) {
|
||||
|
||||
private Boolean onExit(HashSet<AbstractWorldObject> currentPlayers) {
|
||||
|
||||
PlayerCharacter player;
|
||||
int playerUUID = 0;
|
||||
HashSet<Integer> toRemove = new HashSet<>();
|
||||
Iterator<Integer> iter = _playerMemory.iterator();
|
||||
HashSet<AbstractWorldObject> inRange = WorldGrid.getObjectsInRangePartial(BuildingManager.getBuildingFromCache(this.buildingID).loc,Enum.CityBoundsType.ZONE.extents * 0.5f,MBServerStatics.MASK_PLAYER);
|
||||
while (iter.hasNext()) {
|
||||
|
||||
playerUUID = iter.next();
|
||||
@@ -626,15 +679,33 @@ public class Mine extends AbstractGameObject {
|
||||
|
||||
player = PlayerCharacter.getFromCache(playerUUID);
|
||||
|
||||
if (inRange.contains(player))
|
||||
if (currentPlayers.contains(player))
|
||||
continue;
|
||||
|
||||
toRemove.add(playerUUID);
|
||||
if(_recentMemory.containsKey(playerUUID) == false) {
|
||||
_recentMemory.put(playerUUID, System.currentTimeMillis());
|
||||
}
|
||||
player.ZergMultiplier = 1.0f; // reset damage modifier to 1.0
|
||||
}
|
||||
|
||||
// Remove players from mine memory
|
||||
|
||||
_playerMemory.removeAll(toRemove);
|
||||
PowersManager.removeZergBuff(toRemove);
|
||||
//_playerMemory.removeAll(toRemove);
|
||||
HashSet<Integer> purge = new HashSet<>();
|
||||
for(Integer id : _recentMemory.keySet()){
|
||||
if(System.currentTimeMillis() > _recentMemory.get(playerUUID) + 60000){
|
||||
purge.add(id);
|
||||
}
|
||||
}
|
||||
for(Integer id : purge){
|
||||
_recentMemory.remove(id);
|
||||
}
|
||||
if(toRemove.isEmpty()){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+355
-716
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
private AbstractPowerAction suffix;
|
||||
private int pValue;
|
||||
private int sValue;
|
||||
private int magicValue;
|
||||
public int magicValue;
|
||||
|
||||
private float dropChance = 0;
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ public class NPC extends AbstractCharacter {
|
||||
// Used for thread safety
|
||||
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ArrayList<MobLoot> rolling = new ArrayList<>();
|
||||
private final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
|
||||
public HashMap<Integer, MobEquipment> equip = null;
|
||||
@@ -86,6 +85,7 @@ public class NPC extends AbstractCharacter {
|
||||
|
||||
public NPC() {
|
||||
|
||||
super();
|
||||
this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
|
||||
this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
|
||||
}
|
||||
@@ -654,12 +654,14 @@ public class NPC extends AbstractCharacter {
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
DbManager.removeFromCache(toRemove);
|
||||
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
|
||||
toRemove.guardCaptain = null;
|
||||
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
@@ -805,6 +807,8 @@ public class NPC extends AbstractCharacter {
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
|
||||
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
||||
return;
|
||||
|
||||
@@ -846,10 +850,6 @@ public class NPC extends AbstractCharacter {
|
||||
if (wordCount(this.name) < 2 && this.contract != null)
|
||||
this.name += " the " + this.contract.getName();
|
||||
|
||||
// Initialize inventory
|
||||
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
|
||||
// Configure parent zone adding this NPC to the
|
||||
// zone collection
|
||||
|
||||
@@ -1103,10 +1103,6 @@ public class NPC extends AbstractCharacter {
|
||||
return (int) time;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Mob, Integer> getSiegeMinionMap() {
|
||||
return siegeMinionMap;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
|
||||
Building building;
|
||||
@@ -1330,7 +1326,6 @@ public class NPC extends AbstractCharacter {
|
||||
return;
|
||||
|
||||
dateToUpgrade = DateTime.now().plusHours(this.getUpgradeTime());
|
||||
|
||||
this.setUpgradeDateTime(dateToUpgrade);
|
||||
|
||||
// Schedule upgrade job
|
||||
|
||||
@@ -144,7 +144,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
private long lastUpdateTime = System.currentTimeMillis();
|
||||
private long lastStamUpdateTime = System.currentTimeMillis();
|
||||
private boolean safeZone = false;
|
||||
private int bindBuildingID;
|
||||
|
||||
/*
|
||||
DataWarehouse based kill/death tracking.
|
||||
@@ -177,8 +176,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
public boolean isBoxed = false;
|
||||
|
||||
public boolean receivedConc = false;
|
||||
|
||||
public float ZergMultiplier = 1.0f;
|
||||
/**
|
||||
* No Id Constructor
|
||||
*/
|
||||
@@ -209,15 +207,18 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.spiMod.set(spiMod);
|
||||
|
||||
this.guildStatus = new AtomicInteger(0);
|
||||
this.bindBuildingID = -1;
|
||||
this.buildingUUID = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public PlayerCharacter(ResultSet rs) throws SQLException {
|
||||
|
||||
super(rs, true);
|
||||
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
|
||||
this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID());
|
||||
int accountID = rs.getInt("parent");
|
||||
this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID);
|
||||
@@ -269,7 +270,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
this.intMod.set(rs.getShort("char_intMod"));
|
||||
this.spiMod.set(rs.getShort("char_spiMod"));
|
||||
|
||||
this.bindBuildingID = rs.getInt("char_bindBuilding");
|
||||
this.buildingUUID = rs.getInt("char_bindBuilding");
|
||||
|
||||
this.hash = rs.getString("hash");
|
||||
|
||||
@@ -2191,11 +2192,8 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
}
|
||||
|
||||
//public int getInventoryCapacity() {
|
||||
// return statStrBase * 3;
|
||||
//}
|
||||
public int getInventoryCapacity() {
|
||||
return 1000;
|
||||
return statStrBase * 3;
|
||||
}
|
||||
|
||||
public int getInventoryCapacityRemaining() {
|
||||
@@ -2230,7 +2228,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
// Warehouse this event
|
||||
CharacterRecord.updatePromotionClass(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2729,12 +2726,12 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
*/
|
||||
|
||||
public synchronized int getBindBuildingID() {
|
||||
return this.bindBuildingID;
|
||||
return this.buildingUUID;
|
||||
}
|
||||
|
||||
public synchronized void setBindBuildingID(int value) {
|
||||
DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value);
|
||||
this.bindBuildingID = value;
|
||||
this.buildingUUID = value;
|
||||
}
|
||||
|
||||
public AbstractGameObject getLastTarget() {
|
||||
@@ -4569,10 +4566,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
// Init inventory
|
||||
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
|
||||
Bounds playerBounds = Bounds.borrow();
|
||||
playerBounds.setBounds(this.getLoc());
|
||||
this.setBounds(playerBounds);
|
||||
@@ -4700,7 +4693,8 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
} else if (currentPet.isSiege()) {
|
||||
currentPet.agentType = AIAgentType.MOBILE;
|
||||
currentPet.setOwner(null);
|
||||
|
||||
currentPet.guardCaptain = null;
|
||||
currentPet.setCombatTarget(null);
|
||||
if (currentPet.isAlive())
|
||||
WorldGrid.updateObject(currentPet);
|
||||
@@ -4819,9 +4813,14 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
updateBlessingMessage();
|
||||
|
||||
this.safeZone = this.isInSafeZone();
|
||||
if(this.isBoxed == true && this.containsEffect(1672601862) == false)
|
||||
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false);
|
||||
|
||||
if(this.isBoxed && this.containsEffect(1672601862) == false) {//Deathshroud
|
||||
PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false);
|
||||
}
|
||||
//if(this.isBoxed && this.containsEffect(429611355) == false) {//pathfinding
|
||||
// PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 429611355, 40, false);
|
||||
//}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
|
||||
@@ -1334,4 +1334,75 @@ public class Warehouse extends AbstractWorldObject {
|
||||
|
||||
return resourceType.elementOf(this.lockedResourceTypes);
|
||||
}
|
||||
|
||||
public static int getCostForResource(int id){
|
||||
int newCost = 0;
|
||||
switch(id){
|
||||
case 1580000://stone
|
||||
newCost = 3000;
|
||||
break;
|
||||
case 1580001://truesteel
|
||||
newCost = 50000;
|
||||
break;
|
||||
case 1580002://iron
|
||||
newCost = 50000;
|
||||
break;
|
||||
case 1580003://adamant
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580004://lumber
|
||||
newCost = 3000;
|
||||
break;
|
||||
case 1580005://oak
|
||||
newCost = 30000;
|
||||
break;
|
||||
case 1580006://bronzewood
|
||||
newCost = 30000;
|
||||
break;
|
||||
case 1580007://mandrake
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580008://coal
|
||||
newCost = 30000;
|
||||
break;
|
||||
case 1580009://agate
|
||||
newCost = 50000;
|
||||
break;
|
||||
case 1580010://diamond
|
||||
newCost = 50000;
|
||||
break;
|
||||
case 1580011://onyx
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580012://azoth
|
||||
newCost = 50000;
|
||||
break;
|
||||
case 1580013://orichalk
|
||||
newCost = 30000;
|
||||
break;
|
||||
case 1580014://antimony
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580015://sulfur
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580016://quicksilver
|
||||
newCost = 100000;
|
||||
break;
|
||||
case 1580017://galvor
|
||||
newCost = 300000;
|
||||
break;
|
||||
case 1580018://wormwood
|
||||
newCost = 300000;
|
||||
break;
|
||||
case 1580019://obsidian
|
||||
newCost = 200000;
|
||||
break;
|
||||
case 1580020://bloodstone
|
||||
newCost = 200000;
|
||||
break;
|
||||
}
|
||||
|
||||
return newCost;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user