Skip to content

Commit

Permalink
Refactored skill queueing
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-dev committed Jun 1, 2024
1 parent 2155980 commit 78992bd
Show file tree
Hide file tree
Showing 33 changed files with 100 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import com.aionemu.gameserver.ai.poll.AIQuestion;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.utils.PacketSendUtility;
import com.aionemu.gameserver.utils.ThreadPoolManager;
Expand Down Expand Up @@ -42,15 +40,14 @@ protected void handleAttack(Creature creature) {
}

private void startTasks() {
enrageTask = ThreadPoolManager.getInstance()
.schedule(() -> getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(19098, 55, 100))), 600000);
enrageTask = ThreadPoolManager.getInstance().schedule(() -> getOwner().queueSkill(19098, 55), 600000);
portalTask = ThreadPoolManager.getInstance().schedule(() -> spawnPortals(false), 60000);
}

private void onHealingDebuff() {
WorldMapInstance instance = getPosition().getWorldMapInstance();
deleteNpcs(instance.getNpcs(282107));
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(19282, 55, 100)));
getOwner().queueSkill(19282, 55);
spawn(282107, getOwner().getX() + 10, getOwner().getY() - 10, getOwner().getZ(), (byte) 0);
spawn(282107, getOwner().getX() - 10, getOwner().getY() + 10, getOwner().getZ(), (byte) 0);
spawn(282107, getOwner().getX() + 10, getOwner().getY() + 10, getOwner().getZ(), (byte) 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.aionemu.gameserver.model.gameobjects.VisibleObject;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.gameobjects.state.CreatureSeeState;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_FORCED_MOVE;
import com.aionemu.gameserver.utils.PacketSendUtility;
import com.aionemu.gameserver.utils.ThreadPoolManager;
Expand Down Expand Up @@ -69,42 +67,42 @@ private void debuffTarget() {
getOwner().getSkillCoolDowns().clear(); // Make CD rank-dependent, not skill-dependent

if (challengerRank >= CustomInstanceRankEnum.ANCIENT.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3539, 65, 100))); // Ignite Aether
getOwner().queueSkill(3539, 65); // Ignite Aether

if (challengerRank >= CustomInstanceRankEnum.CERANIUM.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(618, 65, 100))); // Ankle Snare
getOwner().queueSkill(618, 65); // Ankle Snare
else if (challengerRank >= CustomInstanceRankEnum.GOLD.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(1328, 65, 100))); // Restraint (^)
getOwner().queueSkill(1328, 65); // Restraint (^)

if (challengerRank >= CustomInstanceRankEnum.ANCIENT_PLUS.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3775, 65, 100))); // Fear
getOwner().queueSkill(3775, 65); // Fear
else if (challengerRank >= CustomInstanceRankEnum.GOLD.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(1417, 65, 100))); // Curse Tree (^)
getOwner().queueSkill(1417, 65); // Curse Tree (^)

// SILVER:
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3581, 65, 100))); // Withering Gloom
getOwner().queueSkill(3581, 65); // Withering Gloom

if (challengerRank >= CustomInstanceRankEnum.PLATINUM.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3574, 65, 100))); // Shackle of Vulnerability
getOwner().queueSkill(3574, 65); // Shackle of Vulnerability
else // SILVER:
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3780, 65, 100))); // Root of Enervation (^)
getOwner().queueSkill(3780, 65); // Root of Enervation (^)

if (challengerRank >= CustomInstanceRankEnum.MITHRIL.getMinRank())
if (getOwner().getTarget() != null && getOwner().getTarget() instanceof Player
&& ((Player) (getOwner().getTarget())).getPlayerClass().isPhysicalClass())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3571, 65, 100))); // Body Root
getOwner().queueSkill(3571, 65); // Body Root
else
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(3572, 65, 100))); // Sigil of Silence
getOwner().queueSkill(3572, 65); // Sigil of Silence

if (challengerRank >= CustomInstanceRankEnum.CERANIUM.getMinRank())
if (getOwner().getTarget() != null && getOwner().getTarget() instanceof Player
&& ((Player) (getOwner().getTarget())).getPlayerClass().isPhysicalClass())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(4135, 65, 100))); // Blinding Light
getOwner().queueSkill(4135, 65); // Blinding Light
else
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(1336, 65, 100))); // Curse of Weakness
getOwner().queueSkill(1336, 65); // Curse of Weakness

if (challengerRank >= CustomInstanceRankEnum.ANCIENT.getMinRank())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(4490, 65, 100))); // Paralysis Resonation
getOwner().queueSkill(4490, 65); // Paralysis Resonation

