Merge remote-tracking branch 'origin/bugfix-runesandbooties' into magicbox1.5

This commit is contained in:
2023-04-03 12:30:49 -04:00
58 changed files with 933 additions and 1896 deletions
+6 -36
View File
@@ -14,7 +14,10 @@ import engine.Enum.*;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid;
import engine.exception.SerializationException;
import engine.gameManager.*;
import engine.gameManager.CombatManager;
import engine.gameManager.ConfigManager;
import engine.gameManager.MovementManager;
import engine.gameManager.PowersManager;
import engine.job.AbstractJob;
import engine.job.JobContainer;
import engine.job.JobScheduler;
@@ -25,9 +28,6 @@ import engine.math.AtomicFloat;
import engine.math.Bounds;
import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.msg.MoveToPointMsg;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
@@ -51,7 +51,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected short statIntCurrent;
protected short statSpiCurrent;
protected short unusedStatPoints;
protected short level;
public short level;
protected int exp;
protected Vector3fImmutable bindLoc;
protected Vector3fImmutable faceDir;
@@ -84,7 +84,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected float manaMax; // Health/Mana/Stamina
protected AtomicBoolean isAlive = new AtomicBoolean(true);
protected Resists resists = new Resists("Genric");
protected AbstractWorldObject combatTarget;
public AbstractWorldObject combatTarget;
protected ConcurrentHashMap<String, JobContainer> timers;
protected ConcurrentHashMap<String, Long> timestamps;
protected int atrHandOne;
@@ -496,26 +496,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
return this.statSpiCurrent;
}
public final void setStatStrCurrent(final short value) {
this.statStrCurrent = (value < 1) ? (short) 1 : value;
}
public final void setStatDexCurrent(final short value) {
this.statDexCurrent = (value < 1) ? (short) 1 : value;
}
public final void setStatConCurrent(final short value) {
this.statConCurrent = (value < 1) ? (short) 1 : value;
}
public final void setStatIntCurrent(final short value) {
this.statIntCurrent = (value < 1) ? (short) 1 : value;
}
public final void setStatSpiCurrent(final short value) {
this.statSpiCurrent = (value < 1) ? (short) 1 : value;
}
public short getLevel() {
return this.level;
}
@@ -1917,16 +1897,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.itemCasting = itemCasting;
}
public static void MoveInsideBuilding(PlayerCharacter source, AbstractCharacter ac){
MoveToPointMsg moveMsg = new MoveToPointMsg();
moveMsg.setPlayer(ac);
moveMsg.setTarget(ac, BuildingManager.getBuildingFromCache(ac.inBuildingID));
Dispatch dispatch = Dispatch.borrow(source, moveMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
//updates
public void update(){
}
@@ -204,8 +204,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
WorldGrid.RemoveWorldObject(this);
if (this.getObjectType() == GameObjectType.Mob){
((Mob)this).setState(STATE.Disabled);
if (((Mob)this).getParentZone() != null)
((Mob)this).state = STATE.Disabled;
if (((Mob)this).getParentZone() != null)
((Mob)this).getParentZone().zoneMobSet.remove(this);
}
+1 -1
View File
@@ -50,7 +50,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
protected AtomicFloat health = new AtomicFloat();
public float healthMax;
protected boolean load = true;
protected ConcurrentHashMap<String, Effect> effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public ConcurrentHashMap<String, Effect> effects = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private int objectTypeMask = 0;
private Bounds bounds;
+29
View File
@@ -0,0 +1,29 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import java.sql.ResultSet;
import java.sql.SQLException;
public class BootySetEntry {
public int itemBase;
public float dropChance;
/**
* ResultSet Constructor
*/
public BootySetEntry(ResultSet rs) throws SQLException {
this.itemBase = (rs.getInt("itemBase"));
this.dropChance = (rs.getFloat("dropChance"));
}
}
-1
View File
@@ -99,7 +99,6 @@ public class Building extends AbstractWorldObject {
public int floor;
public int level;
public HashMap<Integer,Integer> fidelityNpcs = new HashMap<>();
public AtomicBoolean isDeranking = new AtomicBoolean(false);
private ArrayList<Building> children = null;
public LocalDateTime maintDateTime;
+3 -21
View File
@@ -9,39 +9,21 @@
package engine.objects;
import engine.gameManager.DbManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class EquipmentSetEntry {
private float dropChance;
private int itemID;
static HashMap<Integer, ArrayList<EquipmentSetEntry>> EquipmentSetMap = new HashMap<>();
public int itemID;
public float dropChance;
/**
* ResultSet Constructor
*/
public EquipmentSetEntry(ResultSet rs) throws SQLException {
this.dropChance = (rs.getFloat("dropChance"));
this.itemID = (rs.getInt("itemID"));
}
public static void LoadAllEquipmentSets() {
EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
}
float getDropChance() {
return dropChance;
}
public int getItemID() {
return itemID;
this.dropChance = (rs.getFloat("dropChance"));
}
}
-2
View File
@@ -9,13 +9,11 @@
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;
+115 -229
View File
@@ -9,15 +9,14 @@
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.NPCManager;
import engine.gameManager.ZoneManager;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
@@ -182,32 +181,31 @@ public class LootTable {
}
//Returns a list of random loot for a mob based on level, lootTable and hotzone
public static ArrayList<MobLoot> getMobLoot(Mob mob, int mobLevel, int lootTable, boolean hotzone) {
public static ArrayList<MobLoot> getMobLoot(Mob mobile, int mobLevel, int lootTable, boolean hotzone) {
// Member variable declaration
ArrayList<MobLoot> loot;
ArrayList<MobLoot> mobLoot;
int calculatedLootTable;
int roll;
int randomRoll;
// Member variable assignment
loot = new ArrayList<>();
mobLoot = new ArrayList<>();
// Setup default loot table if none exists
calculatedLootTable = lootTable;
LootTable.rollCount++;
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){
if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){
roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true);
randomRoll = ThreadLocalRandom.current().nextInt(100);
if (randomRoll > 90)
if (randomRoll > LootTable.oneDropHotZone)
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true);
else
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, true);
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, true);
}else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){
float chance = mlb.getChance() *.01f;
@@ -215,12 +213,10 @@ public class LootTable {
calculatedLootTable = mlb.getLootTableID();
if (ThreadLocalRandom.current().nextFloat() > chance)
continue;
addMobLoot(mob, loot, mobLevel, calculatedLootTable, 1, false);
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable, 1, false);
}
}
@@ -230,62 +226,48 @@ public class LootTable {
if (calculatedLootTable <= 1)
calculatedLootTable = 1300; // GENERIC WORLD
//handle hotzone random loot
if (hotzone) {
LootTable.rollCount++;
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){
roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true);
else
addMobLoot(mob, loot, mobLevel, calculatedLootTable + 1, 1, true);
}else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){
if (!MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty())
for (MobLootBase mlb : MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())) {
if (!LootTable.lootGroups.containsKey(mlb.getLootTableID() + 1))
continue;
calculatedLootTable = mlb.getLootTableID();
break;
}
roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true);
else
addMobLoot(mob, loot, mobLevel, (calculatedLootTable + 1), 1, true);
}
randomRoll = ThreadLocalRandom.current().nextInt(100);
if (randomRoll > 90)
if (randomRoll > LootTable.oneDropHotZone)
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true);
else
addMobLoot(mobile, mobLoot, mobLevel, calculatedLootTable + 1, 1, true);
}
//handle mob specific special loot
handleSpecialLoot(loot, mob, false);
return loot;
ArrayList bootyLoot = getBootyLoot(mobile);
mobLoot.addAll(bootyLoot);
return mobLoot;
}
public static ArrayList<MobLoot> getMobLootDeath(Mob mob, int mobLevel, int lootTable) {
ArrayList<MobLoot> loot = new ArrayList<>();
public static ArrayList<MobLoot> getMobLootDeath(Mob mobile, int mobLevel, int lootTable) {
ArrayList<MobLoot> mobLoot = new ArrayList<>();
if (mob == null)
return loot;
if (mobile == null)
return mobLoot;
//handle hotzone random loot
boolean hotzone = ZoneManager.inHotZone(mob.getLoc());
boolean hotzone = ZoneManager.inHotZone(mobile.getLoc());
if (hotzone) {
if (MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID()).isEmpty()){
if (MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID()).isEmpty()){
lootTable += 1;
if (lootTable <= 1)
@@ -293,11 +275,11 @@ public class LootTable {
int roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, lootTable, 1, true);
addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true);
else
addMobLoot(mob, loot, mobLevel, lootTable, 1, true);
addMobLoot(mobile, mobLoot, mobLevel, lootTable, 1, true);
}else{
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mob.getMobBase().getLoadID())){
for (MobLootBase mlb:MobLootBase.MobLootSet.get(mobile.getMobBase().getLoadID())){
lootTable = mlb.getLootTableID() + 1;
if (!LootTable.lootGroups.containsKey(lootTable))
continue;
@@ -305,67 +287,54 @@ public class LootTable {
int roll = ThreadLocalRandom.current().nextInt(100);
if (roll > 90)
if (roll > LootTable.oneDropHotZone)
addMobLoot(mob, loot, mobLevel, (lootTable), 1, true);
addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true);
else
addMobLoot(mob, loot, mobLevel, (lootTable), 1, true);
addMobLoot(mobile, mobLoot, mobLevel, (lootTable), 1, true);
break;
}
}
if (loot.isEmpty()){
if (mobLoot.isEmpty()){
LootTable.rollCount++; //add another rollCount here.
int resourceRoll = ThreadLocalRandom.current().nextInt(100);
if (resourceRoll <=5)
addMobLootResources(mob, loot, mobLevel, (lootTable), 1, true);
addMobLootResources(mobile, mobLoot, mobLevel, (lootTable), 1, true);
}
}
//handle mob specific special loot on death
handleSpecialLoot(loot, mob, true);
//handle mob specific booty on death
return loot;
ArrayList bootyLoot = getBootyLoot(mobile);
mobLoot.addAll(bootyLoot);
return mobLoot;
}
private static void handleSpecialLoot(ArrayList<MobLoot> loot, Mob mob, boolean onDeath) {
private static ArrayList<MobLoot> getBootyLoot(Mob mob) {
if (SpecialLoot.LootMap.containsKey(mob.getLootSet())) {
ArrayList<SpecialLoot> specialLoot = SpecialLoot.LootMap.get(mob.getLootSet());
for (SpecialLoot sl : specialLoot) {
if ((onDeath && sl.dropOnDeath()) || (!onDeath && !sl.dropOnDeath()))
if (ThreadLocalRandom.current().nextInt(100) < sl.getDropChance()) {
ItemBase ib = ItemBase.getItemBase(sl.getItemID());
if (ib != null) {
ArrayList<BootySetEntry> bootySetList;
ArrayList<MobLoot> mobLootList = new ArrayList<>();
switch (ib.getUUID()){
case 19290:
continue;
case 19291:
continue;
case 19292:
continue;
case 27530:
continue;
case 973000:
continue;
case 973200:
continue;
case 26360:
continue;
}
MobLoot ml = new MobLoot(mob, ib, sl.noSteal());
loot.add(ml);
if (mob.bootySetID == 0)
return mobLootList;
bootySetList = NPCManager._bootySetMap.get(mob.bootySetID);
}
for (BootySetEntry bootyEntry : bootySetList)
if (ThreadLocalRandom.current().nextInt(100) < bootyEntry.dropChance) {
ItemBase itemBase = ItemBase.getItemBase(bootyEntry.itemBase);
if (itemBase != null) {
MobLoot mobLoot = new MobLoot(mob, itemBase, true);
mobLootList.add(mobLoot);
}
}
}
return mobLootList;
}
@@ -394,40 +363,29 @@ public class LootTable {
LootRow modRow = null;
// Used for actual generation of items
int itemBaseUUID;
ItemBase itemBase = null;
MobLoot mobLoot;
Zone zone = mob.getParentZone();
// Member variable assignment
if (!LootTable.lootGroups.containsKey(lootTableID))
return;
lootGroup = LootTable.lootGroups.get(lootTableID);
calculatedMobLevel = mobLevel;
if (calculatedMobLevel > 49)
calculatedMobLevel = 49;
int roll = 0;
int randomRoll = 0;
for (int i = 0; i < cnt; i++) {
Random random = new Random();
roll = random.nextInt(100) + 1; //random roll between 1 and 100
groupRow = lootGroup.getLootRow(roll);
randomRoll = random.nextInt(100) + 1; //random roll between 1 and 100
groupRow = lootGroup.getLootRow(randomRoll);
if (groupRow == null)
return;
@@ -436,21 +394,13 @@ public class LootTable {
if (!LootTable.lootTables.containsKey(groupRow.getValueOne()))
return;
lootTable = LootTable.lootTables.get(groupRow.getValueOne());
//get item ID //FUCK THIS RETARDED SHIT
// roll = gaussianLevel(calculatedMobLevel);
int minRoll = (int) ((calculatedMobLevel - 5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) * 5);
if (minRoll < (int)lootTable.minRoll){
if (minRoll < (int)lootTable.minRoll)
minRoll = (int)lootTable.minRoll;
}
if (maxRoll < minRoll)
maxRoll = minRoll;
@@ -458,36 +408,30 @@ public class LootTable {
if (maxRoll > lootTable.maxRoll)
maxRoll = (int) lootTable.maxRoll;
if (maxRoll > 320)
maxRoll = 320;
roll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
randomRoll = (int) ThreadLocalRandom.current().nextDouble(minRoll, maxRoll + 1); //Does not return Max, but does return min?
lootRow = lootTable.getLootRow(roll); //get the item row from the bell's curve of level +-15
lootRow = lootTable.getLootRow(randomRoll); //get the item row from the bell's curve of level +-15
if (lootRow == null)
continue; //no item found for roll
itemBaseUUID = lootRow.getValueOne();
if (lootRow.getValueOne() == 0)
continue;
//handle quantities > 1 for resource drops
minSpawn = lootRow.getValueTwo();
maxSpawn = lootRow.getValueThree();
// spawnQuanity between minspawn (inclusive) and maxspawn (inclusive)
// spawnQuantity between min spawn (inclusive) and max spawn (inclusive)
if (maxSpawn > 1)
spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn;
//get modifierPrefix
calculatedMobLevel = mobLevel;
@@ -500,20 +444,18 @@ public class LootTable {
int chanceMod = ThreadLocalRandom.current().nextInt(100) + 1;
if (chanceMod < 25){
if (chanceMod < 25) {
modGroup = LootTable.modGroups.get(groupRow.getValueTwo());
if (modGroup != null) {
for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll);
randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(randomRoll);
if (modRow != null)
break;
}
if (modRow != null) {
subTableID = modRow.getValueOne();
@@ -521,17 +463,15 @@ public class LootTable {
modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel);
randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (randomRoll < modTable.minRoll)
randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll)
roll = (int) modTable.maxRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll);
modRow = modTable.getLootRow(randomRoll);
if (modRow != null) {
prefixValue = modRow.getValueOne();
@@ -540,14 +480,14 @@ public class LootTable {
}
}
}
}else if(chanceMod < 50){
}else if(chanceMod < 50) {
modGroup = LootTable.modGroups.get(groupRow.getValueThree());
if (modGroup != null) {
for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll);
randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(randomRoll);
if (modRow != null)
break;
}
@@ -559,19 +499,19 @@ public class LootTable {
if (LootTable.modTables.containsKey(subTableID)) {
modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel);
randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (randomRoll < modTable.minRoll)
randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll)
roll = (int) modTable.maxRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll);
modRow = modTable.getLootRow(randomRoll);
if (modRow == null){
if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) {
suffixValue = modRow.getValueOne();
@@ -586,9 +526,9 @@ public class LootTable {
if (modGroup != null) {
for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll);
for (int a = 0;a<10;a++) {
randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(randomRoll);
if (modRow != null)
break;
}
@@ -601,21 +541,18 @@ public class LootTable {
modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel);
randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (randomRoll < modTable.minRoll)
randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll)
roll = (int) modTable.maxRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(randomRoll);
modRow = modTable.getLootRow(roll);
if (modRow == null){
if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) {
prefixValue = modRow.getValueOne();
@@ -631,8 +568,8 @@ public class LootTable {
if (modGroup != null) {
for (int a = 0;a<10;a++){
roll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(roll);
randomRoll = ThreadLocalRandom.current().nextInt(100) + 1;
modRow = modGroup.getLootRow(randomRoll);
if (modRow != null)
break;
}
@@ -644,19 +581,18 @@ public class LootTable {
if (LootTable.modTables.containsKey(subTableID)) {
modTable = LootTable.modTables.get(subTableID);
roll = gaussianLevel((int)calculatedMobLevel);
randomRoll = gaussianLevel((int)calculatedMobLevel);
if (roll < modTable.minRoll)
roll = (int) modTable.minRoll;
if (randomRoll < modTable.minRoll)
randomRoll = (int) modTable.minRoll;
if (roll > modTable.maxRoll)
roll = (int) modTable.maxRoll;
if (randomRoll > modTable.maxRoll)
randomRoll = (int) modTable.maxRoll;
modRow = modTable.getLootRow(roll);
modRow = modTable.getLootRow(randomRoll);
if (modRow == null){
if (modRow == null)
modRow = modTable.getLootRow((int) ((modTable.minRoll + modTable.maxRoll) *.05f));
}
if (modRow != null) {
suffixValue = modRow.getValueOne();
@@ -667,7 +603,6 @@ public class LootTable {
}
}
itemBase = ItemBase.getItemBase(itemBaseUUID);
if (itemBase == null)
@@ -676,19 +611,6 @@ public class LootTable {
//Handle logging of drops
LootTable.HandleDropLogs(itemBase);
// Handle drop rates of resources/runes/contracts.
// We intentionally drop them in half
// if ((itemBase.getMessageType() == ItemType.CONTRACT) ||
// (itemBase.getMessageType() == ItemType.RUNE) ){
// if (ThreadLocalRandom.current().nextBoolean() == false)
// continue;
// }
if (itemBase.getType() == ItemType.OFFERING)
spawnQuanity = 1;
@@ -702,12 +624,11 @@ public class LootTable {
if (!modifierSuffix.isEmpty())
mobLoot.addPermanentEnchantment(modifierSuffix, 0, suffixValue, false);
mobLoot.loadEnchantments();
loot.add(mobLoot);
}
}
@@ -718,28 +639,18 @@ public class LootTable {
int minSpawn;
int maxSpawn;
int spawnQuanity = 0;
int prefixValue = 0;
int suffixValue = 0;
int subTableID;
String modifierPrefix = "";
String modifierSuffix = "";
// Lookup Table Variables
LootTable lootTable;
LootRow lootRow;
LootTable lootGroup;
LootRow groupRow = null;
LootTable modTable;
LootTable modGroup;
LootRow modRow = null;
// Used for actual generation of items
int itemBaseUUID;
ItemBase itemBase;
MobLoot mobLoot;
Zone zone = mob.getParentZone();
// Member variable assignment
if (!LootTable.lootGroups.containsKey(lootTableID))
return;
@@ -753,8 +664,6 @@ public class LootTable {
int roll = 0;
for (int i = 0; i < cnt; i++) {
if (lootTableID == 1901)
groupRow = lootGroup.getLootRow(66);
else if (lootTableID == 1501)
@@ -762,38 +671,25 @@ public class LootTable {
else
groupRow = lootGroup.getLootRow(80);
if (groupRow == null)
return;
//get loot table for this group
if (!LootTable.lootTables.containsKey(groupRow.getValueOne()))
return;
lootTable = LootTable.lootTables.get(groupRow.getValueOne());
//get item ID //FUCK THIS RETARDED SHIT
// roll = gaussianLevel(calculatedMobLevel);
int minRoll = (int) ((calculatedMobLevel-5) * 5);
int maxRoll = (int) ((calculatedMobLevel + 15) *5);
if (minRoll < (int)lootTable.minRoll){
if (minRoll < (int)lootTable.minRoll)
minRoll = (int)lootTable.minRoll;
}
if (maxRoll < minRoll)
maxRoll = minRoll;
if (maxRoll > 320)
maxRoll = 320;
@@ -809,19 +705,21 @@ public class LootTable {
continue;
//handle quantities > 1 for resource drops
minSpawn = lootRow.getValueTwo();
maxSpawn = lootRow.getValueThree();
// spawnQuanity between minspawn (inclusive) and maxspawn (inclusive)
if (maxSpawn > 1)
spawnQuanity = ThreadLocalRandom.current().nextInt((maxSpawn + 1 - minSpawn)) + minSpawn;
itemBase = ItemBase.getItemBase(itemBaseUUID);
if (itemBase == null)
return;
LootTable.HandleDropLogs(itemBase);
LootTable.HandleDropLogs(itemBase);
switch (itemBase.getUUID()){
case 19290:
@@ -844,8 +742,6 @@ public class LootTable {
// Handle drop rates of resources/runes/contracts.
// We intentionally drop them in half
if (itemBase.getType() == ItemType.OFFERING)
spawnQuanity = 1;
@@ -867,19 +763,9 @@ public class LootTable {
}
return (level * 5) + ret;
// float useLevel = (float)(level + (ThreadLocalRandom.current().nextGaussian() * 5));
//
// if (useLevel < (level - 15))
// useLevel = level - 15;
// else if (useLevel > (level + 15))
// useLevel = level + 15;
// return (int)(useLevel * 5);
}
//This set's the drop chances for stat runes.
public static void populateStatRuneChances() {
//+3, Increased
+49 -658
View File
@@ -11,7 +11,6 @@ package engine.objects;
import engine.Enum;
import engine.Enum.*;
import engine.InterestManagement.HeightMap;
import engine.InterestManagement.WorldGrid;
import engine.ai.MobileFSM;
import engine.ai.MobileFSM.STATE;
@@ -32,9 +31,7 @@ import engine.net.client.msg.ManageCityAssetsMsg;
import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import org.joda.time.DateTime;
import org.pmw.tinylog.Logger;
@@ -58,7 +55,7 @@ public class Mob extends AbstractIntelligenceAgent {
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
//mob specific
private final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
public long nextCastTime = 0;
public long nextCallForHelp = 0;
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
@@ -69,48 +66,46 @@ public class Mob extends AbstractIntelligenceAgent {
protected int dbID; //the database ID
protected int loadID;
protected boolean isMob;
protected MobBase mobBase;
public MobBase mobBase;
protected float spawnRadius;
protected int spawnTime;
public int spawnTime;
//used by static mobs
protected int parentZoneID;
protected Zone parentZone;
public Zone parentZone;
protected float statLat;
protected float statLon;
protected float statAlt;
protected Building building;
protected Contract contract;
public Building building;
public Contract contract;
private int currentID;
private int ownerUID = 0; //only used by pets
private boolean hasLoot = false;
public boolean hasLoot = false;
private AbstractWorldObject fearedObject = null;
private int buildingID;
private boolean isSiege = false;
private boolean isPlayerGuard = false;
public boolean isPlayerGuard = false;
private long timeToSpawnSiege;
private AbstractCharacter npcOwner;
private Vector3fImmutable inBuildingLoc = null;
public AbstractCharacter npcOwner;
public Vector3fImmutable inBuildingLoc = null;
private boolean noAggro = false;
private STATE state = STATE.Disabled;
public STATE state = STATE.Disabled;
private int aggroTargetID = 0;
private boolean walkingHome = true;
private long lastAttackTime = 0;
private long deathTime = 0;
private final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public long deathTime = 0;
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private int patrolPointIndex = 0;
private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null;
private String nameOverride = "";
public String nameOverride = "";
private Regions lastRegion = null;
private long despawnTime = 0;
private DeferredPowerJob weaponPower;
private DateTime upgradeDateTime = null;
private boolean lootSync = false;
private int fidalityID = 0;
private int equipmentSetID = 0;
private int lootSet = 0;
private boolean isGuard;
private ArrayList<Integer> fidelityRunes = null;
public int equipmentSetID = 0;
public int runeSetID = 0;
public int bootySetID = 0;
/**
* No Id Constructor
@@ -257,12 +252,7 @@ public class Mob extends AbstractIntelligenceAgent {
int guildID = rs.getInt("mob_guildUID");
if (this.fidalityID != 0) {
if (this.building != null)
this.guild = this.building.getGuild();
else
this.guild = Guild.getGuild(guildID);
} else if (this.building != null)
if (this.building != null)
this.guild = this.building.getGuild();
else
this.guild = Guild.getGuild(guildID);
@@ -294,34 +284,15 @@ public class Mob extends AbstractIntelligenceAgent {
this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID));
this.fidalityID = rs.getInt("fidalityID");
this.equipmentSetID = rs.getInt("equipmentSet");
this.runeSetID = rs.getInt("runeSet");
this.bootySetID = rs.getInt("bootySet");
if (this.contract != null)
this.equipmentSetID = this.contract.getEquipmentSet();
this.lootSet = (rs.getInt("lootSet"));
this.nameOverride = rs.getString("mob_name");
if (this.fidalityID != 0)
this.nameOverride = rs.getString("mob_name");
if (this.fidalityID != 0) {
Zone parentZone = ZoneManager.getZoneByUUID(this.parentZoneID);
if (parentZone != null) {
this.fidelityRunes = WorldServer.ZoneFidelityMobRunes.get(parentZone.getLoadNum()).get(this.fidalityID);
if (this.fidelityRunes != null)
for (Integer runeID : this.fidelityRunes) {
if (runeID == 252623) {
this.isGuard = true;
this.noAggro = true;
}
}
}
}
} catch (Exception e) {
Logger.error(currentID + "");
}
@@ -596,8 +567,8 @@ public class Mob extends AbstractIntelligenceAgent {
int level = mob.getLevel();
level = (level < 0) ? 0 : level;
level = (level > 50) ? 50 : level;
level = Math.max(level, 0);
level = Math.min(level, 50);
double minGold;
double maxGold;
@@ -722,30 +693,6 @@ public class Mob extends AbstractIntelligenceAgent {
return skill.getModifiedAmount();
}
public static int getBuildingSlot(Mob mob) {
int slot = -1;
if (mob.building == null)
return -1;
BuildingModelBase buildingModel = BuildingModelBase.getModelBase(mob.building.getMeshUUID());
if (buildingModel == null)
return -1;
if (mob.building.getHirelings().containsKey(mob))
slot = (mob.building.getHirelings().get(mob));
if (buildingModel.getNPCLocation(slot) == null)
return -1;
return slot;
}
public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) {
HashSet<AbstractWorldObject> mobsInRange = WorldGrid.getObjectsInRangePartial(source, MBServerStatics.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB);
@@ -817,58 +764,6 @@ public class Mob extends AbstractIntelligenceAgent {
mob.upgradeDateTime = upgradeDateTime;
}
public static Vector3fImmutable GetSpawnRadiusLocation(Mob mob) {
Vector3fImmutable returnLoc = Vector3fImmutable.ZERO;
if (mob.fidalityID != 0 && mob.building != null) {
Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(mob.localLoc, mob.spawnRadius);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(mob.building, spawnRadiusLoc);
return buildingWorldLoc;
} else {
boolean run = true;
while (run) {
Vector3fImmutable localLoc = new Vector3fImmutable(mob.statLat + mob.parentZone.absX, mob.statAlt + mob.parentZone.absY, mob.statLon + mob.parentZone.absZ);
Vector3fImmutable spawnRadiusLoc = Vector3fImmutable.getRandomPointInCircle(localLoc, mob.spawnRadius);
//not a roaming mob, just return the random loc.
if (mob.spawnRadius < 12000)
return spawnRadiusLoc;
Zone spawnZone = ZoneManager.findSmallestZone(spawnRadiusLoc);
//dont spawn roaming mobs in npc cities
if (spawnZone.isNPCCity())
continue;
//dont spawn roaming mobs in player cities.
if (spawnZone.isPlayerCity())
continue;
//don't spawn mobs in water.
if (HeightMap.isLocUnderwater(spawnRadiusLoc))
continue;
run = false;
return spawnRadiusLoc;
}
}
//shouldn't ever get here.
return returnLoc;
}
private void clearStatic() {
if (this.parentZone != null)
@@ -909,7 +804,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.level = 1;
//add this npc to building
if (this.building != null && this.loadID != 0 && this.fidalityID == 0) {
if (this.building != null && this.loadID != 0 && building.getBlueprintUUID() != 0) {
int maxSlots;
maxSlots = building.getBlueprint().getSlotsForRank(this.building.getRank());
@@ -955,225 +850,6 @@ public class Mob extends AbstractIntelligenceAgent {
Mob.mobMapByDBID.put(this.dbID, this);
}
private void initializeSkills() {
if (this.mobBase.getMobBaseStats() == null)
return;
long skillVector = this.mobBase.getMobBaseStats().getSkillSet();
int skillValue = this.mobBase.getMobBaseStats().getSkillValue();
if (this.mobBase.getObjectUUID() >= 17233) {
for (CharacterSkills cs : CharacterSkills.values()) {
SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken());
CharacterSkill css = new CharacterSkill(sb, this, 50);
this.skills.put(sb.getName(), css);
}
} else {
for (CharacterSkills cs : CharacterSkills.values()) {
if ((skillVector & cs.getFlag()) != 0) {
SkillsBase sb = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(cs.getToken());
CharacterSkill css = new CharacterSkill(sb, this, skillValue);
this.skills.put(sb.getName(), css);
}
}
}
}
private void initializeStaticEffects() {
EffectsBase eb = null;
for (MobBaseEffects mbe : this.mobBase.getRaceEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) this.level)
continue;
Effect eff = this.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) this.level)
continue;
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
//Apply all rune effects.
// Only Captains have contracts
if (contract != null || this.isPlayerGuard) {
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) this.level)
continue;
Effect eff = this.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) this.level)
continue;
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
RuneBase WarriorRune = RuneBase.getRuneBase(2518);
for (MobBaseEffects mbe : WarriorRune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) this.level)
continue;
Effect eff = this.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) this.level)
continue;
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
}
if (this.fidelityRunes != null) {
for (int fidelityRune : this.fidelityRunes) {
RuneBase rune = RuneBase.getRuneBase(fidelityRune);
if (rune != null)
for (MobBaseEffects mbe : rune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) this.level)
continue;
Effect eff = this.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) this.level)
continue;
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
}
} else
for (RuneBase rune : this.mobBase.getRunes()) {
for (MobBaseEffects mbe : rune.getEffectsList()) {
eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (this.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) this.level)
continue;
Effect eff = this.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) this.level)
continue;
this.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
}
}
/*
* Getters
*/
@@ -1259,16 +935,29 @@ public class Mob extends AbstractIntelligenceAgent {
public void setParentZone(Zone zone) {
if (this.parentZone == null) {
if (this.parentZone == null){
zone.zoneMobSet.add(this);
this.parentZone = zone;
}
this.bindLoc = Mob.GetSpawnRadiusLocation(this);
this.lastBindLoc = bindLoc;
this.setLoc(bindLoc);
this.stopMovement(bindLoc);
}
if ( this.building != null) {
Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat,this.statAlt,this.statLon);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, localLoc);
this.setBindLoc(buildingWorldLoc);
this.setLoc(buildingWorldLoc);
this.endLoc = buildingWorldLoc;
this.stopMovement(endLoc);
return;
}
Vector3fImmutable localLoc = new Vector3fImmutable(this.statLat + zone.absX, this.statAlt + zone.absY, this.statLon + zone.absZ);
this.setBindLoc(localLoc);
this.setLoc(localLoc);
this.endLoc = localLoc;
this.stopMovement(endLoc);
}
public int getParentZoneID() {
@@ -1588,7 +1277,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (chance <= me.getDropChance()) {
MobLoot ml = new MobLoot(this, me.getItemBase(), false);
ml.setFidelityEquipID(me.getObjectUUID());
this.charItemManager.addItemToInventory(ml);
}
}
@@ -1627,14 +1315,11 @@ public class Mob extends AbstractIntelligenceAgent {
this.combatTarget = null;
this.isAlive.set(true);
if (!this.isSiege)
this.lastBindLoc = Mob.GetSpawnRadiusLocation(this);
else
this.lastBindLoc = this.bindLoc;
this.lastBindLoc = this.bindLoc;
this.bindLoc = this.lastBindLoc;
this.setLoc(this.lastBindLoc);
this.stopMovement(this.lastBindLoc);
this.initializeStaticEffects();
NPCManager.applyRuneSetEffects(this);
this.recalculateStats();
this.setHealth(this.healthMax);
@@ -1642,8 +1327,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (!this.isSiege && !this.isPlayerGuard && contract == null)
loadInventory();
// LoadJob.getInstance();
// LoadJob.forceLoad(this);
}
public void despawn() {
@@ -2265,10 +1948,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
public Vector3fImmutable getInBuildingLoc() {
return inBuildingLoc;
}
public ItemBase getWeaponItemBase(boolean mainHand) {
if (this.equipmentSetID != 0) {
@@ -2338,14 +2017,7 @@ public class Mob extends AbstractIntelligenceAgent {
}
try {
this.initializeStaticEffects();
try {
this.initializeSkills();
} catch (Exception e) {
Logger.error(e.getMessage());
}
NPCManager.applyRuneSetEffects(this);
recalculateStats();
this.setHealth(this.healthMax);
@@ -2392,10 +2064,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.timeToSpawnSiege = timeToSpawnSiege;
}
public AbstractCharacter getNpcOwner() {
return npcOwner;
}
public void setNpcOwner(AbstractCharacter npcOwner) {
this.npcOwner = npcOwner;
}
@@ -2428,81 +2096,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
}
public boolean remove(Building building) {
// Remove npc from it's building
this.state = STATE.Disabled;
try {
this.clearEffects();
} catch (Exception e) {
Logger.error(e.getMessage());
}
if (this.parentZone != null)
this.parentZone.zoneMobSet.remove(this);
if (building != null) {
building.getHirelings().remove(this);
this.removeMinions();
}
// Delete npc from database
if (DbManager.MobQueries.DELETE_MOB(this) == 0)
return false;
// Remove npc from the simulation
this.removeFromCache();
DbManager.removeFromCache(this);
WorldGrid.RemoveWorldObject(this);
WorldGrid.removeObject(this);
return true;
}
public void removeMinions() {
for (Mob toRemove : this.siegeMinionMap.keySet()) {
toRemove.state = STATE.Disabled;
if (this.isMoving()) {
this.stopMovement(this.getLoc());
this.state = STATE.Disabled;
if (toRemove.parentZone != null)
toRemove.parentZone.zoneMobSet.remove(toRemove);
}
try {
toRemove.clearEffects();
} catch (Exception e) {
Logger.error(e.getMessage());
}
if (toRemove.parentZone != null)
toRemove.parentZone.zoneMobSet.remove(toRemove);
WorldGrid.RemoveWorldObject(toRemove);
WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
}
}
}
public void setRank(int newRank) {
DbManager.MobQueries.SET_PROPERTY(this, "mob_level", newRank);
@@ -2523,14 +2116,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.noAggro = noAggro;
}
public STATE getState() {
return state;
}
public void setState(STATE state) {
this.state = state;
}
public int getAggroTargetID() {
return aggroTargetID;
}
@@ -2555,14 +2140,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.lastAttackTime = lastAttackTime;
}
public ConcurrentHashMap<Integer, Boolean> getPlayerAgroMap() {
return playerAgroMap;
}
public long getDeathTime() {
return deathTime;
}
public void setDeathTime(long deathTime) {
this.deathTime = deathTime;
}
@@ -2583,10 +2160,6 @@ public class Mob extends AbstractIntelligenceAgent {
return siegeMinionMap;
}
public Building getBuilding() {
return this.building;
}
public DateTime getUpgradeDateTime() {
lock.readLock().lock();
@@ -2598,136 +2171,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
}
public synchronized Mob createGuardMob(int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level, String pirateName) {
MobBase minionMobBase;
Mob mob;
int maxSlots = 1;
switch (this.getRank()) {
case 1:
case 2:
maxSlots = 1;
break;
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
default:
maxSlots = 1;
}
if (siegeMinionMap.size() == maxSlots)
return null;
minionMobBase = this.mobBase;
if (minionMobBase == null)
return null;
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, true);
mob.despawned = true;
mob.setLevel(level);
//grab equipment and name from minionbase.
if (this.contract != null) {
MinionType minionType = MinionType.ContractToMinionMap.get(this.contract.getContractID());
if (minionType != null) {
mob.equipmentSetID = minionType.getEquipSetID();
String rank = "";
if (this.getRank() < 3)
rank = MBServerStatics.JUNIOR;
else if (this.getRank() < 6)
rank = "";
else if (this.getRank() == 6)
rank = MBServerStatics.VETERAN;
else
rank = MBServerStatics.ELITE;
if (rank.isEmpty())
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName();
else
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName();
}
}
if (parent != null)
mob.setRelPos(parent, loc.x - parent.absX, loc.y - parent.absY, loc.z - parent.absZ);
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
// mob.setMob();
mob.isPlayerGuard = true;
mob.setParentZone(parent);
DbManager.addToCache(mob);
mob.runAfterLoad();
RuneBase guardRune = RuneBase.getRuneBase(252621);
for (MobBaseEffects mbe : guardRune.getEffectsList()) {
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
if (eb == null) {
Logger.info("EffectsBase Null for Token " + mbe.getToken());
continue;
}
//check to upgrade effects if needed.
if (mob.effects.containsKey(Integer.toString(eb.getUUID()))) {
if (mbe.getReqLvl() > (int) mob.level) {
continue;
}
Effect eff = mob.effects.get(Integer.toString(eb.getUUID()));
if (eff == null)
continue;
//Current effect is a higher rank, dont apply.
if (eff.getTrains() > mbe.getRank())
continue;
//new effect is of a higher rank. remove old effect and apply new one.
eff.cancelJob();
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
} else {
if (mbe.getReqLvl() > (int) mob.level)
continue;
mob.addEffectNoTimer(Integer.toString(eb.getUUID()), eb, mbe.getRank(), true);
}
}
int slot = 0;
slot += siegeMinionMap.size() + 1;
siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(this.building, this);
mob.setBindLoc(loc.add(mob.inBuildingLoc));
mob.deathTime = System.currentTimeMillis();
mob.spawnTime = 900;
mob.npcOwner = this;
mob.state = STATE.Respawn;
return mob;
}
public Contract getContract() {
return contract;
}
@@ -2776,10 +2219,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.lootSync = lootSync;
}
public int getFidalityID() {
return fidalityID;
}
public HashMap<Integer, MobEquipment> getEquip() {
return equip;
}
@@ -2788,14 +2227,6 @@ public class Mob extends AbstractIntelligenceAgent {
return equipmentSetID;
}
public int getLootSet() {
return lootSet;
}
public boolean isGuard() {
return this.isGuard;
}
public String getNameOverride() {
return nameOverride;
}
@@ -2806,7 +2237,7 @@ public class Mob extends AbstractIntelligenceAgent {
try {
building = this.getBuilding();
building = this.building;
// Cannot upgrade an npc not within a building
@@ -2884,7 +2315,7 @@ public class Mob extends AbstractIntelligenceAgent {
if (!building.getHirelings().containsKey(this))
return;
if (!this.remove(building)) {
if (!NPCManager.removeMobileFromBuilding(this, building)) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return;
}
@@ -2941,7 +2372,7 @@ public class Mob extends AbstractIntelligenceAgent {
WorldGrid.RemoveWorldObject(this);
DbManager.removeFromCache(this);
if (this.getObjectType() == GameObjectType.Mob) {
this.setState(STATE.Disabled);
this.state = STATE.Disabled;
if (this.getParentZone() != null)
this.getParentZone().zoneMobSet.remove(this);
}
@@ -2973,44 +2404,4 @@ public class Mob extends AbstractIntelligenceAgent {
}
}
public void dismissNecroPet(boolean updateOwner) {
this.state = STATE.Disabled;
this.combatTarget = null;
this.hasLoot = false;
if (this.parentZone != null)
this.parentZone.zoneMobSet.remove(this);
try {
this.clearEffects();
} catch (Exception e) {
Logger.error(e.getMessage());
}
this.playerAgroMap.clear();
WorldGrid.RemoveWorldObject(this);
DbManager.removeFromCache(this);
// YEAH BONUS CODE! THANKS UNNAMED ASSHOLE!
//WorldServer.removeObject(this);
//WorldGrid.INSTANCE.removeWorldObject(this);
//owner.getPet().disableIntelligence();
PlayerCharacter petOwner = this.getOwner();
if (petOwner != null) {
this.setOwner(null);
petOwner.setPet(null);
if (updateOwner == false)
return;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
}
}
}
+3 -7
View File
@@ -12,6 +12,7 @@ package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum;
import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import engine.server.MBServerStatics;
import java.sql.ResultSet;
@@ -128,7 +129,6 @@ public class MobBase extends AbstractGameObject {
if (Enum.MobFlagType.RAT.elementOf(this.flags))
this.mask += MBServerStatics.MASK_RAT;
this.runes = DbManager.MobBaseQueries.LOAD_RUNES_FOR_MOBBASE(this.loadID);
this.raceEffectsList = DbManager.MobBaseQueries.LOAD_STATIC_EFFECTS(this.loadID);
this.mobBaseStats = DbManager.MobBaseQueries.LOAD_STATS(this.loadID);
DbManager.MobBaseQueries.LOAD_ALL_MOBBASE_LOOT(this.loadID);
@@ -144,14 +144,14 @@ public class MobBase extends AbstractGameObject {
if (equipmentSetID == 0)
return equip;
equipList = EquipmentSetEntry.EquipmentSetMap.get(equipmentSetID);
equipList = NPCManager._equipmentSetMap.get(equipmentSetID);
if (equipList == null)
return equip;
for (EquipmentSetEntry equipmentSetEntry : equipList) {
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.getItemID(), equipmentSetEntry.getDropChance());
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemID, equipmentSetEntry.dropChance);
ItemBase itemBase = mobEquipment.getItemBase();
if (itemBase != null) {
@@ -174,10 +174,6 @@ public class MobBase extends AbstractGameObject {
this.raceEffectsList = DbManager.MobBaseQueries.LOAD_STATIC_EFFECTS(this.getObjectUUID());
}
public void updateRunes() {
this.runes = DbManager.MobBaseQueries.LOAD_RUNES_FOR_MOBBASE(this.getObjectUUID());
}
public void updatePowers() {
this.staticPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getObjectUUID());
}
-16
View File
@@ -12,8 +12,6 @@ package engine.objects;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MobBaseStats {
private final int baseStr;
@@ -21,8 +19,6 @@ public class MobBaseStats {
private final int baseCon;
private final int baseSpi;
private final int baseDex;
private final long skillSet;
private final int skillValue;
public static MobBaseStats mbs = null;
@@ -35,8 +31,6 @@ public class MobBaseStats {
this.baseCon = rs.getInt("Constitution");
this.baseSpi = rs.getInt("Spirit");
this.baseDex = rs.getInt("Dexterity");
this.skillSet = rs.getLong("baseSkills");
this.skillValue = rs.getInt("skillAmount");
}
/**
@@ -49,8 +43,6 @@ public class MobBaseStats {
this.baseCon = 0;
this.baseSpi = 0;
this.baseDex = 0;
this.skillSet = 0;
this.skillValue = 0;
}
public int getBaseStr() {
return baseStr;
@@ -75,14 +67,6 @@ public class MobBaseStats {
public int getBaseDex() {
return baseDex;
}
public long getSkillSet() {
return skillSet;
}
public int getSkillValue() {
return skillValue;
}
public static MobBaseStats GetGenericStats(){
if (mbs != null)
-13
View File
@@ -34,9 +34,6 @@ public final class MobLoot extends Item {
private String prefix = "";
private String suffix = "";
private int fidelityEquipID = 0;
/**
* Create a new MobLoot.
* Do not use this to create Gold.
@@ -395,14 +392,4 @@ public final class MobLoot extends Item {
this.suffix = suffix;
}
public int getFidelityEquipID() {
return fidelityEquipID;
}
public void setFidelityEquipID(int fidelityEquipID) {
this.fidelityEquipID = fidelityEquipID;
}
}
+14 -41
View File
@@ -89,12 +89,12 @@ public class NPC extends AbstractCharacter {
private int parentZoneID;
public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
private int fidalityID;
private int buildingLevel;
private int buildingFloor;
public HashMap<Integer, MobEquipment> equip = null;
private String nameOverride = "";
private int equipmentSetID = 0;
public int runeSetID = 0;
private int slot;
private Regions region = null;
@@ -187,8 +187,8 @@ public class NPC extends AbstractCharacter {
this.gridObjectType = GridObjectType.STATIC;
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
this.fidalityID = (rs.getInt("fidalityID"));
this.equipmentSetID = rs.getInt("equipmentSet");
this.runeSetID = rs.getInt("runeSet");
if (this.equipmentSetID == 0 && this.contract != null)
this.equipmentSetID = this.contract.equipmentSet;
@@ -200,8 +200,7 @@ public class NPC extends AbstractCharacter {
int mobBaseOverride = rs.getInt("npc_raceID");
if ((this.fidalityID != 0) || (mobBaseOverride != 0))
this.loadID = mobBaseOverride;
this.loadID = mobBaseOverride;
this.mobBase = MobBase.getMobBase(this.loadID);
this.level = rs.getByte("npc_level");
@@ -211,9 +210,6 @@ public class NPC extends AbstractCharacter {
try{
this.building = BuildingManager.getBuilding(buildingID);
if (this.building != null)
this.building.fidelityNpcs.put(currentID, this.building.fidelityNpcs.size() + 1);
}catch(Exception e){
this.building = null;
Logger.error( e.getMessage());
@@ -251,12 +247,6 @@ public class NPC extends AbstractCharacter {
int guildID = rs.getInt("npc_guildID");
if (this.fidalityID != 0){
if (this.building != null)
this.guild = this.building.getGuild();
else
this.guild = Guild.getGuild(guildID);
}else
if (this.building != null)
this.guild = this.building.getGuild();
else
@@ -264,9 +254,8 @@ public class NPC extends AbstractCharacter {
if (guildID != 0 && (this.guild == null || this.guild.isEmptyGuild()))
NPC.Oprhans.add(currentID);
else if(this.building == null && buildingID > 0) {
else if(this.building == null && buildingID > 0)
NPC.Oprhans.add(currentID);
}
if (this.guild == null)
this.guild = Guild.getErrantGuild();
@@ -290,8 +279,8 @@ public class NPC extends AbstractCharacter {
this.setParentZone(ZoneManager.getZoneByUUID(this.parentZoneID));
if (this.fidalityID != 0)
this.nameOverride = rs.getString("npc_name");
this.nameOverride = rs.getString("npc_name");
}catch(Exception e){
Logger.error(e);
@@ -365,7 +354,7 @@ public class NPC extends AbstractCharacter {
}
//add this npc to building
if (this.building != null && this.loadID != 0 && this.fidalityID == 0) {
if (this.building != null && this.loadID != 0) {
if (building.getBlueprint() != null){
@@ -808,7 +797,7 @@ public class NPC extends AbstractCharacter {
for (Mob toRemove : this.siegeMinionMap.keySet()) {
toRemove.setState(STATE.Disabled);
toRemove.state = STATE.Disabled;
try {
toRemove.clearEffects();
@@ -1173,9 +1162,6 @@ public class NPC extends AbstractCharacter {
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return;
if (this.fidalityID != 0)
DbManager.NPCQueries.LOAD_RUNES_FOR_FIDELITY_NPC(this);
try{
this.equip = loadEquipmentSet(this.equipmentSetID);
@@ -1475,14 +1461,14 @@ public class NPC extends AbstractCharacter {
siegeMinionMap.put(mob, slot);
mob.setInBuildingLoc(this.building, this);
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, mob.getInBuildingLoc());
Vector3fImmutable buildingWorldLoc = ZoneManager.convertLocalToWorld(this.building, mob.inBuildingLoc);
mob.setBindLoc(buildingWorldLoc);
mob.setLoc(buildingWorldLoc);
mob.setSpawnTime(10);
mob.setNpcOwner(this);
mob.setState(STATE.Awake);
mob.state = STATE.Awake;
return mob;
}
@@ -1619,10 +1605,6 @@ public class NPC extends AbstractCharacter {
return true;
}
public int getFidalityID() {
return fidalityID;
}
public int getBuildingLevel() {
return buildingLevel;
}
@@ -1648,21 +1630,12 @@ public class NPC extends AbstractCharacter {
if (buildingModel == null)
return -1;
if (npc.fidalityID != 0){
if (npc.building.fidelityNpcs.get(npc.currentID) != null){
slot = npc.building.fidelityNpcs.get(npc.currentID);
}
} else{
if (npc.building.getHirelings().containsKey(npc))
slot = (npc.building.getHirelings().get(npc));
}
if (npc.building.getHirelings().containsKey(npc))
slot = (npc.building.getHirelings().get(npc));
if (buildingModel.getNPCLocation(slot) == null)
return -1;
return slot;
}
@@ -1681,7 +1654,7 @@ public class NPC extends AbstractCharacter {
public static boolean UpdateEquipSetID(NPC npc, int equipSetID){
if (!EquipmentSetEntry.EquipmentSetMap.containsKey(equipSetID))
if (!NPCManager._equipmentSetMap.containsKey(equipSetID))
return false;
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))
+4 -68
View File
@@ -626,7 +626,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (this.pet != null)
this.dismissPet();
this.dismissNecroPets();
NPCManager.dismissNecroPets(this);
// remove flight job.
this.setTakeOffTime(0);
@@ -1586,77 +1586,13 @@ public class PlayerCharacter extends AbstractCharacter {
return this.pet;
}
public Mob getNecroPet(int i) {
return this.necroPets.get(i);
}
public static void auditNecroPets(PlayerCharacter player){
int removeIndex =0;
while(player.necroPets.size() >= 10){
if (removeIndex == player.necroPets.size())
break;
Mob toRemove = player.necroPets.get(removeIndex);
if (toRemove == null){
removeIndex++;
continue;
}
toRemove.dismissNecroPet(true);
player.necroPets.remove(toRemove);
removeIndex++;
}
}
public static void resetNecroPets(PlayerCharacter player){
for (Mob necroPet: player.necroPets)
if (necroPet.isPet())
necroPet.setMob();
}
public void spawnNecroPet(Mob mob) {
if (mob == null)
return;
if (mob.getMobBaseID() != 12021 && mob.getMobBaseID() != 12022)
return;
PlayerCharacter.auditNecroPets(this);
PlayerCharacter.resetNecroPets(this);
this.necroPets.add(mob);
}
public void dismissPet() {
if (this.pet != null) {
this.pet.dismiss();
this.pet = null;
}
}
public void dismissNecroPets() {
if (this.necroPets.isEmpty())
return;
for (Mob necroPet: this.necroPets){
try{
necroPet.dismissNecroPet(true);
}catch(Exception e){
necroPet.setState(STATE.Disabled);
Logger.error(e);
}
}
this.necroPets.clear();
}
//called to verify player has correct item equipped for casting.
public boolean validEquip(int slot, String type) {
@@ -4644,7 +4580,7 @@ public void dismissNecroPets() {
if (!currentPet.isSiege()) {
currentPet.setCombatTarget(null);
currentPet.setState(STATE.Disabled);
currentPet.state = STATE.Disabled;
if (currentPet.getParentZone() != null)
@@ -4655,7 +4591,7 @@ public void dismissNecroPets() {
}catch(Exception e){
Logger.error( e.getMessage());
}
currentPet.getPlayerAgroMap().clear();
currentPet.playerAgroMap.clear();
WorldGrid.RemoveWorldObject(currentPet);
DbManager.removeFromCache(currentPet);
-2
View File
@@ -16,13 +16,11 @@ import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
import engine.gameManager.DbManager;
import engine.powers.EffectsBase;
import engine.powers.effectmodifiers.ArmorPiercingEffectModifier;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
-1
View File
@@ -1,7 +1,6 @@
package engine.objects;
import engine.Enum;
import engine.Enum.PortalType;
import engine.gameManager.DbManager;
import engine.net.ByteBufferWriter;
-77
View File
@@ -1,77 +0,0 @@
// ·. · · · · .
// · ·
// · ·
//
// · · ·
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
import engine.gameManager.DbManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class SpecialLoot extends AbstractGameObject {
private int itemID;
private int dropChance;
private boolean dropOnDeath;
private boolean noSteal;
private int lootSetID;
public static HashMap<Integer,ArrayList<SpecialLoot>> LootMap = new HashMap<>();
/**
* ResultSet Constructor
*/
public SpecialLoot(ResultSet rs) throws SQLException {
super(rs);
this.itemID = rs.getInt("itemID");
this.dropChance = rs.getInt("dropChance");
this.dropOnDeath = rs.getBoolean("dropOnDeath");
this.noSteal = rs.getBoolean("noSteal");
}
public SpecialLoot(ResultSet rs,boolean specialLoot) throws SQLException {
super(rs);
this.lootSetID = rs.getInt("lootSet");
this.itemID = rs.getInt("itemID");
this.dropChance = rs.getInt("dropChance");
this.dropOnDeath = false;
this.noSteal = true;
}
/*
* Getters
*/
public int getItemID() {
return this.itemID;
}
public int getDropChance() {
return this.dropChance;
}
public boolean dropOnDeath() {
return this.dropOnDeath;
}
public boolean noSteal() {
return this.noSteal;
}
public static ArrayList<SpecialLoot> getSpecialLoot(int mobbaseID) {
return DbManager.SpecialLootQueries.GET_SPECIALLOOT(mobbaseID);
}
@Override
public void updateDatabase() {
}
}