@Override public boolean useUserCommand(int id, Player activeChar) { if (id != COMMAND_IDS[0]) return false; GameObject objectTarget = Config.OLYMPIAD_OLDSTYLE_STAT ? activeChar : activeChar.getTarget(); if (objectTarget == null || !objectTarget.isPlayer() || !objectTarget.getPlayer().isNoble()) { activeChar.sendPacket(SystemMsg.THIS_COMMAND_CAN_ONLY_BE_USED_BY_A_NOBLESSE); return true; } Player playerTarget = objectTarget.getPlayer(); SystemMessage2 sm = new SystemMessage2( SystemMsg .FOR_THE_CURRENT_GRAND_OLYMPIAD_YOU_HAVE_PARTICIPATED_IN_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_CURRENTLY_HAVE_S4_OLYMPIAD_POINTS); sm.addInteger(Olympiad.getCompetitionDone(playerTarget.getObjectId())); sm.addInteger(Olympiad.getCompetitionWin(playerTarget.getObjectId())); sm.addInteger(Olympiad.getCompetitionLoose(playerTarget.getObjectId())); sm.addInteger(Olympiad.getNoblePoints(playerTarget.getObjectId())); activeChar.sendPacket(sm); int[] ar = Olympiad.getWeekGameCounts(playerTarget.getObjectId()); sm = new SystemMessage2( SystemMsg .YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTICIPATE_IN_THIS_WEEK_S2_1_VS_1_CLASS_MATCHES_S3_1_VS_1_MATCHES__S4_3_VS_3_TEAM_MATCHES); sm.addInteger(ar[0]); sm.addInteger(ar[1]); sm.addInteger(ar[2]); sm.addInteger(0 /*ar[3]*/); activeChar.sendPacket(sm); return true; }
@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); }
public static void teleToLocation(Player player, Location loc, Reflection ref) { if (player.isTeleporting() || player.isDeleted()) return; player.setIsTeleporting(true); player.setTarget(null); player.stopMove(); if (player.isInBoat()) player.setBoat(null); player.breakFakeDeath(); player.sendPacket(new TeleportToLocation(player, loc)); player.decayMe(); player.setLoc(loc); if (ref == null) player.setReflection(ReflectionManager.DEFAULT); // Нужно при телепорте с более высокой точки на более низкую, иначе наносится вред от "падения" player.setLastClientPosition(null); player.setLastServerPosition(null); player.sendPacket(new ExTeleportToLocationActivate(player, loc)); }
@Override public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) { Player player; if (playable.isPlayer()) player = (Player) playable; else if (playable.isPet()) player = playable.getPlayer(); else return false; GameObject target = player.getTarget(); if (target == null || !target.isMonster()) { player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET); return false; } MonsterInstance monster = (MonsterInstance) player.getTarget(); if (!monster.isDead()) { player.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET); return false; } Skill skill = SkillTable.getInstance().getInfo(HARVESTER_SKILL_ID, 1); if (skill != null && skill.checkCondition(player, monster, false, false, true)) { player.getAI().Cast(skill, monster); return true; } return false; }
@Override protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar == null) return; activeChar.sendPacket(new ExResponseCommissionItemList(activeChar)); }
@Override public boolean checkCondition( final Creature activeChar, final Creature target, boolean forceUse, boolean dontMove, boolean first) { if (!activeChar.isPlayer()) return false; Player player = (Player) activeChar; if (_charges == 10 && player.getSkillLevel(10301) != -1) // maybe something more practical? right now overrides any level of force before // that. _charges = 15; // Камушки можно юзать даже если заряд > 7, остальное только если заряд < уровень скила if (getPower() <= 0 && getId() != 2165 && player.getIncreasedForce() >= _charges) { activeChar.sendPacket(SystemMsg.YOUR_FORCE_HAS_REACHED_MAXIMUM_CAPACITY_); return false; } else if (getId() == 2165) player.sendPacket(new MagicSkillUse(player, player, 2165, 1, 0, 0)); return super.checkCondition(activeChar, target, forceUse, dontMove, first); }
private void cleanUp() { startCollapseTimer(15 * 60 * 1000L); for (Player p : getPlayers()) p.sendPacket( new SystemMessage(SystemMessage.THIS_DUNGEON_WILL_EXPIRE_IN_S1_MINUTES).addNumber(15)); for (NpcInstance n : getNpcs()) n.deleteMe(); }
@Override protected void runImpl() throws Exception { Player player = getClient().getActiveChar(); if (player == null) return; player.sendPacket(new ExReceiveShowPostFriend(player)); }
@Override protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar == null) return; CategoryType cat = CategoryType.getCategoryById(_section, _subSection); if (cat == null) { _log.warn( "RequestWorldStatistics: Not found category for section: " + _section + " subsection: " + _subSection); return; } List<CharacterStatistic> generalStatisticList = WorldStatisticsManager.getInstance() .getStatisticTop(cat, true, WorldStatisticsManager.STATISTIC_TOP_PLAYER_LIMIT); List<CharacterStatistic> monthlyStatisticList = WorldStatisticsManager.getInstance() .getStatisticTop(cat, false, WorldStatisticsManager.STATISTIC_TOP_PLAYER_LIMIT); activeChar.sendPacket( new ExLoadStatWorldRank(_section, _subSection, generalStatisticList, monthlyStatisticList)); }
public void onStopEvent(FightBattleEvent event) { Player player = _player; if (player == null) return; if (_returnLoc == null) // игрока не портнуло на стадион return; player.removeEvent(event); if (player.isDead()) { player.setCurrentHp(player.getMaxHp(), true); player.broadcastPacket(new Revive(player)); // player.broadcastStatusUpdate(); } else player.setCurrentHp(player.getMaxHp(), false); player.setCurrentCp(player.getMaxCp()); player.setCurrentMp(player.getMaxMp()); // Возвращаем клановые скиллы если репутация положительная. if (player.getClan() != null && player.getClan().getReputationScore() >= 0) player.getClan().enableSkills(player); // Add Hero Skills player.activateHeroSkills(true); // Обновляем скилл лист, после добавления скилов player.sendPacket(new SkillList(player)); player.setStablePoint(null); player.teleToLocation(_returnLoc, ReflectionManager.DEFAULT); }
public void chargePlayer(Player player, Integer skillId) { if (player.getIncreasedForce() >= _charges) { player.sendPacket(SystemMsg.YOUR_FORCE_HAS_REACHED_MAXIMUM_CAPACITY_); return; } if (_fullCharge) player.setIncreasedForce(_charges); else player.setIncreasedForce(player.getIncreasedForce() + 1); }
@Override protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar != null) { activeChar.setEnchantScroll(null); activeChar.sendPacket(EnchantResult.CANCEL); } }
@Override public void runImpl() throws Exception { if (isNowNight()) getInstance().getListenerEngine().onNight(); else getInstance().getListenerEngine().onDay(); for (Player player : GameObjectsStorage.getAllPlayersForIterate()) { player.checkDayNightMessages(); player.sendPacket(new ClientSetTime()); } }
@Override public void onAction(Player player, boolean shift) { if (Events.onAction(player, this, shift)) { player.sendActionFailed(); return; } if (this != player.getTarget()) { player.setTarget(this); player.sendPacket(new ValidateLocation(this)); } else { player.sendPacket(new MyTargetSelected(player, this)); if (!isInRange(player, INTERACTION_DISTANCE)) player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this); else if (buffs.size() > 4) showChatWindow(player, 1); else showChatWindow(player, 0); player.sendActionFailed(); } }
@Override public void onBypassFeedback(Player player, String command) { if (!canBypassCheck(player, this)) return; if (command.startsWith("tryenter")) { if (NaiaLock.isEntranceActive()) { // instance if (!player.isInParty()) { player.sendPacket(SystemMsg.YOU_ARE_NOT_CURRENTLY_IN_A_PARTY_SO_YOU_CANNOT_ENTER); return; } if (!player.getParty().isLeader(player)) { player.sendPacket(SystemMsg.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER); return; } for (Player member : player.getParty().getPartyMembers()) { if (member.getLevel() < 80) { player.sendPacket( new SystemMessage( SystemMessage.C1S_LEVEL_REQUIREMENT_IS_NOT_SUFFICIENT_AND_CANNOT_BE_ENTERED) .addName(member)); return; } if (!member.isInRange(this, 500)) { player.sendPacket( new SystemMessage( SystemMessage .C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED) .addName(member)); return; } } NaiaTowerManager.startNaiaTower(player); broadcastPacket(new MagicSkillUse(this, this, 5527, 1, 0, 0)); doDie(null); } else { broadcastPacket(new MagicSkillUse(this, this, 5527, 1, 0, 0)); doDie(null); } } else super.onBypassFeedback(player, command); }
@Override public void onPlayerEnter(Player player) { super.onPlayerEnter(player); player.sendPacket( new ExSendUIEventPacket( player, 0, 1, (int) (System.currentTimeMillis() - _savedTime) / 1000, 0, NpcString.ELAPSED_TIME)); }
public static boolean canAddItem(Player player, ItemInstance item) { if (!player.getInventory().validateWeight(item)) { player.sendPacket(SystemMsg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT); return false; } if (!player.getInventory().validateCapacity(item)) { player.sendPacket(SystemMsg.YOUR_INVENTORY_IS_FULL); return false; } if (!item.getTemplate().getHandler().pickupItem(player, item)) return false; PickableAttachment attachment = item.getAttachment() instanceof PickableAttachment ? (PickableAttachment) item.getAttachment() : null; if (attachment != null && !attachment.canPickUp(player)) return false; return true; }
public void showMonsterInfo(Player player) { int npcId = getNpcId(); String filename, search; NpcHtmlMessage html = new NpcHtmlMessage(player, this); filename = getHtmlPath(npcId, 6, 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); } player.sendPacket(html); player.sendActionFailed(); }
@Override public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) { if (playable == null || !playable.isPlayer()) return false; Player player = playable.getPlayer(); if (player.getTarget() == null || !player.getTarget().isMonster()) { player.sendPacket(SystemMsg.INVALID_TARGET, ActionFail.STATIC); return false; } if (player.isImmobilized() || player.isCastingNow()) { player.sendActionFailed(); return false; } MonsterInstance target = (MonsterInstance) player.getTarget(); // u can use soul crystal only when target hp goes to <50% if (target.getCurrentHpPercents() >= 50) { player.sendPacket( SystemMsg.THE_SOUL_CRYSTAL_WAS_NOT_ABLE_TO_ABSORB_THE_SOUL, ActionFail.STATIC); return false; } // Soul Crystal Casting section int skillHitTime = SkillTable.getInstance().getInfo(SOUL_CRYSTAL_SKILL_ID, 1).getHitTime(); player.broadcastPacket(new MagicSkillUse(player, SOUL_CRYSTAL_SKILL_ID, 1, skillHitTime, 0)); player.sendPacket(new SetupGauge(player, SetupGauge.Colors.BLUE, skillHitTime)); // End Soul Crystal Casting section // Continue execution later player._skillTask = ThreadPoolManager.getInstance() .schedule(new CrystalFinalizer(player, target), skillHitTime); return true; }
@Override public void showChatWindow(Player player, int val, Object... replace) { NpcHtmlMessagePacket htmlMessage = new NpcHtmlMessagePacket(getObjectId()); htmlMessage.setFile("default/33785.htm"); if (player.getVar("Altar1") != null) { htmlMessage.setFile("default/33785-2.htm"); } if (player.getVar("Altar2") != null) { htmlMessage.setFile("default/33785-3.htm"); } if (player.getVar("Altar3") != null) { htmlMessage.setFile("default/33785-e.htm"); } player.sendPacket(htmlMessage); }
public void showOdds(Player player) { if (state == ACCEPTING_BETS) return; int npcId = getNpcId(); String filename, search; NpcHtmlMessage html = new NpcHtmlMessage(player, this); filename = getHtmlPath(npcId, 5, player); html.setFile(filename); for (int i = 0; i < 8; i++) { try { int n = i + 1; search = "Mob" + n; html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().name); } catch (Exception e) { } } html.replace("1race", String.valueOf(_raceNumber)); player.sendPacket(html); player.sendActionFailed(); }
protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar == null) return; JumpWay way = activeChar.getCurrentJumpWay(); if (way == null) { activeChar.onJumpingBreak(); return; } JumpPoint point = way.getJumpPoint(_nextWayId); if (point == null) { activeChar.onJumpingBreak(); return; } Location destLoc = point.getLocation(); activeChar.broadcastPacketToOthers(new ExFlyMoveBroadcast(activeChar, destLoc)); activeChar.setLoc(destLoc); JumpTrack track = activeChar.getCurrentJumpTrack(); if (track == null) { activeChar.onJumpingBreak(); return; } JumpWay nextWay = track.getWay(_nextWayId); if (nextWay == null) { activeChar.onJumpingBreak(); return; } activeChar.sendPacket( new ExFlyMove(activeChar.getObjectId(), nextWay.getPoints(), track.getId())); activeChar.setCurrentJumpWay(nextWay); }
public void showHtmlFile(Player player, String file, NpcInstance npc) { NpcHtmlMessage html = new NpcHtmlMessage(player, npc); html.setFile(file); html.replace("%t_name%", npc.getName()); player.sendPacket(html); }
@Override public void broadcastCharInfoImpl() { for (Player player : World.getAroundPlayers(this)) player.sendPacket(new FakePlayerInfo(this)); }
@Override protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar == null) return; if (activeChar.isOutOfControl()) { activeChar.sendActionFailed(); return; } if (activeChar.isProcessingRequest()) { activeChar.sendPacket(SystemMsg.WAITING_FOR_ANOTHER_REPLY); return; } if (activeChar.isChaosFestivalParticipant()) { activeChar.sendPacket( SystemMsg .YOU_CANNOT_INVITE_A_FRIEND_OR_PARTY_WHILE_PARTICIPATING_IN_THE_CEREMONY_OF_CHAOS); return; } Player target = World.getPlayer(_name); if (target == null) { FakePlayerInstance fakePlayer = GameObjectsStorage.getFakePlayerByName(_name); if (fakePlayer != null) { new Request(L2RequestType.PARTY, activeChar, null) .setTimeout(10000L) .set("itemDistribution", _itemDistribution); activeChar.sendPacket( new SystemMessage2(SystemMsg.C1_HAS_BEEN_INVITED_TO_THE_PARTY).addName(fakePlayer)); return; } activeChar.sendPacket(SystemMsg.THAT_PLAYER_IS_NOT_ONLINE); return; } if (target == activeChar) { activeChar.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET); activeChar.sendActionFailed(); return; } if (Config.DISABLE_PARTY_ON_EVENT && target.isInPvPEvent()) { activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target)); return; } if (Config.DISABLE_PARTY_ON_EVENT && activeChar.isInPvPEvent()) { activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target)); return; } if (target.isChaosFestivalParticipant()) { activeChar.sendActionFailed(); return; } if (target.isBusy()) { activeChar.sendPacket(new SystemMessage2(SystemMsg.C1_IS_ON_ANOTHER_TASK).addName(target)); return; } IStaticPacket problem = target.canJoinParty(activeChar); if (problem != null) { activeChar.sendPacket(problem); return; } if (activeChar.isInParty()) { if (activeChar.getParty().getMemberCount() >= Party.MAX_SIZE) { activeChar.sendPacket(SystemMsg.THE_PARTY_IS_FULL); return; } // Только Party Leader может приглашать новых членов if (Config.PARTY_LEADER_ONLY_CAN_INVITE && !activeChar.getParty().isLeader(activeChar)) { activeChar.sendPacket(SystemMsg.ONLY_THE_LEADER_CAN_GIVE_OUT_INVITATIONS); return; } if (activeChar.getParty().isInDimensionalRift()) { activeChar.sendMessage( new CustomMessage( "l2s.gameserver.clientpackets.RequestJoinParty.InDimensionalRift", activeChar)); activeChar.sendActionFailed(); return; } } if (target.isFakePlayer() && activeChar.isGM()) { Party party = activeChar.getParty(); if (party == null) { activeChar.setParty(party = new Party(activeChar, Party.ITEM_ORDER_SPOIL)); } party.addPartyMember(target); return; } new Request(L2RequestType.PARTY, activeChar, target) .setTimeout(10000L) .set("itemDistribution", _itemDistribution); target.sendPacket(new AskJoinParty(activeChar.getName(), _itemDistribution)); activeChar.sendPacket( new SystemMessage2(SystemMsg.C1_HAS_BEEN_INVITED_TO_THE_PARTY).addName(target)); }
@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; }
@Override protected void runImpl() { Player activeChar = getClient().getActiveChar(); if (activeChar == null || _count == 0) return; // Проверяем, не подменили ли id if (activeChar.getBuyListId() != _listId) // TODO audit return; if (activeChar.isActionsDisabled()) { activeChar.sendActionFailed(); return; } if (activeChar.isInStoreMode()) { activeChar.sendPacket( SystemMsg .WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM); return; } if (activeChar.isInTrade()) { activeChar.sendActionFailed(); return; } if (activeChar.isFishing()) { activeChar.sendPacket(SystemMsg.YOU_CANNOT_DO_THAT_WHILE_FISHING); return; } if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && activeChar.isPK() && !activeChar.isGM()) { activeChar.sendActionFailed(); return; } NpcInstance merchant = activeChar.getLastNpc(); boolean isValidMerchant = merchant != null && merchant.isMerchantNpc(); if (!activeChar.isGM() && (merchant == null || !isValidMerchant || !activeChar.isInRange(merchant, Creature.INTERACTION_DISTANCE))) { activeChar.sendActionFailed(); return; } NpcTradeList list = BuyListHolder.getInstance().getBuyList(_listId); if (list == null) { // TODO audit activeChar.sendActionFailed(); return; } int slots = 0; long weight = 0; long totalPrice = 0; long tax = 0; double taxRate = 0; Castle castle = null; if (merchant != null) { castle = merchant.getCastle(activeChar); if (castle != null) taxRate = castle.getTaxRate(); } List<TradeItem> buyList = new ArrayList<TradeItem>(_count); List<TradeItem> tradeList = list.getItems(); try { loop: for (int i = 0; i < _count; i++) { int itemId = _items[i]; long count = _itemQ[i]; long price = 0; for (TradeItem ti : tradeList) if (ti.getItemId() == itemId) { if (ti.isCountLimited() && ti.getCurrentValue() < count) continue loop; price = ti.getOwnersPrice(); } if (price == 0 && (!activeChar.isGM() || !activeChar.getPlayerAccess().UseGMShop)) { // TODO audit activeChar.sendActionFailed(); return; } totalPrice = SafeMath.addAndCheck(totalPrice, SafeMath.mulAndCheck(count, price)); TradeItem ti = new TradeItem(); ti.setItemId(itemId); ti.setCount(count); ti.setOwnersPrice(price); weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, ti.getItem().getWeight())); if (!ti.getItem().isStackable() || activeChar.getInventory().getItemByItemId(itemId) == null) slots++; buyList.add(ti); } tax = (long) (totalPrice * taxRate); totalPrice = SafeMath.addAndCheck(totalPrice, tax); if (!activeChar.getInventory().validateWeight(weight)) { activeChar.sendPacket(SystemMsg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT); return; } if (!activeChar.getInventory().validateCapacity(slots)) { activeChar.sendPacket(SystemMsg.YOUR_INVENTORY_IS_FULL); return; } if (!activeChar.reduceAdena(totalPrice)) { activeChar.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA); return; } for (TradeItem ti : buyList) activeChar.getInventory().addItem(ti.getItemId(), ti.getCount()); // Для магазинов с ограниченным количеством товара число продаваемых предметов уменьшаем после // всех проверок list.updateItems(buyList); // Add tax to castle treasury if not owned by npc clan if (castle != null) if (tax > 0 && castle.getOwnerId() > 0 && activeChar.getReflection() == ReflectionManager.DEFAULT) castle.addToTreasury(tax, true, false); } catch (ArithmeticException ae) { // TODO audit activeChar.sendPacket(SystemMsg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED); return; } sendPacket(new ExBuySellListPacket.SellRefundList(activeChar, true)); activeChar.sendChanges(); }
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(); }
@Override public void onPlayerExit(Player player) { super.onPlayerExit(player); player.sendPacket(new ExSendUIEventPacket(player, 1, 1, 0, 0)); }
public void teleportPlayer(FightBattleArenaObject arena) { Player player = _player; if (player == null) return; if (player.isTeleporting()) { _player = null; return; } if (player.isInObserverMode()) { if (player.getOlympiadObserveGame() != null) player.leaveOlympiadObserverMode(true); else player.leaveObserverMode(); } // Un activate clan skills if (player.getClan() != null) player.getClan().disableSkills(player); // Remove Hero Skills player.activateHeroSkills(false); // Abort casting if player casting if (player.isCastingNow()) player.abortCast(true, true); // Abort attack if player attacking if (player.isAttackingNow()) player.abortAttack(true, true); // Удаляем баффы и чужие кубики for (Effect e : player.getEffectList().getEffects()) { if (!player.isSpecialEffect(e.getSkill()) && (e.getEffectType() != EffectType.Cubic || player.getSkillLevel(e.getSkill().getId()) <= 0)) e.exit(); } // Remove Servitor's Buffs Servitor[] servitors = player.getServitors(); if (servitors.length > 0) { for (Servitor servitor : servitors) { if (servitor.isPet()) servitor.unSummon(false); else { servitor.getEffectList().stopAllEffects(); servitor.transferOwnerBuffs(); } } } // unsummon agathion if (player.getAgathionId() > 0) player.setAgathion(0); // Сброс кулдауна всех скилов, время отката которых меньше 15 минут for (TimeStamp sts : player.getSkillReuses()) { if (sts == null) continue; Skill skill = SkillTable.getInstance().getInfo(sts.getId(), sts.getLevel()); if (skill == null) continue; if (sts.getReuseBasic() <= 15 * 60001L) player.enableSkill(skill); } // Обновляем скилл лист, после удаления скилов player.sendPacket(new SkillList(player)); // Обновляем куллдаун, после сброса player.sendPacket(new SkillCoolTime(player)); // Проверяем одетые вещи на возможность ношения. player.getInventory().validateItems(); // remove bsps/sps/ss automation Set<Integer> activeSoulShots = player.getAutoSoulShot(); for (int itemId : activeSoulShots) { player.removeAutoSoulShot(itemId); player.sendPacket(new ExAutoSoulShot(itemId, false)); } // Разряжаем заряженные соул и спирит шоты ItemInstance weapon = player.getActiveWeaponInstance(); if (weapon != null) { weapon.setChargedSpiritshot(ItemInstance.CHARGED_NONE); weapon.setChargedSoulshot(ItemInstance.CHARGED_NONE); } player.setCurrentCp(player.getMaxCp()); player.setCurrentMp(player.getMaxMp()); if (player.isDead()) { player.setCurrentHp(player.getMaxHp(), true); player.broadcastPacket(new Revive(player)); // player.broadcastStatusUpdate(); } else player.setCurrentHp(player.getMaxHp(), false); player.broadcastUserInfo(true); DuelEvent duel = player.getEvent(DuelEvent.class); if (duel != null) duel.abortDuel(player); _returnLoc = player.getStablePoint() == null ? player.getLoc() : player.getStablePoint(); if (player.isSitting()) player.standUp(); player.setTarget(null); player.leaveParty(); player.setStablePoint(_returnLoc); Location loc = arena.getMember1() == this ? arena.getInfo().getTeleportLoc1() : arena.getInfo().getTeleportLoc2(); player.teleToLocation( Location.findPointToStay(loc, 0, arena.getReflection().getGeoIndex()), arena.getReflection()); setDamage(0.); setKilled(false); }