debuffTask = ThreadPoolManager.getInstance().schedule(this::debuffTarget, 30000 - challengerRank * 1000 / 3); // 30s ... 20s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.stats.calc.Stat2;
import com.aionemu.gameserver.model.stats.container.StatEnum;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_FORCED_MOVE;
import com.aionemu.gameserver.skillengine.model.Effect;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
Expand Down Expand Up @@ -49,7 +47,7 @@ protected void handleAttack(Creature creature) {

@Override
public void handleHpPhase(int phaseHpPercent) {
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21165, 1, 100, 0, 3000)));
getOwner().queueSkill(21165, 1, 3000);
}

@Override
Expand Down Expand Up @@ -127,7 +125,7 @@ public void onEndUseSkill(SkillTemplate skillTemplate, int skillLevel) {
World.getInstance().updatePosition(getOwner(), pos.getX(), pos.getY(), pos.getZ(), pos.getHeading());
PacketSendUtility.broadcastPacketAndReceive(getOwner(), new SM_FORCED_MOVE(getOwner(), getOwner()));
ThreadPoolManager.getInstance()
.schedule(() -> getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21171, 1, 100, 0, 6000))), 500);
.schedule(() -> getOwner().queueSkill(21171, 1, 6000), 500);
}, 500);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.NpcSkillEntry;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_FORCED_MOVE;
import com.aionemu.gameserver.network.aion.serverpackets.SM_HEADING_UPDATE;
import com.aionemu.gameserver.skillengine.model.Effect;
Expand Down Expand Up @@ -239,7 +237,7 @@ private void queueSkill(int id, int lvl) {
}

private void queueSkill(int id, int lvl, int nextSkillTime) {
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(id, lvl, 100, 0, nextSkillTime)));
getOwner().queueSkill(id, lvl, nextSkillTime);
}

private void updatePosition(final int curStage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.NpcSkillEntry;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_FORCED_MOVE;
import com.aionemu.gameserver.network.aion.serverpackets.SM_HEADING_UPDATE;
import com.aionemu.gameserver.skillengine.model.Effect;
Expand Down Expand Up @@ -298,7 +296,7 @@ private void queueSkill(int id, int lvl) {
}

private void queueSkill(int id, int lvl, int nextSkillTime) {
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(id, lvl, 100, 0, nextSkillTime)));
getOwner().queueSkill(id, lvl, nextSkillTime);
}

private boolean isCrazedModor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.aionemu.gameserver.ai.AIActions;
import com.aionemu.gameserver.ai.AIName;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PacketSendUtility;
Expand Down Expand Up @@ -36,7 +34,7 @@ private void scheduleWipe() {
PacketSendUtility.broadcastToMap(getOwner(), SM_SYSTEM_MESSAGE.STR_MSG_INSTANCE_A_RANK_BATTLE_TIME());
wipeTask = ThreadPoolManager.getInstance().schedule(() -> {
if (!isDead())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(19679, 50, 100, 0, 3000)));
getOwner().queueSkill(19679, 50, 3000);
}, 600000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.aionemu.gameserver.ai.AIActions;
import com.aionemu.gameserver.ai.AIName;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PacketSendUtility;
Expand Down Expand Up @@ -36,7 +34,7 @@ private void scheduleWipe() {
PacketSendUtility.broadcastToMap(getOwner(), SM_SYSTEM_MESSAGE.STR_MSG_INSTANCE_S_RANK_BATTLE_TIME());
wipeTask = ThreadPoolManager.getInstance().schedule(() -> {
if (!isDead())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(19679, 50, 100, 0, 3000)));
getOwner().queueSkill(19679, 50, 3000);
}, 300000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PositionUtil;

Expand Down Expand Up @@ -45,13 +43,13 @@ protected void handleAttack(Creature creature) {
public void handleHpPhase(int phaseHpPercent) {
switch (phaseHpPercent) {
case 75, 50, 25 -> startHallucinatoryVictoryEvent();
case 12 -> getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20942, 1, 100)));
case 12 -> getOwner().queueSkill(20942, 1);
}
}

protected void startHallucinatoryVictoryEvent() {
if (getPosition().getWorldMapInstance().getNpc(730695) == null && getPosition().getWorldMapInstance().getNpc(730696) == null)
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20911, 1, 100)));
getOwner().queueSkill(20911, 1);
}

@Override
Expand All @@ -71,7 +69,7 @@ public void onEndUseSkill(SkillTemplate skillTemplate, int skillLevel) {

protected void blazeEngraving() {
if (Rnd.chance() < 2 && getPosition().getWorldMapInstance().getNpc(283131) == null)
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20913, 60, 100)));
getOwner().queueSkill(20913, 60);
}

