Compare commits

..

7 Commits

Author SHA1 Message Date
FatBoy 84446eb726 AI tweaking 2025-01-09 08:41:36 -06:00
FatBoy 99f5a9c606 use new AI system 2025-01-09 08:24:20 -06:00
FatBoy 235b5e7375 remove pet properly when no owner found 2025-01-09 08:23:30 -06:00
FatBoy 7289f9e006 Easy AI 2025-01-08 21:06:02 -06:00
FatBoy 9c1afd9441 Easy AI 2025-01-08 21:01:06 -06:00
FatBoy 56226c71eb Easy AI 2025-01-08 20:41:03 -06:00
FatBoy c1eb6796f5 Easy AI first draft 2025-01-08 20:29:42 -06:00
118 changed files with 1739 additions and 3572 deletions
@@ -22,7 +22,6 @@ import java.util.HashMap;
public class dbItemBaseHandler extends dbHandlerBase {
public static final HashMap<Integer,Float> dexReductions = new HashMap<>();
public dbItemBaseHandler() {
}
@@ -46,14 +45,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
}
}
public void LOAD_DEX_REDUCTION(ItemBase itemBase) {
if(dexReductions.containsKey(itemBase.getUUID())){
itemBase.dexReduction = dexReductions.get(itemBase.getUUID());
}else{
itemBase.dexReduction = 0.0f;
}
}
public void LOAD_ANIMATIONS(ItemBase itemBase) {
ArrayList<Integer> tempList = new ArrayList<>();
@@ -103,21 +94,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
}
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty`")) {
ResultSet rs = preparedStatement.executeQuery();
// Check if a result was found
if (rs.next()) {
int ID = rs.getInt("ID");
float factor = rs.getInt("item_bulk_factor");
dexReductions.put(ID,factor);
}
} catch (SQLException e) {
Logger.error(e);
}
}
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
+7 -14
View File
@@ -15,12 +15,9 @@ import engine.Enum.GameObjectType;
import engine.Enum.TargetColor;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.BuildingManager;
import engine.gameManager.PowersManager;
import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import engine.util.StringUtils;
@@ -342,8 +339,7 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "isMoving : " + targetPC.isMoving();
output += newline;
output += "Zerg Multiplier : " + targetPC.ZergMultiplier+ newline;
output += "Hidden : " + targetPC.getHidden();
output += "Zerg Multiplier : " + targetPC.ZergMultiplier;
break;
case NPC:
@@ -498,16 +494,13 @@ public class InfoCmd extends AbstractDevCmd {
output += newline;
output += "No building found." + newline;
}
output += "Damage: " + targetMob.mobBase.getDamageMin() + " - " + targetMob.mobBase.getDamageMax() + newline;
output += "ATR: " + targetMob.mobBase.getAttackRating() + newline;
output += "DEF: " + targetMob.defenseRating + newline;
output += "RANGE: " + targetMob.getRange() + newline;
output += "Effects:" + newline;
for(MobBaseEffects mbe : targetMob.mobBase.mobbaseEffects){
EffectsBase eb = PowersManager.getEffectByToken(mbe.getToken());
output += eb.getName() + newline;
int max = (int)(4.882 * targetMob.level + 121.0);
if(max > 321){
max = 321;
}
int min = (int)(4.469 * targetMob.level - 3.469);
output += "Min Loot Roll = " + min;
output += "Max Loot Roll = " + max;
break;
case Item: //intentional passthrough
case MobLoot:
@@ -49,8 +49,6 @@ public class PrintSkillsCmd extends AbstractDevCmd {
+ skill.getModifiedAmount() + '('
+ skill.getTotalSkillPercet() + " )");
}
//throwbackInfo(pc, "= = = = = NEW CALCULATIONS = = = = =");
// PlayerCombatStats.PrintSkillsToClient(pc);
} else
throwbackInfo(pc, "Skills not found for player");
}
+21 -30
View File
@@ -57,36 +57,27 @@ public class PrintStatsCmd extends AbstractDevCmd {
public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) {
String newline = "\r\n ";
String newOut = "Server stats for Player " + tar.getFirstName() + newline;
newOut += "HEALTH: " + tar.getHealth() + " / " + tar.getHealthMax() + newline;
newOut += "MANA: " + tar.getMana() + " / " + tar.getManaMax() + newline;
newOut += "STAMINA: " + tar.getStamina() + " / " + tar.getStaminaMax() + newline;
newOut += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
newOut += "Stats Base (Modified)" + newline;
newOut += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline;
newOut += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline;
newOut += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline;
newOut += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline;
newOut += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline;
newOut += "Move Speed: " + tar.getSpeed() + newline;
newOut += "Health Regen: " + tar.combatStats.healthRegen + newline;
newOut += "Mana Regen: " + tar.combatStats.manaRegen + newline;
newOut += "Stamina Regen: " + tar.combatStats.staminaRegen + newline;
newOut += "DEFENSE: " + tar.combatStats.defense + newline;
newOut += "HAND ONE" + newline;
newOut += "ATR: " + tar.combatStats.atrHandOne + newline;
newOut += "MIN: " + tar.combatStats.minDamageHandOne + newline;
newOut += "MAX: " + tar.combatStats.maxDamageHandOne + newline;
newOut += "RANGE: " + tar.combatStats.rangeHandOne + newline;
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandOne + newline;
newOut += "HAND TWO" + newline;
newOut += "ATR: " + tar.combatStats.atrHandTwo + newline;
newOut += "MIN: " + tar.combatStats.minDamageHandTwo + newline;
newOut += "MAX: " + tar.combatStats.maxDamageHandTwo + newline;
newOut += "RANGE: " + tar.combatStats.rangeHandTwo + newline;
newOut += "ATTACK SPEED: " + tar.combatStats.attackSpeedHandTwo + newline;
throwbackInfo(pc, newOut);
String out = "Server stats for Player " + tar.getFirstName() + newline;
out += "Unused Stats: " + tar.getUnusedStatPoints() + newline;
out += "Stats Base (Modified)" + newline;
out += " Str: " + (int) tar.statStrBase + " (" + tar.getStatStrCurrent() + ')' + ", maxStr: " + tar.getStrMax() + newline;
out += " Dex: " + (int) tar.statDexBase + " (" + tar.getStatDexCurrent() + ')' + ", maxDex: " + tar.getDexMax() + newline;
out += " Con: " + (int) tar.statConBase + " (" + tar.getStatConCurrent() + ')' + ", maxCon: " + tar.getConMax() + newline;
out += " Int: " + (int) tar.statIntBase + " (" + tar.getStatIntCurrent() + ')' + ", maxInt: " + tar.getIntMax() + newline;
out += " Spi: " + (int) tar.statSpiBase + " (" + tar.getStatSpiCurrent() + ')' + ", maxSpi: " + tar.getSpiMax() + newline;
throwbackInfo(pc, out);
out = "Health: " + tar.getHealth() + ", maxHealth: " + tar.getHealthMax() + newline;
out += "Mana: " + tar.getMana() + ", maxMana: " + tar.getManaMax() + newline;
out += "Stamina: " + tar.getStamina() + ", maxStamina: " + tar.getStaminaMax() + newline;
out += "Defense: " + tar.getDefenseRating() + newline;
out += "Main Hand: atr: " + tar.getAtrHandOne() + ", damage: " + tar.getMinDamageHandOne() + " to " + tar.getMaxDamageHandOne() + ", speed: " + tar.getSpeedHandOne() + newline;
out += "Off Hand: atr: " + tar.getAtrHandTwo() + ", damage: " + tar.getMinDamageHandTwo() + " to " + tar.getMaxDamageHandTwo() + ", speed: " + tar.getSpeedHandTwo() + newline;
out += "isAlive: " + tar.isAlive() + ", Combat: " + tar.isCombat() + newline;
out += "Move Speed: " + tar.getSpeed() + newline;
out += "Health Regen: " + tar.getRegenModifier(Enum.ModType.HealthRecoverRate) + newline;
out += "Mana Regen: " + tar.getRegenModifier(Enum.ModType.ManaRecoverRate) + newline;
out += "Stamina Regen: " + tar.getRegenModifier(Enum.ModType.StaminaRecoverRate) + newline;
throwbackInfo(pc, out);
}
public void printStatsMob(PlayerCharacter pc, Mob tar) {
@@ -1,6 +1,5 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.LootManager;
import engine.gameManager.ZoneManager;
@@ -27,52 +26,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
String newline = "\r\n ";
String output;
if(target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
int ATR = Integer.parseInt(words[0]);
int DEF = Integer.parseInt(words[1]);
int attacks = Integer.parseInt(words[2]);
int hits = 0;
int misses = 0;
int defaultHits = 0;
int defualtMisses = 0;
float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
float convertedChance = chance * 100;
output = "" + newline;
output += "DEF VS ATR SIMULATION: " + attacks + " ATTACKS SIMULATED" + newline;
output += "DEF = " + DEF + newline;
output += "ATR = " + ATR + newline;
output += "CHANCE TO LAND HIT: " + convertedChance + "%" + newline;
if(convertedChance < 5){
output += "CHANCE ADJUSTED TO 5.0%" + newline;
convertedChance = 5.0f;
}
if(convertedChance > 95){
output += "CHANCE ADJUSTED TO 95.0%" + newline;
convertedChance = 95.0f;
}
for(int i = 0; i < attacks; i++){
int roll = ThreadLocalRandom.current().nextInt(101);
if(roll <= convertedChance){
hits += 1;
}else{
misses += 1;
}
}
float totalHits = defaultHits + hits;
float totalMisses = defualtMisses + misses;
float hitPercent = Math.round(totalHits / attacks * 100);
float missPercent = Math.round(totalMisses / attacks * 100);
output += "HITS LANDED: " + (defaultHits + hits) + "(" + Math.round(hitPercent) + "%)" + newline;
output += "HITS MISSED: " + (defualtMisses + misses) + "(" + Math.round(missPercent) + "%)";
throwbackInfo(playerCharacter,output);
return;
}
try
{
simCount = Integer.parseInt(words[0]);
+57 -143
View File
@@ -301,17 +301,6 @@ public enum CombatManager {
if (target == null)
return 0;
//pet to assist in attacking target
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter attacker = (PlayerCharacter)abstractCharacter;
if(attacker.getPet() != null){
Mob pet = attacker.getPet();
if(pet.combatTarget == null && pet.assist)
pet.setCombatTarget(attacker.combatTarget);
}
}
//target must be valid type
if (AbstractWorldObject.IsAbstractCharacter(target)) {
@@ -494,24 +483,16 @@ public enum CombatManager {
createTimer(abstractCharacter, slot, 20, true); //2 second for no weapon
else {
int wepSpeed = (int) (wb.getSpeed());
if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter pc = (PlayerCharacter)abstractCharacter;
if(slot == 1){
wepSpeed = (int) pc.combatStats.attackSpeedHandOne;
}else{
wepSpeed = (int) pc.combatStats.attackSpeedHandTwo;
}
}else {
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None));
if (weapon != null && weapon.getBonusPercent(ModType.WeaponSpeed, SourceType.None) != 0f) //add weapon speed bonus
wepSpeed *= (1 + weapon.getBonus(ModType.WeaponSpeed, SourceType.None));
if (abstractCharacter.getBonuses() != null && abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None) != 0f) //add effects speed bonus
wepSpeed *= (1 + abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None));
if (abstractCharacter.getBonuses() != null && abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None) != 0f) //add effects speed bonus
wepSpeed *= (1 + abstractCharacter.getBonuses().getFloatPercentAll(ModType.AttackDelay, SourceType.None));
if (wepSpeed < 10)
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
if (wepSpeed < 10)
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
}
createTimer(abstractCharacter, slot, wepSpeed, true);
}
@@ -555,29 +536,15 @@ public enum CombatManager {
if (target == null)
return;
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
PlayerCharacter pc = (PlayerCharacter) ac;
pc.combatStats.calculateATR(true);
pc.combatStats.calculateATR(false);
if (mainHand) {
atr = pc.combatStats.atrHandOne;
minDamage = pc.combatStats.minDamageHandOne;
maxDamage = pc.combatStats.maxDamageHandOne;
} else {
atr = pc.combatStats.atrHandTwo;
minDamage = pc.combatStats.minDamageHandTwo;
maxDamage = pc.combatStats.maxDamageHandTwo;
}
}else {
if (mainHand) {
atr = ac.getAtrHandOne();
minDamage = ac.getMinDamageHandOne();
maxDamage = ac.getMaxDamageHandOne();
} else {
atr = ac.getAtrHandTwo();
minDamage = ac.getMinDamageHandTwo();
maxDamage = ac.getMaxDamageHandTwo();
}
if (mainHand) {
atr = ac.getAtrHandOne();
minDamage = ac.getMinDamageHandOne();
maxDamage = ac.getMaxDamageHandOne();
} else {
atr = ac.getAtrHandTwo();
minDamage = ac.getMinDamageHandTwo();
maxDamage = ac.getMaxDamageHandTwo();
}
boolean tarIsRat = false;
@@ -671,12 +638,7 @@ public enum CombatManager {
}
} else {
AbstractCharacter tar = (AbstractCharacter) target;
if(tar.getObjectType().equals(GameObjectType.PlayerCharacter)){
((PlayerCharacter)tar).combatStats.calculateDefense();
defense = ((PlayerCharacter)tar).combatStats.defense;
}else {
defense = tar.getDefenseRating();
}
defense = tar.getDefenseRating();
handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target
}
@@ -685,7 +647,7 @@ public enum CombatManager {
//Get hit chance
//int chance;
//float dif = atr - defense;
float dif = atr - defense;
//if (dif > 100)
// chance = 94;
@@ -700,8 +662,9 @@ public enum CombatManager {
DeferredPowerJob dpj = null;
boolean hitLanded = LandHit((int)atr,(int)defense);
if (hitLanded) {
if (LandHit((int)atr,(int)defense)) {
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
updateAttackTimers((PlayerCharacter) ac, target, true);
@@ -730,13 +693,7 @@ public enum CombatManager {
PlayerBonuses bonus = ac.getBonuses();
float attackRange = getWeaponRange(wb, bonus);
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange);
}
}else{
dpj.attack(target, attackRange);
}
dpj.attack(target, attackRange);
if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518))
((PlayerCharacter) ac).setWeaponPower(dpj);
@@ -751,13 +708,7 @@ public enum CombatManager {
if (dpj != null && dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) {
float attackRange = getWeaponRange(wb, bonuses);
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange);
}
}else{
dpj.attack(target, attackRange);
}
dpj.attack(target, attackRange);
}
}
@@ -864,22 +815,6 @@ public enum CombatManager {
else
damage = calculateDamage(ac, tarAc, minDamage, maxDamage, damageType, resists);
if(weapon != null && weapon.effects != null){
float armorPierce = 0;
for(Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
if(mod.modType.equals(ModType.ArmorPiercing)){
armorPierce += mod.minMod * (mod.getRamp() * eff.getTrains());
}
}
}
if(armorPierce > 0){
damage *= 1 - armorPierce;
}
}
//Resists.handleFortitude(tarAc,damageType,damage);
float d = 0f;
errorTrack = 12;
@@ -932,18 +867,27 @@ public enum CombatManager {
if (weapon != null && tarAc != null && tarAc.isAlive()) {
if(weapon.effects != null){
for (Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
if(mod.modType.equals(ModType.WeaponProc)){
ConcurrentHashMap<String, Effect> effects = weapon.getEffects();
for (Effect eff : effects.values()) {
if (eff == null)
continue;
HashSet<AbstractEffectModifier> aems = eff.getEffectModifiers();
if (aems != null) {
for (AbstractEffectModifier aem : aems) {
if (!tarAc.isAlive())
break;
if (aem instanceof WeaponProcEffectModifier) {
int procChance = ThreadLocalRandom.current().nextInt(100);
if (procChance < MBServerStatics.PROC_CHANCE) {
try {
((WeaponProcEffectModifier) mod).applyProc(ac, target);
}catch(Exception e){
Logger.error(eff.getName() + " Failed To Cast Proc");
}
}
if (procChance < MBServerStatics.PROC_CHANCE)
((WeaponProcEffectModifier) aem).applyProc(ac, target);
}
}
}
@@ -972,13 +916,7 @@ public enum CombatManager {
if (wp.requiresHitRoll() == false) {
PlayerBonuses bonus = ac.getBonuses();
float attackRange = getWeaponRange(wb, bonus);
if(specialCaseHitRoll(dpj.getPowerToken())) {
if(hitLanded) {
dpj.attack(target, attackRange);
}
}else{
dpj.attack(target, attackRange);
}
dpj.attack(target, attackRange);
} else
((PlayerCharacter) ac).setWeaponPower(null);
}
@@ -1085,12 +1023,10 @@ public enum CombatManager {
//calculate resists in if any
if (resists != null)
damage = resists.getResistedDamage(source, target, damageType, damage, 0);
return damage;
return resists.getResistedDamage(source, target, damageType, damage, 0);
else
return damage;
}
private static void sendPassiveDefenseMessage(AbstractCharacter source, ItemBase wb, AbstractWorldObject target, int passiveType, DeferredPowerJob dpj, boolean mainHand) {
@@ -1244,14 +1180,6 @@ public enum CombatManager {
private static boolean testPassive(AbstractCharacter source, AbstractCharacter target, String type) {
if(target.getBonuses() != null)
if(target.getBonuses().getBool(ModType.Stunned, SourceType.None))
return false;
if(source.getBonuses() != null)
if(source.getBonuses().getBool(ModType.IgnorePassiveDefense, SourceType.None))
return false;
float chance = target.getPassiveChance(type, source.getLevel(), true);
if (chance == 0f)
@@ -1262,7 +1190,7 @@ public enum CombatManager {
if (chance > 75f)
chance = 75f;
int roll = ThreadLocalRandom.current().nextInt(1,100);
int roll = ThreadLocalRandom.current().nextInt(100);
return roll < chance;
@@ -1440,9 +1368,9 @@ public enum CombatManager {
Resists resists = ac.getResists();
if (resists != null) {
if (resists != null)
amount = resists.getResistedDamage(target, ac, ds.getDamageType(), amount, 0);
}
total += amount;
}
@@ -1525,31 +1453,17 @@ public enum CombatManager {
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
}
public static boolean LandHit(int ATR, int DEF){
public static boolean LandHit(int C5, int D5){
//float chance = (ATR-((ATR+DEF) * 0.315f)) / ((DEF-((ATR+DEF) * 0.315f)) + (ATR-((ATR+DEF) * 0.315f)));
//float convertedChance = chance * 100;
float chance = (C5-((C5+D5)*.315f)) / ((D5-((C5+D5)*.315f)) + (C5-((C5+D5)*.315f)));
int convertedChance = Math.round(chance * 100);
//convertedChance = Math.max(5, Math.min(95, convertedChance));
int roll = ThreadLocalRandom.current().nextInt(101);
//if(roll <= 5)//always 5% chance to miss
// return false;
if(roll < 5)//always 5% chance ot miss
return false;
//if(roll >= 95)//always 5% chance to hit
// return true;
float chance = PlayerCombatStats.getHitChance(ATR,DEF);
return chance >= roll;
}
public static boolean specialCaseHitRoll(int powerID){
switch(powerID) {
case 563200808: // Naargal's Bite
case 563205337: // Naargal's Dart
case 563205930: // Sword of Saint Malorn
return true;
default:
return false;
}
return roll <= convertedChance;
}
}
+1 -2
View File
@@ -98,8 +98,7 @@ public enum ConfigManager {
MB_MAGICBOT_FORTOFIX,
MB_MAGICBOT_RECRUIT,
MB_MAGICBOT_MAGICBOX,
MB_MAGICBOT_ADMINLOG,
MB_WORLD_BOXLIMIT;
MB_MAGICBOT_ADMINLOG;
// Map to hold our config pulled in from the environment
// We also use the config to point to the current message pump
-19
View File
@@ -177,11 +177,6 @@ public enum DevCmdManager {
return false;
}
if(!pcSender.getTimestamps().containsKey("DEVCOMMAND"))
pcSender.getTimestamps().put("DEVCOMMAND",System.currentTimeMillis() - 1500L);
else if(System.currentTimeMillis() - pcSender.getTimestamps().get("DEVCOMMAND") < 1000L)
return false;
//kill any commands not available to everyone on production server
//only admin level can run dev commands on production
boolean playerAllowed = false;
@@ -194,20 +189,6 @@ public enum DevCmdManager {
case "gimme":
case "goto":
case "teleportmode":
case "printbonuses":
playerAllowed = true;
if (!a.status.equals(Enum.AccountStatus.ADMIN))
target = pcSender;
break;
}
}else{
switch (adc.getMainCmdString()) {
case "printresists":
case "printstats":
case "printskills":
case "printpowers":
case "printbonuses":
//case "gimme":
playerAllowed = true;
if (!a.status.equals(Enum.AccountStatus.ADMIN))
target = pcSender;
+4 -5
View File
@@ -76,7 +76,8 @@ public enum LootManager {
public static void GenerateMobLoot(Mob mob) {
if(mob == null){
//no loot for safezones
if(mob == null || mob.getSafeZone()){
return;
}
@@ -185,16 +186,14 @@ public enum LootManager {
// Iterate all entries in this bootySet and process accordingly
Zone zone = ZoneManager.findSmallestZone(mob.loc);
for (BootySetEntry bse : entries) {
switch (bse.bootyType) {
case "GOLD":
if (zone != null && zone.getSafeZone() == (byte)1)
return; // no loot to drop in safezones
GenerateGoldDrop(mob, bse, inHotzone);
break;
case "LOOT":
if (zone != null && zone.getSafeZone() == (byte)1)
if (mob.getSafeZone())
return; // no loot to drop in safezones
dropRate = LootManager.NORMAL_DROP_RATE;
+3 -7
View File
@@ -67,10 +67,8 @@ public enum MovementManager {
return;
if (toMove.getObjectType().equals(GameObjectType.PlayerCharacter)) {
if (((PlayerCharacter) toMove).isCasting()) {
((PlayerCharacter) toMove).updateLocation();
((PlayerCharacter) toMove).updateMovementState();
}
if (((PlayerCharacter) toMove).isCasting())
((PlayerCharacter) toMove).update(false);
}
@@ -410,9 +408,7 @@ public enum MovementManager {
if (bonus.getBool(ModType.Stunned, SourceType.None) || bonus.getBool(ModType.CannotMove, SourceType.None))
continue;
//member.update(false);
member.updateLocation();
member.updateMovementState();
member.update(false);
// All checks passed, let's move the player
+35 -224
View File
@@ -10,7 +10,6 @@ package engine.gameManager;
import engine.Enum.*;
import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid;
import engine.db.handlers.dbEffectsBaseHandler;
import engine.db.handlers.dbPowerHandler;
@@ -166,20 +165,12 @@ public enum PowersManager {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if(pc == null)
return;
if(!pc.isFlying() && powersBaseByToken.get(msg.getPowerUsedID()) != null && powersBaseByToken.get(msg.getPowerUsedID()).isSpell) //cant be sitting if flying
CombatManager.toggleSit(false,origin);
if(pc.isMoving())
pc.stopMovement(pc.getMovementLoc());
if(msg.getPowerUsedID() == 429429978){
applyPower(origin.getPlayerCharacter(),origin.getPlayerCharacter(),origin.getPlayerCharacter().getLoc(),429429978,msg.getNumTrains(),false);
return;
}
if (usePowerA(msg, origin, sendCastToSelf)) {
// Cast failed for some reason, reset timer
@@ -206,8 +197,7 @@ public enum PowersManager {
msg.setUnknown04(1);
if (useMobPowerA(msg, caster)) {
if(pb.token == -1994153779)
InterestManager.setObjectDirty(caster);
//sendMobPowerMsg(caster,2,msg); //Lol wtf was i thinking sending msg's to mobs... ZZZZ
}
}
@@ -226,16 +216,16 @@ public enum PowersManager {
City city = ZoneManager.getCityAtLocation(playerCharacter.loc);
if (city == null) {
failed = true;
}//else{
// Bane bane = city.getBane();
// if (bane == null) {
// failed = true;
// }else{
// if(!bane.getSiegePhase().equals(SiegePhase.WAR)){
// failed = true;
// }
// }
//}
}else{
Bane bane = city.getBane();
if (bane == null) {
failed = true;
}else{
if(!bane.getSiegePhase().equals(SiegePhase.WAR)){
failed = true;
}
}
}
if(failed){
//check to see if we are at an active mine
Zone zone = ZoneManager.findSmallestZone(playerCharacter.loc);
@@ -252,15 +242,8 @@ public enum PowersManager {
}
}
if(failed) {
playerCharacter.setIsCasting(false);
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(msg.getPowerUsedID());
Dispatch dispatch = Dispatch.borrow(playerCharacter, recyclePowerMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
if(failed)
return false;
}
}
if (MBServerStatics.POWERS_DEBUG) {
@@ -346,18 +329,17 @@ public enum PowersManager {
// Check powers for normal users
if(msg.getPowerUsedID() != 421084024) {
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
if (!playerCharacter.isCSR()) {
if (!MBServerStatics.POWERS_DEBUG) {
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerUsedID()))
if (!playerCharacter.isCSR()) {
if (!MBServerStatics.POWERS_DEBUG) {
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
Logger.info("usePowerA(): Cheat attempted? '" + msg.getPowerUsedID() + "' was not associated with " + playerCharacter.getName());
return true;
}
} else
CSRCast = true;
Logger.info("usePowerA(): Cheat attempted? '" + msg.getPowerUsedID() + "' was not associated with " + playerCharacter.getName());
return true;
}
} else
CSRCast = true;
}
// get numTrains for power
int trains = msg.getNumTrains();
@@ -367,10 +349,8 @@ public enum PowersManager {
msg.setNumTrains(trains);
}
//double stack point values for some useless disc spells
switch(pb.token){
case 429420458: // BH eyes
case 429601664: // huntsman skin the beast
msg.setNumTrains(msg.getNumTrains() * 2);
break;
}
@@ -510,23 +490,6 @@ public enum PowersManager {
}
}
if(!passed){
if (playerCharacter.getRace().getName().contains("Shade")) {
if(playerCharacter.getHidden() > 0){
switch(msg.getPowerUsedID()){
case -1851459567:
case 2094922127:
case -355707373:
case 246186475:
case 666419835:
case 1480354319:
passed = true;
break;
}
}
}
}
if (!passed)
return true;
}
@@ -639,12 +602,12 @@ public enum PowersManager {
}
// update cast (use skill) fail condition
if(pb.token != 429396028 && pb.breaksForm) {
if(pb.token != 429396028) {
playerCharacter.cancelOnCast();
}
// update castSpell (use spell) fail condition if spell
if (pb.isSpell() && pb.breaksForm)
if (pb.isSpell())
playerCharacter.cancelOnSpell();
// get cast time in ms.
@@ -785,11 +748,10 @@ public enum PowersManager {
// make person casting stand up if spell (unless they're casting a chant which does not make them stand up)
// update cast (use skill) fail condition
if(pb.breaksForm)
caster.cancelOnCast();
caster.cancelOnCast();
// update castSpell (use spell) fail condition if spell
if (pb.isSpell() && pb.breaksForm)
if (pb.isSpell())
caster.cancelOnSpell();
// get cast time in ms.
@@ -825,36 +787,17 @@ public enum PowersManager {
if (playerCharacter == null || msg == null)
return;
//handle sprint for bard sprint
if(msg.getPowerUsedID() == 429005674){
msg.setPowerUsedID(429611355);
}
//handle root and snare break for wildkin's chase
if(msg.getPowerUsedID() == 429494441) {
//if((msg.getPowerUsedID() == 429495514 || msg.getPowerUsedID() == 429407306) && playerCharacter.getRace().getName().toLowerCase().contains("shade")){
// //use sneak instead of hide
// PowersBase pb = PowersManager.getPowerByToken(429397210);
// int offsetTrains = (40 - msg.getNumTrains()) ;
// applyPower(playerCharacter,playerCharacter,playerCharacter.loc,429397210,msg.getNumTrains(),false);
// applyPower(playerCharacter,playerCharacter,playerCharacter.loc,427857146,offsetTrains,false);
//}
if(msg.getPowerUsedID() == 429494441) {//wildkins chase
playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true);
playerCharacter.removeEffectBySource(EffectSourceType.Snare,40,true);
}
//handle power block portion for shade hide
if(playerCharacter.getRace().getName().contains("Shade")) {
if (msg.getPowerUsedID() == 429407306 || msg.getPowerUsedID() == 429495514) {
int trains = msg.getNumTrains() - 1;
if (trains < 1)
trains = 1;
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, 429397210, trains, false);
playerCharacter.removeEffectBySource(EffectSourceType.Invisibility,40,true);
applyPower(playerCharacter, playerCharacter, playerCharacter.loc, msg.getPowerUsedID(), msg.getNumTrains(), false);
}
}
if(msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()) {
PlayerCharacter target = PlayerCharacter.getPlayerCharacter(msg.getTargetID());
if (msg.getPowerUsedID() == 429601664)
if(target.getPromotionClassID() != 2516)
PlayerCharacter.getPlayerCharacter(msg.getTargetID()).removeEffectBySource(EffectSourceType.Transform, msg.getNumTrains(), true);
}
if (playerCharacter.isCasting()) {
playerCharacter.update(false);
playerCharacter.updateStamRegen(-100);
@@ -2465,13 +2408,6 @@ public enum PowersManager {
dodgeMsg.setTargetID(awo.getObjectUUID());
sendPowerMsg(pc, 4, dodgeMsg);
return true;
} else if (testPassive(pc, tarAc, "Block")) {
// Dodge fired, send dodge message
PerformActionMsg dodgeMsg = new PerformActionMsg(msg);
dodgeMsg.setTargetType(awo.getObjectType().ordinal());
dodgeMsg.setTargetID(awo.getObjectUUID());
sendPowerMsg(pc, 4, dodgeMsg);
return true;
}
}
return false;
@@ -2519,12 +2455,7 @@ public enum PowersManager {
if (AbstractWorldObject.IsAbstractCharacter(awo)) {
AbstractCharacter tarAc = (AbstractCharacter) awo;
// Handle Dodge passive
boolean passiveFired = false;
passiveFired = testPassive(caster, tarAc, "Dodge");
if(!passiveFired)
passiveFired = testPassive(caster, tarAc, "Block");
return passiveFired;
return testPassive(caster, tarAc, "Dodge");
}
return false;
} else
@@ -2913,126 +2844,6 @@ public enum PowersManager {
}
}
public static boolean breakForm(int token) {
switch (token) {
case 429505865:
case 429407561:
case 429492073:
case 429644123:
case 429393769:
case 429545819:
case 429426537:
case 429590377:
case 429508425:
case 429541193:
case 429573961:
case 427924330:
case 429402918:
case 429545688:
case 429005674:
case 429637823:
case 429590426:
case 428066972:
case 429441862:
case 431611756:
case 431578988:
case 429502506:
case 429398191:
case 429447384:
case 428892191:
case 431579167:
case 430977067:
case 429409100:
case 429441868:
case 429594877:
case 427908971:
case 683741153:
case 429770569:
case 429452379:
case 429605055:
case 429086971:
case 429443230:
case 429505400:
case 429492122:
case 429643992:
case 550062236:
case 429498252:
case 429611224:
case 429441834:
case 428918940:
case 429633739:
case 429633579:
case 429568043:
case 429048646:
case 428392639:
case 428425407:
case 429054168:
case 429021400:
case 428955864:
case 429119704:
case 428890328:
case 428923096:
case 429218008:
case 429086936:
case 428988632:
case 428688204:
case 429514603:
case 428924959:
case 429393818:
case 429720966:
case 428982463:
case 427933887:
case 429572287:
case 429501222:
case 430694431:
case 429436131:
case 430006124:
case 429611355:
case 428005600:
case 427935608:
case 428949695:
case 427988218:
case 429414616:
case 429496495:
case 429428796:
case 563795754:
case 428988217:
case 429432716:
case 428955899:
case 429393286:
case 550062220:
case 429495557:
case 429401278:
case 428377478:
case 429409094:
case 428191947:
case 429434474:
case 429403363:
case 429512920:
case 429419611:
case 429645676:
case 429602895:
case 429605071:
case 429592428:
case 429500010:
case 429406602:
case 429426586:
case 429633898:
case 550062212:
case 429994027:
case 430813227:
case 429928491:
case 430026795:
case 429517915:
case 431854842:
case 429767544:
case 429502507:
case 428398816:
case 429446315:
return false;
}
return true;
}
}
@@ -93,10 +93,13 @@ public enum SimulationManager {
}
try {
if ((_updatePulseTime != 0) && (System.currentTimeMillis() > _updatePulseTime))
if ((_updatePulseTime != 0)
&& (System.currentTimeMillis() > _updatePulseTime))
pulseUpdate();
} catch (Exception e) {
Logger.error("Fatal error in Update Pulse: DISABLED");
Logger.error(
"Fatal error in Update Pulse: DISABLED");
// _runegatePulseTime = 0;
}
try {
@@ -157,11 +160,7 @@ public enum SimulationManager {
if (player == null)
continue;
try {
player.update(false);
}catch(Exception e){
}
player.update(false);
}
_updatePulseTime = System.currentTimeMillis() + 500;
+1 -1
View File
@@ -68,7 +68,7 @@ public abstract class AbstractJob implements Runnable {
this.markStopRunTime();
}
public abstract void doJob();
protected abstract void doJob();
public void executeJob(String threadName) {
this.workerID.set(threadName);
+1 -1
View File
@@ -17,7 +17,7 @@ public abstract class AbstractScheduleJob extends AbstractJob {
}
@Override
public abstract void doJob();
protected abstract void doJob();
public void cancelJob() {
JobScheduler.getInstance().cancelScheduledJob(this);
+1 -1
View File
@@ -16,7 +16,7 @@ public class JobContainer implements Comparable<JobContainer> {
final long timeOfExecution;
final boolean noTimer;
public JobContainer(AbstractJob job, long timeOfExecution) {
JobContainer(AbstractJob job, long timeOfExecution) {
if (job == null) {
throw new IllegalArgumentException("No 'null' jobs allowed.");
}
-75
View File
@@ -1,75 +0,0 @@
package engine.job;
import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
public class JobThread implements Runnable {
private final AbstractJob currentJob;
private final ReentrantLock lock = new ReentrantLock();
private static Long nextThreadPrint;
public JobThread(AbstractJob job){
this.currentJob = job;
}
@Override
public void run() {
try {
if (this.currentJob != null) {
if (lock.tryLock(5, TimeUnit.SECONDS)) { // Timeout to prevent deadlock
try {
this.currentJob.doJob();
} finally {
lock.unlock();
}
} else {
Logger.warn("JobThread could not acquire lock in time, skipping job.");
}
}
} catch (Exception e) {
Logger.error(e);
}
}
public static void startJobThread(AbstractJob job){
JobThread jobThread = new JobThread(job);
Thread thread = new Thread(jobThread);
thread.setName("JOB THREAD: " + job.getWorkerID());
thread.start();
if(JobThread.nextThreadPrint == null){
JobThread.nextThreadPrint = System.currentTimeMillis();
}else{
if(JobThread.nextThreadPrint < System.currentTimeMillis()){
JobThread.tryPrintThreads();
JobThread.nextThreadPrint = System.currentTimeMillis() + 10000L;
}
}
}
public static void tryPrintThreads(){
ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
while (rootGroup.getParent() != null) {
rootGroup = rootGroup.getParent();
}
// Estimate the number of threads
int activeThreads = rootGroup.activeCount();
// Create an array to hold the threads
Thread[] threads = new Thread[activeThreads];
// Get the active threads
rootGroup.enumerate(threads, true);
int availableThreads = Runtime.getRuntime().availableProcessors();
// Print the count
if(threads.length > 30)
Logger.info("Total threads in application: " + threads.length + " / " + availableThreads);
}
}
+3 -6
View File
@@ -58,13 +58,10 @@ public class JobWorker extends ControlledRunnable {
} else {
// execute the new job..
//this.currentJob.executeJob(this.getThreadName());
if(this.currentJob != null) {
JobThread.startJobThread(this.currentJob);
this.currentJob = null;
}
this.currentJob.executeJob(this.getThreadName());
this.currentJob = null;
}
Thread.yield();
}
return true;
}
+1 -1
View File
@@ -45,7 +45,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
}
@Override
public abstract void doJob();
protected abstract void doJob();
@Override
protected abstract void _cancelJob();
+1 -1
View File
@@ -29,7 +29,7 @@ public class ActivateBaneJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
City city;
+1 -1
View File
@@ -27,7 +27,7 @@ public class AttackJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
CombatManager.doCombat(this.source, slot);
}
+1 -1
View File
@@ -24,7 +24,7 @@ public class BaneDefaultTimeJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
//bane already set.
if (this.bane.getLiveDate() != null) {
+1 -1
View File
@@ -97,7 +97,7 @@ public class BasicScheduledJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
if (execution == null) {
Logger.error("BasicScheduledJob executed with nothing to execute.");
return;
+1 -1
View File
@@ -22,7 +22,7 @@ public class BonusCalcJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.ac != null) {
this.ac.applyBonuses();
+1 -1
View File
@@ -22,7 +22,7 @@ public class CSessionCleanupJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
SessionManager.cSessionCleanup(secKey);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ public class ChangeAltitudeJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.ac != null)
MovementManager.finishChangeAltitude(ac, targetAlt);
}
+1 -1
View File
@@ -36,7 +36,7 @@ public class ChantJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.aej == null || this.source == null || this.target == null || this.action == null || this.power == null || this.source == null || this.eb == null)
return;
PlayerBonuses bonuses = null;
+1 -1
View File
@@ -29,7 +29,7 @@ public class CloseGateJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (building == null) {
Logger.error("Rungate building was null");
+1 -3
View File
@@ -37,7 +37,7 @@ public class DamageOverTimeJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.target.getObjectType().equals(GameObjectType.Building)
&& ((Building) this.target).isVulnerable() == false) {
_cancelJob();
@@ -60,8 +60,6 @@ public class DamageOverTimeJob extends AbstractEffectJob {
if (this.iteration < 0) {
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
if (AbstractWorldObject.IsAbstractCharacter(source))
eb.startEffect((AbstractCharacter) this.source, this.target, this.trains, this);
return;
}
this.skipSendEffect = true;
+1 -1
View File
@@ -28,7 +28,7 @@ public class DatabaseUpdateJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.ago == null)
return;
ago.removeDatabaseJob(this.type, false);
+1 -1
View File
@@ -29,7 +29,7 @@ public class DebugTimerJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.pc == null) {
return;
}
+1 -1
View File
@@ -37,7 +37,7 @@ public class DeferredPowerJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
//Power ended with no attack, cancel weapon power boost
if (this.source != null && this.source instanceof PlayerCharacter) {
((PlayerCharacter) this.source).setWeaponPower(null);
+1 -1
View File
@@ -22,7 +22,7 @@ public class DisconnectJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.origin != null) {
this.origin.disconnect();
}
+1 -1
View File
@@ -28,7 +28,7 @@ public class DoorCloseJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
int doorNumber;
+1 -1
View File
@@ -22,7 +22,7 @@ public class EndFearJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
//cancel fear for mob.
+1 -1
View File
@@ -26,7 +26,7 @@ public class FinishCooldownTimeJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishCooldownTime(this.msg, this.pc);
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ public class FinishEffectTimeJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishEffectTime(this.source, this.target, this.action, this.trains);
}
+1 -1
View File
@@ -26,7 +26,7 @@ public class FinishRecycleTimeJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishRecycleTime(this.msg, this.pc, false);
}
+1 -1
View File
@@ -20,7 +20,7 @@ public class FinishSpireEffectJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
PlayerCharacter pc = (PlayerCharacter) target;
+1 -1
View File
@@ -31,7 +31,7 @@ public class FinishSummonsJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.target == null)
return;
+1 -1
View File
@@ -28,7 +28,7 @@ public class LoadEffectsJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.originToSend == null) {
return;
}
+1 -1
View File
@@ -25,7 +25,7 @@ public class LogoutCharacterJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
server.logoutCharacter(this.pc);
}
+1 -1
View File
@@ -19,7 +19,7 @@ public class NoTimeJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
}
@Override
+1 -1
View File
@@ -40,7 +40,7 @@ public class PersistentAoeJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.aej == null || this.source == null || this.action == null || this.power == null || this.source == null || this.eb == null)
return;
+1 -1
View File
@@ -45,7 +45,7 @@ public class RefreshGroupJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.pc == null || this.origin == null || grp == null) {
return;
+1 -1
View File
@@ -22,7 +22,7 @@ public class RemoveCorpseJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.corpse != null)
Corpse.removeCorpse(corpse, true);
+1 -1
View File
@@ -25,7 +25,7 @@ public class SiegeSpireWithdrawlJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (spire == null)
return;
+1 -1
View File
@@ -30,7 +30,7 @@ public class StuckJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
Vector3fImmutable stuckLoc;
Building building = null;
+1 -1
View File
@@ -27,7 +27,7 @@ public class SummonSendJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.source == null)
return;
+1 -1
View File
@@ -39,7 +39,7 @@ public class TeleportJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.pc == null || this.npc == null || this.origin == null)
return;
+1 -1
View File
@@ -35,7 +35,7 @@ public class TrackJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.tpa == null || this.target == null || this.action == null || this.source == null || this.eb == null || !(this.source instanceof PlayerCharacter))
return;
+1 -1
View File
@@ -29,7 +29,7 @@ public class TransferStatOTJob extends AbstractEffectJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.dot == null || this.target == null || this.action == null || this.source == null || this.eb == null || this.action == null || this.power == null)
return;
if (!this.target.isAlive()) {
+1 -1
View File
@@ -26,7 +26,7 @@ public class UpdateGroupJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.group == null)
return;
+1 -15
View File
@@ -1,9 +1,7 @@
package engine.jobs;
import engine.gameManager.ZoneManager;
import engine.job.AbstractScheduleJob;
import engine.objects.Building;
import engine.objects.City;
import org.pmw.tinylog.Logger;
/*
@@ -22,7 +20,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
// Must have a building to rank!
@@ -43,18 +41,6 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
rankingBuilding.setRank(rankingBuilding.getRank() + 1);
if(rankingBuilding.getBlueprint().isWallPiece()){
City cityObject = ZoneManager.getCityAtLocation(rankingBuilding.loc);
if(cityObject.getTOL().getRank() == 8) {
if (rankingBuilding.getBlueprint() != null && rankingBuilding.getBlueprint().getBuildingGroup() != null && rankingBuilding.getBlueprint().isWallPiece()) {
float currentHealthRatio = rankingBuilding.getCurrentHitpoints() / rankingBuilding.healthMax;
float newMax = rankingBuilding.healthMax * 1.1f;
rankingBuilding.setMaxHitPoints(newMax);
rankingBuilding.setHealth(rankingBuilding.healthMax * currentHealthRatio);
}
}
}
// Reload the object
+1 -1
View File
@@ -27,7 +27,7 @@ public class UpgradeNPCJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
int newRank;
+1 -1
View File
@@ -34,7 +34,7 @@ public class UseItemJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishApplyPower(ac, target, Vector3fImmutable.ZERO, pb, trains, liveCounter);
}
+1 -1
View File
@@ -35,7 +35,7 @@ public class UseMobPowerJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishUseMobPower(this.msg, this.caster, casterLiveCounter, targetLiveCounter);
}
+1 -1
View File
@@ -35,7 +35,7 @@ public class UsePowerJob extends AbstractScheduleJob {
}
@Override
public void doJob() {
protected void doJob() {
PowersManager.finishUsePower(this.msg, this.pc, casterLiveCounter, targetLiveCounter);
}
@@ -0,0 +1,10 @@
package engine.mobileAI.BehaviourFiles;
import engine.objects.Mob;
public class PlayerGuard {
public static void process(Mob guard){
}
}
@@ -0,0 +1,86 @@
package engine.mobileAI.BehaviourFiles;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.PowersManager;
import engine.mobileAI.enumMobState;
import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities;
import engine.objects.AbstractWorldObject;
import engine.objects.ItemBase;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.Map;
public class PlayerPet {
public static void process(Mob pet){
if(pet.getOwner() == null && !pet.isNecroPet()){
pet.killCharacter("no owner");
return;
}
if(!WorldGrid.getObjectsInRangePartial(pet.loc, MBServerStatics.CHARACTER_LOAD_RANGE,1).contains(pet.getOwner())){
pet.teleport(pet.getOwner().loc);
return;
}
switch(enumMobState.getState(pet)){
case dead:
pet.despawn();
return;
case patrolling:
if(pet.loc.distanceSquared(pet.getOwner().loc) > 90 && !pet.isMoving()){
MovementUtilities.aiMove(pet,pet.getOwner().loc,false);
}
return;
case attacking:
attack(pet);
return;
}
}
public static void attack(Mob mob){
if (mob.combatTarget == null || !mob.combatTarget.isAlive()) {
mob.setCombatTarget(null);
aggro(mob);
return;
}
if(!CombatUtilities.inRangeToAttack(mob,mob.combatTarget)){
if (!MovementUtilities.canMove(mob))
return;
MovementUtilities.aiMove(mob,mob.combatTarget.loc,false);
return;
}
mob.updateLocation();
ItemBase weapon = mob.getWeaponItemBase(true);
boolean mainHand = true;
if(weapon == null) {
weapon = mob.getWeaponItemBase(false);
mainHand = false;
}
if (System.currentTimeMillis() > mob.getNextAttackTime()) {
CombatUtilities.combatCycle(mob, mob.combatTarget, mainHand, weapon);
mob.setNextAttackTime(System.currentTimeMillis() + 3000L);
}
}
public static void aggro(Mob mob){
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(mob.loc,30, MBServerStatics.MASK_MOB)) {
Mob potentialTarget = (Mob) awo;
if (!potentialTarget.isAlive())
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
}
}
@@ -0,0 +1,47 @@
package engine.mobileAI.BehaviourFiles;
import engine.Enum;
import engine.mobileAI.utilities.CombatUtilities;
import engine.objects.Mob;
public class SiegeMob {
public static void process(Mob treb){
if(!treb.isAlive()){
if(!treb.despawned){
treb.despawn();
treb.deathTime = System.currentTimeMillis();
return;
}
if(treb.deathTime == 0) {
treb.deathTime = System.currentTimeMillis();
return;
}
if(treb.deathTime + 900000L > System.currentTimeMillis()) {
treb.respawn();
treb.setCombatTarget(null);
return;
}
}
if(treb.combatTarget == null)
return;
if(!treb.combatTarget.getObjectType().equals(Enum.GameObjectType.Building)) {
treb.setCombatTarget(null);
return;
}
if(!treb.combatTarget.isAlive()) {
treb.setCombatTarget(null);
return;
}
if(!CombatUtilities.inRangeToAttack(treb,treb.combatTarget))
treb.setCombatTarget(null);
if (System.currentTimeMillis() > treb.getNextAttackTime()) {
CombatUtilities.combatCycle(treb, treb.combatTarget, true, null);
treb.setNextAttackTime(System.currentTimeMillis() + 11000L);
}
}
}
@@ -0,0 +1,155 @@
package engine.mobileAI.BehaviourFiles;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.PowersManager;
import engine.mobileAI.enumMobState;
import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities;
import engine.objects.*;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.Map;
public class StandardMob {
public static void process(Mob mob){
switch(enumMobState.getState(mob)){
case idle:
return;
case dead:
respawn(mob);
return;
case patrolling:
if(mob.combatTarget == null)
aggro(mob);
if(mob.combatTarget == null)
patrol(mob);
return;
case attacking:
attack(mob);
return;
}
}
public static void respawn(Mob mob){
if (mob.deathTime == 0) {
mob.setDeathTime(System.currentTimeMillis());
return;
}
if (!mob.despawned) {
if (mob.getCharItemManager() != null && mob.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
//No items in inventory.
} else if (mob.isHasLoot()) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
//Mob never had Loot.
} else {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
}
}
if(Mob.discDroppers.contains(mob))
return;
if (System.currentTimeMillis() > (mob.deathTime + (mob.spawnTime * 1000L))) {
if (!Zone.respawnQue.contains(mob)) {
Zone.respawnQue.add(mob);
}
}
}
public static void aggro(Mob mob){
if(enumMobState.Agressive(mob)){
for(int id : mob.playerAgroMap.keySet()){
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache(id);
if(!potentialTarget.isAlive() || !mob.canSee(potentialTarget))
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(mob.loc,60, MBServerStatics.MASK_PET)){
Mob potentialTarget = (Mob)awo;
if(!potentialTarget.isAlive())
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
}
}
public static void patrol(Mob mob){
if (!MovementUtilities.canMove(mob))
return;
if (mob.stopPatrolTime + 5000L > System.currentTimeMillis())
return;
if(mob.isMoving())
return;
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
mob.lastPatrolPointIndex = 0;
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
mob.lastPatrolPointIndex += 1;
MovementUtilities.aiMove(mob, mob.destination, true);
}
public static void attack(Mob mob){
if (!MovementUtilities.inRangeOfBindLocation(mob)) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
for (Map.Entry playerEntry : mob.playerAgroMap.entrySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
mob.setCombatTarget(null);
return;
}
if (mob.combatTarget == null || !mob.combatTarget.isAlive()) {
mob.setCombatTarget(null);
return;
}
if(!mob.isMoving() && !CombatUtilities.inRangeToAttack(mob,mob.combatTarget)){
if (!MovementUtilities.canMove(mob))
return;
MovementUtilities.aiMove(mob,mob.combatTarget.loc,false);
return;
}
mob.updateLocation();
ItemBase weapon = mob.getWeaponItemBase(true);
boolean mainHand = true;
if(weapon == null) {
weapon = mob.getWeaponItemBase(false);
mainHand = false;
}
if (System.currentTimeMillis() > mob.getNextAttackTime()) {
CombatUtilities.combatCycle(mob, mob.combatTarget, mainHand, weapon);
mob.setNextAttackTime(System.currentTimeMillis() + 3000L);
}
}
}
+32
View File
@@ -0,0 +1,32 @@
package engine.mobileAI;
import engine.mobileAI.BehaviourFiles.PlayerGuard;
import engine.mobileAI.BehaviourFiles.PlayerPet;
import engine.mobileAI.BehaviourFiles.SiegeMob;
import engine.mobileAI.BehaviourFiles.StandardMob;
import engine.objects.Mob;
public class EasyAI {
public static void aiRun(Mob mob) {
if (mob == null)
return;
if (mob.isPlayerGuard) {
PlayerGuard.process(mob);
return;
}
if(mob.isSiege()){
SiegeMob.process(mob);
return;
}
if (mob.isPet()) {
PlayerPet.process(mob);
return;
}
StandardMob.process(mob);
}
}
+65 -110
View File
@@ -9,7 +9,6 @@
package engine.mobileAI;
import engine.Enum;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.*;
import engine.math.Vector3f;
@@ -17,9 +16,7 @@ import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities;
import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
@@ -49,19 +46,18 @@ public class MobAI {
return;
}
//mob casting disabled
//if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
//if (mob.isPlayerGuard() == false && MobCast(mob)) {
// mob.updateLocation();
// return;
//}
if (mob.isPlayerGuard() == false && MobCast(mob)) {
mob.updateLocation();
return;
}
//if (mob.isPlayerGuard() == true && GuardCast(mob)) {
// mob.updateLocation();
// return;
//}
//}
if (mob.isPlayerGuard() == true && GuardCast(mob)) {
mob.updateLocation();
return;
}
}
if (!CombatUtilities.inRangeToAttack(mob, target))
return;
@@ -107,14 +103,10 @@ public class MobAI {
return;
}
if(target.getPet() != null && target.getPet().isAlive()){
mob.setCombatTarget(target.getPet());
}
if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob);
if (MovementUtilities.outOfAggroRange(mob, target)) {
if (!MovementUtilities.inRangeDropAggro(mob, target)) {
mob.setCombatTarget(null);
return;
}
@@ -123,7 +115,7 @@ public class MobAI {
//no weapons, default mob attack speed 3 seconds.
if (System.currentTimeMillis() < mob.getLastAttackTime())
if (System.currentTimeMillis() < mob.getNextAttackTime())
return;
// ranged mobs cant attack while running. skip until they finally stop.
@@ -141,19 +133,19 @@ public class MobAI {
int delay = 3000;
if (mob.isSiege())
delay = 11000;
mob.setLastAttackTime(System.currentTimeMillis() + delay);
mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) {
int delay = 3000;
if (mob.isSiege())
delay = 11000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + delay);
mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
}
}
@@ -161,12 +153,6 @@ public class MobAI {
if (target.getPet().getCombatTarget() == null && target.getPet().assist == true)
target.getPet().setCombatTarget(mob);
try{
InterestManager.forceLoad(mob);
}catch(Exception e){
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackPlayer" + " " + e.getMessage());
}
@@ -182,14 +168,14 @@ public class MobAI {
if (target.getRank() == -1 || !target.isVulnerable() || BuildingManager.getBuildingFromCache(target.getObjectUUID()) == null) {
mob.setCombatTarget(null);
return;
return;
}
City playercity = ZoneManager.getCityAtLocation(mob.getLoc());
if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet)
if (guard.BehaviourType != null && guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (guard.getCombatTarget() == null && guard.getGuild() != null && mob.getGuild() != null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob);
@@ -204,19 +190,19 @@ public class MobAI {
int delay = 3000;
if (mob.isSiege())
delay = 15000;
mob.setLastAttackTime(System.currentTimeMillis() + delay);
mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 15000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 15000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
}
//if (mob.isSiege()) {
@@ -247,26 +233,23 @@ public class MobAI {
int delay = 3000;
if (mob.isSiege())
delay = 11000;
mob.setLastAttackTime(System.currentTimeMillis() + delay);
mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000;
if (mob.isSiege())
attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay);
mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
if (target.getCombatTarget() == null) {
target.setCombatTarget(mob);
}
}
if(target.combatTarget == null)
target.setCombatTarget(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
}
@@ -335,32 +318,28 @@ public class MobAI {
if (mob == null)
return false;
if (mob.nextCastTime == 0)
mob.nextCastTime = System.currentTimeMillis() - 1000L;
if(mob.isPlayerGuard == true){
if(mob.nextCastTime > System.currentTimeMillis())
return false;
int contractID;
if(mob.isPlayerGuard){
int contractID = 0;
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion) && mob.npcOwner != null)
if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.npcOwner.contract.getContractID();
else if(mob.contract != null)
else
contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.containsKey(contractID) && !Enum.MinionType.ContractToMinionMap.get(contractID).isMage())
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
return false;
}
if (mob.mobPowers == null || mob.mobPowers.isEmpty())
if (mob.mobPowers.isEmpty())
return false;
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
mob.setCombatTarget(null);
return false;
}
if (mob.nextCastTime == 0)
mob.nextCastTime = System.currentTimeMillis();
return mob.nextCastTime <= System.currentTimeMillis();
@@ -419,9 +398,6 @@ public class MobAI {
PowersBase mobPower = PowersManager.getPowerByToken(powerToken);
if(mobPower.powerCategory.equals(Enum.PowerCategoryType.DEBUFF))
return false;
//check for hit-roll
if (mobPower.requiresHitRoll)
@@ -445,9 +421,9 @@ public class MobAI {
msg.setUnknown04(2);
PowersManager.finishUseMobPower(msg, mob, 0, 0);
long delay = 20000L;
mob.nextCastTime = System.currentTimeMillis() + delay;
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true;
}
} catch (Exception e) {
@@ -570,6 +546,7 @@ public class MobAI {
PowersManager.finishUseMobPower(msg, mob, 0, 0);
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY);
mob.nextCastTime = System.currentTimeMillis() + randomCooldown;
return true;
}
} catch (Exception e) {
@@ -726,8 +703,8 @@ public class MobAI {
DefaultLogic(mob);
break;
}
//if(mob.isAlive())
// RecoverHealth(mob);
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
}
@@ -737,10 +714,6 @@ public class MobAI {
try {
//do not switch target if you already have one, dropping out of range is handled elsewhere
if(aiAgent.combatTarget != null)
return;
//looks for and sets mobs combatTarget
if (!aiAgent.isAlive())
@@ -908,7 +881,6 @@ public class MobAI {
return;
}
}
return;
}
if(Mob.discDroppers.contains(aiAgent))
@@ -917,7 +889,7 @@ public class MobAI {
if(aiAgent.StrongholdGuardian || aiAgent.StrongholdEpic || aiAgent.StrongholdCommander)
return;
if (aiAgent.despawned && System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000L))) {
if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000L))) {
if (!Zone.respawnQue.contains(aiAgent)) {
Zone.respawnQue.add(aiAgent);
}
@@ -938,14 +910,12 @@ public class MobAI {
if (mob.getCombatTarget() == null)
return;
if(!mob.isCombat())
enterCombat(mob);
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.outOfAggroRange(mob, (PlayerCharacter) mob.getCombatTarget()) && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
mob.setCombatTarget(null);
return;
}
if (System.currentTimeMillis() > mob.getLastAttackTime())
if (System.currentTimeMillis() > mob.getNextAttackTime())
AttackTarget(mob, mob.getCombatTarget());
} catch (Exception e) {
@@ -989,6 +959,7 @@ public class MobAI {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
//guard captain pulls his minions home with him
@@ -1018,11 +989,6 @@ public class MobAI {
try {
if(mob.combatTarget != null && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && !mob.canSee((PlayerCharacter)mob.combatTarget)){
mob.setCombatTarget(null);
return;
}
float rangeSquared = mob.getRange() * mob.getRange();
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
@@ -1097,8 +1063,8 @@ public class MobAI {
if(mob.combatTarget == null)
return;
//if(city._playerMemory.contains(mob.combatTarget.getObjectUUID()) && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
// mob.setCombatTarget(null);
if(city._playerMemory.contains(mob.combatTarget.getObjectUUID()) && mob.combatTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
mob.setCombatTarget(null);
}
public static void GuardCaptainLogic(Mob mob) {
@@ -1108,17 +1074,17 @@ public class MobAI {
if (mob.getCombatTarget() == null)
CheckForPlayerGuardAggro(mob);
//AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
//if (newTarget != null) {
if (newTarget != null) {
// if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
// if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
// mob.setCombatTarget(newTarget);
// } else
// mob.setCombatTarget(newTarget);
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
//}
}
CheckMobMovement(mob);
CheckForAttack(mob);
} catch (Exception e) {
@@ -1170,10 +1136,6 @@ public class MobAI {
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner");
if(!mob.isSiege())
mob.BehaviourType.canRoam = true;
if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob);
@@ -1204,24 +1166,25 @@ public class MobAI {
try {
//check for players that can be aggroed if mob is agressive and has no target
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false && !mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.Mob))
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null);
//if (mob.BehaviourType.isAgressive) {
if (mob.BehaviourType.isAgressive) {
// AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
// if (newTarget != null)
// mob.setCombatTarget(newTarget);
// else {
// if (mob.getCombatTarget() == null) {
// if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
// SafeGuardAggro(mob); //safehold guard
// else
// CheckForAggro(mob); //normal aggro
// }
// }
//}
if (newTarget != null)
mob.setCombatTarget(newTarget);
else {
if (mob.getCombatTarget() == null) {
if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard
else
CheckForAggro(mob); //normal aggro
}
}
}
//check if mob can move for patrol or moving to target
@@ -1233,7 +1196,6 @@ public class MobAI {
if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
CheckForAttack(mob);
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage());
}
@@ -1452,11 +1414,4 @@ public class MobAI {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: RecoverHealth" + " " + e.getMessage());
}
}
public static void enterCombat(Mob mob){
mob.setCombat(true);
UpdateStateMsg rwss = new UpdateStateMsg();
rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss);
}
}
+10 -17
View File
@@ -1,6 +1,7 @@
package engine.mobileAI.Threads;
import engine.gameManager.ConfigManager;
import engine.mobileAI.EasyAI;
import engine.mobileAI.MobAI;
import engine.gameManager.ZoneManager;
import engine.objects.Mob;
@@ -28,26 +29,18 @@ public class MobAIThread implements Runnable{
AI_BASE_AGGRO_RANGE = (int)(60 * Float.parseFloat(ConfigManager.MB_AI_AGGRO_RANGE.getValue()));
while (true) {
for (Zone zone : ZoneManager.getAllZones()) {
if (zone != null && zone.zoneMobSet != null) {
synchronized (zone.zoneMobSet) {
for (Mob mob : zone.zoneMobSet) {
try {
if (mob != null) {
MobAI.DetermineAction(mob);
}
} catch (Exception e) {
Logger.error("Error processing Mob [Name: {}, UUID: {}]", mob.getName(), mob.getObjectUUID(), e);
}
}
for (Mob mob : zone.zoneMobSet) {
try {
if (mob != null)
EasyAI.aiRun(mob);
} catch (Exception e) {
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
e.printStackTrace();
}
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Logger.error("AI Thread interrupted", e);
Thread.currentThread().interrupt();
}
}
}
public static void startAIThread() {
@@ -13,9 +13,6 @@ import engine.objects.Mob;
import engine.objects.Zone;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.Collection;
/**
* Thread blocks until MagicBane dispatch messages are
* enqueued then processes them in FIFO order. The collection
@@ -28,48 +25,41 @@ import java.util.Collection;
public class MobRespawnThread implements Runnable {
private volatile boolean running = true;
private static final long RESPAWN_INTERVAL = 100; // Configurable interval
public MobRespawnThread() {
Logger.info("MobRespawnThread initialized.");
Logger.info(" MobRespawnThread thread has started!");
}
@Override
public void run() {
while (running) {
try {
Collection<Zone> zones = ZoneManager.getAllZones();
if (zones != null) {
for (Zone zone : zones) {
synchronized (zone) { // Optional: Synchronize on zone
if (!Zone.respawnQue.isEmpty() && Zone.lastRespawn + RESPAWN_INTERVAL < System.currentTimeMillis()) {
Mob respawner = Zone.respawnQue.iterator().next();
if (respawner != null) {
respawner.respawn();
Zone.respawnQue.remove(respawner);
Zone.lastRespawn = System.currentTimeMillis();
Thread.sleep(100);
}
}
}
while (true) {
try {
for (Zone zone : ZoneManager.getAllZones()) {
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
Mob respawner = zone.respawnQue.iterator().next();
if (respawner == null)
continue;
respawner.respawn();
zone.respawnQue.remove(respawner);
zone.lastRespawn = System.currentTimeMillis();
}
}
Thread.sleep(100); // Prevent busy-waiting
} catch (Exception e) {
Logger.error("Error in MobRespawnThread", e);
Logger.error(e);
}
}
Logger.info("MobRespawnThread stopped.");
}
public void stop() {
running = false;
}
public static void startRespawnThread() {
Thread respawnThread = new Thread(new MobRespawnThread());
Thread respawnThread;
respawnThread = new Thread(new MobRespawnThread());
respawnThread.setName("respawnThread");
respawnThread.start();
}
+27
View File
@@ -0,0 +1,27 @@
package engine.mobileAI;
import engine.objects.Mob;
public enum enumMobState {
idle,
attacking,
patrolling,
dead;
public static enumMobState getState(Mob mob){
if(mob.playerAgroMap.isEmpty())
return enumMobState.idle;
if(!mob.isAlive())
return enumMobState.dead;
if(mob.combatTarget != null)
return enumMobState.attacking;
return enumMobState.patrolling;
}
public static boolean Agressive(Mob mob){
return mob.BehaviourType.name().contains("Aggro");
}
}
@@ -101,10 +101,9 @@ public class CombatUtilities {
if (!target.isAlive())
return;
if (AbstractWorldObject.IsAbstractCharacter(target)) {
//damage = Resists.handleFortitude((AbstractCharacter) target,DamageType.Crush,damage);
if (AbstractWorldObject.IsAbstractCharacter(target))
trueDamage = ((AbstractCharacter) target).modifyHealth(-damage, agent, false);
}else if (target.getObjectType() == GameObjectType.Building)
else if (target.getObjectType() == GameObjectType.Building)
trueDamage = ((Building) target).modifyHealth(-damage, agent);
//Don't send 0 damage kay thanx.
@@ -141,24 +140,16 @@ public class CombatUtilities {
public static boolean triggerDefense(Mob agent, AbstractWorldObject target) {
int defense = 0;
int atr = agent.mobBase.getAtr();
if(agent.getBonuses() != null){
atr += agent.getBonuses().getFloat(ModType.OCV,SourceType.None);
atr *= 1 + agent.getBonuses().getFloatPercentAll(ModType.OCV,SourceType.None);
}
int atr = agent.getAtrHandOne();
switch (target.getObjectType()) {
case PlayerCharacter:
PlayerCharacter pc = (PlayerCharacter)target;
pc.combatStats.calculateDefense();
defense = pc.combatStats.defense;
defense = ((AbstractCharacter) target).getDefenseRating();
break;
case Mob:
Mob mob = (Mob) target;
if (mob.isSiege())
defense = atr;
else
defense = ((Mob) target).mobBase.getDefense();
break;
case Building:
return false;
@@ -201,10 +192,12 @@ public class CombatUtilities {
return;
int anim = 75;
float speed;
//handle the retaliate here because even if the mob misses you can still retaliate
if (AbstractWorldObject.IsAbstractCharacter(target))
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
if (mainHand)
speed = agent.getSpeedHandOne();
else
speed = agent.getSpeedHandTwo();
DamageType dt = DamageType.Crush;
@@ -259,12 +252,12 @@ public class CombatUtilities {
if (agent.getEquip().get(1) != null && agent.getEquip().get(2) != null && agent.getEquip().get(2).getItemBase().isShield() == false) {
//mob is duel wielding and should conduct an attack for each hand
ItemBase weapon1 = agent.getEquip().get(1).getItemBase();
double range1 = getMaxDmg(agent) - getMinDmg(agent);
double damage1 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
double range1 = getMaxDmg(weapon1.getMinDamage(), agent, weapon1) - getMinDmg(weapon1.getMinDamage(), agent, weapon1);
double damage1 = getMinDmg(weapon1.getMinDamage(), agent, weapon1) + ((ThreadLocalRandom.current().nextFloat() * range1) + (ThreadLocalRandom.current().nextFloat() * range1)) / 2;
swingIsDamage(agent, target, (float) damage1, CombatManager.getSwingAnimation(weapon1, null, true));
ItemBase weapon2 = agent.getEquip().get(2).getItemBase();
double range2 = getMaxDmg(agent) - getMinDmg(agent);
double damage2 = getMinDmg(agent) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
double range2 = getMaxDmg(weapon2.getMinDamage(), agent, weapon2) - getMinDmg(weapon2.getMinDamage(), agent, weapon2);
double damage2 = getMinDmg(weapon2.getMinDamage(), agent, weapon2) + ((ThreadLocalRandom.current().nextFloat() * range2) + (ThreadLocalRandom.current().nextFloat() * range2)) / 2;
swingIsDamage(agent, target, (float) damage2, CombatManager.getSwingAnimation(weapon1, null, false));
} else {
swingIsDamage(agent, target, determineDamage(agent), anim);
@@ -286,6 +279,11 @@ public class CombatUtilities {
if (((Mob) target).isSiege())
return;
//handle the retaliate
if (AbstractWorldObject.IsAbstractCharacter(target))
CombatManager.handleRetaliate((AbstractCharacter) target, agent);
if (target.getObjectType() == GameObjectType.Mob) {
Mob targetMob = (Mob) target;
if (targetMob.isSiege())
@@ -309,9 +307,9 @@ public class CombatUtilities {
float damage = 0;
DamageType dt = getDamageType(agent);
if (agent.BehaviourType.equals(MobBehaviourType.Pet1)) {
damage = calculateMobDamage(agent);
} else if (agent.isPlayerGuard()) {
if ((agent.agentType.equals(AIAgentType.PET)) == true || agent.isPet() == true || agent.isNecroPet() == true) {
damage = calculatePetDamage(agent);
} else if (agent.isPlayerGuard() == true) {
//damage = calculateGuardDamage(agent);
damage = calculateMobDamage(agent);
} else if (agent.getLevel() > 80) {
@@ -320,9 +318,9 @@ public class CombatUtilities {
damage = calculateMobDamage(agent);
}
if (AbstractWorldObject.IsAbstractCharacter(target)) {
//if (((AbstractCharacter) target).isSit()) {
// damage *= 2.5f; //increase damage if sitting
//}
if (((AbstractCharacter) target).isSit()) {
damage *= 2.5f; //increase damage if sitting
}
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0));
}
if (target.getObjectType() == GameObjectType.Building) {
@@ -351,8 +349,8 @@ public class CombatUtilities {
float min = 40;
float max = 60;
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double minDmg = getMinDmg(agent);
double maxDmg = getMaxDmg(agent);
double minDmg = getMinDmg(min, agent, null);
double maxDmg = getMaxDmg(max, agent, null);
dmgMultiplier += agent.getLevel() * 0.1f;
range = (float) (maxDmg - minDmg);
damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
@@ -368,8 +366,8 @@ public class CombatUtilities {
double minDmg = weapon.getMinDamage();
double maxDmg = weapon.getMaxDamage();
double min = getMinDmg(agent);
double max = getMaxDmg(agent);
double min = getMinDmg(minDmg, agent, weapon);
double max = getMaxDmg(maxDmg, agent, weapon);
DamageType dt = weapon.getDamageType();
@@ -410,48 +408,92 @@ public class CombatUtilities {
}
public static int calculateMobDamage(Mob agent) {
double minDmg = getMinDmg(agent);
double maxDmg = getMaxDmg(agent);
DamageType dt = getDamageType(agent);
ItemBase weapon = null;
double minDmg;
double maxDmg;
DamageType dt;
//main hand or offhand damage
if (agent.getEquip().get(1) != null)
weapon = agent.getEquip().get(1).getItemBase();
else if (agent.getEquip().get(2) != null)
weapon = agent.getEquip().get(2).getItemBase();
if (weapon != null) {
minDmg = getMinDmg(weapon.getMinDamage(), agent, weapon);
maxDmg = getMaxDmg(weapon.getMaxDamage(), agent, weapon);
dt = weapon.getDamageType();
} else {
minDmg = agent.getMobBase().getDamageMin();
maxDmg = agent.getMobBase().getDamageMax();
dt = DamageType.Crush;
}
AbstractWorldObject target = agent.getCombatTarget();
double damage = ThreadLocalRandom.current().nextInt((int)minDmg,(int)maxDmg + 1);
float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
double range = maxDmg - minDmg;
double damage = minDmg + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2;
if (AbstractWorldObject.IsAbstractCharacter(target))
if (((AbstractCharacter) target).isSit())
damage *= 2.5f; //increase damage if sitting
if (AbstractWorldObject.IsAbstractCharacter(target))
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0));
return (int) (((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, (float) damage, 0) * dmgMultiplier);
return 0;
}
public static double getMinDmg(Mob agent) {
if(agent.getEquip() != null){
if(agent.getEquip().get(ItemSlotType.RHELD) != null){
return agent.minDamageHandOne;
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){
return agent.getMinDamageHandTwo();
}else{
return agent.minDamageHandOne;
public static double getMinDmg(double min, Mob agent, ItemBase weapon) {
int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent();
int focusLevel = 0;
int masteryLevel = 0;
if (weapon != null) {
if (weapon.isStrBased() == true) {
primary = agent.getStatStrCurrent();
secondary = agent.getStatDexCurrent();
} else {
primary = agent.getStatDexCurrent();
secondary = agent.getStatStrCurrent();
if (agent.getSkills().containsKey(weapon.getSkillRequired())) {
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
}
if (agent.getSkills().containsKey(weapon.getMastery())) {
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
}
}else{
return agent.minDamageHandOne;
}
}
return min * (pow(0.0048 * primary + .049 * (primary - 0.75), 0.5) + pow(0.0066 * secondary + 0.064 * (secondary - 0.75), 0.5) + +0.01 * (focusLevel + masteryLevel));
}
public static double getMaxDmg(Mob agent) {
if(agent.getEquip() != null){
if(agent.getEquip().get(ItemSlotType.RHELD) != null){
return agent.maxDamageHandOne;
}else if(agent.getEquip().get(ItemSlotType.LHELD) != null){
return agent.getMaxDamageHandTwo();
}else{
return agent.maxDamageHandOne;
}
}else{
return agent.maxDamageHandOne;
public static double getMaxDmg(double max, Mob agent, ItemBase weapon) {
int primary = agent.getStatStrCurrent();
int secondary = agent.getStatDexCurrent();
int focusLevel = 0;
int masteryLevel = 0;
if (weapon != null) {
if (weapon.isStrBased() == true) {
primary = agent.getStatStrCurrent();
secondary = agent.getStatDexCurrent();
} else {
primary = agent.getStatDexCurrent();
secondary = agent.getStatStrCurrent();
}
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
focusLevel = (int) agent.getSkills().get(weapon.getSkillRequired()).getModifiedAmount();
if (agent.getSkills().containsKey(weapon.getSkillRequired()))
masteryLevel = (int) agent.getSkills().get(weapon.getMastery()).getModifiedAmount();
}
return max * (pow(0.0124 * primary + 0.118 * (primary - 0.75), 0.5) + pow(0.0022 * secondary + 0.028 * (secondary - 0.75), 0.5) + 0.0075 * (focusLevel + masteryLevel));
}
}
@@ -83,7 +83,7 @@ public class MovementUtilities {
}
public static boolean inRangeToAggro(Mob agent, PlayerCharacter target) {
public static boolean inRangeToAggro(Mob agent, AbstractCharacter target) {
Vector3fImmutable sl = agent.getLoc();
Vector3fImmutable tl = target.getLoc();
@@ -98,24 +98,20 @@ public class MovementUtilities {
}
public static boolean outOfAggroRange(Mob agent, AbstractCharacter target) {
public static boolean inRangeDropAggro(Mob agent, AbstractCharacter target) {
Vector3fImmutable sl = agent.getLoc();
Vector3fImmutable tl = target.getLoc();
float disSq = sl.distanceSquared(tl);
float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
float range = agent.getRange() + 150;
//float distanceSquaredToTarget = sl.distanceSquared2D(tl) - sqr(agent.calcHitBox() + target.calcHitBox()); //distance to center of target
if (range > 200)
range = 200;
return disSq > (range * range);
return distanceSquaredToTarget < sqr(range);
}
@@ -173,6 +169,9 @@ public class MovementUtilities {
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
return false;
if(!agent.BehaviourType.canRoam)
return false;
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
}
+1 -1
View File
@@ -38,7 +38,7 @@ public abstract class AbstractConnection implements
protected final AtomicBoolean execTask = new AtomicBoolean(false);
protected final ReentrantLock writeLock = new ReentrantLock();
protected final ReentrantLock readLock = new ReentrantLock();
public long lastMsgTime = System.currentTimeMillis();
protected long lastMsgTime = System.currentTimeMillis();
protected long lastKeepAliveTime = System.currentTimeMillis();
protected long lastOpcode = -1;
protected ConcurrentLinkedQueue<ByteBuffer> outbox = new ConcurrentLinkedQueue<>();
@@ -87,7 +87,6 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
this.processChangeRequests();
this.auditSocketChannelToConnectionMap();
//this.selector.select();
this.selector.select(250L);
this.processNewEvents();
@@ -665,7 +664,7 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
}
@Override
public void doJob() {
protected void doJob() {
if (runStatus) {
this.ac.connMan.receive(sk);
this.ac.execTask.compareAndSet(true, false);
@@ -694,7 +693,7 @@ public abstract class AbstractConnectionManager extends ControlledRunnable {
}
@Override
public void doJob() {
protected void doJob() {
if (runStatus) {
this.ac.connMan.sendFinish(sk);
this.ac.execTask.compareAndSet(true, false);
+1 -1
View File
@@ -23,7 +23,7 @@ public class CheckNetMsgFactoryJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
NetMsgFactory factory = conn.getFactory();
// Make any/all msg possible
+1 -1
View File
@@ -26,7 +26,7 @@ public class ConnectionMonitorJob extends AbstractJob {
}
@Override
public void doJob() {
protected void doJob() {
if (this.cnt >= 5) {
this.connMan.auditSocketChannelToConnectionMap();
+4 -11
View File
@@ -44,16 +44,9 @@ public class ClientConnection extends AbstractConnection {
public ReentrantLock buyLock = new ReentrantLock();
public boolean desyncDebug = false;
public byte[] lastByteBuffer;
public long lastTargetSwitchTime;
protected SessionID sessionID = null;
private byte cryptoInitTries = 0;
public int strikes = 0;
public Long lastStrike = 0L;
public int finalStrikes = 0;
public long finalStrikeRefresh = 0L;
public ClientConnection(ClientConnectionManager connMan,
SocketChannel sockChan) {
super(connMan, sockChan, true);
@@ -234,10 +227,10 @@ public class ClientConnection extends AbstractConnection {
SessionManager.remSession(
SessionManager.getSession(sessionID));
} catch (NullPointerException e) {
//Logger
//.error(
//"Tried to remove improperly initialized session. Skipping." +
//e);
Logger
.error(
"Tried to remove improperly initialized session. Skipping." +
e);
}
}
@@ -29,7 +29,6 @@ import engine.objects.*;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import engine.session.Session;
import engine.util.KeyCloneAudit;
import engine.util.StringUtils;
import org.pmw.tinylog.Logger;
@@ -239,11 +238,6 @@ public class ClientMessagePump implements NetMsgHandler {
return;
}
if(pc.getRaceID() == 1999 && msg.getSlotNumber() == MBServerStatics.SLOT_FEET){
forceTransferFromEquipToInventory(msg, origin, "Saetors Cannot Wear FEET Slot Items");
return;
}
//dupe check
if (!i.validForInventory(origin, pc, itemManager))
return;
@@ -1886,7 +1880,6 @@ public class ClientMessagePump implements NetMsgHandler {
switch (protocolMsg) {
case SETSELECTEDOBECT:
KeyCloneAudit.auditTargetMsg(msg);
ClientMessagePump.targetObject((TargetObjectMsg) msg, origin);
break;
@@ -78,7 +78,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
return false;
}
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size() && building.getRank() != 8)
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
return false;
Item contractItem = Item.getFromCache(msg.getContractItem());
@@ -9,7 +9,6 @@
package engine.net.client.handlers;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.exception.MsgSendException;
import engine.net.DispatchMessage;
@@ -43,9 +42,6 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
if (!AbstractCharacter.CanFly(pc))
return false;
if(pc.getBonuses().getBool(Enum.ModType.Stunned, Enum.SourceType.None))
return false;
if (pc.isSwimming())
return false;
if (pc.region != null && !pc.region.isOutside())
@@ -232,13 +232,11 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (pc == null || origin == null) {
return;
}
ItemBase runeBase = ItemBase.getItemBase(runeID);
boolean discRune = runeBase.isDiscRune();
boolean statRune = runeBase.isStatRune();
if(!runeBase.isDiscRune() && !runeBase.isStatRune())
//remove only if rune is discipline
if (runeID < 3001 || runeID > 3048) {
return;
}
//see if pc has rune
ArrayList<CharacterRune> runes = pc.getRunes();
@@ -1148,15 +1148,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
wallPiece.setProtectionState(ProtectionState.PROTECTED);
PlaceAssetMsg.sendPlaceAssetConfirmWall(origin, serverZone);
//walls in R8 city are immediately granted extra HP by 10%
if(cityObject.getTOL().getRank() == 8) {
if (wallPiece.getBlueprint() != null && wallPiece.getBlueprint().getBuildingGroup() != null && wallPiece.getBlueprint().isWallPiece()) {
float currentHealthRatio = wallPiece.getCurrentHitpoints() / wallPiece.healthMax;
float newMax = wallPiece.healthMax * 1.1f;
wallPiece.setMaxHitPoints(newMax);
wallPiece.setHealth(wallPiece.healthMax * currentHealthRatio);
}
}
}
// Deduct gold from character's inventory
+5 -9
View File
@@ -202,7 +202,7 @@ public class ApplyRuneMsg extends ClientNetMsg {
for (CharacterRune cr : runes) {
int runeBaseID = cr.getRuneBaseID();
//count number of discipline runes
if(isDiscipline(runeBaseID)){
if (runeBaseID > 3000 && runeBaseID < 3049) {
discCount++;
}
//see if rune is already applied
@@ -331,27 +331,23 @@ public class ApplyRuneMsg extends ClientNetMsg {
break;
}
//if discipline, check number applied
int discAllowed = 0;
if (isDiscipline(runeID)) {
switch(playerCharacter.getRank()){
case 1:
discAllowed = 0;
break;
case 2:
case 3:
case 4:
case 5:
case 6:
discAllowed = 3;
if(discCount > 3)
return false;
break;
case 7:
case 8:
discAllowed = 5;
if(discCount > 5)
return false;
break;
}
if(discCount >= discAllowed)
return false;
}
//Everything succeeded. Let's apply the rune
//Attempt add rune to database
@@ -124,9 +124,6 @@ public class VendorDialogMsg extends ClientNetMsg {
}else if(contract.getContractID() == 1502042){
vd = Contract.HandleBaneCommanderOptions(msg.unknown03, npc, playerCharacter);
msg.updateMessage(3, vd);
}else if(contract.getContractID() == 1502044){
vd = Contract.HandleGamblerOptions(msg.unknown03, npc, playerCharacter);
msg.updateMessage(3, vd);
}else {
if (contract == null)
@@ -579,7 +576,6 @@ public class VendorDialogMsg extends ClientNetMsg {
case 2520:
case 2521:
case 2523:
case 2525:
valid = true;
break;
}
@@ -636,7 +632,7 @@ public class VendorDialogMsg extends ClientNetMsg {
DispatchMessage.dispatchMsgToInterestArea(pc, arm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
if(pc.getCharItemManager() != null && pc.getCharItemManager().getGoldInventory() != null && pc.getCharItemManager().getGoldInventory().getNumOfItems() < 1000) {
pc.getCharItemManager().addGoldToInventory(1500, false);
pc.getCharItemManager().addGoldToInventory(1000, false);
pc.getCharItemManager().addItemToInventory(new MobLoot(pc, ItemBase.getItemBase(980066), 1, false).promoteToItem(pc));
pc.getCharItemManager().updateInventory();
}
@@ -63,9 +63,6 @@ public class WhoResponseMsg extends ClientNetMsg {
public static void HandleResponse(int set, int filterType, String filter, ClientConnection origin) {
if (filter.equals("")) {
filter = "Saetor";
}
WhoResponseMsg msg = new WhoResponseMsg();
WhoResponseMsg.setWorldPop(SessionManager.getAllActivePlayerCharacters().size());
+10 -6
View File
@@ -500,6 +500,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
canFly = false;
}
return canFly;
}
@@ -1101,7 +1102,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
public final void setCombatTarget(final AbstractWorldObject value) {
if (this.getObjectTypeMask() == 2050) {//MOB?
if(this.getObjectTypeMask() == 2050) {//MOB?
if (value == null) {
if (this.isCombat()) {
this.setCombat(false);
@@ -1109,6 +1110,13 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
rwss.setPlayer(this);
DispatchMessage.sendToAllInRange(this, rwss);
}
}else {
if (!this.isCombat()) {
this.setCombat(true);
UpdateStateMsg rwss = new UpdateStateMsg();
rwss.setPlayer(this);
DispatchMessage.sendToAllInRange(this, rwss);
}
}
}
this.combatTarget = value;
@@ -1718,11 +1726,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// clear bonuses and reapply rune bonuses
if (this.getObjectType().equals(GameObjectType.PlayerCharacter)) {
try {
this.bonuses.calculateRuneBaseEffects((PlayerCharacter) this);
}catch(Exception ignored){
}
this.bonuses.calculateRuneBaseEffects((PlayerCharacter) this);
} else {
this.bonuses.clearRuneBaseEffects();
}
+1 -2
View File
@@ -271,8 +271,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
if (this.getObjectType().equals(GameObjectType.PlayerCharacter))
if (name.equals("Flight")) {
((PlayerCharacter) this).update(false);
if(!AbstractCharacter.CanFly((PlayerCharacter) this))
PlayerCharacter.GroundPlayer((PlayerCharacter) this);
PlayerCharacter.GroundPlayer((PlayerCharacter) this);
}
}
applyAllBonuses();
-5
View File
@@ -59,11 +59,6 @@ public class Account extends AbstractGameObject {
this.status = Enum.AccountStatus.valueOf(resultSet.getString("status"));
}
public Account() {
this.uname = "";
this.status = Enum.AccountStatus.ACTIVE;
}
public ArrayList<Item> getVault() {
return vault;
}
+22 -14
View File
@@ -428,24 +428,32 @@ public final class Bane {
// Cache access
public void setDefaultTime() {
private void setDefaultTime() {
DateTime timeToSetDefault = new DateTime(this.placementDate);
timeToSetDefault = timeToSetDefault.plusDays(1);
if (DateTime.now().isAfter(timeToSetDefault)){
if(!this.capSet){
DbManager.BaneQueries.SET_BANE_CAP_NEW(20,this.getCityUUID());
this.capSet = true;
}
if(!this.daySet){
DbManager.BaneQueries.SET_BANE_DAY_NEW(3,this.getCityUUID());
this.daySet = true;
}
if(!this.timeSet){
DbManager.BaneQueries.SET_BANE_TIME_NEW(9,this.getCityUUID());
this.timeSet = true;
}
DateTime currentTime = DateTime.now();
DateTime defaultTime = new DateTime(this.placementDate);
defaultTime = defaultTime.plusDays(2);
defaultTime = defaultTime.hourOfDay().setCopy(22);
defaultTime = defaultTime.minuteOfHour().setCopy(0);
defaultTime = defaultTime.secondOfMinute().setCopy(0);
if (currentTime.isAfter(timeToSetDefault)){
DbManager.BaneQueries.SET_BANE_CAP_NEW(20,this.getCityUUID());
DbManager.BaneQueries.SET_BANE_TIME_NEW(9,this.getCityUUID());
DbManager.BaneQueries.SET_BANE_DAY_NEW(3,this.getCityUUID());
}
//this.setLiveDate(defaultTime);
else {
if (this.defaultTimeJob != null)
this.defaultTimeJob.cancelJob();
BaneDefaultTimeJob bdtj = new BaneDefaultTimeJob(this);
JobScheduler.getInstance().scheduleJob(bdtj, timeToSetDefault.getMillis());
this.defaultTimeJob = bdtj;
}
}
-4
View File
@@ -360,10 +360,6 @@ this.maxRank = rs.getInt("MaxRank");
return 3;
}
if(bg != null && bg.equals(BuildingGroup.TOL) && currentRank == 8){
return 5;
}
if (this.maxRank == 1 && currentRank == 1)
return getMaxSlots();
+7 -32
View File
@@ -160,16 +160,23 @@ public class Building extends AbstractWorldObject {
// in City resulting in a stack ovreflow.
if (blueprint != null) {
// Only switch mesh for player dropped structures
if (this.blueprintUUID != 0)
this.meshUUID = blueprint.getMeshForRank(rank);
this.healthMax = blueprint.getMaxHealth(this.rank);
// If this object has no blueprint but is a blueprint
// mesh then set it's current health to max health
if (this.blueprintUUID == 0)
this.setHealth(healthMax);
if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK))
this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this);
} else {
this.healthMax = 100000; // Structures with no blueprint mesh
this.setHealth(healthMax);
@@ -412,22 +419,6 @@ public class Building extends AbstractWorldObject {
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
this.setCurrentHitPoints(this.healthMax);
if(!this.ownerIsNPC && this.getBlueprint() != null && this.getBlueprint().isWallPiece()){
//add extra HP for city walls of R8 trees
City city = ZoneManager.getCityAtLocation(this.loc);
if(city != null){
Building ToL = city.getTOL();
if(ToL != null){
if(ToL.rank == 8){
float currentHealth = this.health.get();
float newHealth = (currentHealth/this.healthMax) * (this.healthMax * 1.1f);
this.healthMax *= 1.1f;
this.setHealth(newHealth);
}
}
}
}
if (this.getUpgradeDateTime() != null)
BuildingManager.setUpgradeDateTime(this, null, 0);
@@ -1137,22 +1128,6 @@ public class Building extends AbstractWorldObject {
}
}
if(!this.ownerIsNPC && this.getBlueprint() != null && this.getBlueprint().isWallPiece()){
//add extra HP for city walls of R8 trees
City city = ZoneManager.getCityAtLocation(this.loc);
if(city != null){
Building ToL = city.getTOL();
if(ToL != null){
if(ToL.rank == 8){
float currentHealth = this.health.get();
float newHealth = (currentHealth/this.healthMax) * (this.healthMax * 1.1f);
this.healthMax *= 1.1f;
this.setHealth(newHealth);
}
}
}
}
// Set bounds for this building
Bounds buildingBounds = Bounds.borrow();
+4 -13
View File
@@ -610,7 +610,7 @@ public class CharacterItemManager {
if (i == null)
return false;
//i.stripCastableEnchants();
i.stripCastableEnchants();
if (!this.doesCharOwnThisItem(i.getObjectUUID()))
return false;
@@ -1056,11 +1056,7 @@ public class CharacterItemManager {
// add to Bank
this.bank.add(i);
i.addToCache();
try {
i.stripCastableEnchants();
}catch(Exception ignored){
Logger.error("FAILED TO STRIP CASTABLE ENCHANTS: Move Item To Bank");
}
i.stripCastableEnchants();
calculateWeights();
@@ -1201,12 +1197,6 @@ public class CharacterItemManager {
} else
return false; // NPC's dont have vaults!
try {
i.stripCastableEnchants();
}catch(Exception ignored){
Logger.error("FAILED TO STRIP CASTABLE ENCHANTS: Move Item To Vault");
}
// remove it from other lists:
this.remItemFromLists(i, slot);
@@ -1215,6 +1205,7 @@ public class CharacterItemManager {
calculateWeights();
i.stripCastableEnchants();
return true;
}
@@ -2022,7 +2013,7 @@ public class CharacterItemManager {
if (item.getItemBase().getType().equals(ItemType.GOLD)) {
int amt = item.getNumOfItems();
item.setNumOfItems(0);
//item.stripCastableEnchants();
item.stripCastableEnchants();
MobLoot ml = new MobLoot(this.absCharacter, amt);
ml.zeroItem();
ml.containerType = Enum.ItemContainerType.INVENTORY;
-13
View File
@@ -164,19 +164,6 @@ public class CharacterRune extends AbstractGameObject {
runes.remove(runes.indexOf(rune));
CharacterSkill.calculateSkills(pc);
pc.applyBonuses();
if(ItemBase.getItemBase(rune.getRuneBaseID()) != null && ItemBase.getItemBase(rune.getRuneBaseID()).isStatRune()){
//handle point refund
int creationCost = 0;
for(RuneBaseAttribute attr : rune.runeBase.getAttrs()){
if(attr.getAttributeID() == MBServerStatics.RUNE_COST_ATTRIBUTE_ID){
creationCost = (int)attr.getModValue();
}
}
if(creationCost > 0){
pc.unusedStatPoints += creationCost;
pc.syncClient();
}
}
return true;
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ public class CharacterSkill extends AbstractGameObject {
165, 166, 166, 167, 167, //185 to 189
168}; //190
static final float[] baseSkillValues = {
private static final float[] baseSkillValues = {
0.0f, 0.0f, 0.2f, 0.4f, 0.6f, //0 to 4
0.8f, 1.0f, 1.1666666f, 1.3333334f, 1.5f, //5 to 9
1.6666667f, 1.8333334f, 2.0f, 2.2f, 2.4f, //10 to 14
+8 -14
View File
@@ -389,22 +389,18 @@ public class City extends AbstractWorldObject {
if (pc.getAccount().status.equals(AccountStatus.ADMIN)) {
cities.add(city);
} else {
} else
//list Player cities
//open city, just list
if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) {
if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc))
cities.add(city); //verify nation or guild is same
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG))
cities.add(city);
}else {
try {
if (city.getGuild().getNation().equals(pc.guild.getNation())) {
cities.add(city);
}
}catch(Exception e){
Logger.error(e);
}
}
}
} else if (city.isNpc == 1) {
//list NPC cities
Guild g = city.getGuild();
@@ -815,10 +811,8 @@ public class City extends AbstractWorldObject {
// Set city motto to current guild motto
if (BuildingManager.getBuilding(this.treeOfLifeID) == null) {
if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
this.destroy();
}
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER))
&& (this.isNpc == (byte) 0)) {
-75
View File
@@ -22,7 +22,6 @@ import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
public class Contract extends AbstractGameObject {
@@ -249,80 +248,6 @@ public class Contract extends AbstractGameObject {
}
return vd;
}
public static VendorDialog HandleGamblerOptions(int optionId, NPC npc, PlayerCharacter pc){
pc.setLastNPCDialog(npc);
VendorDialog vd = new VendorDialog(VendorDialog.getHostileVendorDialog().getDialogType(),VendorDialog.getHostileVendorDialog().getIntro(),-1);//VendorDialog.getHostileVendorDialog();
vd.getOptions().clear();
MenuOption option1 = new MenuOption(15020441, "Gamble 1000", 15020441);
vd.getOptions().add(option1);
MenuOption option2 = new MenuOption(15020442, "Gamble 10,000", 15020442);
vd.getOptions().add(option2);
MenuOption option3 = new MenuOption(15020443, "Gamble 100,000", 15020443);
vd.getOptions().add(option3);
switch(optionId) {
case 15020441: // gamble 1000
gamble(pc,1000);
break;
case 15020442: // gamble 10,000
gamble(pc,10000);
break;
case 15020443: // gamble 100,000
gamble(pc,100000);
break;
}
return vd;
}
public static void gamble(PlayerCharacter pc, int amount){
if(!pc.timestamps.containsKey("NextSlot"))
pc.timestamps.put("NextSlot",System.currentTimeMillis());
if(pc.timestamps.get("NextSlot") > System.currentTimeMillis())
return;
pc.timestamps.put("NextSlot",System.currentTimeMillis() + 2000L);
if(pc.charItemManager == null){
return;
}
int goldAmount = pc.charItemManager.getGoldInventory().getNumOfItems();
if(goldAmount < amount) {
ChatManager.chatSystemInfo(pc, "You Cannot Afford This Wager");
return;
}
goldAmount -= amount;
pc.charItemManager.getGoldInventory().setNumOfItems(goldAmount);
pc.charItemManager.updateInventory();
ChatManager.chatSystemInfo(pc, "You Attempt To Gamble " + amount + " ...");
int roll1 = ThreadLocalRandom.current().nextInt(1,7);
int roll2 = ThreadLocalRandom.current().nextInt(1,7);
int roll3 = ThreadLocalRandom.current().nextInt(1,7);
ChatManager.chatSystemInfo(pc, "Gambler Has Rolled: " + roll1 + " " + roll2 + " " + roll3);
int winnings = 0;
if(roll1 == roll2 && roll1 == roll3)
winnings = amount * roll1 * 10;
if(winnings > 0)
ChatManager.chatSystemInfo(pc, "You Have Won " + winnings + " Gold Coins!");
else
ChatManager.chatSystemInfo(pc, "You Have Lost The Wager");
goldAmount += winnings;
pc.charItemManager.getGoldInventory().setNumOfItems(goldAmount);
pc.charItemManager.updateInventory();
}
public static VendorDialog HandleBaneCommanderOptions(int optionId, NPC npc, PlayerCharacter pc){
pc.setLastNPCDialog(npc);
VendorDialog vd = new VendorDialog(VendorDialog.getHostileVendorDialog().getDialogType(),VendorDialog.getHostileVendorDialog().getIntro(),-1);//VendorDialog.getHostileVendorDialog();
-8
View File
@@ -326,10 +326,6 @@ public class Effect {
writer.putString(item.getName());
writer.putFloat(-1000f);
} else {
if(true){
serializeForClientMsg(writer);
return;
}
float duration = this.jc.timeToExecutionLeft() / 1000;
writer.putInt(this.eb.getToken());
writer.putInt(aej.getTrains());
@@ -342,10 +338,6 @@ public class Effect {
}
public void serializeForClientMsg(ByteBufferWriter writer) {
if(true){
serializeForLoad(writer);
return;
}
AbstractJob aj = this.jc.getJob();
if (aj == null || (!(aj instanceof AbstractEffectJob))) {
//TODO put error message here
+100 -44
View File
@@ -11,7 +11,6 @@ package engine.objects;
import engine.Enum;
import engine.Enum.TargetColor;
import engine.gameManager.LootManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics;
@@ -350,72 +349,129 @@ public class Experience {
if(killer.equals(mob))
return;
if(killer.pvpKills.contains(mob.getObjectUUID()))
return;
double grantedExperience = 0.0;
double baseXP;
if (g != null) { // Do group EXP stuff
if(g != null) {
//group experience
PlayerCharacter leader = g.getGroupLead();
float leadership = 0.0f;
if(leader.skills.containsKey("Leadership"))
leadership = leader.skills.get("Leadership").getModifiedAmount();
int leadership = 0;
int highestLevel = 0;
double penalty = 0.0;
for(PlayerCharacter member : g.members){
ArrayList<PlayerCharacter> giveEXPTo = new ArrayList<>();
if (member.getLevel() >= MBServerStatics.LEVELCAP)
continue;
// Check if leader is within range of kill and then get leadership
// skill
if(!member.isAlive())
continue;
Vector3fImmutable killLoc = mob.getLoc();
if(member.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
continue; // cannot PVE higher than level 75
if (killLoc.distanceSquared2D(g.getGroupLead().getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) {
CharacterSkill leaderskill = g.getGroupLead().skills
.get("Leadership");
float range = member.loc.distanceSquared(killer.loc);
if(range <= (MBServerStatics.CHARACTER_LOAD_RANGE * MBServerStatics.CHARACTER_LOAD_RANGE)){
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(member.getLevel());
double mod = getConMod(member, mob);
if (leaderskill != null)
leadership = leaderskill.getNumTrains();
if (leadership > 90)
leadership = 90; // leadership caps at 90%
}
if(leadership > 0 && mod != 0)
mod += (leadership * 0.01f);
// Check every group member for distance to see if they get xp
baseXP *= mod;
for (PlayerCharacter pc : g.getMembers()) {
if (pc.isAlive()) { // Skip if the player is dead.
if(baseXP < 1)
baseXP = 1;
// Check within range
baseXP *= (1.0f / g.members.size()+0.9f);
if (killLoc.distanceSquared2D(pc.getLoc()) < (MBServerStatics.EXP_RANGE * MBServerStatics.EXP_RANGE)) {
member.grantXP((int) baseXP);
giveEXPTo.add(pc);
// Track highest level character
if (pc.getLevel() > highestLevel)
highestLevel = pc.getLevel();
}
}
}
}else{
//solo no group
// Process every player in the group getting XP
for (PlayerCharacter playerCharacter : giveEXPTo) {
if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP)
continue;
if(playerCharacter.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
continue; // cannot PVE higher than level 75
// Sets Max XP with server exp mod taken into account.
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(playerCharacter.getLevel());
grantedExperience *= (1/ giveEXPTo.size()+0.9);
// Adjust XP for Mob Level
grantedExperience *= getConMod(playerCharacter, mob);
// Process XP for this member
penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo,
highestLevel);
// Leadership Penalty Reduction
if (leadership > 0)
penalty -= ((leadership) * 0.01) * penalty;
// Modify for hotzone
if (grantedExperience != 0)
if (ZoneManager.inHotZone(mob.getLoc()))
grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE;
// Check for 0 XP due to white mob, otherwise subtract penalty
// xp
if (grantedExperience == 0)
grantedExperience = 1;
else {
grantedExperience -= (penalty * 0.01) * grantedExperience;
// Errant Penalty Calculation
if (playerCharacter.getGuild().isEmptyGuild())
grantedExperience *= 0.6;
}
if (grantedExperience == 0)
grantedExperience = 1;
// Grant the player the EXP
playerCharacter.grantXP((int) Math.floor(grantedExperience));
}
} else { // Give EXP to a single character
//if (!killer.isAlive()) // Skip if the player is dead.
// return;
if (killer.getLevel() >= MBServerStatics.LEVELCAP)
return;
if(killer.level >= 75 && !mob.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))
return; // cannot PVE higher than level 75
return;
baseXP = LootManager.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
double mod = getConMod(killer, mob);
float leadership = 0.0f;
if(killer.skills.containsKey("Leadership"))
leadership = killer.skills.get("Leadership").getModifiedAmount();
if(leadership > 0 && mod != 0){
mod += (leadership * 0.01f);
}
// Get XP and adjust for Mob Level with world xp modifier taken into account
grantedExperience = (double) LOOTMANAGER.NORMAL_EXP_RATE * maxXPPerKill(killer.getLevel());
grantedExperience *= getConMod(killer, mob);
baseXP *= mod;
if(baseXP < 1)
baseXP = 1;
// Modify for hotzone
if (ZoneManager.inHotZone(mob.getLoc()))
grantedExperience *= LOOTMANAGER.HOTZONE_EXP_RATE;
baseXP *= 1.9f;
// Errant penalty
if (grantedExperience != 1)
if (killer.getGuild().isEmptyGuild())
grantedExperience *= .6;
killer.grantXP((int) baseXP);
// Grant XP
killer.grantXP((int) Math.floor(grantedExperience));
}
}
}
+19 -27
View File
@@ -818,15 +818,24 @@ public class Item extends AbstractWorldObject {
}
public void stripCastableEnchants(){
ArrayList<Effect> ToRemove = new ArrayList<>();
for(Effect eff : this.effects.values()){
if(eff.getJobContainer() != null && !eff.getJobContainer().noTimer()){
eff.endEffectNoPower();
eff.getJobContainer().cancelJob();
ToRemove.add(eff);
ArrayList<String> keys =new ArrayList<>();
for(String eff : this.effects.keySet()){
for(AbstractEffectModifier mod : this.effects.get(eff).getEffectsBase().getModifiers()){
if(mod.modType.equals(ModType.WeaponProc)){
keys.add(eff);
}
}
}
for(String eff : keys){
try {
this.effects.get(eff).endEffect();
this.effects.remove(eff);
}catch(Exception e){
}
}
this.effects.values().removeAll(ToRemove);
}
//Only to be used for trading
public void setOwnerID(int ownerID) {
@@ -1076,7 +1085,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = pc.getObjectUUID();
this.ownerType = OwnerType.PlayerCharacter;
this.containerType = ItemContainerType.INVENTORY;
//this.stripCastableEnchants();
this.stripCastableEnchants();
return true;
}
@@ -1097,7 +1106,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = npc.getObjectUUID();
this.ownerType = OwnerType.Npc;
this.containerType = Enum.ItemContainerType.INVENTORY;
//this.stripCastableEnchants();
this.stripCastableEnchants();
return true;
}
@@ -1115,7 +1124,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = 0;
this.ownerType = null;
this.containerType = Enum.ItemContainerType.INVENTORY;
//this.stripCastableEnchants();
this.stripCastableEnchants();
return true;
}
@@ -1483,21 +1492,4 @@ public class Item extends AbstractWorldObject {
return false;
return true;
}
public float getModifiedSpeed() {
float speed = this.getItemBase().getSpeed();
try {
for (Effect eff : this.effects.values()) {
for (AbstractEffectModifier mod : eff.getEffectModifiers()) {
if (mod.modType.equals(ModType.WeaponSpeed)) {
float modValue = 1 + mod.getPercentMod() * 0.01f;
speed *= modValue;
}
}
}
}catch(Exception e){
}
return speed;
}
}
+1 -7
View File
@@ -76,8 +76,6 @@ public class ItemBase {
private ArrayList<Integer> animations = new ArrayList<>();
private ArrayList<Integer> offHandAnimations = new ArrayList<>();
public float dexReduction = 0.0f;
/**
* ResultSet Constructor
*/
@@ -153,7 +151,7 @@ public class ItemBase {
}
initBakedInStats();
initializeHashes();
initDexReduction();
}
public static void addToCache(ItemBase itemBase) {
@@ -321,10 +319,6 @@ public class ItemBase {
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
}
private void initDexReduction(){
DbManager.ItemBaseQueries.LOAD_DEX_REDUCTION(this);
}
//TODO fix this later. Shouldn't be gotten from item base
public int getMagicValue() {
return this.value;
-1
View File
@@ -341,7 +341,6 @@ public class Mine extends AbstractGameObject {
if(!mine.isActive)
if(mine.getOwningGuild() != null)
if(mine.getOwningGuild().getNation().equals(player.getGuild().getNation()))
if(!mine.getOwningGuild().equals(Guild.getErrantGuild()))
mines.add(mine);
return mines;
+228 -118
View File
@@ -96,7 +96,7 @@ public class Mob extends AbstractIntelligenceAgent {
private AbstractWorldObject fearedObject = null;
private int buildingID;
private boolean isSiege = false;
private long lastAttackTime = 0;
private long nextAttackTime = 0;
private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null;
private DeferredPowerJob weaponPower;
@@ -620,7 +620,6 @@ public class Mob extends AbstractIntelligenceAgent {
DbManager.addToCache(mob);
mob.setPet(owner, true);
mob.setWalkMode(false);
mob.level = level;
mob.runAfterLoad();
} catch (Exception e) {
@@ -629,12 +628,8 @@ public class Mob extends AbstractIntelligenceAgent {
createLock.writeLock().unlock();
}
parent.zoneMobSet.add(mob);
// mob.level = level;
float healthMax = mob.getMobBase().getHealthMax();
if(mob.bonuses != null){
healthMax += mob.bonuses.getFloat(ModType.HealthFull,SourceType.None);
}
mob.healthMax = healthMax;
mob.level = level;
mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f);
mob.health.set(mob.healthMax);
return mob;
}
@@ -1447,9 +1442,6 @@ public class Mob extends AbstractIntelligenceAgent {
loadInventory();
this.updateLocation();
this.stopPatrolTime = 0;
this.lastPatrolPointIndex = 0;
InterestManager.setObjectDirty(this);
}
public void despawn() {
@@ -1644,67 +1636,67 @@ public class Mob extends AbstractIntelligenceAgent {
this.defenseRating = defense;
this.atrHandOne = atr;
return;
}else {
if (this.charItemManager == null || this.equip == null) {
Logger.error("Player " + currentID + " missing skills or equipment");
defaultAtrAndDamage(true);
defaultAtrAndDamage(false);
this.defenseRating = 0;
return;
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
} catch (Exception e) {
this.atrHandOne = GetAttackRating(this.mobBase.getAttackRating(), this);
this.minDamageHandOne = (short) this.mobBase.getDamageMin();
this.maxDamageHandOne = (short) this.mobBase.getDamageMax();
this.rangeHandOne = 6.5f;
this.speedHandOne = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false);
} catch (Exception e) {
this.atrHandTwo = GetAttackRating(this.mobBase.getAttackRating(), this);
this.minDamageHandTwo = (short) this.mobBase.getDamageMin();
this.maxDamageHandTwo = (short) this.mobBase.getDamageMax();
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
float defense = this.mobBase.getDefenseRating();
defense += getShieldDefense(equip.get(MBServerStatics.SLOT_OFFHAND));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_HELMET));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_CHEST));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_ARMS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_GLOVES));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_LEGGINGS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_FEET));
defense += getWeaponDefense(equip);
// TODO add error log here
if (this.bonuses != null) {
defense = GetDefense((int) defense, this);
} else
Logger.error("Error: missing bonuses");
defense = (defense < 1) ? 1 : defense;
this.defenseRating = (short) (defense + 0.5f);
} catch (Exception e) {
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. Setting to Default Defense." + e.getMessage());
this.defenseRating = (short) this.mobBase.getDefense();
}
// calculate defense for equipment
}
if((this.isDropper || Mob.discDroppers.contains(this)) && !this.mobBase.getFirstName().contains("Blood Mage")){
if (this.charItemManager == null || this.equip == null) {
Logger.error("Player " + currentID + " missing skills or equipment");
defaultAtrAndDamage(true);
defaultAtrAndDamage(false);
this.defenseRating = 0;
return;
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true);
} catch (Exception e) {
this.atrHandOne = GetAttackRating(this.mobBase.getAttackRating(), this);
this.minDamageHandOne = (short) this.mobBase.getMinDmg();
this.maxDamageHandOne = (short) this.mobBase.getMaxDmg();
this.rangeHandOne = 6.5f;
this.speedHandOne = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false);
} catch (Exception e) {
this.atrHandTwo = GetAttackRating(this.mobBase.getAttackRating(), this);
this.minDamageHandTwo = (short) this.mobBase.getMinDmg();
this.maxDamageHandTwo = (short) this.mobBase.getMaxDmg();
this.rangeHandTwo = 6.5f;
this.speedHandTwo = 20;
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. setting to default ATR and Damage." + e.getMessage());
}
try {
float defense = this.mobBase.getDefenseRating();
defense += getShieldDefense(equip.get(MBServerStatics.SLOT_OFFHAND));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_HELMET));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_CHEST));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_ARMS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_GLOVES));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_LEGGINGS));
defense += getArmorDefense(equip.get(MBServerStatics.SLOT_FEET));
defense += getWeaponDefense(equip);
// TODO add error log here
if (this.bonuses != null) {
defense = GetDefense((int)defense, this);
} else
Logger.error("Error: missing bonuses");
defense = (defense < 1) ? 1 : defense;
this.defenseRating = (short) (defense + 0.5f);
} catch (Exception e) {
Logger.info("Mobbase ID " + this.getMobBaseID() + " returned an error. Setting to Default Defense." + e.getMessage());
this.defenseRating = (short) this.mobBase.getDefense();
}
// calculate defense for equipment
if(this.isDropper || Mob.discDroppers.contains(this)){
this.defenseRating *= 2;
this.atrHandOne *= 2;
this.atrHandTwo *= 2;
@@ -1848,46 +1840,168 @@ public class Mob extends AbstractIntelligenceAgent {
private void calculateAtrDamageForWeapon(MobEquipment weapon, boolean mainHand) {
if(mainHand){
int min = (int)this.mobBase.getDamageMin();
int max = (int)this.mobBase.getDamageMax();
int atr = this.mobBase.getAtr();
if(this.bonuses != null){
min *= 1 + this.bonuses.getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
max *= 1 + this.bonuses.getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
atr *= 1 + this.bonuses.getFloatPercentAll(ModType.OCV,SourceType.None);
atr += this.bonuses.getFloat(ModType.OCV,SourceType.None);
}
this.minDamageHandOne = min;
this.maxDamageHandOne = max;
this.atrHandOne = atr;
if(weapon == null){
int baseStrength = 0;
float skillPercentage, masteryPercentage;
float mastDam;
// make sure weapon exists
boolean noWeapon = false;
ItemBase wb = null;
if (weapon == null)
noWeapon = true;
else {
ItemBase ib = weapon.getItemBase();
if (ib == null)
noWeapon = true;
else if (ib.getType().equals(ItemType.WEAPON) == false) {
defaultAtrAndDamage(mainHand);
return;
} else
wb = ib;
}
float min, max;
float speed;
boolean strBased = false;
// get skill percentages and min and max damage for weapons
if (noWeapon) {
if (mainHand)
this.rangeHandOne = this.mobBase.getAttackRange();
this.speedHandTwo = 20.0f;
}else{
this.rangeHandOne = weapon.getItemBase().getRange();
this.speedHandTwo = weapon.getItemBase().getSpeed();
}
}else{
int min = (int)this.mobBase.getDamageMin();
int max = (int)this.mobBase.getDamageMax();
int atr = this.mobBase.getAtr();
if(this.bonuses != null){
min *= 1 + this.bonuses.getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
max *= 1 + this.bonuses.getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None);
atr *= 1 + this.bonuses.getFloatPercentAll(ModType.OCV,SourceType.None);
atr += this.bonuses.getFloat(ModType.OCV,SourceType.None);
}
this.minDamageHandTwo = min;
this.maxDamageHandTwo = max;
this.atrHandTwo = atr;
if(weapon == null){
this.rangeHandTwo = this.mobBase.getAttackRange();
this.speedHandTwo = 20.0f;
}else{
this.rangeHandTwo = weapon.getItemBase().getRange();
this.speedHandTwo = weapon.getItemBase().getSpeed();
}
else
this.rangeHandTwo = -1; // set to do not attack
skillPercentage = getModifiedAmount(this.skills.get("Unarmed Combat"));
masteryPercentage = getModifiedAmount(this.skills.get("Unarmed Combat Mastery"));
if (masteryPercentage == 0f)
mastDam = CharacterSkill.getQuickMastery(this, "Unarmed Combat Mastery");
else
mastDam = masteryPercentage;
// TODO Correct these
min = this.mobBase.getMinDmg();
max = this.mobBase.getMaxDmg();
} else {
if (mainHand)
this.rangeHandOne = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f));
else
this.rangeHandTwo = weapon.getItemBase().getRange() * (1 + (baseStrength / 600.0f));
skillPercentage = getModifiedAmount(this.skills.get(wb.getSkillRequired()));
masteryPercentage = getModifiedAmount(this.skills.get(wb.getMastery()));
if (masteryPercentage == 0f)
mastDam = 0f;
else
mastDam = masteryPercentage;
min = wb.getMinDamage();
max = wb.getMaxDamage();
strBased = wb.isStrBased();
}
// calculate atr
float atr = this.mobBase.getAttackRating();
if (this.statStrCurrent > this.statDexCurrent)
atr += statStrCurrent * .5;
else
atr += statDexCurrent * .5;
// add in any bonuses to atr
if (this.bonuses != null) {
atr += this.bonuses.getFloat(ModType.OCV, SourceType.None);
// Finally use any multipliers. DO THIS LAST!
float pos_Bonus = 1 + this.bonuses.getFloatPercentPositive(ModType.OCV, SourceType.None);
atr *= pos_Bonus;
//and negative percent modifiers
//TODO DO DEBUFFS AFTER?? wILL TEst when finished
float neg_Bonus = this.bonuses.getFloatPercentNegative(ModType.OCV, SourceType.None);
atr *= (1 + neg_Bonus);
}
atr = (atr < 1) ? 1 : atr;
// set atr
if (mainHand)
this.atrHandOne = (short) (atr + 0.5f);
else
this.atrHandTwo = (short) (atr + 0.5f);
//calculate speed
if (wb != null)
speed = wb.getSpeed();
else
speed = 20f; //unarmed attack speed
if (this.bonuses != null && this.bonuses.getFloat(ModType.AttackDelay, SourceType.None) != 0f) //add effects speed bonus
speed *= (1 + this.bonuses.getFloatPercentAll(ModType.AttackDelay, SourceType.None));
if (speed < 10)
speed = 10;
//add min/max damage bonuses for weapon **REMOVED
//if duel wielding, cut damage by 30%
// calculate damage
float minDamage;
float maxDamage;
float pri = (strBased) ? (float) this.statStrCurrent : (float) this.statDexCurrent;
float sec = (strBased) ? (float) this.statDexCurrent : (float) this.statStrCurrent;
minDamage = (float) (min * ((0.0315f * Math.pow(pri, 0.75f)) + (0.042f * Math.pow(sec, 0.75f)) + (0.01f * ((int) skillPercentage + (int) mastDam))));
maxDamage = (float) (max * ((0.0785f * Math.pow(pri, 0.75f)) + (0.016f * Math.pow(sec, 0.75f)) + (0.0075f * ((int) skillPercentage + (int) mastDam))));
minDamage = (float) ((int) (minDamage + 0.5f)); //round to nearest decimal
maxDamage = (float) ((int) (maxDamage + 0.5f)); //round to nearest decimal
//add Base damage last.
float minDamageMod = this.mobBase.getDamageMin();
float maxDamageMod = this.mobBase.getDamageMax();
minDamage += minDamageMod;
maxDamage += maxDamageMod;
// add in any bonuses to damage
if (this.bonuses != null) {
// Add any base bonuses
minDamage += this.bonuses.getFloat(ModType.MinDamage, SourceType.None);
maxDamage += this.bonuses.getFloat(ModType.MaxDamage, SourceType.None);
// Finally use any multipliers. DO THIS LAST!
minDamage *= (1 + this.bonuses.getFloatPercentAll(ModType.MinDamage, SourceType.None));
maxDamage *= (1 + this.bonuses.getFloatPercentAll(ModType.MaxDamage, SourceType.None));
}
// set damages
if (mainHand) {
this.minDamageHandOne = (short) minDamage;
this.maxDamageHandOne = (short) maxDamage;
this.speedHandOne = 30;
} else {
this.minDamageHandTwo = (short) minDamage;
this.maxDamageHandTwo = (short) maxDamage;
this.speedHandTwo = 30;
}
}
@@ -1962,9 +2076,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
try {
if(this.equipmentSetID == 6481) {
int i = 0;
}
if (this.equipmentSetID != 0)
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
else
@@ -2004,7 +2115,6 @@ public class Mob extends AbstractIntelligenceAgent {
try {
NPCManager.applyRuneSetEffects(this);
MobBase.applyMobbaseEffects(this);
recalculateStats();
this.setHealth(this.healthMax);
@@ -2127,12 +2237,12 @@ public class Mob extends AbstractIntelligenceAgent {
return this.upgradeDateTime != null;
}
public long getLastAttackTime() {
return lastAttackTime;
public long getNextAttackTime() {
return nextAttackTime;
}
public void setLastAttackTime(long lastAttackTime) {
this.lastAttackTime = lastAttackTime;
public void setNextAttackTime(long lastAttackTime) {
this.nextAttackTime = lastAttackTime;
}
public void setDeathTime(long deathTime) {
+9 -40
View File
@@ -13,11 +13,8 @@ import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum;
import engine.gameManager.DbManager;
import engine.gameManager.LootManager;
import engine.gameManager.PowersManager;
import engine.loot.BootySetEntry;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -57,8 +54,6 @@ public class MobBase extends AbstractGameObject {
private float walkCombat = 0;
private float runCombat = 0;
public ArrayList<MobBaseEffects> mobbaseEffects;
/**
* ResultSet Constructor
*/
@@ -113,7 +108,6 @@ public class MobBase extends AbstractGameObject {
this.mobBaseStats = DbManager.MobBaseQueries.LOAD_STATS(this.loadID);
DbManager.MobBaseQueries.LOAD_ALL_MOBBASE_SPEEDS(this);
this.mobbaseEffects = DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.getObjectUUID());
}
@@ -131,22 +125,16 @@ public class MobBase extends AbstractGameObject {
return equip;
for (BootySetEntry equipmentSetEntry : equipList) {
try {
if(equipmentSetEntry.itemBase == 189500){
int i = 0;
}
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
ItemBase itemBase = mobEquipment.getItemBase();
if (itemBase != null) {
if (itemBase.getType().equals(Enum.ItemType.WEAPON))
if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
mobEquipment.setSlot(2);
MobEquipment mobEquipment = new MobEquipment(equipmentSetEntry.itemBase, equipmentSetEntry.dropChance);
ItemBase itemBase = mobEquipment.getItemBase();
equip.put(mobEquipment.getSlot(), mobEquipment);
}
}catch(Exception e){
Logger.error(e);
if (itemBase != null) {
if (itemBase.getType().equals(Enum.ItemType.WEAPON))
if (mobEquipment.getSlot() == 1 && itemBase.getEquipFlag() == 2)
mobEquipment.setSlot(2);
equip.put(mobEquipment.getSlot(), mobEquipment);
}
}
@@ -266,7 +254,7 @@ public class MobBase extends AbstractGameObject {
}
public int getAtr() {
return attackRating;
return atr;
}
public void setAtr(int atr) {
@@ -313,23 +301,4 @@ public class MobBase extends AbstractGameObject {
return runCombat;
}
public static void applyMobbaseEffects(Mob mob){
if(mob.getMobBaseID() == 12008)
mob.level = 65;
else if(mob.getMobBaseID() == 12019)
mob.level = 80;
for(MobBaseEffects mbe : mob.mobBase.mobbaseEffects){
if(mob.level >= mbe.getReqLvl()){
try {
//PowersManager.applyPower(mob, mob, mob.loc, mbe.getToken(), mbe.getRank(), false);
EffectsBase effectsBase = PowersManager.getEffectByToken(mbe.getToken());
if(effectsBase != null)
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
}catch(Exception e){
Logger.error("NULL POWER FOR MOB: " + mob.getObjectUUID() + ", POWER TOKEN: " + mbe.getToken());
}
}
}
}
}
+1 -5
View File
@@ -98,11 +98,7 @@ public class MobEquipment extends AbstractGameObject {
this.dropChance = dropChance;
this.parentID = 0;
try {
setMagicValue();
}catch(Exception e){
}
setMagicValue();
}
public static int getNewID() {

Some files were not shown because too many files have changed in this diff Show More