Combine type and skillLevel in MobSkill

This commit is contained in:
P0nk
2022-09-03 14:07:24 +02:00
parent 7cdaabf6f8
commit a6ec6adbb5
5 changed files with 38 additions and 41 deletions

View File

@@ -47,8 +47,7 @@ import java.util.*;
public class MobSkill {
private static final Logger log = LoggerFactory.getLogger(MobSkill.class);
private final MobSkillType type;
private final int skillLevel;
private final MobSkillId id;
private final int mpCon;
private final int spawnEffect;
private final int hp;
@@ -65,8 +64,7 @@ public class MobSkill {
private MobSkill(MobSkillType type, int level, int mpCon, int spawnEffect, int hp, int x, int y, int count,
long duration, long cooltime, float prop, Point lt, Point rb, int limit, List<Integer> toSummon) {
this.type = type;
this.skillLevel = level;
this.id = new MobSkillId(type, level);
this.mpCon = mpCon;
this.spawnEffect = spawnEffect;
this.hp = hp;
@@ -195,7 +193,7 @@ public class MobSkill {
Disease disease = null;
Map<MonsterStatus, Integer> stats = new EnumMap<>(MonsterStatus.class);
List<Integer> reflection = new ArrayList<>();
switch (type) {
switch (id.type()) {
case ATTACK_UP, ATTACK_UP_M, PAD -> stats.put(MonsterStatus.WEAPON_ATTACK_UP, x);
case MAGIC_ATTACK_UP, MAGIC_ATTACK_UP_M, MAD -> stats.put(MonsterStatus.MAGIC_ATTACK_UP, x);
case DEFENSE_UP, DEFENSE_UP_M, PDR -> stats.put(MonsterStatus.WEAPON_DEFENSE_UP, x);
@@ -368,10 +366,10 @@ public class MobSkill {
private void applyMonsterBuffs(Map<MonsterStatus, Integer> stats, boolean skill, Monster monster, List<Integer> reflection) {
if (lt != null && rb != null && skill) {
for (MapObject mons : getObjectsInRange(monster, MapObjectType.MONSTER)) {
((Monster) mons).applyMonsterBuff(stats, getX(), type.getId(), getDuration(), this, reflection);
((Monster) mons).applyMonsterBuff(stats, getX(), getDuration(), this, reflection);
}
} else {
monster.applyMonsterBuff(stats, getX(), type.getId(), getDuration(), this, reflection);
monster.applyMonsterBuff(stats, getX(), getDuration(), this, reflection);
}
}
@@ -399,16 +397,12 @@ public class MobSkill {
return monster.getMap().getPlayersInRange(calculateBoundingBox(monster.getPosition()));
}
public MobSkillId getId() {
return id;
}
public MobSkillType getType() {
return type;
}
public int getSkillId() {
return type.getId();
}
public int getSkillLevel() {
return skillLevel;
return id.type();
}
public int getMpCon() {

View File

@@ -82,7 +82,7 @@ public class Monster extends AbstractLoadedLife {
private int VenomMultiplier = 0;
private boolean fake = false;
private boolean dropsDisabled = false;
private final List<Pair<Integer, Integer>> usedSkills = new ArrayList<>();
private final List<Pair<Integer, Integer>> usedSkills = new ArrayList<>(); // TODO: change to Set<MobSkillId>
private final Map<Pair<Integer, Integer>, Integer> skillsUsed = new HashMap<>();
private final Set<Integer> usedAttacks = new HashSet<>();
private Set<Integer> calledMobOids = null;
@@ -1289,7 +1289,7 @@ public class Monster extends AbstractLoadedLife {
}
}
public void applyMonsterBuff(final Map<MonsterStatus, Integer> stats, final int x, int skillId, long duration, MobSkill skill, final List<Integer> reflection) {
public void applyMonsterBuff(final Map<MonsterStatus, Integer> stats, final int x, long duration, MobSkill skill, final List<Integer> reflection) {
final Runnable cancelTask = () -> {
if (isAlive()) {
Packet packet = PacketCreator.cancelMonsterStatus(getObjectId(), stats);
@@ -1448,7 +1448,8 @@ public class Monster extends AbstractLoadedLife {
monsterLock.lock();
try {
for (Pair<Integer, Integer> skill : usedSkills) { // thanks OishiiKawaiiDesu for noticing an issue with mobskill cooldown
if (skill.getLeft() == toUse.getSkillId() && skill.getRight() == toUse.getSkillLevel()) {
MobSkillId msId = toUse.getId();
if (skill.getLeft() == msId.type().getId() && skill.getRight() == msId.level()) {
return false;
}
}
@@ -1482,8 +1483,8 @@ public class Monster extends AbstractLoadedLife {
}
private void usedSkill(MobSkill skill) {
final int skillId = skill.getSkillId();
final int level = skill.getSkillLevel();
final int skillId = skill.getId().type().getId();
final int level = skill.getId().level();
long cooltime = skill.getCoolTime();
monsterLock.lock();