Compare commits
73 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ffdd79c497 | |||
| b156da7ded | |||
| 9278954f2f | |||
| 4324ebe855 | |||
| 4a69dca5cc | |||
| 2cc54b4002 | |||
| eac0aebd59 | |||
| 172dcfb6d8 | |||
| d320d83c22 | |||
| af2dd004e4 | |||
| dfbace76db | |||
| 119f762492 | |||
| e586c442c1 | |||
| c01e87ee8b | |||
| af4025d948 | |||
| b7c2b7a0d5 | |||
| f073a93d47 | |||
| 47914838f5 | |||
| 69e2630d77 | |||
| 08148c058c | |||
| a7ee8f553b | |||
| 8395bb80f1 | |||
| becd3cbf65 | |||
| 80ec681a2c | |||
| 96a80ce1b6 | |||
| f18cf5c8a6 | |||
| 4c21159553 | |||
| 475c0a9b09 | |||
| f80ad61179 | |||
| 10ccfb1086 | |||
| 44197fd83c | |||
| 0d9e03f848 | |||
| 810812d06b | |||
| 539d7f6e79 | |||
| 3358d9e943 | |||
| eeffd9b357 | |||
| b33f41200e | |||
| 030d1110b9 | |||
| 09af8084b9 | |||
| 0cff9524c2 | |||
| f6299f5b97 | |||
| b1250ae4e4 | |||
| a9144471b1 | |||
| 9f924da18b | |||
| aac92f1760 | |||
| fdf42bd913 | |||
| ecee2f2e8c | |||
| 1b487fdbb6 | |||
| bb7bd6d71b | |||
| 34178906a3 | |||
| c689722459 | |||
| 8e4ff8c67f | |||
| 4ff22d1d20 | |||
| 5ed7712aed | |||
| a6fcb5ea00 | |||
| 8f402c8c03 | |||
| 5761e313fd | |||
| 441771839a | |||
| ad6700974f | |||
| 499aec2c61 | |||
| ceed4c641a | |||
| 669c0b4cd7 | |||
| 7964de1045 | |||
| 961e2915b4 | |||
| 6c6a64fa98 | |||
| 7a8a751bca | |||
| 69bf6ef8cd | |||
| 05e542215d | |||
| 868eaab5ed | |||
| e7d22717cd | |||
| bbabf814e1 | |||
| 938fcb1352 | |||
| 42a71396cd |
@@ -45,6 +45,24 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_DEX_REDUCTION(ItemBase itemBase) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty` WHERE `ID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBase.getUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
// Check if a result was found
|
||||
if (rs.next()) {
|
||||
itemBase.dexReduction = rs.getFloat("item_bulk_factor");
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void LOAD_ANIMATIONS(ItemBase itemBase) {
|
||||
|
||||
ArrayList<Integer> tempList = new ArrayList<>();
|
||||
|
||||
@@ -342,7 +342,8 @@ public class InfoCmd extends AbstractDevCmd {
|
||||
output += newline;
|
||||
output += "isMoving : " + targetPC.isMoving();
|
||||
output += newline;
|
||||
output += "Zerg Multiplier : " + targetPC.ZergMultiplier;
|
||||
output += "Zerg Multiplier : " + targetPC.ZergMultiplier+ newline;
|
||||
output += "Hidden : " + targetPC.getHidden();
|
||||
break;
|
||||
|
||||
case NPC:
|
||||
|
||||
@@ -57,27 +57,36 @@ public class PrintStatsCmd extends AbstractDevCmd {
|
||||
|
||||
public void printStatsPlayer(PlayerCharacter pc, PlayerCharacter tar) {
|
||||
String newline = "\r\n ";
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void printStatsMob(PlayerCharacter pc, Mob tar) {
|
||||
|
||||
@@ -483,16 +483,24 @@ 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 (wepSpeed < 10)
|
||||
wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects.
|
||||
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.
|
||||
}
|
||||
createTimer(abstractCharacter, slot, wepSpeed, true);
|
||||
}
|
||||
|
||||
@@ -536,15 +544,27 @@ public enum CombatManager {
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (mainHand) {
|
||||
atr = ac.getAtrHandOne();
|
||||
minDamage = ac.getMinDamageHandOne();
|
||||
maxDamage = ac.getMaxDamageHandOne();
|
||||
} else {
|
||||
atr = ac.getAtrHandTwo();
|
||||
minDamage = ac.getMinDamageHandTwo();
|
||||
maxDamage = ac.getMaxDamageHandTwo();
|
||||
if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
PlayerCharacter pc = (PlayerCharacter) ac;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
boolean tarIsRat = false;
|
||||
@@ -638,7 +658,11 @@ public enum CombatManager {
|
||||
}
|
||||
} else {
|
||||
AbstractCharacter tar = (AbstractCharacter) target;
|
||||
defense = tar.getDefenseRating();
|
||||
if(tar.getObjectType().equals(GameObjectType.PlayerCharacter)){
|
||||
defense = ((PlayerCharacter)tar).combatStats.defense;
|
||||
}else {
|
||||
defense = tar.getDefenseRating();
|
||||
}
|
||||
handleRetaliate(tar, ac); //Handle target attacking back if in combat and has no other target
|
||||
}
|
||||
|
||||
@@ -878,27 +902,18 @@ public enum CombatManager {
|
||||
|
||||
if (weapon != null && tarAc != null && tarAc.isAlive()) {
|
||||
|
||||
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) {
|
||||
|
||||
if(weapon.effects != null){
|
||||
for (Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(ModType.WeaponProc)){
|
||||
int procChance = ThreadLocalRandom.current().nextInt(100);
|
||||
|
||||
if (procChance < MBServerStatics.PROC_CHANCE)
|
||||
((WeaponProcEffectModifier) aem).applyProc(ac, target);
|
||||
|
||||
if (procChance < MBServerStatics.PROC_CHANCE) {
|
||||
try {
|
||||
((WeaponProcEffectModifier) mod).applyProc(ac, target);
|
||||
}catch(Exception e){
|
||||
Logger.error(eff.getName() + " Failed To Cast Proc");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1472,15 +1487,17 @@ public enum CombatManager {
|
||||
|
||||
public static boolean LandHit(int C5, int D5){
|
||||
|
||||
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));
|
||||
float chance = (C5-((C5+D5) * 0.315f)) / ((D5-((C5+D5) * 0.315f)) + (C5-((C5+D5) * 0.315f)));
|
||||
float convertedChance = chance * 100;
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(101);
|
||||
|
||||
if(roll < 5)//always 5% chance ot miss
|
||||
if(roll <= 5)//always 5% chance to miss
|
||||
return false;
|
||||
|
||||
if(roll >= 95)//always 5% chance to hit
|
||||
return true;
|
||||
|
||||
return roll <= convertedChance;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,20 @@ 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;
|
||||
|
||||
@@ -10,6 +10,7 @@ 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;
|
||||
@@ -197,7 +198,8 @@ public enum PowersManager {
|
||||
msg.setUnknown04(1);
|
||||
|
||||
if (useMobPowerA(msg, caster)) {
|
||||
//sendMobPowerMsg(caster,2,msg); //Lol wtf was i thinking sending msg's to mobs... ZZZZ
|
||||
if(pb.token == -1994153779)
|
||||
InterestManager.setObjectDirty(caster);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2958,6 +2960,8 @@ public enum PowersManager {
|
||||
case 429517915:
|
||||
case 431854842:
|
||||
case 429767544:
|
||||
case 429502507:
|
||||
case 428398816:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -964,7 +964,6 @@ 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
|
||||
@@ -994,6 +993,11 @@ 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());
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public class MobRespawnThread implements Runnable {
|
||||
respawner.respawn();
|
||||
zone.respawnQue.remove(respawner);
|
||||
zone.lastRespawn = System.currentTimeMillis();
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +345,6 @@ public class ApplyRuneMsg extends ClientNetMsg {
|
||||
discAllowed = 3;
|
||||
break;
|
||||
case 7:
|
||||
discAllowed = 4;
|
||||
break;
|
||||
case 8:
|
||||
discAllowed = 5;
|
||||
break;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class CharacterSkill extends AbstractGameObject {
|
||||
165, 166, 166, 167, 167, //185 to 189
|
||||
168}; //190
|
||||
|
||||
private static final float[] baseSkillValues = {
|
||||
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
|
||||
|
||||
@@ -1492,4 +1492,21 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ public class ItemBase {
|
||||
private ArrayList<Integer> animations = new ArrayList<>();
|
||||
private ArrayList<Integer> offHandAnimations = new ArrayList<>();
|
||||
|
||||
public float dexReduction = 0.0f;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
@@ -151,7 +153,7 @@ public class ItemBase {
|
||||
}
|
||||
initBakedInStats();
|
||||
initializeHashes();
|
||||
|
||||
initDexReduction();
|
||||
}
|
||||
|
||||
public static void addToCache(ItemBase itemBase) {
|
||||
@@ -319,6 +321,10 @@ 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;
|
||||
|
||||
@@ -1444,6 +1444,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.updateLocation();
|
||||
this.stopPatrolTime = 0;
|
||||
this.lastPatrolPointIndex = 0;
|
||||
InterestManager.setObjectDirty(this);
|
||||
}
|
||||
|
||||
public void despawn() {
|
||||
@@ -1698,7 +1699,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
// calculate defense for equipment
|
||||
}
|
||||
if(this.isDropper || Mob.discDroppers.contains(this)){
|
||||
if((this.isDropper || Mob.discDroppers.contains(this)) && !this.mobBase.getFirstName().contains("Blood Mage")){
|
||||
this.defenseRating *= 2;
|
||||
this.atrHandOne *= 2;
|
||||
this.atrHandTwo *= 2;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class PlayerBonuses {
|
||||
|
||||
//First bonus set
|
||||
private ConcurrentHashMap<AbstractEffectModifier, Float> bonusFloats = new ConcurrentHashMap<>();
|
||||
ConcurrentHashMap<AbstractEffectModifier, Float> bonusFloats = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<AbstractEffectModifier, DamageShield> bonusDamageShields = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<AbstractEffectModifier, String> bonusStrings = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<ModType, HashSet<SourceType>> bonusLists = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -36,6 +36,7 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.*;
|
||||
import engine.net.client.msg.login.CommitNewCharacterMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.login.LoginServer;
|
||||
import engine.server.login.LoginServerMsgHandler;
|
||||
@@ -179,6 +180,8 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
public boolean isBoxed = false;
|
||||
|
||||
public PlayerCombatStats combatStats;
|
||||
|
||||
/**
|
||||
* No Id Constructor
|
||||
*/
|
||||
@@ -3837,6 +3840,285 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateATR(){
|
||||
if(this.charItemManager == null){
|
||||
this.atrHandOne = 1;
|
||||
this.atrHandTwo = 1;
|
||||
return;
|
||||
}
|
||||
for(int i = 1; i < 3; i++){
|
||||
float atr = 0;
|
||||
int primaryStat;
|
||||
Item weapon = this.charItemManager.getEquipped(i);
|
||||
ItemBase weaponBase = null;
|
||||
String skill = "Unarmed Combat";
|
||||
String mastery = "Unarmed Combat Mastery";
|
||||
|
||||
if(weapon != null) {
|
||||
weaponBase = weapon.getItemBase();
|
||||
skill = weaponBase.getSkillRequired();
|
||||
mastery = weaponBase.getMastery();
|
||||
}
|
||||
int skillPercentage = this.skills.containsKey(skill) && this.skills.get(skill) != null
|
||||
? this.skills.get(skill).getTotalSkillPercet()
|
||||
: 1;
|
||||
int masteryPercentage = this.skills.containsKey(mastery) && this.skills.get(mastery) != null
|
||||
? this.skills.get(mastery).getTotalSkillPercet()
|
||||
: 1;
|
||||
|
||||
// Determine the primary stat based on the weapon base
|
||||
if (weaponBase != null && weaponBase.isStrBased()) {
|
||||
primaryStat = this.statStrCurrent;
|
||||
} else {
|
||||
primaryStat = this.statDexCurrent;
|
||||
}
|
||||
|
||||
// Calculate ATR based on primary stat, skill, and mastery
|
||||
atr = (primaryStat * 0.5f) + (skillPercentage * 4) + (masteryPercentage * 3);
|
||||
|
||||
// Add any bonuses to ATR
|
||||
if (this.bonuses != null) {
|
||||
atr += this.bonuses.getFloat(ModType.OCV, SourceType.None);
|
||||
|
||||
// Apply positive bonus multipliers
|
||||
float pos_Bonus = (1 + this.bonuses.getFloatPercentPositive(ModType.OCV, SourceType.None));
|
||||
atr *= pos_Bonus;
|
||||
|
||||
// Apply negative bonus multipliers
|
||||
float neg_Bonus = this.bonuses.getFloatPercentNegative(ModType.OCV, SourceType.None);
|
||||
atr *= (1 + neg_Bonus);
|
||||
}
|
||||
|
||||
atr -= 2;//no idea why, need for sync
|
||||
// Ensure ATR is at least 1
|
||||
atr = (atr < 1) ? 1 : atr;
|
||||
|
||||
// Set atrHandOne
|
||||
if(i == 1)
|
||||
this.atrHandOne = (short) atr;
|
||||
else if(i == 2)
|
||||
this.atrHandTwo = (short) atr;
|
||||
}
|
||||
}
|
||||
public void calculateDamage(){
|
||||
if(this.charItemManager == null){
|
||||
this.minDamageHandOne = 1;
|
||||
this.maxDamageHandOne = 5;
|
||||
this.minDamageHandTwo = 1;
|
||||
this.maxDamageHandTwo = 5;
|
||||
return;
|
||||
}
|
||||
this.calculateMinDamage();
|
||||
this.calculateMaxDamage();
|
||||
}
|
||||
public void calculateMinDamage(){
|
||||
int baseDMG1 = 2;
|
||||
int baseDMG2 = 2;
|
||||
int weaponSkill1 = this.skills.containsKey("Unarmed Combat") && this.skills.get("Unarmed Combat") != null
|
||||
? this.skills.get("Unarmed Combat").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponSkill2 = this.skills.containsKey("Unarmed Combat") && this.skills.get("Unarmed Combat") != null
|
||||
? this.skills.get("Unarmed Combat").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponMastery1 = this.skills.containsKey("Unarmed Combat Mastery") && this.skills.get("Unarmed Combat Mastery") != null
|
||||
? this.skills.get("Unarmed Combat Mastery").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponMastery2 = this.skills.containsKey("Unarmed Combat Mastery") && this.skills.get("Unarmed Combat Mastery") != null
|
||||
? this.skills.get("Unarmed Combat Mastery").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
Item equippedRight = this.charItemManager.getEquipped(1);
|
||||
Item equippedLeft = this.charItemManager.getEquipped(2);
|
||||
|
||||
int primary1 = this.statDexCurrent;
|
||||
int secondary1 = this.statStrCurrent;
|
||||
int primary2 = this.statDexCurrent;
|
||||
int secondary2 = this.statStrCurrent;
|
||||
|
||||
if(equippedRight != null){
|
||||
baseDMG1 = equippedRight.getItemBase().getMinDamage();
|
||||
weaponSkill1 = this.skills.containsKey(equippedRight.getItemBase().getSkillRequired())
|
||||
&& this.skills.get(equippedRight.getItemBase().getSkillRequired()) != null
|
||||
? this.skills.get(equippedRight.getItemBase().getSkillRequired()).getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
weaponMastery1 = this.skills.containsKey(equippedRight.getItemBase().getMastery())
|
||||
&& this.skills.get(equippedRight.getItemBase().getMastery()) != null
|
||||
? this.skills.get(equippedRight.getItemBase().getMastery()).getTotalSkillPercet()
|
||||
: 0;
|
||||
if(equippedRight.getItemBase().isStrBased()) {
|
||||
primary1 = this.statStrCurrent;
|
||||
secondary1 = this.statDexCurrent;
|
||||
}
|
||||
}
|
||||
if(equippedLeft != null){
|
||||
baseDMG2 = equippedLeft.getItemBase().getMinDamage();
|
||||
weaponSkill2 = this.skills.containsKey(equippedLeft.getItemBase().getSkillRequired())
|
||||
&& this.skills.get(equippedLeft.getItemBase().getSkillRequired()) != null
|
||||
? this.skills.get(equippedLeft.getItemBase().getSkillRequired()).getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
weaponMastery2 = this.skills.containsKey(equippedLeft.getItemBase().getMastery())
|
||||
&& this.skills.get(equippedLeft.getItemBase().getMastery()) != null
|
||||
? this.skills.get(equippedLeft.getItemBase().getMastery()).getTotalSkillPercet()
|
||||
: 0;
|
||||
if(equippedLeft.getItemBase().isStrBased()) {
|
||||
primary2 = this.statStrCurrent;
|
||||
secondary2 = this.statDexCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
double primaryComponent1 = 0.0048 * primary1 + 0.049 * Math.sqrt(primary1 - 0.75);
|
||||
double secondaryComponent1 = 0.0066 * secondary1 + 0.064 * Math.sqrt(secondary1 - 0.75);
|
||||
double skillComponent1 = 0.01 * (weaponSkill1 + weaponMastery1);
|
||||
|
||||
int min1 = (int)(baseDMG1 * (primaryComponent1 + secondaryComponent1 + skillComponent1));
|
||||
|
||||
double primaryComponent2 = 0.0048 * primary2 + 0.049 * Math.sqrt(primary2 - 0.75);
|
||||
double secondaryComponent2 = 0.0066 * secondary2 + 0.064 * Math.sqrt(secondary2 - 0.75);
|
||||
double skillComponent2 = 0.01 * (weaponSkill2 + weaponMastery2);
|
||||
|
||||
int min2 = (int)(baseDMG2 * (primaryComponent2 + secondaryComponent2 + skillComponent2));
|
||||
|
||||
this.minDamageHandOne = min1;
|
||||
this.minDamageHandTwo = min2;
|
||||
}
|
||||
public void calculateMaxDamage() {
|
||||
int baseDMG1 = 8;
|
||||
int baseDMG2 = 8;
|
||||
int weaponSkill1 = this.skills.containsKey("Unarmed Combat") && this.skills.get("Unarmed Combat") != null
|
||||
? this.skills.get("Unarmed Combat").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponSkill2 = this.skills.containsKey("Unarmed Combat") && this.skills.get("Unarmed Combat") != null
|
||||
? this.skills.get("Unarmed Combat").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponMastery1 = this.skills.containsKey("Unarmed Combat Mastery") && this.skills.get("Unarmed Combat Mastery") != null
|
||||
? this.skills.get("Unarmed Combat Mastery").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
int weaponMastery2 = this.skills.containsKey("Unarmed Combat Mastery") && this.skills.get("Unarmed Combat Mastery") != null
|
||||
? this.skills.get("Unarmed Combat Mastery").getTotalSkillPercet()
|
||||
: 0;
|
||||
|
||||
Item equippedRight = this.charItemManager.getItemFromEquipped(ItemSlotType.RHELD.ordinal());
|
||||
Item equippedLeft = this.charItemManager.getItemFromEquipped(ItemSlotType.LHELD.ordinal());
|
||||
|
||||
int primary1 = this.statDexCurrent;
|
||||
int secondary1 = this.statStrCurrent;
|
||||
int primary2 = this.statDexCurrent;
|
||||
int secondary2 = this.statStrCurrent;
|
||||
|
||||
if (equippedRight != null) {
|
||||
baseDMG1 = equippedRight.getItemBase().getMaxDamage();
|
||||
weaponSkill1 = this.skills.containsKey(equippedRight.getItemBase().getSkillRequired())
|
||||
&& this.skills.get(equippedRight.getItemBase().getSkillRequired()) != null
|
||||
? this.skills.get(equippedRight.getItemBase().getSkillRequired()).getTotalSkillPercet()
|
||||
: 1;
|
||||
|
||||
weaponMastery1 = this.skills.containsKey(equippedRight.getItemBase().getMastery())
|
||||
&& this.skills.get(equippedRight.getItemBase().getMastery()) != null
|
||||
? this.skills.get(equippedRight.getItemBase().getMastery()).getTotalSkillPercet()
|
||||
: 1;
|
||||
if (equippedRight.getItemBase().isStrBased()) {
|
||||
primary1 = this.statStrCurrent;
|
||||
secondary1 = this.statDexCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
if (equippedLeft != null) {
|
||||
baseDMG2 = equippedLeft.getItemBase().getMaxDamage();
|
||||
weaponSkill2 = this.skills.containsKey(equippedLeft.getItemBase().getSkillRequired())
|
||||
&& this.skills.get(equippedLeft.getItemBase().getSkillRequired()) != null
|
||||
? this.skills.get(equippedLeft.getItemBase().getSkillRequired()).getTotalSkillPercet()
|
||||
: 1;
|
||||
|
||||
weaponMastery2 = this.skills.containsKey(equippedLeft.getItemBase().getMastery())
|
||||
&& this.skills.get(equippedLeft.getItemBase().getMastery()) != null
|
||||
? this.skills.get(equippedLeft.getItemBase().getMastery()).getTotalSkillPercet()
|
||||
: 1;
|
||||
if (equippedLeft.getItemBase().isStrBased()) {
|
||||
primary2 = this.statStrCurrent;
|
||||
secondary2 = this.statDexCurrent;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate max damage for right hand weapon
|
||||
double primaryComponent1 = 0.0124 * primary1 + 0.118 * Math.sqrt(primary1 - 0.75);
|
||||
double secondaryComponent1 = 0.0022 * secondary1 + 0.028 * Math.sqrt(secondary1 - 0.75);
|
||||
double skillComponent1 = 0.0075 * (weaponSkill1 + weaponMastery1);
|
||||
|
||||
int max1 = (int) (baseDMG1 * (primaryComponent1 + secondaryComponent1 + skillComponent1));
|
||||
|
||||
// Calculate max damage for left hand weapon
|
||||
double primaryComponent2 = 0.0124 * primary2 + 0.118 * Math.sqrt(primary2 - 0.75);
|
||||
double secondaryComponent2 = 0.0022 * secondary2 + 0.028 * Math.sqrt(secondary2 - 0.75);
|
||||
double skillComponent2 = 0.0075 * (weaponSkill2 + weaponMastery2);
|
||||
|
||||
int max2 = (int) (baseDMG2 * (primaryComponent2 + secondaryComponent2 + skillComponent2));
|
||||
|
||||
this.maxDamageHandOne = max1;
|
||||
this.maxDamageHandTwo = max2;
|
||||
}
|
||||
public void calculateSpeed(){
|
||||
if(this.charItemManager == null){
|
||||
this.speedHandOne = 20.0f;
|
||||
this.speedHandTwo = 20.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
ItemBase weaponBase1 = null;
|
||||
ItemBase weaponBase2 = null;
|
||||
if(this.charItemManager.getItemFromEquipped(ItemSlotType.RHELD.ordinal()) != null){
|
||||
weaponBase1 = this.charItemManager.getItemFromEquipped(ItemSlotType.RHELD.ordinal()).getItemBase();
|
||||
}
|
||||
if(this.charItemManager.getItemFromEquipped(ItemSlotType.LHELD.ordinal()) != null){
|
||||
weaponBase2 = this.charItemManager.getItemFromEquipped(ItemSlotType.LHELD.ordinal()).getItemBase();
|
||||
}
|
||||
|
||||
float speed1;
|
||||
float speed2;
|
||||
if (weaponBase1 != null)
|
||||
speed1 = weaponBase1.getSpeed();
|
||||
else
|
||||
speed1 = 20f;
|
||||
if (weaponBase2 != null)
|
||||
speed2 = weaponBase2.getSpeed();
|
||||
else
|
||||
speed2 = 20f;
|
||||
|
||||
if(this.bonuses!= null){
|
||||
for (AbstractEffectModifier mod : this.bonuses.bonusFloats.keySet()) {
|
||||
if (mod.modType.equals(ModType.AttackDelay) || mod.modType.equals(ModType.WeaponSpeed)) {
|
||||
float modValue = 1 + mod.getPercentMod() * 0.01f;
|
||||
speed1 *= modValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.bonuses!= null){
|
||||
for (AbstractEffectModifier mod : this.bonuses.bonusFloats.keySet()) {
|
||||
if (mod.modType.equals(ModType.AttackDelay) || mod.modType.equals(ModType.WeaponSpeed)) {
|
||||
float modValue = 1 + mod.getPercentMod() * 0.01f;
|
||||
speed2 *= modValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (speed1 < 10)
|
||||
speed1 = 10;
|
||||
|
||||
if (speed2 < 10)
|
||||
speed2 = 10;
|
||||
|
||||
this.speedHandOne = speed1;
|
||||
this.speedHandTwo= speed2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ Calculates Atr, and Damage for each weapon
|
||||
*/
|
||||
@@ -3863,9 +4145,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
float speed = 20f;
|
||||
boolean strBased = false;
|
||||
|
||||
ItemBase wbMain = (weapon != null) ? weapon.getItemBase() : null;
|
||||
ItemBase wbOff = (otherHand != null) ? otherHand.getItemBase() : null;
|
||||
|
||||
// get skill percentages and min and max damage for weapons
|
||||
if (noWeapon) {
|
||||
if (mainHand) {
|
||||
@@ -3929,8 +4208,6 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
//(Primary Stat / 2) + (Weapon Skill * 4) + (Weapon Mastery * 3) + (ATR Enchantments) * 1.stance modifier
|
||||
float atr = 0;
|
||||
int primaryStat;
|
||||
int dexMod = this.getDexMod();
|
||||
int strMod = this.getStrMod();
|
||||
if(weaponBase != null && weaponBase.isStrBased()){
|
||||
primaryStat = this.statStrCurrent;
|
||||
}else{
|
||||
@@ -3952,6 +4229,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
float neg_Bonus = this.bonuses.getFloatPercentNegative(ModType.OCV, SourceType.None);
|
||||
|
||||
atr *= (1 + neg_Bonus);
|
||||
|
||||
}
|
||||
|
||||
atr = (atr < 1) ? 1 : atr;
|
||||
@@ -3964,13 +4242,41 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
}
|
||||
|
||||
//calculate speed
|
||||
if (weaponBase != null)
|
||||
speed = weaponBase.getSpeed();
|
||||
if (weapon != null)
|
||||
speed = weapon.getModifiedSpeed();
|
||||
else
|
||||
speed = 20f; //unarmed attack speed
|
||||
if (weapon != null)
|
||||
speed *= (1 + this.bonuses.getFloatPercentAll(ModType.WeaponSpeed, SourceType.None));
|
||||
speed *= (1 + this.bonuses.getFloatPercentAll(ModType.AttackDelay, SourceType.None));
|
||||
|
||||
//if(this.effects != null) {
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (Effect eff : this.effects.values()) {
|
||||
// for (AbstractEffectModifier mod : eff.getEffectModifiers()) {
|
||||
// if (mod.modType.equals(ModType.AttackDelay)) {
|
||||
// float modValue = 1 + mod.getPercentMod() * 0.01f;
|
||||
// speed *= modValue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
if(this.bonuses!= null){
|
||||
for (AbstractEffectModifier mod : this.bonuses.bonusFloats.keySet()) {
|
||||
if (mod.modType.equals(ModType.AttackDelay)) {
|
||||
float modValue = 1 + mod.getPercentMod() * 0.01f;
|
||||
speed *= modValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (speed < 10)
|
||||
speed = 10;
|
||||
|
||||
@@ -4048,16 +4354,21 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// set damages
|
||||
if (mainHand) {
|
||||
this.minDamageHandOne = (int) minDamage;
|
||||
this.maxDamageHandOne = (int) maxDamage;
|
||||
this.maxDamageHandOne = (int) maxDamage + 1;
|
||||
this.speedHandOne = speed;
|
||||
} else {
|
||||
this.minDamageHandTwo = (int) minDamage;
|
||||
this.maxDamageHandTwo = (int) maxDamage;
|
||||
this.maxDamageHandTwo = (int) maxDamage + 1;
|
||||
this.speedHandTwo = speed;
|
||||
}
|
||||
|
||||
//this.calculateATR();
|
||||
//this.calculateDamage();
|
||||
//this.calculateSpeed();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4079,9 +4390,15 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
float def = ab.getDefense();
|
||||
//apply item defense bonuses
|
||||
if (shield != null) {
|
||||
def += shield.getBonus(ModType.DR, SourceType.None);
|
||||
def *= (1 + shield.getBonusPercent(ModType.DR, SourceType.None));
|
||||
|
||||
//def += shield.getBonus(ModType.DR, SourceType.None);
|
||||
//def *= (1 + shield.getBonusPercent(ModType.DR, SourceType.None));
|
||||
for(Effect eff : shield.effects.values()) {
|
||||
for (AbstractEffectModifier mod : eff.getEffectModifiers()) {
|
||||
if (mod.modType.equals(ModType.DR)) {
|
||||
def += mod.minMod * (1 + (eff.getTrains() * mod.getRamp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// float val = ((float)ab.getDefense()) * (1 + (skillMod / 100));
|
||||
@@ -4139,8 +4456,10 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
|
||||
if (!ib.getType().equals(ItemType.ARMOR))
|
||||
return 0;
|
||||
|
||||
if (ib.getSkillRequired().isEmpty())
|
||||
return ib.getDefense();
|
||||
|
||||
CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired());
|
||||
if (armorSkill == null) {
|
||||
Logger.error("Player " + this.getObjectUUID()
|
||||
@@ -4151,8 +4470,18 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
float def = ib.getDefense();
|
||||
//apply item defense bonuses
|
||||
if (armor != null) {
|
||||
def += armor.getBonus(ModType.DR, SourceType.None);
|
||||
def *= (1 + armor.getBonusPercent(ModType.DR, SourceType.None));
|
||||
|
||||
for(Effect eff : armor.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(ModType.DR)){
|
||||
def += mod.minMod * (1+(eff.getTrains() * mod.getRamp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//def += armor.getBonus(ModType.DR, SourceType.None);
|
||||
//def *= (1 + armor.getBonusPercent(ModType.DR, SourceType.None));
|
||||
}
|
||||
|
||||
|
||||
@@ -4375,7 +4704,7 @@ public class PlayerCharacter extends AbstractCharacter {
|
||||
ModType modType = ModType.GetModType(type);
|
||||
|
||||
// must be allowed to use this passive
|
||||
if (!this.bonuses.getBool(modType, SourceType.None))
|
||||
if (!this.bonuses.getBool(modType, SourceType.None) && this.getRaceID() != 1999)
|
||||
return 0f;
|
||||
|
||||
// must not be stunned
|
||||
|
||||
@@ -0,0 +1,752 @@
|
||||
package engine.objects;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PlayerCombatStats {
|
||||
|
||||
public PlayerCharacter owner;
|
||||
//main hand data
|
||||
public int minDamageHandOne;
|
||||
public int maxDamageHandOne;
|
||||
public float attackSpeedHandOne;
|
||||
public float rangeHandOne;
|
||||
public float atrHandOne;
|
||||
//off hand data
|
||||
public int minDamageHandTwo;
|
||||
public int maxDamageHandTwo;
|
||||
public float attackSpeedHandTwo;
|
||||
public float rangeHandTwo;
|
||||
public float atrHandTwo;
|
||||
//defense
|
||||
public int defense;
|
||||
//regen rates
|
||||
public float healthRegen;
|
||||
public float manaRegen;
|
||||
public float staminaRegen;
|
||||
|
||||
public PlayerCombatStats(PlayerCharacter pc) {
|
||||
this.owner = pc;
|
||||
this.update();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
try {
|
||||
this.calculateATR(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE ATR FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateATR(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE ATR FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateMin(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Min FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateMin(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Min FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateMax(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Max FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateMax(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Max FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateAttackSpeed(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Attack Speed FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateAttackSpeed(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Attack Speed FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateAttackRange(true);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Attack Range FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateAttackRange(false);
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Attack Range FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateRegen();
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Regen FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
try {
|
||||
this.calculateDefense();
|
||||
} catch (Exception e) {
|
||||
Logger.error("FAILED TO CALCULATE Defense FOR: " + this.owner.getObjectUUID());
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateATR(boolean mainHand) {
|
||||
Item weapon;
|
||||
float atr;
|
||||
|
||||
if(mainHand) {
|
||||
weapon = this.owner.charItemManager.getEquipped(1);
|
||||
}else {
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
|
||||
String skill = "Unarmed Combat";
|
||||
String mastery = "Unarmed Combat Mastery";
|
||||
int primaryStat = getDexAfterPenalty(this.owner);
|
||||
if(weapon != null) {
|
||||
skill= weapon.getItemBase().getSkillRequired();
|
||||
mastery = weapon.getItemBase().getMastery();
|
||||
if(weapon.getItemBase().isStrBased())
|
||||
primaryStat = this.owner.statStrCurrent;
|
||||
}
|
||||
|
||||
float skillLevel = 0;
|
||||
float masteryLevel = 0;
|
||||
|
||||
if(this.owner.skills.containsKey(skill)) {
|
||||
skillLevel = this.owner.skills.get(skill).getModifiedAmount();
|
||||
}
|
||||
if(this.owner.skills.containsKey(mastery))
|
||||
masteryLevel = this.owner.skills.get(mastery).getModifiedAmount();
|
||||
|
||||
float stanceValue = 0.0f;
|
||||
float atrEnchants = 0;
|
||||
|
||||
for(String effID : this.owner.effects.keySet()) {
|
||||
if (effID.contains("Stance")) {
|
||||
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) {
|
||||
if (mod.modType.equals(Enum.ModType.OCV)) {
|
||||
float percent = mod.getPercentMod();
|
||||
int trains = this.owner.effects.get(effID).getTrains();
|
||||
float modValue = percent + (trains * mod.getRamp());
|
||||
stanceValue += modValue * 0.01f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) {
|
||||
if (mod.modType.equals(Enum.ModType.OCV)) {
|
||||
float value = mod.getMinMod();
|
||||
int trains = this.owner.effects.get(effID).getTrains();
|
||||
float modValue = value + (trains * mod.getRamp());
|
||||
atrEnchants += modValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float prefixValues = 0.0f;
|
||||
if(weapon != null){
|
||||
if(this.owner.charItemManager.getEquipped(1) != null){
|
||||
for(Effect eff : this.owner.charItemManager.getEquipped(1).effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.OCV)){
|
||||
prefixValues += mod.minMod + (eff.getTrains() * mod.getRamp());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.owner.charItemManager.getEquipped(2) != null){
|
||||
for(Effect eff : this.owner.charItemManager.getEquipped(2).effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.OCV)){
|
||||
prefixValues += mod.minMod + (eff.getTrains() * mod.getRamp());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float preciseRune = 1.0f;
|
||||
for(CharacterRune rune : this.owner.runes){
|
||||
if(rune.getRuneBase().getName().equals("Precise"))
|
||||
preciseRune += 0.05f;
|
||||
}
|
||||
|
||||
if(weapon != null && weapon.getItemBase().isStrBased()){
|
||||
atr = (((primaryStat / 2) + (skillLevel * 4 + masteryLevel * 3) + prefixValues) * preciseRune + atrEnchants) * (1.0f + stanceValue);
|
||||
atr = (float) Math.round(atr);
|
||||
}else {
|
||||
float dexterity = getDexAfterPenalty(this.owner);
|
||||
atr = dexterity / 2;
|
||||
atr += skillLevel * 4;
|
||||
atr += masteryLevel * 3;
|
||||
atr += prefixValues;
|
||||
atr *= preciseRune;
|
||||
atr += atrEnchants;
|
||||
atr *= 1.0f + stanceValue;
|
||||
atr = (float) Math.round(atr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(mainHand){
|
||||
this.atrHandOne = atr;
|
||||
}else{
|
||||
this.atrHandTwo = atr;
|
||||
if(this.owner.charItemManager.getEquipped(1) == null && this.owner.charItemManager.getEquipped(2) != null){
|
||||
if(!this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
this.atrHandOne = 0.0f;
|
||||
}else if(this.owner.charItemManager.getEquipped(2) == null && this.owner.charItemManager.getEquipped(1) != null){
|
||||
this.atrHandTwo = 0.0f;
|
||||
}
|
||||
}
|
||||
} //perfect DO NOT TOUCH
|
||||
|
||||
public void calculateMin(boolean mainHand) {
|
||||
Item weapon;
|
||||
float specialDex = this.owner.statDexBase;
|
||||
specialDex += this.owner.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
|
||||
float baseDMG = 1;
|
||||
float primaryStat = specialDex;//getDexAfterPenalty(this.owner);
|
||||
float secondaryStat = this.owner.statStrCurrent;
|
||||
double weaponSkill = 5;
|
||||
double weaponMastery = 5;
|
||||
|
||||
if (mainHand) {
|
||||
weapon = this.owner.charItemManager.getEquipped(1);
|
||||
} else {
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
|
||||
String skill = "Unarmed Combat";
|
||||
String mastery = "Unarmed Combat Mastery";
|
||||
|
||||
if (weapon != null) {
|
||||
baseDMG = weapon.getItemBase().getMinDamage();
|
||||
skill = weapon.getItemBase().getSkillRequired();
|
||||
mastery = weapon.getItemBase().getMastery();
|
||||
if (weapon.getItemBase().isStrBased()) {
|
||||
primaryStat = this.owner.statStrCurrent;
|
||||
secondaryStat = specialDex;//getDexAfterPenalty(this.owner);
|
||||
}
|
||||
for(Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.MinDamage)){
|
||||
baseDMG += mod.minMod + (mod.getRamp() * eff.getTrains());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.owner.skills.containsKey(skill)) {
|
||||
weaponSkill = this.owner.skills.get(skill).getTotalSkillPercet();
|
||||
}
|
||||
|
||||
if (this.owner.skills.containsKey(mastery)) {
|
||||
weaponMastery = this.owner.skills.get(mastery).getTotalSkillPercet();
|
||||
}
|
||||
|
||||
double minDMG = baseDMG * (
|
||||
0.0048 * primaryStat +
|
||||
0.049 * Math.sqrt(primaryStat - 0.75) +
|
||||
0.0066 * secondaryStat +
|
||||
0.064 * Math.sqrt(secondaryStat - 0.75) +
|
||||
0.01 * (weaponSkill + weaponMastery)
|
||||
);
|
||||
if(this.owner.bonuses != null){
|
||||
minDMG += this.owner.bonuses.getFloat(Enum.ModType.MinDamage, Enum.SourceType.None);
|
||||
minDMG *= 1 + this.owner.bonuses.getFloatPercentAll(Enum.ModType.MeleeDamageModifier, Enum.SourceType.None);
|
||||
}
|
||||
|
||||
if(this.owner.charItemManager != null){
|
||||
if(this.owner.charItemManager.getEquipped(1) != null && this.owner.charItemManager.getEquipped(2) != null && !this.owner.charItemManager.getEquipped(2).getItemBase().isShield()){
|
||||
minDMG *= 0.7f;
|
||||
}
|
||||
}
|
||||
|
||||
int roundedMin = (int)Math.round(minDMG);
|
||||
|
||||
if (mainHand) {
|
||||
this.minDamageHandOne = roundedMin;
|
||||
} else {
|
||||
this.minDamageHandTwo = roundedMin;
|
||||
if(this.owner.charItemManager.getEquipped(1) == null && this.owner.charItemManager.getEquipped(2) != null){
|
||||
if(!this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
this.minDamageHandOne = 0;
|
||||
}else if(this.owner.charItemManager.getEquipped(2) == null && this.owner.charItemManager.getEquipped(1) != null){
|
||||
this.minDamageHandTwo = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateMax(boolean mainHand) {
|
||||
//Weapon Max DMG = BaseDMG * (0.0124*Primary Stat + 0.118*(Primary Stat -0.75)^0.5
|
||||
// + 0.0022*Secondary Stat + 0.028*(Secondary Stat-0.75)^0.5 + 0.0075*(Weapon Skill + Weapon Mastery))
|
||||
Item weapon;
|
||||
float specialDex = this.owner.statDexBase;
|
||||
specialDex += this.owner.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
|
||||
double baseDMG = 5;
|
||||
float primaryStat = specialDex;//getDexAfterPenalty(this.owner);
|
||||
float secondaryStat = this.owner.statStrCurrent;
|
||||
double weaponSkill = 5;
|
||||
double weaponMastery = 5;
|
||||
|
||||
|
||||
if (mainHand) {
|
||||
weapon = this.owner.charItemManager.getEquipped(1);
|
||||
} else {
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
|
||||
String skill = "Unarmed Combat";
|
||||
String mastery = "Unarmed Combat Mastery";
|
||||
if (weapon != null) {
|
||||
baseDMG = weapon.getItemBase().getMaxDamage();
|
||||
skill = weapon.getItemBase().getSkillRequired();
|
||||
mastery = weapon.getItemBase().getMastery();
|
||||
if (weapon.getItemBase().isStrBased()) {
|
||||
primaryStat = this.owner.statStrCurrent;
|
||||
secondaryStat = specialDex;//getDexAfterPenalty(this.owner);
|
||||
}
|
||||
for(Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.MaxDamage)){
|
||||
baseDMG += mod.minMod + (mod.getRamp() * eff.getTrains());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.owner.skills.containsKey(skill)) {
|
||||
weaponSkill = this.owner.skills.get(skill).getModifiedAmount();
|
||||
}
|
||||
|
||||
if (this.owner.skills.containsKey(mastery)) {
|
||||
weaponMastery = this.owner.skills.get(mastery).getModifiedAmount();
|
||||
}
|
||||
|
||||
double maxDMG = baseDMG * (
|
||||
0.0124 * primaryStat +
|
||||
0.118 * Math.sqrt(primaryStat - 0.75) +
|
||||
0.0022 * secondaryStat +
|
||||
0.028 * Math.sqrt(secondaryStat - 0.75) +
|
||||
0.0075 * (weaponSkill + weaponMastery)
|
||||
);
|
||||
|
||||
if(this.owner.bonuses != null){
|
||||
maxDMG += this.owner.bonuses.getFloat(Enum.ModType.MaxDamage, Enum.SourceType.None);
|
||||
maxDMG *= 1 + this.owner.bonuses.getFloatPercentAll(Enum.ModType.MeleeDamageModifier, Enum.SourceType.None);
|
||||
}
|
||||
|
||||
if(this.owner.charItemManager != null){
|
||||
if(this.owner.charItemManager.getEquipped(1) != null && this.owner.charItemManager.getEquipped(2) != null && !this.owner.charItemManager.getEquipped(2).getItemBase().isShield()){
|
||||
maxDMG *= 0.7f;
|
||||
}
|
||||
}
|
||||
|
||||
int roundedMax = (int)(maxDMG);
|
||||
|
||||
if(mainHand){
|
||||
this.maxDamageHandOne = roundedMax;
|
||||
}else{
|
||||
this.maxDamageHandTwo = roundedMax;
|
||||
if(this.owner.charItemManager.getEquipped(1) == null && this.owner.charItemManager.getEquipped(2) != null){
|
||||
if(!this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
this.maxDamageHandOne = 0;
|
||||
}else if(this.owner.charItemManager.getEquipped(2) == null && this.owner.charItemManager.getEquipped(1) != null){
|
||||
this.maxDamageHandTwo = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateAttackSpeed(boolean mainHand){
|
||||
Item weapon;
|
||||
float speed;
|
||||
if(mainHand) {
|
||||
weapon = this.owner.charItemManager.getEquipped(1);
|
||||
}else {
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
float delayExtra = 0;
|
||||
if(weapon == null) {
|
||||
speed = 20.0f;
|
||||
}else{
|
||||
speed = weapon.getItemBase().getSpeed();
|
||||
for(Effect eff : weapon.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.WeaponSpeed) || mod.modType.equals(Enum.ModType.AttackDelay)){
|
||||
float percent = mod.getPercentMod();
|
||||
int trains = eff.getTrains();
|
||||
float modValue = percent + (trains * mod.getRamp());
|
||||
speed *= 1 + (modValue * 0.01f);
|
||||
if(mod.modType.equals(Enum.ModType.AttackDelay)){
|
||||
delayExtra += modValue * 0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float stanceValue = 0.0f;
|
||||
for(String effID : this.owner.effects.keySet()){
|
||||
if(effID.contains("Stance")){
|
||||
if(this.owner.effects != null) {
|
||||
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) {
|
||||
if (mod.modType.equals(Enum.ModType.AttackDelay)) {
|
||||
float percent = mod.getPercentMod();
|
||||
int trains = this.owner.effects.get(effID).getTrains();
|
||||
float modValue = percent + (trains * mod.getRamp());
|
||||
stanceValue += modValue * 0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float bonusValues = 1 + this.owner.bonuses.getFloatPercentAll(Enum.ModType.AttackDelay,Enum.SourceType.None);//1.0f;
|
||||
bonusValues -= stanceValue + delayExtra; // take away stance modifier from alac bonus values
|
||||
speed *= 1 + stanceValue; // apply stance bonus
|
||||
speed *= bonusValues; // apply alac bonuses without stance mod
|
||||
|
||||
if(speed < 10.0f)
|
||||
speed = 10.0f;
|
||||
|
||||
if(mainHand){
|
||||
this.attackSpeedHandOne = speed;
|
||||
}else{
|
||||
this.attackSpeedHandTwo = speed;
|
||||
if(this.owner.charItemManager.getEquipped(1) == null && this.owner.charItemManager.getEquipped(2) != null){
|
||||
if(!this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
this.attackSpeedHandOne = 0.0f;
|
||||
}else if(this.owner.charItemManager.getEquipped(2) == null && this.owner.charItemManager.getEquipped(1) != null){
|
||||
this.attackSpeedHandTwo = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateAttackRange(boolean mainHand){
|
||||
Item weapon;
|
||||
float range;
|
||||
if(mainHand) {
|
||||
weapon = this.owner.charItemManager.getEquipped(1);
|
||||
}else {
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
|
||||
if(weapon == null) {
|
||||
range = 6.0f;
|
||||
}else{
|
||||
range = weapon.getItemBase().getRange();
|
||||
}
|
||||
if(owner.bonuses != null){
|
||||
range *= 1 + this.owner.bonuses.getFloatPercentAll(Enum.ModType.WeaponRange, Enum.SourceType.None);
|
||||
}
|
||||
if(mainHand){
|
||||
this.rangeHandOne = range;
|
||||
}else{
|
||||
this.rangeHandTwo = range;
|
||||
if(this.owner.charItemManager.getEquipped(1) == null && this.owner.charItemManager.getEquipped(2) != null){
|
||||
if(!this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
this.rangeHandOne = 0.0f;
|
||||
}else if(this.owner.charItemManager.getEquipped(2) == null && this.owner.charItemManager.getEquipped(1) != null){
|
||||
this.rangeHandTwo = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateRegen(){
|
||||
if(owner.bonuses != null){
|
||||
this.healthRegen = 1.0f + this.owner.bonuses.getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None);
|
||||
this.manaRegen = 1.0f + this.owner.bonuses.getFloatPercentAll(Enum.ModType.ManaRecoverRate, Enum.SourceType.None);
|
||||
this.staminaRegen = 1.0f + this.owner.bonuses.getFloatPercentAll(Enum.ModType.StaminaRecoverRate, Enum.SourceType.None);
|
||||
|
||||
}else{
|
||||
this.healthRegen = 1.0f;
|
||||
this.manaRegen = 1.0f;
|
||||
this.staminaRegen = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateDefense() {
|
||||
//Defense = (1+Armor skill / 50) * Armor defense + (1 + Block skill / 100) * Shield defense + (Primary weapon skill / 2)
|
||||
// + (Weapon mastery skill/ 2) + Dexterity * 2 + Flat bonuses from rings or cloth
|
||||
float armorSkill = 0.0f;
|
||||
float armorDefense = 0.0f;
|
||||
ArrayList<String> armorsUsed = new ArrayList<>();
|
||||
for(Item equipped : this.owner.charItemManager.getEquipped().values()){
|
||||
ItemBase ib = equipped.getItemBase();
|
||||
if(ib.isHeavyArmor() || ib.isMediumArmor() || ib.isLightArmor() || ib.isClothArmor()){
|
||||
armorDefense += ib.getDefense();
|
||||
for(Effect eff : equipped.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.DR)){
|
||||
armorDefense += mod.minMod + (mod.getRamp() * eff.getTrains());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ib.isClothArmor() && !armorsUsed.contains(ib.getSkillRequired())) {
|
||||
armorsUsed.add(ib.getSkillRequired());
|
||||
}
|
||||
}
|
||||
}
|
||||
for(String armorUsed : armorsUsed){
|
||||
if(this.owner.skills.containsKey(armorUsed)) {
|
||||
armorSkill += calculateModifiedSkill(armorUsed,this.owner);
|
||||
}
|
||||
}
|
||||
if(armorsUsed.size() > 0)
|
||||
armorSkill = armorSkill / armorsUsed.size();
|
||||
|
||||
float blockSkill = 0.0f;
|
||||
if(this.owner.skills.containsKey("Block"))
|
||||
blockSkill = calculateModifiedSkill("Block",this.owner);
|
||||
|
||||
float shieldDefense = 0.0f;
|
||||
if(this.owner.charItemManager.getEquipped(2) != null && this.owner.charItemManager.getEquipped(2).getItemBase().isShield()){
|
||||
Item shield = this.owner.charItemManager.getEquipped(2);
|
||||
shieldDefense += shield.getItemBase().getDefense();
|
||||
for(Effect eff : shield.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.DR)){
|
||||
shieldDefense += mod.minMod + (mod.getRamp() * eff.getTrains());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float weaponSkill = 0.0f;
|
||||
float masterySkill = 0.0f;
|
||||
Item weapon = this.owner.charItemManager.getEquipped(1);
|
||||
if(weapon == null){
|
||||
weapon = this.owner.charItemManager.getEquipped(2);
|
||||
}
|
||||
if(weapon != null && weapon.getItemBase().isShield())
|
||||
weapon = null;
|
||||
|
||||
String skillName = "Unarmed Combat";
|
||||
String masteryName = "Unarmed Combat Mastery";
|
||||
|
||||
if(weapon != null){
|
||||
skillName = weapon.getItemBase().getSkillRequired();
|
||||
masteryName = weapon.getItemBase().getMastery();
|
||||
}
|
||||
if(this.owner.skills.containsKey(skillName))
|
||||
weaponSkill = this.owner.skills.get(skillName).getModifiedAmount();//calculateModifiedSkill(skillName,this.owner);//this.owner.skills.get(skillName).getModifiedAmount();
|
||||
|
||||
if(this.owner.skills.containsKey(masteryName))
|
||||
masterySkill = this.owner.skills.get(masteryName).getModifiedAmount();//calculateModifiedSkill(masteryName,this.owner);//this.owner.skills.get(masteryName).getModifiedAmount();
|
||||
|
||||
float dexterity = getDexAfterPenalty(this.owner);
|
||||
|
||||
float luckyRune = 1.0f;
|
||||
for(CharacterRune rune : this.owner.runes){
|
||||
if(rune.getRuneBase().getName().equals("Lucky"))
|
||||
luckyRune += 0.05f;
|
||||
}
|
||||
|
||||
float flatBonuses = 0.0f;
|
||||
float stanceMod = 1.0f;
|
||||
for(String effID : this.owner.effects.keySet()) {
|
||||
if (effID.contains("Stance")) {
|
||||
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) {
|
||||
if (mod.modType.equals(Enum.ModType.DCV)) {
|
||||
float percent = mod.getPercentMod();
|
||||
int trains = this.owner.effects.get(effID).getTrains();
|
||||
float modValue = percent + (trains * mod.getRamp());
|
||||
stanceMod += modValue * 0.01f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) {
|
||||
if (mod.modType.equals(Enum.ModType.DCV)) {
|
||||
float value = mod.getMinMod();
|
||||
int trains = this.owner.effects.get(effID).getTrains();
|
||||
float modValue = value + (trains * mod.getRamp());
|
||||
flatBonuses += modValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.owner.charItemManager.getEquipped(2) == null)
|
||||
blockSkill = 0;
|
||||
else if(this.owner.charItemManager != null && this.owner.charItemManager.getEquipped(2) != null && !this.owner.charItemManager.getEquipped(2).getItemBase().isShield())
|
||||
blockSkill = 0;
|
||||
|
||||
//Defense = (1+Armor skill / 50) * Armor defense + (1 + Block skill / 100) * Shield defense
|
||||
// + (Primary weapon skill / 2) + (Weapon mastery skill/ 2) + ROUND((Dexterity-Dex penalty),0) * 2 + Flat bonuses from rings or cloth
|
||||
float defense = 0;
|
||||
for(Item equipped : this.owner.charItemManager.getEquippedList()){
|
||||
ItemBase ib = equipped.getItemBase();
|
||||
if(ib.getType().equals(Enum.ItemType.ARMOR) && !ib.isShield()){
|
||||
defense += getArmorDefense(equipped,this.owner);
|
||||
}
|
||||
}
|
||||
//float defense = (1 + armorSkill / 50) * armorDefense;
|
||||
defense += (1 + blockSkill / 100) * shieldDefense;
|
||||
defense += (weaponSkill / 2);
|
||||
defense += (masterySkill / 2);
|
||||
defense += dexterity * 2;
|
||||
defense += flatBonuses;
|
||||
defense *= luckyRune;
|
||||
defense *= stanceMod;
|
||||
|
||||
defense = Math.round(defense);
|
||||
|
||||
this.defense = (int) defense;
|
||||
}
|
||||
|
||||
public static float calculateModifiedSkill(String skillName, PlayerCharacter pc) {
|
||||
|
||||
CharacterSkill skill = null;
|
||||
if (pc.skills.containsKey(skillName)) {
|
||||
skill = pc.skills.get(skillName);
|
||||
}
|
||||
SkillsBase skillBase = skill.getSkillsBase();
|
||||
if(skillBase == null)
|
||||
return 0;
|
||||
|
||||
//Get any rune bonus
|
||||
float bonus = 0f;
|
||||
if (pc.getBonuses() != null) {
|
||||
//Get bonuses from runes
|
||||
bonus = pc.getBonuses().getSkillBonus(skillBase.sourceType);
|
||||
}
|
||||
|
||||
//Get Base skill for modified stats
|
||||
float base = 7f;
|
||||
if(skillBase.getToken() == -660435875){
|
||||
base = 0;
|
||||
}
|
||||
float statMod = 0.5f;
|
||||
if (skillBase.getStrMod() > 0)
|
||||
statMod += (float) skillBase.getStrMod() * (float) pc.getStatStrCurrent() / 100f;
|
||||
if (skillBase.getDexMod() > 0)
|
||||
statMod += (float) skillBase.getDexMod() * (float) getDexAfterPenalty(pc) / 100f;
|
||||
if (skillBase.getConMod() > 0)
|
||||
statMod += (float) skillBase.getConMod() * (float) pc.getStatConCurrent() / 100f;
|
||||
if (skillBase.getIntMod() > 0)
|
||||
statMod += (float) skillBase.getIntMod() * (float) pc.getStatIntCurrent() / 100f;
|
||||
if (skillBase.getSpiMod() > 0)
|
||||
statMod += (float) skillBase.getSpiMod() * (float) pc.getStatSpiCurrent() / 100f;
|
||||
|
||||
if (statMod < 1)
|
||||
statMod = 1f;
|
||||
|
||||
if(skillBase.getToken() == -660435875){
|
||||
statMod = 0;
|
||||
}
|
||||
base += CharacterSkill.baseSkillValues[(int) statMod];
|
||||
Enum.SourceType sourceType = Enum.SourceType.GetSourceType(skillBase.getNameNoSpace());
|
||||
|
||||
//Get any rune, effect and item bonus
|
||||
|
||||
if (pc.getBonuses() != null) {
|
||||
//add bonuses from effects/items and runes
|
||||
base += bonus + pc.getBonuses().getFloat(Enum.ModType.Skill, sourceType);
|
||||
}
|
||||
float baseAmount;
|
||||
if (base < 1f && skillBase.getToken() != -660435875)
|
||||
baseAmount = 1f;
|
||||
else
|
||||
baseAmount = base;
|
||||
|
||||
int amount;
|
||||
|
||||
int trains = skill.getNumTrains();
|
||||
if (trains < 10)
|
||||
amount = (trains * 2);
|
||||
else if (trains < 90)
|
||||
amount = 10 + trains;
|
||||
else if (trains < 134)
|
||||
amount = 100 + ((trains - 90) / 2);
|
||||
else
|
||||
amount = 122 + ((trains - 134) / 3);
|
||||
|
||||
float modAmount = baseAmount + amount;
|
||||
|
||||
if (pc.getBonuses() != null) {
|
||||
//Multiply any percent bonuses
|
||||
modAmount *= (1 + pc.getBonuses().getFloatPercentAll(Enum.ModType.Skill, sourceType));
|
||||
}
|
||||
|
||||
float modifiedAmount = (float) Math.round(modAmount);
|
||||
|
||||
return modifiedAmount;
|
||||
}
|
||||
|
||||
public static int getDexAfterPenalty(PlayerCharacter pc){
|
||||
if(pc.charItemManager == null)
|
||||
return pc.statDexCurrent;
|
||||
|
||||
float dex = pc.statDexBase;
|
||||
if(pc.bonuses != null)
|
||||
dex += pc.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
|
||||
|
||||
float penaltyFactor = 0.0f;
|
||||
for(Item equipped : pc.charItemManager.getEquipped().values()){
|
||||
ItemBase ib = equipped.getItemBase();
|
||||
if(ib.isHeavyArmor() || ib.isLightArmor() || ib.isMediumArmor()){
|
||||
penaltyFactor += ib.dexReduction;
|
||||
}
|
||||
}
|
||||
|
||||
if(penaltyFactor > 0)
|
||||
penaltyFactor *= 0.01f;
|
||||
|
||||
float totalPenalty = dex * penaltyFactor;
|
||||
float returnedDex = Math.round(dex - totalPenalty);
|
||||
return (int) returnedDex;
|
||||
|
||||
}
|
||||
|
||||
private static float getArmorDefense(Item armor, PlayerCharacter pc) {
|
||||
|
||||
if (armor == null)
|
||||
return 0;
|
||||
|
||||
ItemBase ib = armor.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return 0;
|
||||
|
||||
if (!ib.getType().equals(Enum.ItemType.ARMOR))
|
||||
return 0;
|
||||
|
||||
if (ib.getSkillRequired().isEmpty())
|
||||
return ib.getDefense();
|
||||
|
||||
CharacterSkill armorSkill = pc.skills.get(ib.getSkillRequired());
|
||||
if (armorSkill == null) {
|
||||
Logger.error("Player " + pc.getObjectUUID()
|
||||
+ " has armor equipped without the nescessary skill to equip it");
|
||||
return ib.getDefense();
|
||||
}
|
||||
|
||||
float def = ib.getDefense();
|
||||
//apply item defense bonuses
|
||||
if (armor != null) {
|
||||
|
||||
for(Effect eff : armor.effects.values()){
|
||||
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
|
||||
if(mod.modType.equals(Enum.ModType.DR)){
|
||||
def += mod.minMod * (1+(eff.getTrains() * mod.getRamp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//def += armor.getBonus(ModType.DR, SourceType.None);
|
||||
//def *= (1 + armor.getBonusPercent(ModType.DR, SourceType.None));
|
||||
}
|
||||
return (def * (1 + ((int) armorSkill.getModifiedAmount() / 50f)));
|
||||
}
|
||||
}
|
||||
@@ -457,7 +457,9 @@ public class Resists {
|
||||
//damage = handleFortitude(target, type, damage);
|
||||
//calculate armor piercing
|
||||
float ap = source.getBonuses().getFloatPercentAll(ModType.ArmorPiercing, SourceType.None);
|
||||
float damageAfterResists = damage * (1 - (this.getResist(type, trains) * 0.01f) + ap);
|
||||
float damageAfterResists = damage;
|
||||
if(type.equals(DamageType.Pierce) || type.equals(DamageType.Crush) || type.equals(DamageType.Slash))
|
||||
damageAfterResists = damage * (1 - (this.getResist(type, trains) * 0.01f) + ap);
|
||||
//check to see if any damage absorbers should cancel
|
||||
if (target != null) {
|
||||
//debug damage shields if any found
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PeekPowerAction extends AbstractPowerAction {
|
||||
if (!tar.isAlive())
|
||||
return;
|
||||
|
||||
lwrm = new LootWindowResponseMsg(tar.getObjectType().ordinal(), tar.getObjectUUID(), tar.getInventory(true));
|
||||
lwrm = new LootWindowResponseMsg(tar.getObjectType().ordinal(), tar.getObjectUUID(), tar.getInventory(false));
|
||||
} else if (awo.getObjectType().equals(Enum.GameObjectType.Mob)) {
|
||||
|
||||
Mob tar = (Mob) awo;
|
||||
|
||||
@@ -89,6 +89,8 @@ public class StealPowerAction extends AbstractPowerAction {
|
||||
if (!sourcePlayer.isAlive())
|
||||
return;
|
||||
|
||||
sourcePlayer.cancelOnAttackSwing();
|
||||
|
||||
//prevent stealing no steal mob loot
|
||||
if (awo instanceof MobLoot && ((MobLoot) awo).noSteal())
|
||||
return;
|
||||
@@ -173,8 +175,21 @@ public class StealPowerAction extends AbstractPowerAction {
|
||||
|
||||
if (tar.getItemBase().getType().equals(ItemType.GOLD)) {
|
||||
//stealing gold
|
||||
if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount))
|
||||
//if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount))
|
||||
// return;
|
||||
|
||||
int targetGold = ownerCIM.getGoldInventory().getNumOfItems();
|
||||
int myGold = myCIM.getGoldInventory().getNumOfItems();
|
||||
if(myGold + amount > 10000000)
|
||||
return;
|
||||
|
||||
ownerCIM.getGoldInventory().setNumOfItems(targetGold - amount);
|
||||
ownerCIM.updateInventory();
|
||||
|
||||
myCIM.addGoldToInventory(amount,false);
|
||||
myCIM.updateInventory();
|
||||
|
||||
|
||||
} else {
|
||||
//stealing items
|
||||
if (ownerCIM.lootItemFromMe(tar, sourcePlayer, origin, true, amount) == null)
|
||||
@@ -187,8 +202,9 @@ public class StealPowerAction extends AbstractPowerAction {
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
//update thief's inventory
|
||||
if (sourcePlayer.getCharItemManager() != null)
|
||||
if (sourcePlayer.getCharItemManager() != null) {
|
||||
sourcePlayer.getCharItemManager().updateInventory();
|
||||
}
|
||||
|
||||
//update victims inventory
|
||||
if (owner.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import engine.gameManager.SessionManager;
|
||||
import engine.gameManager.SimulationManager;
|
||||
import engine.objects.Bane;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.objects.PlayerCombatStats;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class UpdateThread implements Runnable {
|
||||
@@ -32,6 +33,17 @@ public class UpdateThread implements Runnable {
|
||||
for(PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()){
|
||||
if (player != null) {
|
||||
player.doRegen();
|
||||
try {
|
||||
if (player.isAlive() && player.isActive() && player.isEnteredWorld()) {
|
||||
if (player.combatStats == null) {
|
||||
player.combatStats = new PlayerCombatStats(player);
|
||||
}
|
||||
PlayerCombatStats cStats = player.combatStats;
|
||||
cStats.update();
|
||||
}
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user