Browse Source

DamageType defined as in JSON

combat-2
MagicBot 8 months ago
parent
commit
14ee83e147
  1. 71
      src/engine/Enum.java
  2. 4
      src/engine/gameManager/CombatManager.java
  3. 6
      src/engine/gameManager/NPCManager.java
  4. 162
      src/engine/objects/Resists.java

71
src/engine/Enum.java

@ -725,51 +725,50 @@ public class Enum { @@ -725,51 +725,50 @@ public class Enum {
}
public enum DamageType {
None,
Crush,
Slash,
Siege,
Pierce,
Magic,
Bleed,
Poison,
Mental,
Holy,
Unholy,
Lightning,
Fire,
Cold,
Healing,
Acid,
Disease,
Unknown,
NONE,
CRUSHING,
SLASHING,
SIEGE,
PIERCE,
MAGIC,
BLEEDING,
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;
ATTACK,
POWERS,
COMBAT,
SPIRES,
SNARE,
STUN,
BLIND,
ROOT,
FEAR,
CHARM,
POWERBLOCK,
DEBUFF,
STEAL,
DRAIN;
public static DamageType GetDamageType(String modName) {
DamageType damageType;
if (modName.isEmpty())
return DamageType.None;
return DamageType.NONE;
try {
damageType = DamageType.valueOf(modName.replace(",", ""));
damageType = DamageType.valueOf(modName.replace(",", "").toUpperCase());
} catch (Exception e) {
Logger.error(e);
return DamageType.None;
return DamageType.NONE;
}
return damageType;
}

4
src/engine/gameManager/CombatManager.java

@ -213,10 +213,10 @@ public enum CombatManager { @@ -213,10 +213,10 @@ public enum CombatManager {
Enum.DamageType damageType;
if (attacker.charItemManager.getEquipped().get(slot) == null) {
damageType = Enum.DamageType.Crush;
damageType = Enum.DamageType.CRUSHING;
if (attacker.getObjectType().equals(Enum.GameObjectType.Mob))
if (((Mob) attacker).isSiege())
damageType = Enum.DamageType.Siege;
damageType = Enum.DamageType.SIEGE;
} else {
damageType = (Enum.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0];
}

6
src/engine/gameManager/NPCManager.java

@ -433,9 +433,9 @@ public enum NPCManager { @@ -433,9 +433,9 @@ public enum NPCManager {
for (Item equipped : mob.charItemManager.equipped.values()) {
if (equipped.template.item_type.equals(Enum.ItemType.ARMOR)) {
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce, 0) + equipped.template.combat_attack_resist.get("PIERCING"));
mob.resists.setResist(Enum.DamageType.SLASHING, mob.resists.getResist(Enum.DamageType.SLASHING, 0) + equipped.template.combat_attack_resist.get("SLASHING"));
mob.resists.setResist(Enum.DamageType.CRUSHING, mob.resists.getResist(Enum.DamageType.CRUSHING, 0) + equipped.template.combat_attack_resist.get("CRUSHING"));
mob.resists.setResist(Enum.DamageType.PIERCE, mob.resists.getResist(Enum.DamageType.PIERCE, 0) + equipped.template.combat_attack_resist.get("PIERCING"));
}
}
}

162
src/engine/objects/Resists.java

@ -83,19 +83,19 @@ public class Resists { @@ -83,19 +83,19 @@ public class Resists {
*/
public Resists(ResultSet rs) throws SQLException {
this.immuneToAll = false;
this.resists.put(Enum.DamageType.Slash, rs.getFloat("slash"));
this.resists.put(Enum.DamageType.Crush, rs.getFloat("crush"));
this.resists.put(Enum.DamageType.Pierce, rs.getFloat("pierce"));
this.resists.put(Enum.DamageType.Magic, rs.getFloat("magic"));
this.resists.put(Enum.DamageType.Bleed, rs.getFloat("bleed"));
this.resists.put(Enum.DamageType.Poison, rs.getFloat("poison"));
this.resists.put(Enum.DamageType.Mental, rs.getFloat("mental"));
this.resists.put(Enum.DamageType.Holy, rs.getFloat("holy"));
this.resists.put(Enum.DamageType.Unholy, rs.getFloat("unholy"));
this.resists.put(Enum.DamageType.Lightning, rs.getFloat("lightning"));
this.resists.put(Enum.DamageType.Fire, rs.getFloat("fire"));
this.resists.put(Enum.DamageType.Cold, rs.getFloat("cold"));
this.resists.put(Enum.DamageType.Healing, 0f);
this.resists.put(Enum.DamageType.SLASHING, rs.getFloat("slash"));
this.resists.put(Enum.DamageType.CRUSHING, rs.getFloat("crush"));
this.resists.put(Enum.DamageType.PIERCE, rs.getFloat("pierce"));
this.resists.put(Enum.DamageType.MAGIC, rs.getFloat("magic"));
this.resists.put(Enum.DamageType.BLEEDING, rs.getFloat("bleed"));
this.resists.put(Enum.DamageType.POISON, rs.getFloat("poison"));
this.resists.put(Enum.DamageType.MENTAL, rs.getFloat("mental"));
this.resists.put(Enum.DamageType.HOLY, rs.getFloat("holy"));
this.resists.put(Enum.DamageType.UNHOLY, rs.getFloat("unholy"));
this.resists.put(Enum.DamageType.LIGHTNING, rs.getFloat("lightning"));
this.resists.put(Enum.DamageType.FIRE, rs.getFloat("fire"));
this.resists.put(Enum.DamageType.COLD, rs.getFloat("cold"));
this.resists.put(Enum.DamageType.HEALING, 0f);
}
//Handle Fortitudes
@ -106,7 +106,7 @@ public class Resists { @@ -106,7 +106,7 @@ public class Resists {
//see if there is a fortitude
float damageCap = bonus.getFloatPercentAll(ModType.DamageCap, SourceType.None);
if (damageCap == 0f || type == Enum.DamageType.Healing)
if (damageCap == 0f || type == Enum.DamageType.HEALING)
return damage;
//is fortitude, Are we under the cap?
@ -137,7 +137,7 @@ public class Resists { @@ -137,7 +137,7 @@ public class Resists {
for (SourceType fort : forts) {
Enum.DamageType dt = Enum.DamageType.valueOf(fort.name());
if (dt.equals(Enum.DamageType.None))
if (dt.equals(Enum.DamageType.NONE))
continue;
if (dt.equals(damageType)) {
@ -195,19 +195,19 @@ public class Resists { @@ -195,19 +195,19 @@ public class Resists {
*/
public final void setBuildingResists() {
this.immuneToAll = false;
this.resists.put(Enum.DamageType.Slash, 85f);
this.resists.put(Enum.DamageType.Crush, 85f);
this.resists.put(Enum.DamageType.Siege, 0f);
this.immuneTo.put(Enum.DamageType.Pierce, true);
this.immuneTo.put(Enum.DamageType.Magic, true);
this.immuneTo.put(Enum.DamageType.Bleed, true);
this.immuneTo.put(Enum.DamageType.Poison, true);
this.immuneTo.put(Enum.DamageType.Mental, true);
this.immuneTo.put(Enum.DamageType.Holy, true);
this.immuneTo.put(Enum.DamageType.Unholy, true);
this.immuneTo.put(Enum.DamageType.Lightning, true);
this.immuneTo.put(Enum.DamageType.Fire, true);
this.immuneTo.put(Enum.DamageType.Cold, true);
this.resists.put(Enum.DamageType.SLASHING, 85f);
this.resists.put(Enum.DamageType.CRUSHING, 85f);
this.resists.put(Enum.DamageType.SIEGE, 0f);
this.immuneTo.put(Enum.DamageType.PIERCE, true);
this.immuneTo.put(Enum.DamageType.MAGIC, true);
this.immuneTo.put(Enum.DamageType.BLEEDING, true);
this.immuneTo.put(Enum.DamageType.POISON, true);
this.immuneTo.put(Enum.DamageType.MENTAL, true);
this.immuneTo.put(Enum.DamageType.HOLY, true);
this.immuneTo.put(Enum.DamageType.UNHOLY, true);
this.immuneTo.put(Enum.DamageType.LIGHTNING, true);
this.immuneTo.put(Enum.DamageType.FIRE, true);
this.immuneTo.put(Enum.DamageType.COLD, true);
}
@ -216,19 +216,19 @@ public class Resists { @@ -216,19 +216,19 @@ public class Resists {
*/
public final void setMineResists() {
this.immuneToAll = false;
this.immuneTo.put(Enum.DamageType.Slash, true);
this.immuneTo.put(Enum.DamageType.Crush, true);
this.immuneTo.put(Enum.DamageType.Pierce, true);
this.immuneTo.put(Enum.DamageType.Magic, true);
this.immuneTo.put(Enum.DamageType.Bleed, true);
this.immuneTo.put(Enum.DamageType.Poison, true);
this.immuneTo.put(Enum.DamageType.Mental, true);
this.immuneTo.put(Enum.DamageType.Holy, true);
this.immuneTo.put(Enum.DamageType.Unholy, true);
this.immuneTo.put(Enum.DamageType.Lightning, true);
this.immuneTo.put(Enum.DamageType.Fire, true);
this.immuneTo.put(Enum.DamageType.Cold, true);
this.resists.put(Enum.DamageType.Siege, 0f);
this.immuneTo.put(Enum.DamageType.SLASHING, true);
this.immuneTo.put(Enum.DamageType.CRUSHING, true);
this.immuneTo.put(Enum.DamageType.PIERCE, true);
this.immuneTo.put(Enum.DamageType.MAGIC, true);
this.immuneTo.put(Enum.DamageType.BLEEDING, true);
this.immuneTo.put(Enum.DamageType.POISON, true);
this.immuneTo.put(Enum.DamageType.MENTAL, true);
this.immuneTo.put(Enum.DamageType.HOLY, true);
this.immuneTo.put(Enum.DamageType.UNHOLY, true);
this.immuneTo.put(Enum.DamageType.LIGHTNING, true);
this.immuneTo.put(Enum.DamageType.FIRE, true);
this.immuneTo.put(Enum.DamageType.COLD, true);
this.resists.put(Enum.DamageType.SIEGE, 0f);
}
/**
@ -236,20 +236,20 @@ public class Resists { @@ -236,20 +236,20 @@ public class Resists {
*/
public final void setGenericResists() {
this.immuneToAll = false;
this.resists.put(Enum.DamageType.Slash, 0f);
this.resists.put(Enum.DamageType.Crush, 0f);
this.resists.put(Enum.DamageType.Pierce, 0f);
this.resists.put(Enum.DamageType.Magic, 0f);
this.resists.put(Enum.DamageType.Bleed, 0f);
this.resists.put(Enum.DamageType.Poison, 0f);
this.resists.put(Enum.DamageType.Mental, 0f);
this.resists.put(Enum.DamageType.Holy, 0f);
this.resists.put(Enum.DamageType.Unholy, 0f);
this.resists.put(Enum.DamageType.Lightning, 0f);
this.resists.put(Enum.DamageType.Fire, 0f);
this.resists.put(Enum.DamageType.Cold, 0f);
this.resists.put(Enum.DamageType.Healing, 0f);
this.immuneTo.put(Enum.DamageType.Siege, true);
this.resists.put(Enum.DamageType.SLASHING, 0f);
this.resists.put(Enum.DamageType.CRUSHING, 0f);
this.resists.put(Enum.DamageType.PIERCE, 0f);
this.resists.put(Enum.DamageType.MAGIC, 0f);
this.resists.put(Enum.DamageType.BLEEDING, 0f);
this.resists.put(Enum.DamageType.POISON, 0f);
this.resists.put(Enum.DamageType.MENTAL, 0f);
this.resists.put(Enum.DamageType.HOLY, 0f);
this.resists.put(Enum.DamageType.UNHOLY, 0f);
this.resists.put(Enum.DamageType.LIGHTNING, 0f);
this.resists.put(Enum.DamageType.FIRE, 0f);
this.resists.put(Enum.DamageType.COLD, 0f);
this.resists.put(Enum.DamageType.HEALING, 0f);
this.immuneTo.put(Enum.DamageType.SIEGE, true);
}
@ -293,7 +293,7 @@ public class Resists { @@ -293,7 +293,7 @@ public class Resists {
}
public boolean immuneToAttacks() {
return immuneTo(Enum.DamageType.Attack);
return immuneTo(Enum.DamageType.ATTACK);
}
/**
@ -347,25 +347,25 @@ public class Resists { @@ -347,25 +347,25 @@ public class Resists {
if (rb != null) {
// Handle immunities
if (rb.getBool(ModType.ImmuneTo, SourceType.Stun))
this.immuneTo.put(Enum.DamageType.Stun, true);
this.immuneTo.put(Enum.DamageType.STUN, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Blind))
this.immuneTo.put(Enum.DamageType.Blind, true);
this.immuneTo.put(Enum.DamageType.BLIND, true);
if (rb.getBool(ModType.ImmuneToAttack, SourceType.None))
this.immuneTo.put(Enum.DamageType.Attack, true);
this.immuneTo.put(Enum.DamageType.ATTACK, true);
if (rb.getBool(ModType.ImmuneToPowers, SourceType.None))
this.immuneTo.put(Enum.DamageType.Powers, true);
this.immuneTo.put(Enum.DamageType.POWERS, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Powerblock))
this.immuneTo.put(Enum.DamageType.Powerblock, true);
this.immuneTo.put(Enum.DamageType.POWERBLOCK, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.DeBuff))
this.immuneTo.put(Enum.DamageType.DeBuff, true);
this.immuneTo.put(Enum.DamageType.DEBUFF, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Fear))
this.immuneTo.put(Enum.DamageType.Fear, true);
this.immuneTo.put(Enum.DamageType.FEAR, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Charm))
this.immuneTo.put(Enum.DamageType.Charm, true);
this.immuneTo.put(Enum.DamageType.CHARM, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Root))
this.immuneTo.put(Enum.DamageType.Root, true);
this.immuneTo.put(Enum.DamageType.ROOT, true);
if (rb.getBool(ModType.ImmuneTo, SourceType.Snare))
this.immuneTo.put(Enum.DamageType.Snare, true);
this.immuneTo.put(Enum.DamageType.SNARE, true);
// Handle resists
slash += rb.getFloat(ModType.Resistance, SourceType.Slash);
@ -404,21 +404,21 @@ public class Resists { @@ -404,21 +404,21 @@ public class Resists {
}
}
this.resists.put(Enum.DamageType.Slash, slash);
this.resists.put(Enum.DamageType.Crush, crush);
this.resists.put(Enum.DamageType.Pierce, pierce);
this.resists.put(Enum.DamageType.Magic, magic);
this.resists.put(Enum.DamageType.Bleed, bleed);
this.resists.put(Enum.DamageType.Poison, poison);
this.resists.put(Enum.DamageType.Mental, mental);
this.resists.put(Enum.DamageType.Holy, holy);
this.resists.put(Enum.DamageType.Unholy, unholy);
this.resists.put(Enum.DamageType.Lightning, lightning);
this.resists.put(Enum.DamageType.Fire, fire);
this.resists.put(Enum.DamageType.Cold, cold);
this.resists.put(Enum.DamageType.Healing, healing);
this.immuneTo.put(Enum.DamageType.Siege, true);
this.resists.put(Enum.DamageType.SLASHING, slash);
this.resists.put(Enum.DamageType.CRUSHING, crush);
this.resists.put(Enum.DamageType.PIERCE, pierce);
this.resists.put(Enum.DamageType.MAGIC, magic);
this.resists.put(Enum.DamageType.BLEEDING, bleed);
this.resists.put(Enum.DamageType.POISON, poison);
this.resists.put(Enum.DamageType.MENTAL, mental);
this.resists.put(Enum.DamageType.HOLY, holy);
this.resists.put(Enum.DamageType.UNHOLY, unholy);
this.resists.put(Enum.DamageType.LIGHTNING, lightning);
this.resists.put(Enum.DamageType.FIRE, fire);
this.resists.put(Enum.DamageType.COLD, cold);
this.resists.put(Enum.DamageType.HEALING, healing);
this.immuneTo.put(Enum.DamageType.SIEGE, true);
// debug printing of resists
// printResists(pc);

Loading…
Cancel
Save