Skip to content

Commit

Permalink
Fix EmpyreanCrucibleInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
w4terbomb committed Jul 26, 2024
1 parent 03b3931 commit 1763269
Show file tree
Hide file tree
Showing 19 changed files with 755 additions and 523 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ protected void handleSpawned() {
@Override
protected void handleMoveArrived() {
super.handleMoveArrived();
if (getOwner().getMoveController().getCurrentStep().isLastStep()) {
if (getOwner().getMoveController().getCurrentStep().isLastStep())
if (!isStart) {
getSpawnTemplate().setWalkerId(null);
WalkManager.stopWalking(this);
AIActions.deleteOwner(this);
} else {
isStart = false;
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.aionemu.gameserver.utils.PacketSendUtility;

/**
* @author xTz
* @author xTz, w4terbomb
*/
@AIName("empadministratorarminos")
public class EmpyreanAdministratorArminosAI extends NpcAI {
Expand All @@ -23,23 +23,33 @@ protected void handleSpawned() {

private void startEvent() {
switch (getNpcId()) {
case 217744 -> {
PacketSendUtility.broadcastMessage(getOwner(), 1500247, 8000);
PacketSendUtility.broadcastMessage(getOwner(), 1500250, 20000);
PacketSendUtility.broadcastMessage(getOwner(), 1500251, 60000);
}
case 217749 -> {
PacketSendUtility.broadcastMessage(getOwner(), 1500252, 8000);
PacketSendUtility.broadcastMessage(getOwner(), 1500253, 16000);
PacketSendUtility.broadcastToMap(getOwner(), 1400982, 25000);
PacketSendUtility.broadcastToMap(getOwner(), 1400988, 27000);
PacketSendUtility.broadcastToMap(getOwner(), 1400989, 29000);
PacketSendUtility.broadcastToMap(getOwner(), 1400990, 31000);
PacketSendUtility.broadcastToMap(getOwner(), 1401013, 93000);
PacketSendUtility.broadcastToMap(getOwner(), 1401014, 113000);
PacketSendUtility.broadcastToMap(getOwner(), 1401015, 118000);
PacketSendUtility.broadcastMessage(getOwner(), 1500255, 118000);
case 217744 -> handleEventForNpcId217744();
case 217749 -> handleEventForNpcId217749();
default -> {
}
}
}
}

private void handleEventForNpcId217744() {
sendBroadcastMessages(new int[] { 1500247, 1500250, 1500251 }, new int[] { 8000, 20000, 60000 });
}

private void handleEventForNpcId217749() {
sendBroadcastMessages(new int[] { 1500252, 1500253, 1500255 }, new int[] { 8000, 16000, 118000 });

broadcastToMap(new int[] { 1400982, 1400988, 1400989, 1400990, 1401013, 1401014, 1401015 },
new int[] { 25000, 27000, 29000, 31000, 93000, 113000, 118000 });
}

private void sendBroadcastMessages(int[] messageIds, int[] delays) {
for (int i = 0; i < messageIds.length; i++) {
PacketSendUtility.broadcastMessage(getOwner(), messageIds[i], delays[i]);
}
}

private void broadcastToMap(int[] mapMessageIds, int[] delays) {
for (int i = 0; i < mapMessageIds.length; i++) {
PacketSendUtility.broadcastToMap(getOwner(), mapMessageIds[i], delays[i]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public EmpyreanArbiterAI(Npc owner) {

@Override
protected void handleDialogStart(Player player) {
if (player.getInventory().getFirstItemByItemId(186000124) != null)
PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 1011));
else
PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), 0));
PacketSendUtility.sendPacket(player, player.getInventory().getFirstItemByItemId(186000124) != null ? new SM_DIALOG_WINDOW(getObjectId(), 1011)
: new SM_DIALOG_WINDOW(getObjectId(), 0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public boolean onDialogSelect(Player player, int dialogActionId, int questId, in
case 205336 -> instanceHandler.onChangeStage(StageType.START_STAGE_9_ROUND_1);
case 205343 -> instanceHandler.onChangeStage(StageType.START_STAGE_10);
case 205337 -> instanceHandler.onChangeStage(StageType.START_STAGE_10_ROUND_1);
case 205344 -> getPosition().getWorldMapInstance().getInstanceHandler().doReward(player);
}
AIActions.deleteOwner(this);
} else if (dialogActionId == SETPRO2 && getNpcId() == 799567) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ai.instance.empyreanCrucible;

import com.aionemu.gameserver.utils.ThreadPoolManager;

import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -9,20 +11,17 @@
import com.aionemu.gameserver.controllers.attack.AggroInfo;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.Npc;
import com.aionemu.gameserver.skillengine.SkillEngine;
import com.aionemu.gameserver.utils.ThreadPoolManager;
import com.aionemu.gameserver.world.WorldPosition;

import ai.AggressiveNpcAI;

/**
* @author Luzien
* @author Luzien, w4terbomb
*/
@AIName("king_consierd")
public class KingConsierdAI extends AggressiveNpcAI implements HpPhases.PhaseHandler {

private final HpPhases hpPhases = new HpPhases(75, 25);
private AtomicBoolean isHome = new AtomicBoolean(true);
private final AtomicBoolean isHome = new AtomicBoolean(true);
private Future<?> eventTask;
private Future<?> skillTask;

Expand Down Expand Up @@ -57,54 +56,58 @@ public void handleAttack(Creature creature) {
hpPhases.tryEnterNextPhase(this);
if (isHome.compareAndSet(true, false)) {
startBloodThirstTask();
ThreadPoolManager.getInstance().schedule(() -> {
SkillEngine.getInstance().getSkill(getOwner(), 19691, 1, getTarget()).useNoAnimationSkill();
ThreadPoolManager.getInstance().schedule(() -> SkillEngine.getInstance().getSkill(getOwner(), 17954, 29, getTarget()).useNoAnimationSkill(),
4000);
}, 2000);
scheduleInitialSkills();
}
}

private void scheduleInitialSkills() {
ThreadPoolManager.getInstance().schedule(() -> {
getOwner().queueSkill(19691, 1, 0);
ThreadPoolManager.getInstance().schedule(() -> getOwner().queueSkill(17954, 29, 0), 4000);
}, 2000);
}

@Override
public void handleHpPhase(int phaseHpPercent) {
switch (phaseHpPercent) {
case 75 -> startSkillTask();
case 25 -> SkillEngine.getInstance().getSkill(getOwner(), 19690, 1, getTarget()).useNoAnimationSkill();
case 25 -> getOwner().queueSkill(19690, 1, 0);
}
}

private void startBloodThirstTask() {
eventTask = ThreadPoolManager.getInstance().schedule(
() -> SkillEngine.getInstance().getSkill(getOwner(), 19624, 10, getOwner()).useNoAnimationSkill(), 180 * 1000); // 3min, need confirm
eventTask = ThreadPoolManager.getInstance().schedule(() -> getOwner().queueSkill(19624, 10, 0), 180000); // 3min, need confirm
}

private void startSkillTask() {
skillTask = ThreadPoolManager.getInstance().scheduleAtFixedRate(() -> {
if (isDead()) {
cancelTasks();
} else {
SkillEngine.getInstance().getSkill(getOwner(), 17951, 29, getTarget()).useNoAnimationSkill();
ThreadPoolManager.getInstance().schedule(() -> {
dropAggro();
if (getLifeStats().getHpPercentage() <= 50) {
WorldPosition p = getPosition();
spawn(282378, p.getX(), p.getY(), p.getZ(), p.getHeading());
spawn(282378, p.getX(), p.getY(), p.getZ(), p.getHeading());
}
ThreadPoolManager.getInstance().schedule(() -> SkillEngine.getInstance().getSkill(getOwner(), 17952, 29, getTarget()).useNoAnimationSkill(),
2000);
}, 3500);
}
}, 0, 25000);
skillTask = ThreadPoolManager.getInstance().scheduleAtFixedRate(this::executeSkillTask, 0, 25000);
}

private void executeSkillTask() {
if (isDead()) {
cancelTasks();
} else {
getOwner().queueSkill(17951, 29, 0);
ThreadPoolManager.getInstance().schedule(() -> {
dropAggro();
if (getLifeStats().getHpPercentage() <= 50)
spawnBabyConsierd();
ThreadPoolManager.getInstance().schedule(() -> getOwner().queueSkill(17952, 29, 0), 2000);
}, 3500);
}
}

private void spawnBabyConsierd() {
var position = getPosition();
spawn(282378, position.getX(), position.getY(), position.getZ(), position.getHeading());
spawn(282378, position.getX(), position.getY(), position.getZ(), position.getHeading());
}

private void dropAggro() {
if (getTarget() instanceof Creature hated) {
if (getAggroList().isHating(hated)) {
AggroInfo ai = getAggroList().getAggroInfo(hated);
ai.setHate(ai.getHate() / 2);
think();
}
if (getTarget() instanceof Creature hated && getAggroList().isHating(hated)) {
AggroInfo ai = getAggroList().getAggroInfo(hated);
ai.setHate(ai.getHate() / 2);
think();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package ai.instance.empyreanCrucible;

import java.util.ArrayList;
import java.util.List;

import com.aionemu.commons.utils.Rnd;
import com.aionemu.gameserver.ai.AIName;
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.gameobjects.player.Player;
import com.aionemu.gameserver.skillengine.SkillEngine;
import com.aionemu.gameserver.utils.PositionUtil;
import com.aionemu.gameserver.model.templates.npcskill.NpcSkillTargetAttribute;
import com.aionemu.gameserver.utils.ThreadPoolManager;
import com.aionemu.gameserver.world.WorldPosition;

import ai.AggressiveNpcAI;

/**
* @author Luzien
* AI for Mage Preceptor in Empyrean Crucible
* @author Luzien, w4terbomb
*/
@AIName("mage_preceptor")
public class MagePreceptorAI extends AggressiveNpcAI implements HpPhases.PhaseHandler {
Expand Down Expand Up @@ -56,54 +51,57 @@ public void handleAttack(Creature creature) {
@Override
public void handleHpPhase(int phaseHpPercent) {
switch (phaseHpPercent) {
case 75 -> SkillEngine.getInstance().getSkill(getOwner(), 19605, 10, getTargetPlayer()).useNoAnimationSkill();
case 50 -> {
SkillEngine.getInstance().getSkill(getOwner(), 19606, 10, getTarget()).useNoAnimationSkill();
ThreadPoolManager.getInstance().schedule(() -> {
if (!isDead()) {
SkillEngine.getInstance().getSkill(getOwner(), 19609, 10, getOwner()).useNoAnimationSkill();
ThreadPoolManager.getInstance().schedule(() -> {
WorldPosition p = getPosition();
spawn(282364, p.getX(), p.getY(), p.getZ(), p.getHeading());
spawn(282363, p.getX(), p.getY(), p.getZ(), p.getHeading());
scheduleSkill(2000);
}, 4500);
}
}, 3000);
}
case 25 -> {
SkillEngine.getInstance().getSkill(getOwner(), 19606, 10, getTarget()).useNoAnimationSkill();
scheduleSkill(3000);
scheduleSkill(9000);
scheduleSkill(15000);
}
case 75 -> queueSkill(19605, NpcSkillTargetAttribute.RANDOM);
case 50 -> handle50PercentPhase();
case 25 -> handle25PercentPhase();
}
}

private void scheduleSkill(int delay) {
ThreadPoolManager.getInstance().schedule(() -> {
if (!isDead())
SkillEngine.getInstance().getSkill(getOwner(), 19605, 10, getTargetPlayer()).useNoAnimationSkill();
}, delay);
private void handle50PercentPhase() {
queueSkill(19609, NpcSkillTargetAttribute.MOST_HATED);
scheduleTask(() -> {
if (!isDead()) {
queueSkill(19609, NpcSkillTargetAttribute.MOST_HATED);
scheduleTask(this::spawnNpcs, 4500);
}
}, 3000);
}

private void handle25PercentPhase() {
queueSkill(19605, NpcSkillTargetAttribute.RANDOM);
scheduleRepeatedSkills(3000, 9000, 15000);
}

private Player getTargetPlayer() {
List<Player> players = new ArrayList<>();
getKnownList().forEachPlayer(player -> {
if (!player.isDead() && PositionUtil.isInRange(player, getOwner(), 37)) {
players.add(player);
}
});
return Rnd.get(players);
private void queueSkill(int skillId, NpcSkillTargetAttribute targetAttribute) {
getOwner().queueSkill(skillId, 10, 0, targetAttribute);
}

private void scheduleTask(Runnable task, int delay) {
ThreadPoolManager.getInstance().schedule(task, delay);
}

private void scheduleRepeatedSkills(int... delays) {
for (int delay : delays) {
scheduleTask(() -> queueSkill(19605, NpcSkillTargetAttribute.RANDOM), delay);
}
}

private void spawnNpcs() {
WorldPosition p = getPosition();
spawn(282364, p.getX(), p.getY(), p.getZ(), p.getHeading());
spawn(282363, p.getX(), p.getY(), p.getZ(), p.getHeading());
scheduleTask(() -> queueSkill(19605, NpcSkillTargetAttribute.RANDOM), 2000);
}

private void despawnNpcs() {
despawnNpc(getPosition().getWorldMapInstance().getNpc(282364));
despawnNpc(getPosition().getWorldMapInstance().getNpc(282363));
despawnNpc(282364);
despawnNpc(282363);
}

private void despawnNpc(Npc npc) {
if (npc != null)
private void despawnNpc(int npcId) {
Npc npc = getPosition().getWorldMapInstance().getNpc(npcId);
if (npc != null) {
npc.getController().delete();
}
}
}
Loading

0 comments on commit 1763269

Please sign in to comment.