@Override public void onBypassFeedback(Player player, String command) { if (!canBypassCheck(player, this)) return; if (command.startsWith("BuyTicket") && state != ACCEPTING_BETS) { player.sendPacket(SystemMsg.MONSTER_RACE_TICKETS_ARE_NO_LONGER_AVAILABLE); command = "Chat 0"; } if (command.startsWith("ShowOdds") && state == ACCEPTING_BETS) { player.sendPacket( SystemMsg.MONSTER_RACE_PAYOUT_INFORMATION_IS_NOT_AVAILABLE_WHILE_TICKETS_ARE_BEING_SOLD); command = "Chat 0"; } if (command.startsWith("BuyTicket")) { int val = Integer.parseInt(command.substring(10)); if (val == 0) { player.setRace(0, 0); player.setRace(1, 0); } if (val == 10 && player.getRace(0) == 0 || val == 20 && player.getRace(0) == 0 && player.getRace(1) == 0) val = 0; showBuyTicket(player, val); } else if (command.equals("ShowOdds")) showOdds(player); else if (command.equals("ShowInfo")) showMonsterInfo(player); else if (command.equals("calculateWin")) { // displayCalculateWinnings(player); } else if (command.equals("viewHistory")) { // displayHistory(player); } else super.onBypassFeedback(player, command); }
@Override public boolean checkStartCondition(Player player) { return (player.getLevel() >= minLevel && player.getLevel() <= maxLevel && player.getRace() == Race.ERTHEIA && player.getQuestState("_10779_LetterFromTheQueen_SeaOfSpores") == null); }
public static Location getRestartLocation(Player player, Location from, RestartType restartType) { Reflection r = player.getReflection(); if (r != ReflectionManager.DEFAULT) if (r.getCoreLoc() != null) return r.getCoreLoc(); else if (r.getReturnLoc() != null) return r.getReturnLoc(); Clan clan = player.getClan(); if (clan != null) { // If teleport to clan hall if (restartType == RestartType.TO_CLANHALL && clan.getHasHideout() != 0) return ResidenceHolder.getInstance() .getResidence(clan.getHasHideout()) .getOwnerRestartPoint(); // If teleport to castle if (restartType == RestartType.TO_CASTLE && clan.getCastle() != 0) return ResidenceHolder.getInstance().getResidence(clan.getCastle()).getOwnerRestartPoint(); // If teleport to fortress if (restartType == RestartType.TO_FORTRESS && clan.getHasFortress() != 0) return ResidenceHolder.getInstance() .getResidence(clan.getHasFortress()) .getOwnerRestartPoint(); } if (player.isPK()) { if (player.getPKRestartPoint() != null) return player.getPKRestartPoint(); } else { if (player.getRestartPoint() != null) return player.getRestartPoint(); } RestartArea ra = MapRegionManager.getInstance().getRegionData(RestartArea.class, from); if (ra != null) { RestartPoint rp = ra.getRestartPoint().get(player.getRace()); Location restartPoint = Rnd.get(rp.getRestartPoints()); Location PKrestartPoint = Rnd.get(rp.getPKrestartPoints()); return player.isPK() ? PKrestartPoint : restartPoint; } _log.warn("Cannot find restart location from coordinates: " + from + "!"); return DEFAULT_RESTART; }
/** * Проверяет возможность носить эту вещь. * * @return null, если вещь носить можно, либо SystemMessage, который можно показать игроку */ public static final IStaticPacket checkIfCanEquip(Player player, ItemInstance item) { // FIXME [G1ta0] черезмерный хардкод, переделать на условия int itemId = item.getItemId(); int targetSlot = item.getTemplate().getBodyPart(); Clan clan = player.getClan(); // TODO: [Bonux] проверить, могут ли носить Камаэли щиты и сигили R ранга. if (!player.getClassId().isOfLevel(ClassLevel.AWAKED) && item.getGrade() != ItemGrade.R && item.getGrade() != ItemGrade.R95 && item.getGrade() != ItemGrade.R99) { // камаэли и хеви/робы/щиты/сигилы if (player.getRace() == Race.KAMAEL && (item.getItemType() == ArmorType.HEAVY || item.getItemType() == ArmorType.MAGIC || item.getItemType() == ArmorType.SIGIL || item.getItemType() == WeaponType.NONE)) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; // не камаэли и рапиры/арбалеты/древние мечи if (player.getRace() != Race.KAMAEL && (item.getItemType() == WeaponType.CROSSBOW || item.getItemType() == WeaponType.RAPIER || item.getItemType() == WeaponType.ANCIENTSWORD)) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; } if (itemId >= 7850 && itemId <= 7859 && player.getLvlJoinedAcademy() == 0) // Clan Oath Armor return SystemMsg.THIS_ITEM_CAN_ONLY_BE_WORN_BY_A_MEMBER_OF_THE_CLAN_ACADEMY; if (isClanApellaItem(itemId) && player.getPledgeRank().ordinal() < PledgeRank.WISEMAN.ordinal()) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; if (item.getItemType() == WeaponType.DUALDAGGER && player.getSkillLevel(923) < 1 && player.getSkillLevel(10502) < 1) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; // Корона лидера клана, владеющего замком if (itemId == 6841 && (clan == null || !player.isClanLeader() || clan.getCastle() == 0)) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; // Нельзя одевать оружие, если уже одето проклятое оружие. Проверка двумя способами, для // надежности. if (targetSlot == ItemTemplate.SLOT_LR_HAND || targetSlot == ItemTemplate.SLOT_L_HAND || targetSlot == ItemTemplate.SLOT_R_HAND) { if (itemId != player.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) && CursedWeaponsManager.getInstance() .isCursed(player.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND))) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; if (player.isCursedWeaponEquipped() && itemId != player.getCursedWeaponEquippedId()) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; } // Плащи if (item.getTemplate().isCloak()) { // Can be worn by Knights or higher ranks who own castle if (item.getName().contains("Knight") && (player.getPledgeRank().ordinal() < PledgeRank.KNIGHT.ordinal() || player.getCastle() == null)) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; // Плащи для камаэлей if (item.getName().contains("Kamael") && player.getRace() != Race.KAMAEL) return SystemMsg.YOU_DO_NOT_MEET_THE_REQUIRED_CONDITION_TO_EQUIP_THAT_ITEM; // Плащи можно носить только с S80 или S84 сетом if (!player.getOpenCloak()) return SystemMsg.THE_CLOAK_CANNOT_BE_EQUIPPED_BECAUSE_YOUR_ARMOR_SET_IS_NOT_COMPLETE; } if (targetSlot == ItemTemplate.SLOT_DECO) { int count = player.getTalismanCount(); if (count <= 0) return new SystemMessage2( SystemMsg.YOU_CANNOT_WEAR_S1_BECAUSE_YOU_ARE_NOT_WEARING_A_BRACELET) .addItemName(itemId); ItemInstance deco; for (int slot = Inventory.PAPERDOLL_DECO1; slot <= Inventory.PAPERDOLL_DECO6; slot++) { deco = player.getInventory().getPaperdollItem(slot); if (deco != null) { if (deco == item) return null; // талисман уже одет и количество слотов больше нуля // Проверяем на количество слотов и одинаковые талисманы if (--count <= 0 || deco.getItemId() == itemId) return new SystemMessage2( SystemMsg.YOU_CANNOT_EQUIP_S1_BECAUSE_YOU_DO_NOT_HAVE_ANY_AVAILABLE_SLOTS) .addItemName(itemId); } } } return null; }
@Override public String onEvent(String event, QuestState st, NpcInstance npc) { Player player = st.getPlayer(); if (player == null) return null; String htmltext = event; System.out.println("quest event " + event.toString()); int classId = player.getClassId().getId(); if (event.startsWith("UC")) { if (checkStartCondition(player)) { Quest q = QuestManager.getQuest(10779); player.processQuestEvent(q.getName(), "start_quest", null); } htmltext = ""; } if (event.equalsIgnoreCase("start_quest") || event.equalsIgnoreCase("start_quest_7s")) { st.setCond(1); st.setState(STARTED); alertLetterReceived(st); st.showQuestHTML(st.getQuest(), "queen_letter.htm"); htmltext = ""; } if (event.equalsIgnoreCase("start_quest_delay")) { st.startQuestTimer("start_quest_7s", 7000); // only start quest after 7s to avoid crash on enterworld htmltext = ""; } if (event.equalsIgnoreCase("Quest _10779_LetterFromTheQueen_SeaOfSpores to_oren")) { // System.out.println("in Quest _10779_LetterFromTheQueen_SeaOfSpores to_dion"); if (st.getCond() == 1) { if (getItemCountById(player, SOE_OREN) > 0) { st.takeItems(SOE_OREN, 1); player.teleToLocation(83633, 53064, -1456); player.sendPacket(TutorialCloseHtmlPacket.STATIC); } else { player.sendMessage("Không tìm thấy Scroll of Escape: Town of Oren"); } } htmltext = ""; } // System.out.println("out " + event); if (event.equalsIgnoreCase("Quest _10779_LetterFromTheQueen_SeaOfSpores close_window")) { // System.out.println("in Quest _10779_LetterFromTheQueen_SeaOfSpores close_window"); player.sendPacket(TutorialCloseHtmlPacket.STATIC); htmltext = ""; } // Question mark clicked if (event.startsWith("QM")) { int MarkId = Integer.valueOf(event.substring(2)); // System.out.println("Mark id " + MarkId); if (MarkId == 10779) { if (player.getRace() == Race.ERTHEIA) st.showQuestHTML(st.getQuest(), "queen_letter.htm"); htmltext = ""; } } if (event.equalsIgnoreCase("30191-3.htm")) { st.giveItems(SOE_SEA_OF_SPORES, 1); st.setCond(2); htmltext = "30191-3.htm"; } if (event.equalsIgnoreCase("33845-2.htm")) { st.giveItems(STEEL_DOOR_COIN, 37, true); st.giveItems(SCROLL_EWB, 3, true); st.addExpAndSp(635250, 152); st.setState(COMPLETED); st.exitCurrentQuest(false); st.playSound(SOUND_FINISH); st.getPlayer() .sendPacket( new ExShowScreenMessage( NEXT_LETTER_STRING, 7000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, true)); htmltext = "33845-2.htm"; } if (htmltext.isEmpty()) return null; else return htmltext; }
public void showBuyTicket(Player player, int val) { if (state != ACCEPTING_BETS) return; int npcId = getNpcId(); String filename, search, replace; NpcHtmlMessage html = new NpcHtmlMessage(player, this); if (val < 10) { filename = getHtmlPath(npcId, 2, player); html.setFile(filename); for (int i = 0; i < 8; i++) { int n = i + 1; search = "Mob" + n; html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().name); } search = "No1"; if (val == 0) html.replace(search, ""); else { html.replace(search, "" + val); player.setRace(0, val); } } else if (val < 20) { if (player.getRace(0) == 0) return; filename = getHtmlPath(npcId, 3, player); html.setFile(filename); html.replace("0place", "" + player.getRace(0)); search = "Mob1"; replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name; html.replace(search, replace); search = "0adena"; if (val == 10) html.replace(search, ""); else { html.replace(search, "" + cost[val - 11]); player.setRace(1, val - 10); } } else if (val == 20) { if (player.getRace(0) == 0 || player.getRace(1) == 0) return; filename = getHtmlPath(npcId, 4, player); html.setFile(filename); html.replace("0place", "" + player.getRace(0)); search = "Mob1"; replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name; html.replace(search, replace); search = "0adena"; int price = cost[player.getRace(1) - 1]; html.replace(search, "" + price); search = "0tax"; int tax = 0; html.replace(search, "" + tax); search = "0total"; int total = price + tax; html.replace(search, "" + total); } else { if (player.getRace(0) == 0 || player.getRace(1) == 0) return; if (player.getAdena() < cost[player.getRace(1) - 1]) { player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA); return; } int ticket = player.getRace(0); int priceId = player.getRace(1); player.setRace(0, 0); player.setRace(1, 0); player.reduceAdena(cost[priceId - 1], true); SystemMessage sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2); sm.addNumber(_raceNumber); sm.addItemName(4443); player.sendPacket(sm); ItemInstance item = ItemFunctions.createItem(4443); item.setEnchantLevel(_raceNumber); item.setCustomType1(ticket); item.setCustomType2(cost[priceId - 1] / 100); player.getInventory().addItem(item); return; } html.replace("1race", String.valueOf(_raceNumber)); player.sendPacket(html); player.sendActionFailed(); }