protected void rndSpawn(int npcId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.aionemu.gameserver.model.EmotionType;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.state.CreatureState;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_EMOTION;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PacketSendUtility;
Expand Down Expand Up @@ -45,7 +43,7 @@ protected void handleSpawned() {
private void transform() {
ThreadPoolManager.getInstance().schedule(() -> {
if (!isDead())
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(getNpcId() == 283141 ? 20967 : 21900, 1, 100)));
getOwner().queueSkill(getNpcId() == 283141 ? 20967 : 21900, 1);
}, 30000);
}

Expand All @@ -64,7 +62,7 @@ public void onEndUseSkill(SkillTemplate skillTemplate, int skillLevel) {
@Override
public void handleMoveArrived() {
super.handleMoveArrived();
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20987, 1, 100)));
getOwner().queueSkill(20987, 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.aionemu.gameserver.ai.AIName;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;

/**
Expand All @@ -21,7 +19,7 @@ public HM_CalindiFlamelordAI(Npc owner) {
@Override
protected void startHallucinatoryVictoryEvent() {
if (getPosition().getWorldMapInstance().getNpc(731629) == null && getPosition().getWorldMapInstance().getNpc(731630) == null)
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21887, 1, 100)));
getOwner().queueSkill(21887, 1);
}

@Override
Expand All @@ -42,6 +40,6 @@ public void onEndUseSkill(SkillTemplate skillTemplate, int skillLevel) {
@Override
protected void blazeEngraving() {
if (Rnd.chance() < 3 && getPosition().getWorldMapInstance().getNpc(856299) == null)
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21888, 60, 100)));
getOwner().queueSkill(21888, 60);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.aionemu.gameserver.ai.AIName;
import com.aionemu.gameserver.ai.poll.AIQuestion;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.PacketSendUtility;
Expand All @@ -28,7 +26,7 @@ protected void handleSpawned() {
super.handleSpawned();
ThreadPoolManager.getInstance().schedule(() -> AIActions.useSkill(this, 20920), 4000);
ThreadPoolManager.getInstance()
.schedule(() -> getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20984, 1, 100))), 300000);
.schedule(() -> getOwner().queueSkill(20984, 1), 300000);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import com.aionemu.gameserver.ai.poll.AIQuestion;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.item.ItemAttackType;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.services.RespawnService;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
import com.aionemu.gameserver.utils.ThreadPoolManager;
Expand Down Expand Up @@ -70,8 +68,8 @@ public void handleHpPhase(int phaseHpPercent) {
private void offerAtrocityEvent() {
if (!isDead() && hasAggro.get()) {
if (getLifeStats().getHpPercentage() <= 50)
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20921, 1, 100)));
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(calculateAtrocitySkillId(), 1, 100)));
getOwner().queueSkill(20921, 1);
getOwner().queueSkill(calculateAtrocitySkillId(), 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.skill.NpcSkillEntry;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.model.templates.spawns.SpawnTemplate;
import com.aionemu.gameserver.skillengine.SkillEngine;
import com.aionemu.gameserver.skillengine.effect.AbnormalState;
Expand Down Expand Up @@ -195,8 +193,8 @@ protected void handleBuffsRemovedByNpc() {
int chainId = getOwner().getGameStats().getLastSkill().getNextChainId();
NpcSkillEntry entry = getOwner().getSkillList().getNpcSkills().stream().filter(nse -> nse.getChainId() == chainId).findAny().orElse(null);

getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21604, 56, 100, 0, 0)));
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(21603, 56, 100, 0, 0)));
getOwner().queueSkill(21604, 56);
getOwner().queueSkill(21603, 56);
if (entry != null)
getOwner().getQueuedSkills().offer(entry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.aionemu.gameserver.ai.HpPhases;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.model.skill.QueuedNpcSkillEntry;
import com.aionemu.gameserver.model.templates.npcskill.QueuedNpcSkillTemplate;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.skillengine.SkillEngine;
import com.aionemu.gameserver.skillengine.model.SkillTemplate;
Expand Down Expand Up @@ -39,7 +37,7 @@ public Lv3HumanBeritraAI(Npc owner) {

@Override
protected void handleLastSealBlasted() {
getOwner().getQueuedSkills().offer(new QueuedNpcSkillEntry(new QueuedNpcSkillTemplate(20842, 56, 100)));
getOwner().queueSkill(20842, 56);
}

/**
Expand Down
Loading

0 comments on commit 78992bd

Please sign in to comment.