@Override public void onDie(Creature lastAttacker) { super.onDie(lastAttacker); Npc owner = getOwner(); addTask(TaskId.DECAY, RespawnService.scheduleDecayTask(this.getOwner())); scheduleRespawn(); PacketSendUtility.broadcastPacket( owner, new SM_EMOTION( owner, EmotionType.DIE, 0, lastAttacker == null ? 0 : lastAttacker.getObjectId())); // Monster Controller overrides this method. this.doReward(); Npc npc = getOwner(); List<QuestDrop> drops = QuestEngine.getInstance().getQuestDrop(npc.getNpcId()); if (drops.size() > 0) { DropService.getInstance() .registerDrop(getOwner(), (Player) lastAttacker, lastAttacker.getLevel()); } owner.getAi().handleEvent(Event.DIED); // deselect target at the end owner.setTarget(null); PacketSendUtility.broadcastPacket(owner, new SM_LOOKATOBJECT(owner)); }
public void cancelRegisteredItem(Player player, int brokerItemId) { if (player.getInventory().isFull()) { PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(901298)); return; } int playerId = player.getObjectId(); Map<Integer, BrokerItem> brokerItems = getRaceBrokerItems(player.getCommonData().getRace()); BrokerItem brokerItem = brokerItems.get(brokerItemId); if (brokerItem == null) return; if (playerId != brokerItem.getSellerId()) { Logger.getLogger(this.getClass()) .info( "[AUDIT]Player: " + player.getName() + " is trying to steal: " + brokerItem.getItemId() + " => Hacking!"); return; } synchronized (brokerItem) { if (brokerItem != null) { Item item = player.getInventory().putToBag(brokerItem.getItem()); PacketSendUtility.sendPacket(player, new SM_INVENTORY_UPDATE(item, true)); PacketSendUtility.sendPacket(player, new SM_BROKER_ITEMS(brokerItemId, 4)); brokerItem.setPersistentState(PersistentState.DELETED); saveManager.add(new BrokerOpSaveTask(brokerItem)); brokerItems.remove(brokerItemId); } showRegisteredItems(player); } }
/** {@inheritDoc} */ @Override public void executeCommand(Player admin, String[] params) { if (admin.getAccessLevel() < AdminConfig.COMMAND_SENDFAKESERVERPACKET) { PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command"); return; } if (params.length < 3) { PacketSendUtility.sendMessage(admin, "Incorrent number of params in //fsc command"); return; } int id = Integer.decode(params[0]); String format = ""; if (params.length > 1) format = params[1]; SM_CUSTOM_PACKET packet = new SM_CUSTOM_PACKET(id); int i = 0; for (char c : format.toCharArray()) { packet.addElement(PacketElementType.getByCode(c), params[i + 2]); i++; } PacketSendUtility.sendPacket(admin, packet); }
@Override public boolean onDialogEvent(final QuestCookie env) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); final QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) { if (targetId == 205130) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1011); else return defaultQuestStartDialog(env); } } else if (qs.getStatus() == QuestStatus.START) { switch (targetId) { case 730107: { if (qs.getQuestVarById(0) == 0 && env.getDialogId() == -1) { final int targetObjectId = env.getVisibleObject().getObjectId(); PacketSendUtility.sendPacket( player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 1)); PacketSendUtility.broadcastPacket( player, new SM_EMOTION(player, EmotionType.NEUTRALMODE2, 0, targetObjectId), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { if (!player.isTargeting(targetObjectId)) return; PacketSendUtility.sendPacket( player, new SM_USE_OBJECT(player.getObjectId(), targetObjectId, 3000, 0)); PacketSendUtility.broadcastPacket( player, new SM_EMOTION(player, EmotionType.START_LOOT, 0, targetObjectId), true); qs.setQuestVarById(0, 1); updateQuestStatus(env); } }, 3000); } } case 205130: { if (qs.getQuestVarById(0) == 1) { if (env.getDialogId() == 26) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 1009) { qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return defaultQuestEndDialog(env); } else return defaultQuestEndDialog(env); } } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 205130) return defaultQuestEndDialog(env); } return false; }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); int targetId = 0; final QuestState qs = player.getQuestStateList().getQuestState(questId); if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (env.getDialogId() == 1002) { QuestService.startQuest(env, QuestStatus.START); PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0)); return true; } else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0)); } if (qs == null) return false; int var = qs.getQuestVarById(0); if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 798316) { if (env.getDialogId() == -1) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5); else return defaultQuestEndDialog(env); } } else if (qs.getStatus() != QuestStatus.START) { return false; } if (targetId == 278591) { switch (env.getDialogId()) { case 25: if (var == 0) return sendQuestDialog(env, 1352); case 10000: if (var == 0) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } return false; } } else if (targetId == 278624) { switch (env.getDialogId()) { case 25: if (var == 1) return sendQuestDialog(env, 1693); case 10001: if (var == 1) { qs.setQuestVarById(0, var + 1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } return false; } } return false; }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) return false; final int var = qs.getQuestVarById(0); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (qs.getStatus() == QuestStatus.START) { switch (targetId) { case 203665: switch (env.getDialogId()) { case 25: if (var == 0) return sendQuestDialog(env, 1011); break; case 10000: if (var == 0) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } break; case 203668: switch (env.getDialogId()) { case 25: if (var == 1) return sendQuestDialog(env, 1352); else if (var == 5) return sendQuestDialog(env, 1693); else if (var == 6) return sendQuestDialog(env, 2034); break; case 10001: case 10002: if (var == 1 || var == 5) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } case 33: if (var == 6) { if (QuestService.collectItemCheck(env, true)) { qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return sendQuestDialog(env, 5); } else return sendQuestDialog(env, 2120); } } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 203668) return defaultQuestEndDialog(env); } return false; }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); final QuestState qs = player.getQuestStateList().getQuestState(questId); if (targetId == 203550) // Munin { if (qs == null || qs.getStatus() == QuestStatus.START) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1011); else if (env.getDialogId() == 10000) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } else return defaultQuestStartDialog(env); } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) // Reward { if (env.getDialogId() == -1) return sendQuestDialog(env, 10002); else if (env.getDialogId() == 1009) defaultQuestRemoveItem(env, 182207085, 1); return defaultQuestEndDialog(env); } } else if (targetId == 203546) // Skuld { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1352); else if (env.getDialogId() == 10001) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } else return defaultQuestStartDialog(env); } } else if (targetId == 279034) // Baoninerk { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 2) { switch (env.getDialogId()) { case 26: return sendQuestDialog(env, 1693); case 34: return defaultQuestItemCheck(env, 2, 0, true, 10000, 10001, 182207085, 1); } } } else if (qs != null && qs.getStatus() == QuestStatus.START) { switch (targetId) { case 700509: // Shining Box case 700510: // Balaur Supply Box { if (qs.getQuestVarById(0) == 2 && env.getDialogId() == -1) return true; } } } return false; }
@Override protected void onInteractionAbort() { PacketSendUtility.sendPacket( requestor, new SM_CRAFT_UPDATE(recipeTemplate.getSkillid(), itemTemplate, 0, 0, 4)); PacketSendUtility.broadcastPacket( requestor, new SM_CRAFT_ANIMATION(requestor.getObjectId(), responder.getObjectId(), 0, 2), true); }
@Override protected void onComboStart() { PacketSendUtility.sendPacket( requestor, new SM_CRAFT_UPDATE(recipeTemplate.getSkillid(), itemTemplate, 75, 100, 3)); PacketSendUtility.broadcastPacket( requestor, new SM_CRAFT_ANIMATION( requestor.getObjectId(), responder.getObjectId(), recipeTemplate.getSkillid(), 5), true); }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (targetId == 203590) { if (env.getDialogId() == 25) return sendQuestDialog(env, 1011); else if (env.getDialogId() == 1002) { if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182203257, 1)))) return defaultQuestStartDialog(env); return true; } else return defaultQuestStartDialog(env); } } if (qs == null) return false; int var = qs.getQuestVarById(0); if (qs.getStatus() == QuestStatus.START || qs.getStatus() == QuestStatus.REWARD) { if (targetId == 203591) { if (var == 0) { if (env.getDialogId() == 25) return sendQuestDialog(env, 1352); else if (env.getDialogId() == 10000) { qs.setQuestVar(1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0)); return true; } } if (var == 2 || var == 3) { if (env.getDialogId() == 25) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 1009) { qs.setQuestVar(3); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return defaultQuestEndDialog(env); } else return defaultQuestEndDialog(env); } } else if (targetId == 203557) { if (var == 1) { if (env.getDialogId() == 25) return sendQuestDialog(env, 1693); else if (env.getDialogId() == 10001) { qs.setQuestVar(2); updateQuestStatus(env); player.getInventory().removeFromBagByItemId(182203257, 1); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0)); return true; } } } } return false; }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (targetId == 204193) { if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1011); else if (env.getDialogId() == 1002) { if (ItemService.addItems(player, Collections.singletonList(new QuestItems(182207006, 1)))) return defaultQuestStartDialog(env); return true; } else return defaultQuestStartDialog(env); } } else if (targetId == 204170) { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1352); else if (env.getDialogId() == 10000) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0)); return true; } } } else if (targetId == 798065) { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) { if (env.getDialogId() == 26) return sendQuestDialog(env, 1693); else if (env.getDialogId() == 10001) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0)); return true; } } } else if (targetId == 204173) { if (qs != null) { if (env.getDialogId() == 26 && qs.getStatus() == QuestStatus.START) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 1009) { qs.setQuestVar(3); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return defaultQuestEndDialog(env); } else return defaultQuestEndDialog(env); } } return false; }
@Override public void executeCommand(Player admin, String[] params) { if (admin.getAccessLevel() < AdminConfig.COMMAND_BAN) { PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command!"); return; } if (params == null || params.length < 1) { PacketSendUtility.sendMessage(admin, "Syntax: //unbanip <mask>"); return; } LoginServer.getInstance().sendBanPacket((byte) 2, 0, params[0], -1, admin.getObjectId()); }
@Override public boolean onDialogEvent(QuestEnv env) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (targetId == 798126) { if (qs == null || qs.getStatus() == QuestStatus.NONE) { if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1011); else return sendQuestStartDialog(env); } } else if (targetId == 203940) { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) { if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1352); else if (env.getDialog() == QuestDialog.STEP_TO_1) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } else return sendQuestStartDialog(env); } } else if (targetId == 203944) { if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 1) { if (env.getDialog() == QuestDialog.START_DIALOG) return sendQuestDialog(env, 1352); else if (env.getDialog() == QuestDialog.STEP_TO_1) { qs.setQuestVarById(0, qs.getQuestVarById(0) + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 1693)); return true; } else return sendQuestStartDialog(env); } } else if (targetId == 798127) { if (qs != null) { if (env.getDialog() == QuestDialog.START_DIALOG && qs.getStatus() == QuestStatus.START) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 1009 && qs.getStatus() != QuestStatus.COMPLETE && qs.getStatus() != QuestStatus.NONE) { qs.setQuestVar(3); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return sendQuestEndDialog(env); } else return sendQuestEndDialog(env); } } return false; }
@Override public boolean onItemUseEvent(QuestCookie env, Item item) { final Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); switch (id) { case 182207006: if (qs == null || qs.getStatus() != QuestStatus.START) return false; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 1000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); } }, 1000); return true; } return false; }
public static boolean questTimerStart(QuestCookie env, int timeInSeconds) { final Player player = env.getPlayer(); final int id = env.getQuestId(); if (!player.getQuestTimerOn()) { // Schedule Action When Timer Finishes Future<?> task = ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { player.setQuestTimerOn(false); QuestEngine.getInstance() .onQuestTimerEnd(new QuestCookie(null, player, 0, 0)); if (QuestEngine.getInstance().deleteQuest(player, id)) PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(id)); player.getController().updateNearbyQuests(); } }, timeInSeconds * 1000); player.setQuestTimerOn(true); player.getController().addTask(TaskId.QUEST_TIMER, task); PacketSendUtility.sendPacket(player, new SM_QUEST_ACCEPTED(4, id, timeInSeconds)); return true; } return false; }
@Override public HandlerResult onItemUseEvent(final QuestCookie env, Item item) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); if (id != 182204304 || qs == null) return HandlerResult.UNKNOWN; if (qs.getQuestVarById(0) != 15 || id != 182204304) return HandlerResult.FAILED; if (!ZoneService.getInstance().isInsideZone(player, ZoneName.BERITRAS_WEAPON_220040000)) return HandlerResult.FAILED; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); player.getInventory().removeFromBagByItemId(182204304, 1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); } }, 3000); return HandlerResult.SUCCESS; }
@Override public void attackTarget(Creature target) { Npc npc = getOwner(); /** Check all prerequisites */ if (npc == null || npc.getLifeStats().isAlreadyDead() || !npc.isSpawned()) return; if (!npc.canAttack()) return; AI<?> ai = npc.getAi(); NpcGameStats gameStats = npc.getGameStats(); if (target == null || target.getLifeStats().isAlreadyDead()) { ai.handleEvent(Event.MOST_HATED_CHANGED); return; } /** notify attack observers */ super.attackTarget(target); /** Calculate and apply damage */ List<AttackResult> attackList = AttackUtil.calculateAttackResult(npc, target); int damage = 0; for (AttackResult result : attackList) { damage += result.getDamage(); } int attackType = 0; // TODO investigate attack types (0 or 1) PacketSendUtility.broadcastPacket( npc, new SM_ATTACK(npc, target, gameStats.getAttackCounter(), 274, attackType, attackList)); target.getController().onAttack(npc, damage, true); gameStats.increaseAttackCounter(); }
/** * Calculates the fall damage * * @param player * @param distance * @return True if the player is forced to his bind location. */ public static boolean calculateFallDamage(Player player, float distance) { if (player.isInvul()) { return false; } if (distance >= FallDamageConfig.MAXIMUM_DISTANCE_DAMAGE) { player.getController().onStopMove(); player.getFlyController().onStopGliding(); player.getController().onDie(player); if (player.getKisk() != null) player.getReviveController().kiskRevive(); else player.getReviveController().bindRevive(); return true; } else if (distance >= FallDamageConfig.MINIMUM_DISTANCE_DAMAGE) { float dmgPerMeter = player.getLifeStats().getMaxHp() * FallDamageConfig.FALL_DAMAGE_PERCENTAGE / 100f; int damage = (int) (distance * dmgPerMeter); player.getLifeStats().reduceHp(damage, player); PacketSendUtility.sendPacket( player, new SM_ATTACK_STATUS(player, SM_ATTACK_STATUS.TYPE.FALL_DAMAGE, -damage)); } return false; }
@Override public boolean onDialogEvent(QuestEnv env) { final Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (targetId == 0) { if (env.getDialogId() == 1002) { QuestService.startQuest(env); PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0)); return true; } } else if (targetId == 278055) { if (qs != null) { if (env.getDialog() == QuestDialog.START_DIALOG && qs.getStatus() == QuestStatus.START) { return sendQuestDialog(env, 2375); } else if (env.getDialogId() == 1009 && qs.getStatus() != QuestStatus.COMPLETE && qs.getStatus() != QuestStatus.NONE) { removeQuestItem(env, 182207044, 1); qs.setQuestVar(1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return sendQuestEndDialog(env); } else return sendQuestEndDialog(env); } } return false; }
@Override public boolean onItemUseEvent(final QuestCookie env, Item item) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); if (id != 182203019) return false; if (!ZoneService.getInstance().isInsideZone(player, ZoneName.Q2016)) return false; if (qs == null) return false; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); player.getInventory().removeFromBagByObjectId(itemObjId, 1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); } }, 3000); return true; }
@Override public boolean onDialogEvent(QuestEnv env) { Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); if (qs == null) return false; int var = qs.getQuestVarById(0); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (qs.getStatus() == QuestStatus.START) { if (targetId == 203129) { switch (env.getDialog()) { case START_DIALOG: if (var == 0) return sendQuestDialog(env, 1011); case STEP_TO_1: case STEP_TO_2: if (var == 0) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } } } else if (qs.getStatus() == QuestStatus.REWARD) { if (targetId == 203129) return sendQuestEndDialog(env); } return false; }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); QuestState qs = player.getQuestStateList().getQuestState(questId); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); if (targetId == 0) { if (env.getDialogId() == 1002) { QuestService.startQuest(env, QuestStatus.START); PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(0, 0)); return true; } } else if (targetId == 799939) // Emma { if (qs != null) { if (env.getDialogId() == 26 && qs.getStatus() == QuestStatus.START) { return sendQuestDialog(env, 2375); } else if (env.getDialogId() == 1009) { qs.setQuestVar(1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); return defaultQuestEndDialog(env); } else return defaultQuestEndDialog(env); } } return false; }
@Override public void executeCommand(Player admin, String[] params) { if (admin.getAccessLevel() < AdminConfig.COMMAND_RELOADSPAWNS) { PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command"); return; } // despawn all World.getInstance() .doOnAllObjects( new Executor<AionObject>() { @Override public boolean run(AionObject obj) { if (obj instanceof Npc || obj instanceof Gatherable || obj instanceof StaticObject) { ((VisibleObject) obj).getController().delete(); } return true; } }); // spawn all; SpawnEngine.getInstance().spawnAll(); }
@Override public void updateStatInfo() { Player master = owner.getMaster(); if (master != null) { PacketSendUtility.sendPacket(master, new SM_SUMMON_UPDATE(owner)); } }
@Override public HandlerResult onItemUseEvent(final QuestEnv env, Item item) { final Player player = env.getPlayer(); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); if (id != 182207044) return HandlerResult.UNKNOWN; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); sendQuestDialog(env, 4); } }, 3000); return HandlerResult.SUCCESS; }
@Override public boolean onDie(Player player, Creature lastAttacker) { Summon summon = player.getSummon(); if (summon != null) { summon.getController().release(UnsummonType.UNSPECIFIED); } PacketSendUtility.broadcastPacket( player, new SM_EMOTION( player, EmotionType.DIE, 0, lastAttacker == null ? 0 : lastAttacker.getObjectId()), true); PacketSendUtility.sendPacket(player, new SM_DIE(false, false, 0, 8)); return true; }
@Override public HandlerResult onItemUseEvent(final QuestCookie env, Item item) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); if (id != 182201783 || qs == null) return HandlerResult.UNKNOWN; int var = qs.getQuestVars().getQuestVars(); if (var != 0 || qs.getStatus() != QuestStatus.START) return HandlerResult.FAILED; if (MathUtil.getDistance( 1677, 2520, 100, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()) > 5) return HandlerResult.FAILED; int itemId1 = 110100150; int itemId2 = 113100144; boolean CheckitemId1 = false; boolean CheckitemId2 = false; List<Item> items1 = player.getEquipment().getEquippedItemsByItemId(itemId1); for (@SuppressWarnings("unused") Item ListeCheckitemId1 : items1) { CheckitemId1 = true; } List<Item> items2 = player.getEquipment().getEquippedItemsByItemId(itemId2); for (@SuppressWarnings("unused") Item ListeCheckitemId2 : items2) { CheckitemId2 = true; } if (!CheckitemId1 && CheckitemId2 || CheckitemId1 && !CheckitemId2 || !CheckitemId1 && !CheckitemId2) return HandlerResult.FAILED; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); player.getInventory().removeFromBagByObjectId(itemObjId, 1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); } }, 3000); return HandlerResult.SUCCESS; }
@Override public boolean onDialogEvent(QuestCookie env) { if (env.getPlayer().getTribe().equals("PC_DARK")) { final Player player = env.getPlayer(); int targetId = 0; if (env.getVisibleObject() instanceof Npc) targetId = ((Npc) env.getVisibleObject()).getNpcId(); QuestTemplate template = DataManager.QUEST_DATA.getQuestById(questId); QuestState qs = player.getQuestStateList().getQuestState(questId); if (targetId == 730330) { PlayerClass playerClass = player.getCommonData().getPlayerClass(); if (playerClass == PlayerClass.RANGER || playerClass == PlayerClass.ASSASSIN || playerClass == PlayerClass.MAGE || playerClass == PlayerClass.PRIEST || playerClass == PlayerClass.GLADIATOR || playerClass == PlayerClass.WARRIOR || playerClass == PlayerClass.SCOUT) { if (qs == null || qs.getStatus() == QuestStatus.NONE || (qs.getStatus() == QuestStatus.COMPLETE && (qs.getCompleteCount() <= template.getMaxRepeatCount()))) { if (env.getDialogId() == -1) return sendQuestDialog(env, 1011); else return defaultQuestStartDialog(env); } else if (qs != null && qs.getStatus() == QuestStatus.START && qs.getQuestVarById(0) == 0) { if (env.getDialogId() == -1) return sendQuestDialog(env, 2375); else if (env.getDialogId() == 34) { if (player.getInventory().getItemCountByItemId(185000102) >= 1) { player.getInventory().removeFromBagByItemId(185000102, 1); qs.setStatus(QuestStatus.REWARD); qs.setQuestVar(1); qs.setCompliteCount(0); updateQuestStatus(env); return sendQuestDialog(env, 5); } else return sendQuestDialog(env, 2716); } } else if (qs != null && qs.getStatus() == QuestStatus.REWARD) { int var = qs.getQuestVarById(0); switch (env.getDialogId()) { case -1: if (var == 1) return sendQuestDialog(env, 5); case 17: QuestService.questFinish(env, qs.getQuestVars().getQuestVars() - 1); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } } return false; } return false; } else { return false; } }
@Override public void executeCommand(Player admin, String[] params) { int time = 0; // Default: infinity String targetName = "direct_type"; String macAddress = null; int targetId = 0; if (admin.getAccessLevel() < AdminConfig.COMMAND_BANMAC) { PacketSendUtility.sendMessage( admin, LanguageHandler.translate(CustomMessageId.COMMAND_NOT_ENOUGH_RIGHTS)); return; } VisibleObject target = admin.getTarget(); if (target != null && target instanceof Player) { if (target.getObjectId() == admin.getObjectId()) { PacketSendUtility.sendMessage(admin, "omg, disselect yourself please."); return; } Player targetpl = (Player) target; macAddress = targetpl.getClientConnection().getMacAddress(); targetName = targetpl.getName(); targetId = targetpl.getObjectId(); targetpl.getClientConnection().closeNow(); } else { PacketSendUtility.sendMessage(admin, "Please select target first!!"); return; } if (params.length > 0) { try { time = Integer.parseInt(params[0]); } catch (NumberFormatException e) { PacketSendUtility.sendMessage(admin, "Syntax: //banmac [time in minutes]"); return; } } BannedMacManager.getInstance() .banAddress( macAddress, targetId, System.currentTimeMillis() + time * 60000, "author=" + admin.getName() + ", " + admin.getObjectId() + "; target=" + targetName); }
@Override public void startEffect(Effect effect) { final Creature effected = effect.getEffected(); effected.getController().cancelCurrentSkill(); effect.setAbnormal(EffectId.STUMBLE.getEffectId()); effected.getEffectController().setAbnormal(EffectId.STUMBLE.getEffectId()); PacketSendUtility.broadcastPacketAndReceive( effected, new SM_FORCED_MOVE(effect.getEffector(), effected)); }