Browse Source

Merge Damage and Source types.

combat-2
MagicBot 9 months ago
parent
commit
e8e84e00af
  1. 69
      src/engine/Enum.java
  2. 8
      src/engine/gameManager/CombatManager.java
  3. 9
      src/engine/gameManager/NPCManager.java
  4. 16
      src/engine/mobileAI/utilities/CombatUtilities.java
  5. 2
      src/engine/objects/AbstractCharacter.java
  6. 4
      src/engine/objects/Effect.java
  7. 7
      src/engine/objects/ItemBase.java
  8. 4
      src/engine/objects/ItemTemplate.java
  9. 294
      src/engine/objects/Resists.java
  10. 9
      src/engine/powers/DamageShield.java
  11. 35
      src/engine/powers/EffectsBase.java
  12. 6
      src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java
  13. 8
      src/engine/powers/effectmodifiers/HealthEffectModifier.java
  14. 7
      src/engine/powers/effectmodifiers/ManaEffectModifier.java
  15. 7
      src/engine/powers/effectmodifiers/StaminaEffectModifier.java
  16. 5
      src/engine/powers/poweractions/TransferStatPowerAction.java

69
src/engine/Enum.java

@ -774,58 +774,6 @@ public class Enum { @@ -774,58 +774,6 @@ public class Enum {
}
}
public enum DamageType {
None,
Crush,
Slash,
Siege,
Pierce,
Magic,
Bleed,
Poison,
Mental,
Holy,
Unholy,
Lightning,
Fire,
Cold,
Healing,
Acid,
Disease,
Unknown,
// these added for immunities
Attack,
Powers,
Combat,
Spires,
Snare,
Stun,
Blind,
Root,
Fear,
Charm,
PowerBlock,
DeBuff,
Powerblock,
Steel,
Drain;
public static DamageType GetDamageType(String modName) {
DamageType damageType;
if (modName.isEmpty())
return DamageType.None;
try {
damageType = DamageType.valueOf(modName.replace(",", ""));
} catch (Exception e) {
Logger.error(e);
return DamageType.None;
}
return damageType;
}
}
public enum SourceType {
None,
Abjuration,
@ -837,7 +785,7 @@ public class Enum { @@ -837,7 +785,7 @@ public class Enum {
Beastcraft,
Benediction,
BladeWeaving,
Bleed,
Bleeding,
Blind,
Block,
Bloodcraft,
@ -846,11 +794,10 @@ public class Enum { @@ -846,11 +794,10 @@ public class Enum {
Channeling,
Charm,
Cold,
COLD,
Constitution,
Corruption,
Crossbow,
Crush,
Crushing,
Dagger,
DaggerMastery,
DeBuff,
@ -864,16 +811,13 @@ public class Enum { @@ -864,16 +811,13 @@ public class Enum {
Exorcism,
Fear,
Fire,
FIRE,
Fly,
Giant,
GreatAxeMastery,
GreatSwordMastery,
Hammer,
Heal,
Healing,
Holy,
HOLY,
ImmuneToAttack,
ImmuneToPowers,
Intelligence,
@ -882,15 +826,12 @@ public class Enum { @@ -882,15 +826,12 @@ public class Enum {
LIGHTNING,
Liturgy,
Magic,
MAGIC,
Mental,
MENTAL,
NatureLore,
Necromancy,
Parry,
Pierce,
Piercing,
Poison,
POISON,
PoleArm,
Powerblock,
Rat,
@ -899,13 +840,14 @@ public class Enum { @@ -899,13 +840,14 @@ public class Enum {
Root,
Shadowmastery,
Siege,
Slash,
Slashing,
Snare,
Sorcery,
Spear,
SpearMastery,
Spirit,
Staff,
Steal,
Stormcalling,
Strength,
Stun,
@ -918,7 +860,6 @@ public class Enum { @@ -918,7 +860,6 @@ public class Enum {
UnarmedCombat,
UnarmedCombatMastery,
Unholy,
UNHOLY,
Unknown,
Warding,
Warlockry,

8
src/engine/gameManager/CombatManager.java

@ -686,14 +686,14 @@ public enum CombatManager { @@ -686,14 +686,14 @@ public enum CombatManager {
//Get damage Type
DamageType damageType;
SourceType damageType;
if (wb != null)
damageType = wb.getDamageType();
else if (attacker.getObjectType().equals(GameObjectType.Mob) && ((Mob) attacker).isSiege())
damageType = DamageType.Siege;
damageType = SourceType.Siege;
else
damageType = DamageType.Crush;
damageType = SourceType.Crushing;
errorTrack = 10;
@ -910,7 +910,7 @@ public enum CombatManager { @@ -910,7 +910,7 @@ public enum CombatManager {
}
private static float calculateDamage(AbstractCharacter source, AbstractCharacter target, float minDamage, float maxDamage, DamageType damageType, Resists resists) {
private static float calculateDamage(AbstractCharacter source, AbstractCharacter target, float minDamage, float maxDamage, SourceType damageType, Resists resists) {
//get range between min and max

9
src/engine/gameManager/NPCManager.java

@ -5,17 +5,14 @@ import engine.InterestManagement.WorldGrid; @@ -5,17 +5,14 @@ import engine.InterestManagement.WorldGrid;
import engine.math.Quaternion;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.mobileAI.MobAI;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.msg.PetMsg;
import engine.objects.*;
import engine.powers.EffectsBase;
import engine.powers.PowersBase;
import engine.powers.RuneSkillAdjustEntry;
import org.pmw.tinylog.Logger;
import javax.smartcardio.ATR;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ThreadLocalRandom;
@ -428,9 +425,9 @@ public enum NPCManager { @@ -428,9 +425,9 @@ public enum NPCManager {
for(MobEquipment equipped : mob.equip.values()){
ItemBase itemBase = equipped.getItemBase();
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush,0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash,0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce,0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.SourceType.Crushing, mob.resists.getResist(Enum.SourceType.Crushing, 0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.SourceType.Slashing, mob.resists.getResist(Enum.SourceType.Slashing, 0) + itemBase.getCrushResist());
mob.resists.setResist(Enum.SourceType.Piercing, mob.resists.getResist(Enum.SourceType.Piercing, 0) + itemBase.getCrushResist());
}
}
}

16
src/engine/mobileAI/utilities/CombatUtilities.java

@ -9,7 +9,10 @@ @@ -9,7 +9,10 @@
package engine.mobileAI.utilities;
import engine.Enum.*;
import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
import engine.gameManager.CombatManager;
import engine.math.Vector3fImmutable;
@ -22,7 +25,6 @@ import org.pmw.tinylog.Logger; @@ -22,7 +25,6 @@ import org.pmw.tinylog.Logger;
import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.sqr;
import static java.lang.Math.pow;
public class CombatUtilities {
@ -214,10 +216,10 @@ public class CombatUtilities { @@ -214,10 +216,10 @@ public class CombatUtilities {
else
speed = agent.getSpeedHandTwo();
DamageType dt = DamageType.Crush;
SourceType dt = SourceType.Crushing;
if (agent.isSiege())
dt = DamageType.Siege;
dt = SourceType.Siege;
if (wb != null) {
anim = CombatManager.getSwingAnimation(wb, null, mainHand);
dt = wb.getDamageType();
@ -311,7 +313,7 @@ public class CombatUtilities { @@ -311,7 +313,7 @@ public class CombatUtilities {
int damage = 0;
DamageType dt = getDamageType(agent);
SourceType dt = getDamageType(agent);
damage = ThreadLocalRandom.current().nextInt((int)getMinDmg(agent), (int)getMaxDmg(agent) + 1);
if (AbstractWorldObject.IsAbstractCharacter(target)) {
if (((AbstractCharacter) target).isSit()) {
@ -327,8 +329,8 @@ public class CombatUtilities { @@ -327,8 +329,8 @@ public class CombatUtilities {
return damage;
}
public static DamageType getDamageType(Mob agent) {
DamageType dt = DamageType.Crush;
public static SourceType getDamageType(Mob agent) {
SourceType dt = SourceType.Crushing;
if (agent.getEquip().get(1) != null) {
return agent.getEquip().get(1).getItemBase().getDamageType();
}

2
src/engine/objects/AbstractCharacter.java

@ -1651,7 +1651,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -1651,7 +1651,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
PowersManager.cancelOnTakeDamage(this);
}
public final void cancelOnTakeDamage(final DamageType type, final float amount) {
public final void cancelOnTakeDamage(final SourceType type, final float amount) {
boolean changed = false;
for (String s : this.effects.keySet()) {
Effect eff = this.effects.get(s);

4
src/engine/objects/Effect.java

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
package engine.objects;
import engine.Enum.DamageType;
import engine.Enum;
import engine.Enum.EffectSourceType;
import engine.gameManager.PowersManager;
import engine.job.AbstractJob;
@ -592,7 +592,7 @@ public class Effect { @@ -592,7 +592,7 @@ public class Effect {
}
//Used for verifying when damage absorbers fails
public boolean cancelOnTakeDamage(DamageType type, float amount) {
public boolean cancelOnTakeDamage(Enum.SourceType type, float amount) {
if (!this.eb.cancelOnTakeDamage())
return false;
if (this.eb == null || amount < 0f)

7
src/engine/objects/ItemBase.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.objects;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.GameObjectType;
import engine.Enum.ItemType;
import engine.gameManager.DbManager;
@ -72,7 +71,7 @@ public class ItemBase { @@ -72,7 +71,7 @@ public class ItemBase {
private final short minDamage;
private final short maxDamage;
private final String mastery;
private final engine.Enum.DamageType damageType;
private final engine.Enum.SourceType damageType;
private final boolean twoHanded;
private boolean isConsumable;
private boolean isStackable;
@ -133,7 +132,7 @@ public class ItemBase { @@ -133,7 +132,7 @@ public class ItemBase {
this.requiredDiscs = DbManager.parseEnumSet(rs.getString("disc_required"), Enum.DisciplineType.class);
this.mastery = rs.getString("mastery");
damageType = DamageType.valueOf(rs.getString("damageType"));
damageType = Enum.SourceType.valueOf(rs.getString("damageType"));
this.twoHanded = (rs.getInt("twoHanded") == 1);
@ -900,7 +899,7 @@ public class ItemBase { @@ -900,7 +899,7 @@ public class ItemBase {
/**
* @return the damageType
*/
public engine.Enum.DamageType getDamageType() {
public Enum.SourceType getDamageType() {
return damageType;
}

4
src/engine/objects/ItemTemplate.java

@ -54,7 +54,7 @@ public class ItemTemplate { @@ -54,7 +54,7 @@ public class ItemTemplate {
public int item_weapon_projectile_id;
public float item_weapon_projectile_speed;
public int item_weapon_combat_idle_anim;
public Enum.DamageType item_weapon_damage_type;
public Enum.SourceType item_weapon_damage_type;
public int item_weapon_damage_min;
public int item_weapon_damage_max;
public EnumSet<Enum.ItemFlags> item_flags = EnumSet.noneOf(Enum.ItemFlags.class);
@ -169,7 +169,7 @@ public class ItemTemplate { @@ -169,7 +169,7 @@ public class ItemTemplate {
for (Object o : weapon_damage) {
JSONObject damage_entry = (JSONObject) o;
item_weapon_damage_type = Enum.DamageType.valueOf((String) damage_entry.get("damage_type"));
item_weapon_damage_type = Enum.SourceType.valueOf((String) damage_entry.get("damage_type"));
item_weapon_damage_min = ((Long) damage_entry.get("damage_min")).intValue();
item_weapon_damage_max = ((Long) damage_entry.get("damage_max")).intValue();
}

294
src/engine/objects/Resists.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.objects;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
@ -28,9 +27,9 @@ import java.util.concurrent.ConcurrentHashMap; @@ -28,9 +27,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class Resists {
private static ConcurrentHashMap<Integer, Resists> mobResists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private ConcurrentHashMap<DamageType, Float> resists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private ConcurrentHashMap<DamageType, Boolean> immuneTo = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private DamageType protection;
private ConcurrentHashMap<SourceType, Float> resists = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private ConcurrentHashMap<SourceType, Boolean> immuneTo = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private SourceType protection;
private int protectionTrains = 0;
private boolean immuneToAll;
@ -53,9 +52,9 @@ public class Resists { @@ -53,9 +52,9 @@ public class Resists {
}
public Resists(Resists r) {
for (DamageType dt : r.resists.keySet())
for (SourceType dt : r.resists.keySet())
this.resists.put(dt, r.resists.get(dt));
for (DamageType dt : r.immuneTo.keySet())
for (SourceType dt : r.immuneTo.keySet())
this.immuneTo.put(dt, r.immuneTo.get(dt));
this.protection = r.protection;
this.protectionTrains = r.protectionTrains;
@ -85,30 +84,30 @@ public class Resists { @@ -85,30 +84,30 @@ public class Resists {
*/
public Resists(ResultSet rs) throws SQLException {
this.immuneToAll = false;
this.resists.put(DamageType.Slash, rs.getFloat("slash"));
this.resists.put(DamageType.Crush, rs.getFloat("crush"));
this.resists.put(DamageType.Pierce, rs.getFloat("pierce"));
this.resists.put(DamageType.Magic, rs.getFloat("magic"));
this.resists.put(DamageType.Bleed, rs.getFloat("bleed"));
this.resists.put(DamageType.Poison, rs.getFloat("poison"));
this.resists.put(DamageType.Mental, rs.getFloat("mental"));
this.resists.put(DamageType.Holy, rs.getFloat("holy"));
this.resists.put(DamageType.Unholy, rs.getFloat("unholy"));
this.resists.put(DamageType.Lightning, rs.getFloat("lightning"));
this.resists.put(DamageType.Fire, rs.getFloat("fire"));
this.resists.put(DamageType.Cold, rs.getFloat("cold"));
this.resists.put(DamageType.Healing, 0f);
this.resists.put(SourceType.Slashing, rs.getFloat("slash"));
this.resists.put(SourceType.Crushing, rs.getFloat("crush"));
this.resists.put(SourceType.Piercing, rs.getFloat("pierce"));
this.resists.put(SourceType.Magic, rs.getFloat("magic"));
this.resists.put(SourceType.Bleeding, rs.getFloat("bleed"));
this.resists.put(SourceType.Poison, rs.getFloat("poison"));
this.resists.put(SourceType.Mental, rs.getFloat("mental"));
this.resists.put(SourceType.Holy, rs.getFloat("holy"));
this.resists.put(SourceType.Unholy, rs.getFloat("unholy"));
this.resists.put(SourceType.Lightning, rs.getFloat("lightning"));
this.resists.put(SourceType.Fire, rs.getFloat("fire"));
this.resists.put(SourceType.Cold, rs.getFloat("cold"));
this.resists.put(SourceType.Healing, 0f);
}
//Handle Fortitudes
private static float handleFortitude(AbstractCharacter target, DamageType type, float damage) {
private static float handleFortitude(AbstractCharacter target, SourceType type, float damage) {
if (target == null || !(target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)))
return damage;
PlayerBonuses bonus = target.getBonuses();
//see if there is a fortitude
float damageCap = bonus.getFloatPercentAll(ModType.DamageCap, SourceType.None);
if (damageCap == 0f || type == DamageType.Healing)
if (damageCap == 0f || type == SourceType.Healing)
return damage;
//is fortitude, Are we under the cap?
@ -135,11 +134,11 @@ public class Resists { @@ -135,11 +134,11 @@ public class Resists {
}
//Test if Damagetype is valid for foritude
private static boolean isValidDamageCapType(HashSet<SourceType> forts, DamageType damageType, boolean exclusive) {
private static boolean isValidDamageCapType(HashSet<SourceType> forts, SourceType damageType, boolean exclusive) {
for (SourceType fort : forts) {
DamageType dt = DamageType.valueOf(fort.name());
SourceType dt = SourceType.valueOf(fort.name());
if (dt == DamageType.None)
if (dt == SourceType.None)
continue;
if (dt == damageType) {
@ -195,19 +194,19 @@ public class Resists { @@ -195,19 +194,19 @@ public class Resists {
*/
public final void setBuildingResists() {
this.immuneToAll = false;
this.resists.put(DamageType.Slash, 85f);
this.resists.put(DamageType.Crush, 85f);
this.resists.put(DamageType.Siege, 0f);
this.immuneTo.put(DamageType.Pierce, true);
this.immuneTo.put(DamageType.Magic, true);
this.immuneTo.put(DamageType.Bleed, true);
this.immuneTo.put(DamageType.Poison, true);
this.immuneTo.put(DamageType.Mental, true);
this.immuneTo.put(DamageType.Holy, true);
this.immuneTo.put(DamageType.Unholy, true);
this.immuneTo.put(DamageType.Lightning, true);
this.immuneTo.put(DamageType.Fire, true);
this.immuneTo.put(DamageType.Cold, true);
this.resists.put(SourceType.Slashing, 85f);
this.resists.put(SourceType.Crushing, 85f);
this.resists.put(SourceType.Siege, 0f);
this.immuneTo.put(SourceType.Piercing, true);
this.immuneTo.put(SourceType.Magic, true);
this.immuneTo.put(SourceType.Bleeding, true);
this.immuneTo.put(SourceType.Poison, true);
this.immuneTo.put(SourceType.Mental, true);
this.immuneTo.put(SourceType.Holy, true);
this.immuneTo.put(SourceType.Unholy, true);
this.immuneTo.put(SourceType.Lightning, true);
this.immuneTo.put(SourceType.Fire, true);
this.immuneTo.put(SourceType.Cold, true);
}
@ -216,19 +215,19 @@ public class Resists { @@ -216,19 +215,19 @@ public class Resists {
*/
public final void setMineResists() {
this.immuneToAll = false;
this.immuneTo.put(DamageType.Slash, true);
this.immuneTo.put(DamageType.Crush, true);
this.immuneTo.put(DamageType.Pierce, true);
this.immuneTo.put(DamageType.Magic, true);
this.immuneTo.put(DamageType.Bleed, true);
this.immuneTo.put(DamageType.Poison, true);
this.immuneTo.put(DamageType.Mental, true);
this.immuneTo.put(DamageType.Holy, true);
this.immuneTo.put(DamageType.Unholy, true);
this.immuneTo.put(DamageType.Lightning, true);
this.immuneTo.put(DamageType.Fire, true);
this.immuneTo.put(DamageType.Cold, true);
this.resists.put(DamageType.Siege, 0f);
this.immuneTo.put(SourceType.Slashing, true);
this.immuneTo.put(SourceType.Crushing, true);
this.immuneTo.put(SourceType.Piercing, true);
this.immuneTo.put(SourceType.Magic, true);
this.immuneTo.put(SourceType.Bleeding, true);
this.immuneTo.put(SourceType.Poison, true);
this.immuneTo.put(SourceType.Mental, true);
this.immuneTo.put(SourceType.Holy, true);
this.immuneTo.put(SourceType.Unholy, true);
this.immuneTo.put(SourceType.Lightning, true);
this.immuneTo.put(SourceType.Fire, true);
this.immuneTo.put(SourceType.Cold, true);
this.resists.put(SourceType.Siege, 0f);
}
/**
@ -236,27 +235,27 @@ public class Resists { @@ -236,27 +235,27 @@ public class Resists {
*/
public final void setGenericResists() {
this.immuneToAll = false;
this.resists.put(DamageType.Slash, 0f);
this.resists.put(DamageType.Crush, 0f);
this.resists.put(DamageType.Pierce, 0f);
this.resists.put(DamageType.Magic, 0f);
this.resists.put(DamageType.Bleed, 0f);
this.resists.put(DamageType.Poison, 0f);
this.resists.put(DamageType.Mental, 0f);
this.resists.put(DamageType.Holy, 0f);
this.resists.put(DamageType.Unholy, 0f);
this.resists.put(DamageType.Lightning, 0f);
this.resists.put(DamageType.Fire, 0f);
this.resists.put(DamageType.Cold, 0f);
this.resists.put(DamageType.Healing, 0f);
this.immuneTo.put(DamageType.Siege, true);
this.resists.put(SourceType.Slashing, 0f);
this.resists.put(SourceType.Crushing, 0f);
this.resists.put(SourceType.Piercing, 0f);
this.resists.put(SourceType.Magic, 0f);
this.resists.put(SourceType.Bleeding, 0f);
this.resists.put(SourceType.Poison, 0f);
this.resists.put(SourceType.Mental, 0f);
this.resists.put(SourceType.Holy, 0f);
this.resists.put(SourceType.Unholy, 0f);
this.resists.put(SourceType.Lightning, 0f);
this.resists.put(SourceType.Fire, 0f);
this.resists.put(SourceType.Cold, 0f);
this.resists.put(SourceType.Healing, 0f);
this.immuneTo.put(SourceType.Siege, true);
}
/**
* Get a resist
*/
public float getResist(DamageType type, int trains) {
public float getResist(SourceType type, int trains) {
//get resisted amount
Float amount = 0f;
if (this.resists.containsKey(type))
@ -278,7 +277,7 @@ public class Resists { @@ -278,7 +277,7 @@ public class Resists {
/**
* get immuneTo
*/
public boolean immuneTo(DamageType type) {
public boolean immuneTo(SourceType type) {
if (this.immuneTo.containsKey(type))
return this.immuneTo.get(type);
else
@ -292,84 +291,46 @@ public class Resists { @@ -292,84 +291,46 @@ public class Resists {
return this.immuneToAll;
}
public boolean immuneToPowers() {
return immuneTo(DamageType.Powers);
}
public boolean immuneToAttacks() {
return immuneTo(DamageType.Attack);
return immuneTo(SourceType.ImmuneToAttack);
}
public boolean immuneToSpires() {
return immuneTo(DamageType.Spires);
}
/**
* gets immuneTo(type) and immuneToAll
*/
public boolean isImmune(DamageType type) {
if (this.immuneToAll)
return true;
return this.immuneTo(type);
}
/**
* Set a resist
*/
public void setResist(DamageType type, float value) {
public void setResist(SourceType type, float value) {
this.resists.put(type, value);
}
/**
* add to a resist
*/
public void incResist(DamageType type, float value) {
Float amount = this.resists.get(type);
if (amount == null)
this.resists.put(type, value);
else
this.resists.put(type, amount + value);
}
/**
* subtract from a resist
*/
public void decResist(DamageType type, float value) {
Float amount = this.resists.get(type);
if (amount == null)
this.resists.put(type, (0 - value));
else
this.resists.put(type, amount - value);
}
/**
* set immunities from mobbase
*/
public void setImmuneTo(int immune) {
setImmuneTo(DamageType.Stun, ((immune & 1) != 0));
setImmuneTo(DamageType.PowerBlock, ((immune & 2) != 0));
setImmuneTo(DamageType.Drain, ((immune & 4) != 0));
setImmuneTo(DamageType.Snare, ((immune & 8) != 0));
setImmuneTo(DamageType.Siege, ((immune & 16) != 0));
setImmuneTo(DamageType.Slash, ((immune & 32) != 0));
setImmuneTo(DamageType.Crush, ((immune & 64) != 0));
setImmuneTo(DamageType.Pierce, ((immune & 128) != 0));
setImmuneTo(DamageType.Magic, ((immune & 256) != 0));
setImmuneTo(DamageType.Bleed, ((immune & 512) != 0));
setImmuneTo(DamageType.Poison, ((immune & 1024) != 0));
setImmuneTo(DamageType.Mental, ((immune & 2048) != 0));
setImmuneTo(DamageType.Holy, ((immune & 4096) != 0));
setImmuneTo(DamageType.Unholy, ((immune & 8192) != 0));
setImmuneTo(DamageType.Lightning, ((immune & 16384) != 0));
setImmuneTo(DamageType.Fire, ((immune & 32768) != 0));
setImmuneTo(DamageType.Cold, ((immune & 65536) != 0));
setImmuneTo(DamageType.Steel, ((immune & 131072) != 0));
setImmuneTo(SourceType.Stun, ((immune & 1) != 0));
setImmuneTo(SourceType.Powerblock, ((immune & 2) != 0));
setImmuneTo(SourceType.Drain, ((immune & 4) != 0));
setImmuneTo(SourceType.Snare, ((immune & 8) != 0));
setImmuneTo(SourceType.Siege, ((immune & 16) != 0));
setImmuneTo(SourceType.Slashing, ((immune & 32) != 0));
setImmuneTo(SourceType.Crushing, ((immune & 64) != 0));
setImmuneTo(SourceType.Piercing, ((immune & 128) != 0));
setImmuneTo(SourceType.Magic, ((immune & 256) != 0));
setImmuneTo(SourceType.Bleeding, ((immune & 512) != 0));
setImmuneTo(SourceType.Poison, ((immune & 1024) != 0));
setImmuneTo(SourceType.Mental, ((immune & 2048) != 0));
setImmuneTo(SourceType.Holy, ((immune & 4096) != 0));
setImmuneTo(SourceType.Unholy, ((immune & 8192) != 0));
setImmuneTo(SourceType.Lightning, ((immune & 16384) != 0));
setImmuneTo(SourceType.Fire, ((immune & 32768) != 0));
setImmuneTo(SourceType.Cold, ((immune & 65536) != 0));
setImmuneTo(SourceType.Steal, ((immune & 131072) != 0));
}
/**
* set/unset immuneTo
*/
public void setImmuneTo(DamageType type, boolean value) {
public void setImmuneTo(SourceType type, boolean value) {
this.immuneTo.put(type, value);
}
@ -392,7 +353,7 @@ public class Resists { @@ -392,7 +353,7 @@ public class Resists {
* get Damage after resist
* Expects heals as negative damage and damage as positive damage for fortitudes.
*/
public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType type, float damage, int trains) {
public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, SourceType type, float damage, int trains) {
//handle fortitudes
damage = handleFortitude(target, type, damage);
//calculate armor piercing
@ -430,32 +391,32 @@ public class Resists { @@ -430,32 +391,32 @@ public class Resists {
if (rb != null) {
// Handle immunities
if (rb.getBool(ModType.ImmuneTo, SourceType.Stun))
this.immuneTo.put(DamageType.Stun, true);
this.immuneTo.put(SourceType.Stun, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Blind))
this.immuneTo.put(DamageType.Blind, true);
this.immuneTo.put(SourceType.Blind, true);
if (rb.getBool(ModType.ImmuneToAttack, SourceType.None))
this.immuneTo.put(DamageType.Attack, true);
this.immuneTo.put(SourceType.ImmuneToAttack, true);
if (rb.getBool(ModType.ImmuneToPowers, SourceType.None))
this.immuneTo.put(DamageType.Powers, true);
this.immuneTo.put(SourceType.ImmuneToPowers, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Powerblock))
this.immuneTo.put(DamageType.Powerblock, true);
this.immuneTo.put(SourceType.Powerblock, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.DeBuff))
this.immuneTo.put(DamageType.DeBuff, true);
this.immuneTo.put(SourceType.DeBuff, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Fear))
this.immuneTo.put(DamageType.Fear, true);
this.immuneTo.put(SourceType.Fear, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Charm))
this.immuneTo.put(DamageType.Charm, true);
this.immuneTo.put(SourceType.Charm, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Root))
this.immuneTo.put(DamageType.Root, true);
this.immuneTo.put(SourceType.Root, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Snare))
this.immuneTo.put(DamageType.Snare, true);
this.immuneTo.put(SourceType.Snare, true);
// Handle resists
slash += rb.getFloat(ModType.Resistance, SourceType.Slash);
crush += rb.getFloat(ModType.Resistance, SourceType.Crush);
pierce += rb.getFloat(ModType.Resistance, SourceType.Pierce);
slash += rb.getFloat(ModType.Resistance, SourceType.Slashing);
crush += rb.getFloat(ModType.Resistance, SourceType.Crushing);
pierce += rb.getFloat(ModType.Resistance, SourceType.Piercing);
magic += rb.getFloat(ModType.Resistance, SourceType.Magic);
bleed += rb.getFloat(ModType.Resistance, SourceType.Bleed);
bleed += rb.getFloat(ModType.Resistance, SourceType.Bleeding);
poison += rb.getFloat(ModType.Resistance, SourceType.Poison);
mental += rb.getFloat(ModType.Resistance, SourceType.Mental);
holy += rb.getFloat(ModType.Resistance, SourceType.Holy);
@ -465,19 +426,6 @@ public class Resists { @@ -465,19 +426,6 @@ public class Resists {
cold += rb.getFloat(ModType.Resistance, SourceType.Cold);
healing += rb.getFloat(ModType.Resistance, SourceType.Healing); // DamageType.Healing.name());
//HHO
// String protectionString = rb.getString("protection");
//
// if (protectionString.isEmpty())
// this.protection = null;
// else try {
// this.protection = DamageType.valueOf(rb.getString("protection"));
// } catch (IllegalArgumentException e) {
// Logger.error( "No enum for: " + protectionString);
// this.protection = null;
// }
// this.protectionTrains = rb.getFloat("protection");
}
// get resists from equipment
@ -500,30 +448,30 @@ public class Resists { @@ -500,30 +448,30 @@ public class Resists {
}
}
this.resists.put(DamageType.Slash, slash);
this.resists.put(DamageType.Crush, crush);
this.resists.put(DamageType.Pierce, pierce);
this.resists.put(DamageType.Magic, magic);
this.resists.put(DamageType.Bleed, bleed);
this.resists.put(DamageType.Poison, poison);
this.resists.put(DamageType.Mental, mental);
this.resists.put(DamageType.Holy, holy);
this.resists.put(DamageType.Unholy, unholy);
this.resists.put(DamageType.Lightning, lightning);
this.resists.put(DamageType.Fire, fire);
this.resists.put(DamageType.Cold, cold);
this.resists.put(DamageType.Healing, healing);
this.immuneTo.put(DamageType.Siege, true);
this.resists.put(SourceType.Slashing, slash);
this.resists.put(SourceType.Crushing, crush);
this.resists.put(SourceType.Piercing, pierce);
this.resists.put(SourceType.Magic, magic);
this.resists.put(SourceType.Bleeding, bleed);
this.resists.put(SourceType.Poison, poison);
this.resists.put(SourceType.Mental, mental);
this.resists.put(SourceType.Holy, holy);
this.resists.put(SourceType.Unholy, unholy);
this.resists.put(SourceType.Lightning, lightning);
this.resists.put(SourceType.Fire, fire);
this.resists.put(SourceType.Cold, cold);
this.resists.put(SourceType.Healing, healing);
this.immuneTo.put(SourceType.Siege, true);
// debug printing of resists
// printResists(pc);
}
public void printResistsToClient(PlayerCharacter pc) {
for (DamageType dt : resists.keySet())
for (SourceType dt : resists.keySet())
ChatManager.chatSystemInfo(pc, " resist." + dt.name() + ": " + resists.get(dt));
for (DamageType dt : immuneTo.keySet())
for (SourceType dt : immuneTo.keySet())
ChatManager.chatSystemInfo(pc, " immuneTo." + dt.name() + ": " + immuneTo.get(dt));
ChatManager.chatSystemInfo(pc, " immuneToAll: " + this.immuneToAll);
if (protection != null)
@ -536,9 +484,9 @@ public class Resists { @@ -536,9 +484,9 @@ public class Resists {
String out = pc.getName();
out += "Resists: ";
Iterator<DamageType> it = this.resists.keySet().iterator();
Iterator<SourceType> it = this.resists.keySet().iterator();
while (it.hasNext()) {
DamageType damType = it.next();
SourceType damType = it.next();
String dtName = damType.name();
out += dtName + '=' + this.resists.get(dtName) + ", ";
}
@ -546,7 +494,7 @@ public class Resists { @@ -546,7 +494,7 @@ public class Resists {
out += "ImmuneTo: ";
it = this.immuneTo.keySet().iterator();
while (it.hasNext()) {
DamageType damType = it.next();
SourceType damType = it.next();
String dtName = damType.name();
out += dtName + '=' + this.resists.get(dtName) + ", ";

9
src/engine/powers/DamageShield.java

@ -8,23 +8,22 @@ @@ -8,23 +8,22 @@
package engine.powers;
import engine.Enum.DamageType;
import engine.Enum;
public class DamageShield {
private final DamageType damageType;
private final Enum.SourceType damageType;
private final float amount;
private final boolean usePercent;
public DamageShield(DamageType damageType, float amount, boolean usePercent) {
public DamageShield(Enum.SourceType damageType, float amount, boolean usePercent) {
super();
this.damageType = damageType;
this.amount = amount;
this.usePercent = usePercent;
}
public DamageType getDamageType() {
public Enum.SourceType getDamageType() {
return this.damageType;
}

35
src/engine/powers/EffectsBase.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.powers;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.EffectSourceType;
import engine.Enum.GameObjectType;
import engine.Enum.PowerFailCondition;
@ -45,7 +44,7 @@ public class EffectsBase { @@ -45,7 +44,7 @@ public class EffectsBase {
public static HashMap<String, HashMap<String, ArrayList<String>>> NewEffectsMap = new HashMap<>();
public static HashMap<String, HashMap<String, ArrayList<String>>> ChangedEffectsMap = new HashMap<>();
public static HashMap<String, HashSet<PowerFailCondition>> EffectFailConditions = new HashMap<>();
public static HashMap<Integer, HashSet<DamageType>> EffectDamageTypes = new HashMap<>();
public static HashMap<Integer, HashSet<Enum.SourceType>> EffectDamageTypes = new HashMap<>();
public static HashSet<AbstractEffectModifier> DefaultModifiers = new HashSet<>();
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private static int NewID = 3000;
@ -245,7 +244,7 @@ public class EffectsBase { @@ -245,7 +244,7 @@ public class EffectsBase {
damageType3 = "Pierce";
if (damageType3.equalsIgnoreCase("Slashing"))
damageType3 = "Slash";
DamageType dt = getDamageType(damageType1);
Enum.SourceType dt = getDamageType(damageType1);
if (dt != null)
EffectsBase.EffectDamageTypes.get(eb.token).add(dt);
@ -301,27 +300,13 @@ public class EffectsBase { @@ -301,27 +300,13 @@ public class EffectsBase {
}
private static DamageType getDamageType(String name) {
try {
switch (name) {
case "Crushing":
name = "Crush";
break;
case "Slashing":
name = "Slash";
break;
case "Piercing":
name = "Pierce";
break;
}
if (name.isEmpty())
return null;
else
return DamageType.valueOf(name);
} catch (Exception e) {
Logger.error(name);
private static Enum.SourceType getDamageType(String name) {
if (name.isEmpty())
return null;
}
else
return Enum.SourceType.valueOf(name);
}
public static String getItemEffectsByName(String string) {
@ -351,7 +336,7 @@ public class EffectsBase { @@ -351,7 +336,7 @@ public class EffectsBase {
}
public boolean containsDamageType(DamageType dt) {
public boolean containsDamageType(Enum.SourceType dt) {
if (!EffectsBase.EffectDamageTypes.containsKey(this.token))
return false;
return EffectsBase.EffectDamageTypes.get(this.token).contains(dt);
@ -742,7 +727,7 @@ public class EffectsBase { @@ -742,7 +727,7 @@ public class EffectsBase {
String text = "";
if (!EffectsBase.EffectDamageTypes.containsKey(this.token))
return text;
for (DamageType type : EffectsBase.EffectDamageTypes.get(this.token)) {
for (Enum.SourceType type : EffectsBase.EffectDamageTypes.get(this.token)) {
text += type.name() + ' ';
}
return text;

6
src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java

@ -8,8 +8,7 @@ @@ -8,8 +8,7 @@
package engine.powers.effectmodifiers;
import engine.Enum.DamageType;
import engine.Enum;
import engine.jobs.AbstractEffectJob;
import engine.objects.*;
import engine.powers.DamageShield;
@ -49,7 +48,8 @@ public class DamageShieldEffectModifier extends AbstractEffectModifier { @@ -49,7 +48,8 @@ public class DamageShieldEffectModifier extends AbstractEffectModifier {
amount *= (1 + mod);
}
DamageType dt = DamageType.valueOf(this.type);
Enum.SourceType dt = Enum.SourceType.valueOf(this.type);
if (dt != null) {
DamageShield ds = new DamageShield(dt, amount, usePercent);
PlayerBonuses bonus = ac.getBonuses();

8
src/engine/powers/effectmodifiers/HealthEffectModifier.java

@ -8,8 +8,6 @@ @@ -8,8 +8,6 @@
package engine.powers.effectmodifiers;
import engine.Enum.DamageType;
import engine.Enum.GameObjectType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
@ -29,13 +27,13 @@ import java.util.concurrent.ThreadLocalRandom; @@ -29,13 +27,13 @@ import java.util.concurrent.ThreadLocalRandom;
public class HealthEffectModifier extends AbstractEffectModifier {
private DamageType damageType;
private SourceType damageType;
public HealthEffectModifier(ResultSet rs) throws SQLException {
super(rs);
String damageTypeDB = rs.getString("type");
try {
this.damageType = DamageType.valueOf(damageTypeDB);
this.damageType = SourceType.valueOf(damageTypeDB);
} catch (IllegalArgumentException e) {
Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID
+ " value received = '" + damageTypeDB + '\'', e);
@ -205,7 +203,7 @@ public class HealthEffectModifier extends AbstractEffectModifier { @@ -205,7 +203,7 @@ public class HealthEffectModifier extends AbstractEffectModifier {
}*/
PlayerBonuses bonus = ac.getBonuses();
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) {
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Healing) >= trains) {
ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID);
mhm.setUnknown03(5); //set target is immune
DispatchMessage.sendToAllInRange(ac, mhm);

7
src/engine/powers/effectmodifiers/ManaEffectModifier.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.powers.effectmodifiers;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
@ -32,13 +31,13 @@ import java.util.concurrent.ThreadLocalRandom; @@ -32,13 +31,13 @@ import java.util.concurrent.ThreadLocalRandom;
public class ManaEffectModifier extends AbstractEffectModifier {
private DamageType damageType;
private SourceType damageType;
public ManaEffectModifier(ResultSet rs) throws SQLException {
super(rs);
String damageTypeDB = rs.getString("type");
try {
this.damageType = DamageType.valueOf(damageTypeDB);
this.damageType = SourceType.valueOf(damageTypeDB);
} catch (IllegalArgumentException e) {
Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID
+ " value received = '" + damageTypeDB + '\'', e);
@ -158,7 +157,7 @@ public class ManaEffectModifier extends AbstractEffectModifier { @@ -158,7 +157,7 @@ public class ManaEffectModifier extends AbstractEffectModifier {
}
}
PlayerBonuses bonus = ac.getBonuses();
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) {
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Healing) >= trains) {
ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID);
mhm.setUnknown03(5); //set target is immune
DispatchMessage.sendToAllInRange(ac, mhm);

7
src/engine/powers/effectmodifiers/StaminaEffectModifier.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.powers.effectmodifiers;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
@ -32,13 +31,13 @@ import java.util.concurrent.ThreadLocalRandom; @@ -32,13 +31,13 @@ import java.util.concurrent.ThreadLocalRandom;
public class StaminaEffectModifier extends AbstractEffectModifier {
private DamageType damageType;
private SourceType damageType;
public StaminaEffectModifier(ResultSet rs) throws SQLException {
super(rs);
String damageTypeDB = rs.getString("type");
try {
this.damageType = DamageType.valueOf(damageTypeDB);
this.damageType = SourceType.valueOf(damageTypeDB);
} catch (IllegalArgumentException e) {
Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID
+ " value received = '" + damageTypeDB + '\'', e);
@ -154,7 +153,7 @@ public class StaminaEffectModifier extends AbstractEffectModifier { @@ -154,7 +153,7 @@ public class StaminaEffectModifier extends AbstractEffectModifier {
}
}
PlayerBonuses bonus = ac.getBonuses();
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Heal) >= trains) {
if (!skipImmune && bonus.getFloat(ModType.BlackMantle, SourceType.Healing) >= trains) {
ModifyHealthMsg mhm = new ModifyHealthMsg(source, ac, 0f, 0f, 0f, powerID, powerName, trains, effectID);
mhm.setUnknown03(5); //set target is immune
DispatchMessage.sendToAllInRange(ac, mhm);

5
src/engine/powers/poweractions/TransferStatPowerAction.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.powers.poweractions;
import engine.Enum;
import engine.Enum.DamageType;
import engine.Enum.ModType;
import engine.Enum.SourceType;
import engine.gameManager.ChatManager;
@ -46,7 +45,7 @@ public class TransferStatPowerAction extends AbstractPowerAction { @@ -46,7 +45,7 @@ public class TransferStatPowerAction extends AbstractPowerAction {
protected float transferEfficiencyRamp;
protected boolean transferEfficiencyRampAdd;
protected boolean targetToCaster;
protected DamageType damageType;
protected SourceType damageType;
protected EffectsBase effect;
public TransferStatPowerAction(ResultSet rs, HashMap<String, EffectsBase> effects) throws SQLException {
@ -80,7 +79,7 @@ public class TransferStatPowerAction extends AbstractPowerAction { @@ -80,7 +79,7 @@ public class TransferStatPowerAction extends AbstractPowerAction {
// Damage type can sometimes be null in the DB.
if (damageString.isEmpty() == false)
this.damageType = DamageType.valueOf(damageString);
this.damageType = SourceType.valueOf(damageString);
} catch (Exception e) {
this.damageType = null;
}

Loading…
Cancel
Save