Minor Attackable class cleanup.

This commit is contained in:
MobiusDevelopment 2022-01-06 21:18:55 +00:00
parent e4d6b3190f
commit eb59d00dac
25 changed files with 121 additions and 152 deletions

View File

@ -324,8 +324,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1850,12 +1850,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1796,12 +1796,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1796,12 +1796,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1796,12 +1796,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1784,12 +1784,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1784,12 +1784,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1784,12 +1784,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1795,12 +1795,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1795,12 +1795,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1795,12 +1795,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -319,8 +319,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1795,12 +1795,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -512,13 +512,10 @@ public class Attackable extends Npc
} }
setChampion(false); setChampion(false);
if (Config.CHAMPION_ENABLE) // Set champion on next spawn.
if (Config.CHAMPION_ENABLE && !(this instanceof GrandBoss) && !(this instanceof RaidBoss) && (this instanceof Monster) /* && !getTemplate().isQuestMonster */ && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LEVEL) && (getLevel() <= Config.CHAMP_MAX_LEVEL) && (Rnd.get(100) < Config.CHAMPION_FREQUENCY))
{ {
// Set champion on next spawn. setChampion(true);
if (!(this instanceof GrandBoss) && !(this instanceof RaidBoss) && (this instanceof Monster) /* && !getTemplate().isQuestMonster */ && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LEVEL) && (getLevel() <= Config.CHAMP_MAX_LEVEL) && (Rnd.get(100) < Config.CHAMPION_FREQUENCY))
{
setChampion(true);
}
} }
return true; return true;
@ -2190,10 +2187,8 @@ public class Attackable extends Npc
return; return;
} }
final int maxAbsorbLevel = getAbsorbLevel();
int minAbsorbLevel = 0;
// If this is not a valid Attackable, clears the _absorbersList and just return // If this is not a valid Attackable, clears the _absorbersList and just return
final int maxAbsorbLevel = getAbsorbLevel();
if (maxAbsorbLevel == 0) if (maxAbsorbLevel == 0)
{ {
resetAbsorbList(); resetAbsorbList();
@ -2201,6 +2196,7 @@ public class Attackable extends Npc
} }
// All boss mobs with maxAbsorbLevel 13 have minAbsorbLevel of 12 else 10 // All boss mobs with maxAbsorbLevel 13 have minAbsorbLevel of 12 else 10
int minAbsorbLevel = 0;
if (maxAbsorbLevel > 10) if (maxAbsorbLevel > 10)
{ {
minAbsorbLevel = maxAbsorbLevel > 12 ? 12 : 10; minAbsorbLevel = maxAbsorbLevel > 12 ? 12 : 10;
@ -2547,8 +2543,7 @@ public class Attackable extends Npc
final double overhitExp = (overhitPercentage / 100) * normalExp; final double overhitExp = (overhitPercentage / 100) * normalExp;
// Return the rounded ammount of exp points to be added to the player's normal exp reward // Return the rounded ammount of exp points to be added to the player's normal exp reward
final long bonusOverhit = Math.round(overhitExp); return Math.round(overhitExp);
return bonusOverhit;
} }
@Override @Override

View File

@ -513,13 +513,10 @@ public class Attackable extends Npc
} }
setChampion(false); setChampion(false);
if (Config.CHAMPION_ENABLE) // Set champion on next spawn.
if (Config.CHAMPION_ENABLE && !(this instanceof GrandBoss) && !(this instanceof RaidBoss) && (this instanceof Monster) /* && !getTemplate().isQuestMonster */ && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LEVEL) && (getLevel() <= Config.CHAMP_MAX_LEVEL) && (Rnd.get(100) < Config.CHAMPION_FREQUENCY))
{ {
// Set champion on next spawn. setChampion(true);
if (!(this instanceof GrandBoss) && !(this instanceof RaidBoss) && (this instanceof Monster) /* && !getTemplate().isQuestMonster */ && (Config.CHAMPION_FREQUENCY > 0) && (getLevel() >= Config.CHAMP_MIN_LEVEL) && (getLevel() <= Config.CHAMP_MAX_LEVEL) && (Rnd.get(100) < Config.CHAMPION_FREQUENCY))
{
setChampion(true);
}
} }
return true; return true;
@ -2542,10 +2539,8 @@ public class Attackable extends Npc
return; return;
} }
final int maxAbsorbLevel = getAbsorbLevel();
int minAbsorbLevel = 0;
// If this is not a valid Attackable, clears the _absorbersList and just return // If this is not a valid Attackable, clears the _absorbersList and just return
final int maxAbsorbLevel = getAbsorbLevel();
if (maxAbsorbLevel == 0) if (maxAbsorbLevel == 0)
{ {
resetAbsorbList(); resetAbsorbList();
@ -2553,6 +2548,7 @@ public class Attackable extends Npc
} }
// All boss mobs with maxAbsorbLevel 13 have minAbsorbLevel of 12 else 10 // All boss mobs with maxAbsorbLevel 13 have minAbsorbLevel of 12 else 10
int minAbsorbLevel = 0;
if (maxAbsorbLevel > 10) if (maxAbsorbLevel > 10)
{ {
minAbsorbLevel = maxAbsorbLevel > 12 ? 12 : 10; minAbsorbLevel = maxAbsorbLevel > 12 ? 12 : 10;
@ -2899,8 +2895,7 @@ public class Attackable extends Npc
final double overhitExp = (overhitPercentage / 100) * normalExp; final double overhitExp = (overhitPercentage / 100) * normalExp;
// Return the rounded ammount of exp points to be added to the player's normal exp reward // Return the rounded ammount of exp points to be added to the player's normal exp reward
final long bonusOverhit = Math.round(overhitExp); return Math.round(overhitExp);
return bonusOverhit;
} }
@Override @Override

View File

@ -338,8 +338,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {

View File

@ -338,8 +338,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1788,12 +1788,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1788,12 +1788,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -320,8 +320,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1788,12 +1788,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -322,8 +322,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1809,12 +1809,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -322,8 +322,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1809,12 +1809,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -322,8 +322,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1809,12 +1809,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -324,8 +324,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1842,12 +1842,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -323,8 +323,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1805,12 +1805,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -328,8 +328,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1810,12 +1810,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {

View File

@ -328,8 +328,8 @@ public class Attackable extends Npc
static class PartyContainer static class PartyContainer
{ {
Party party; public Party party;
long damage = 0L; public long damage;
public PartyContainer(Party party, long damage) public PartyContainer(Party party, long damage)
{ {
@ -1810,12 +1810,11 @@ public class Attackable extends Npc
if (object == null) if (object == null)
{ {
final WorldObject target = getTarget(); final WorldObject target = getTarget();
final Map<Creature, AggroInfo> aggroList = _aggroList; if (target != null)
if ((target != null) && (aggroList != null))
{ {
aggroList.remove(target); _aggroList.remove(target);
} }
if ((aggroList != null) && aggroList.isEmpty()) if (_aggroList.isEmpty())
{ {
if (getAI() instanceof AttackableAI) if (getAI() instanceof AttackableAI)
{ {