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 onCreate() { super.onCreate(); getZone("[Frintezza]").addListener(_zoneListener); for (NpcInstance n : getNpcs()) n.addListener(_deathListener); blockUnblockNpcs(true, blockANpcs); }
/** * Shows a movie to the players in the lair. * * @param target - L2NpcInstance target is the center of this movie * @param dist - int distance from target * @param yaw - angle of movie (north = 90, south = 270, east = 0 , west = 180) * @param pitch - pitch > 0 looks up / pitch < 0 looks down * @param time - fast ++ or slow -- depends on the value * @param duration - How long to watch the movie * @param socialAction - 1,2,3,4 social actions / other values do nothing */ private void showSocialActionMovie( NpcInstance target, int dist, int yaw, int pitch, int time, int duration, int socialAction) { if (target == null) return; for (Player pc : getPlayers()) if (pc.getDistance(target) <= 2550) { pc.enterMovieMode(); pc.specialCamera(target, dist, yaw, pitch, time, duration); } else pc.leaveMovieMode(); if (socialAction > 0 && socialAction < 5) target.broadcastPacket(new SocialActionPacket(target.getObjectId(), socialAction)); }
@Override protected void onEvtAttacked(Creature attacker, int damage) { NpcInstance actor = getActor(); if (actor.getCurrentHpPercents() < 70 && !summonsReleased) { summonsReleased = true; summon1 = NpcUtils.spawnSingle( 18950, Location.findAroundPosition(actor, 150), actor.getReflection()); summon2 = NpcUtils.spawnSingle( 18951, Location.findAroundPosition(actor, 150), actor.getReflection()); } super.onEvtAttacked(attacker, damage); }
@Override public String onKill(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); if (cond == 3 && ArrayUtils.contains(MOBS_1, npcId) && Rnd.chance(70)) { st.giveItems(ELCARDIAS_MARK, 1); if (st.getQuestItemsCount(ELCARDIAS_MARK) < 10) st.playSound(SOUND_ITEMGET); else { st.playSound(SOUND_MIDDLE); st.setCond(4); } } else if (npcId == CREATURE_OF_THE_DUSK_1) { st.set("CreatureOfTheDusk1", 2); if (st.get("CreatureOfTheDusk2") != null && Integer.parseInt(st.get("CreatureOfTheDusk2")) == 2) { st.playSound(SOUND_MIDDLE); st.setCond(6); } } else if (npcId == CREATURE_OF_THE_DUSK_2) { st.set("CreatureOfTheDusk2", 2); if (st.get("CreatureOfTheDusk1") != null && Integer.parseInt(st.get("CreatureOfTheDusk1")) == 2) { st.playSound(SOUND_MIDDLE); st.setCond(6); } } return null; }
@Override public String onTalk(NpcInstance npc, QuestState st) { String htmltext = "noquest"; int npcId = npc.getNpcId(); int cond = st.getCond(); if (npcId == THEODRIC) { if (cond == 0) { if (st.getPlayer().getLevel() < 84) htmltext = "antharas_watchman_theodric_q10504_00.htm"; else if (st.getQuestItemsCount(PORTAL_STONE) < 1) htmltext = "antharas_watchman_theodric_q10504_00a.htm"; else if (st.isNowAvailable()) htmltext = "antharas_watchman_theodric_q10504_01.htm"; else htmltext = "antharas_watchman_theodric_q10504_09.htm"; } else if (cond == 1) { if (st.getQuestItemsCount(CLEAR_CRYSTAL) < 1) { htmltext = "antharas_watchman_theodric_q10504_08.htm"; st.giveItems(CLEAR_CRYSTAL, 1); } else htmltext = "antharas_watchman_theodric_q10504_05.htm"; } else if (cond == 2) { if (st.getQuestItemsCount(FILLED_CRYSTAL_ANTHARAS) >= 1) { htmltext = "antharas_watchman_theodric_q10504_07.htm"; st.takeAllItems(FILLED_CRYSTAL_ANTHARAS); st.giveItems(JEWEL_OF_ANTHARAS, 1); st.playSound(SOUND_FINISH); st.exitCurrentQuest(this); } else htmltext = "antharas_watchman_theodric_q10504_06.htm"; } } return htmltext; }
@Override public void onBypassFeedback(Player player, String command) { if (!canBypassCheck(player, this)) { return; } if (command.startsWith("start1")) { // тут пропускам т.к. это первый этаж, и перемещение на него == вход в инстанс } else if (command.startsWith("start2")) { for (Player party : GameObjectsStorage.getAllPlayersForIterate()) { party.unsetVar("Altar1"); party.setVar("Altar2", "true", -1); party.teleToLocation(FLOOR2, player.getReflection()); } } else if (command.startsWith("start3")) { for (Player party : GameObjectsStorage.getAllPlayersForIterate()) { party.unsetVar("Altar2"); party.setVar("Altar3", "true", -1); party.teleToLocation(FLOOR3, player.getReflection()); } } else if (command.startsWith("exit")) { for (Player party : GameObjectsStorage.getAllPlayersForIterate()) { party.unsetVar("Altar3"); party.teleToLocation(OFF, 0); } } else { super.onBypassFeedback(player, command); } }
@Override public String onTalk(NpcInstance npc, QuestState st) { String htmltext = "noquest"; int npcId = npc.getNpcId(); int cond = st.getCond(); if (npcId == Droph) if (cond == 0) { if (st.getPlayer().getLevel() >= 79) htmltext = "droph_q307_1.htm"; else { htmltext = "droph_q307_0.htm"; st.exitCurrentQuest(true); } } else if (cond == 1) { if (st.getQuestItemsCount(CaveExplorationText1Sheet) >= 1 && st.getQuestItemsCount(CaveExplorationText2Sheet) >= 1 && st.getQuestItemsCount(CaveExplorationText3Sheet) >= 1) if (ServerVariables.getLong("HekatonPrimeRespawn", 0) < System.currentTimeMillis()) htmltext = "droph_q307_3.htm"; else htmltext = "droph_q307_4.htm"; else htmltext = "droph_q307_2a.htm"; } else if (cond == 2) { htmltext = "droph_q307_5.htm"; st.giveItems(DrophsSupportItems, 1); st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); } return htmltext; }
@Override public String onKill(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); if (cond == 1 && npcId == HekatonPrime) st.setCond(2); return null; }
@Override public void onZoneLeave(Zone zone, Creature cha) { if (cha.isNpc() && (cha.getNpcId() == _weakScarletId || cha.getNpcId() == _strongScarletId)) { cha.teleToLocation(new Location(-87784, -153304, -9176)); ((NpcInstance) cha).getAggroList().clear(true); cha.setCurrentHpMp(cha.getMaxHp(), cha.getMaxMp()); cha.broadcastCharInfo(); } }
public BumbalumpSpawner() { if (BumbalumpSpawned()) return; NpcTemplate template = NpcHolder.getInstance().getTemplate(RB_Icicle_Emperor_Bumbalump); if (template == null) return; try { _spawn = new SimpleSpawner(template); } catch (Exception E) { return; } _spawn.setLocx(158240); _spawn.setLocy(-121536); _spawn.setLocz(-2253); _spawn.setHeading(Rnd.get(0, 0xFFFF)); _spawn.setAmount(1); _spawn.doSpawn(true); _spawn.stopRespawn(); for (NpcInstance _npc : _spawn.getAllSpawned()) _npc.addListener(new DeathListener()); }
private void block(NpcInstance npc, boolean flag) { if (npc == null || npc.isDead()) return; if (flag) { npc.abortAttack(true, false); npc.abortCast(true, true); npc.setTarget(null); if (npc.isMoving) npc.stopMove(); npc.block(); } else npc.unblock(); npc.setIsInvul(flag); }
@Override public String onEvent(String event, QuestState st, NpcInstance npc) { String htmltext = event; if (event.equalsIgnoreCase("droph_q307_2.htm")) { st.setCond(1); st.setState(STARTED); } else if (event.equalsIgnoreCase("loc1")) { htmltext = "droph_q307_2a_1.htm"; RadarControlPacket rc = new RadarControlPacket(0, 1, GorgolosLoc); st.getPlayer().sendPacket(rc); } else if (event.equalsIgnoreCase("loc2")) { htmltext = "droph_q307_2a_2.htm"; RadarControlPacket rc = new RadarControlPacket(0, 1, LastTitanUtenusLoc); st.getPlayer().sendPacket(rc); } else if (event.equalsIgnoreCase("loc3")) { htmltext = "droph_q307_2a_3.htm"; RadarControlPacket rc = new RadarControlPacket(0, 1, GiantMarpanakLoc); st.getPlayer().sendPacket(rc); } else if (event.equalsIgnoreCase("summon_rb")) { if (ServerVariables.getLong("HekatonPrimeRespawn", 0) < System.currentTimeMillis() && st.getQuestItemsCount(CaveExplorationText1Sheet) >= 1 && st.getQuestItemsCount(CaveExplorationText2Sheet) >= 1 && st.getQuestItemsCount(CaveExplorationText3Sheet) >= 1) { st.takeItems(CaveExplorationText1Sheet, 1); st.takeItems(CaveExplorationText2Sheet, 1); st.takeItems(CaveExplorationText3Sheet, 1); ServerVariables.set( "HekatonPrimeRespawn", System.currentTimeMillis() + HekatonPrimeRespawn); NpcInstance boss = st.addSpawn( HekatonPrime, HekatonPrimeLoc.x, HekatonPrimeLoc.y, HekatonPrimeLoc.z, HekatonPrimeLoc.h, 0, 0); boss.getMinionList().spawnMinions(); htmltext = "droph_q307_3a.htm"; } else htmltext = "droph_q307_2b.htm"; } return htmltext; }
@Override public String onTalk(NpcInstance npc, QuestState st) { String htmltext = "noquest"; int npcId = npc.getNpcId(); int cond = st.getCond(); int id = st.getState(); Player player = st.getPlayer(); if (!player.isBaseClassActive()) return "no_subclass_allowed.htm"; switch (npcId) { case WOOD: if (cond == 0) { QuestState qs = player.getQuestState(_198_SevenSignsEmbryo.class); if (player.getLevel() >= 81 && qs != null && qs.isCompleted()) htmltext = "priest_wood_q10292_0.htm"; else { htmltext = "priest_wood_q10292_0n.htm"; st.exitCurrentQuest(true); } } else if (cond == 1) htmltext = "priest_wood_q10292_3.htm"; else if (cond > 1 && !st.isCompleted()) htmltext = "priest_wood_q10292_5.htm"; // TODO: Отредактировать диалог по оффу else if (st.isCompleted()) htmltext = "priest_wood_q10292_6.htm"; break; case FRANZ: if (cond == 1) htmltext = "witness_of_dawn_q10292_0.htm"; else if (cond == 2) htmltext = "witness_of_dawn_q10292_4.htm"; break; case ELCARDIA: if (cond == 2) htmltext = "elcadia_abyssal_saintess_q10292_0.htm"; else if (cond == 3) htmltext = "elcadia_abyssal_saintess_q10292_2.htm"; else if (cond == 4) { htmltext = "elcadia_abyssal_saintess_q10292_3.htm"; st.takeItems(ELCARDIAS_MARK, -1); st.playSound(SOUND_MIDDLE); st.setCond(5); } else if (cond == 5) htmltext = "elcadia_abyssal_saintess_q10292_5.htm"; else if (cond == 6) htmltext = "elcadia_abyssal_saintess_q10292_6.htm"; else if (cond == 7) htmltext = "elcadia_abyssal_saintess_q10292_9.htm"; else if (cond == 8) { htmltext = "elcadia_abyssal_saintess_q10292_10.htm"; st.addExpAndSp(10000000, 1000000); st.setState(COMPLETED); st.exitCurrentQuest(false); st.playSound(SOUND_FINISH); } break; case HARDIN: if (cond == 7) htmltext = "hardin_q10292_0.htm"; else if (cond == 8) htmltext = "hardin_q10292_2.htm"; break; } return htmltext; }
@Override public String onKill(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); if (npcId == GUILLOTINE_OF_DEATH) { if (cond == 1) { st.setCond(2); st.playSound(SOUND_MIDDLE); } } return null; }
@Override public String onKill(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); if (cond == 1 && npcId == ULTIMATE_ANTHARAS) { st.takeAllItems(CLEAR_CRYSTAL); st.giveItems(FILLED_CRYSTAL_ANTHARAS, 1); st.setCond(2); } return null; }
@Override protected boolean thinkActive() { NpcInstance actor = getActor(); if (actor.isDead()) return true; if (_def_think) { doTask(); return true; } if (System.currentTimeMillis() > wait_timeout && (current_point > -1 || Rnd.chance(5))) { if (!wait) switch (current_point) { case 5: wait_timeout = System.currentTimeMillis() + 15000; Functions.npcSay(actor, "The Mother Tree is always so gorgeous!"); wait = true; return true; case 9: wait_timeout = System.currentTimeMillis() + 60000; Functions.npcSay(actor, "Lady Mirabel, may the peace of the lake be with you!"); wait = true; return true; } wait_timeout = 0; wait = false; current_point++; if (current_point >= points.length) current_point = 0; addTaskMove(points[current_point], true); doTask(); return true; } if (randomAnimation()) return true; return false; }
@Override protected boolean thinkActive() { NpcInstance actor = getActor(); int[][] coords; coords = SMP_COORDS; actor.setRunning(); if (actor.getTarget() == null || currentState >= coords.length || currentState == 0) { if (currentState < coords.length) { actor.moveToLocation( coords[currentState][0], coords[currentState][1], coords[currentState][2], Rnd.get(0, 50), true); if (actor.getDestination() == null) { ++currentState; } } else { actor.doDie(actor); } } if (lastSayTimer + SAY_RAFF < System.currentTimeMillis()) { lastSayTimer = System.currentTimeMillis(); Functions.npcSay(actor, NpcString.ITS_HERE, ChatType.NPC_ALL, 800); } return true; }
@Override public String onTalk(NpcInstance npc, QuestState st) { String htmltext = "noquest"; int npcId = npc.getNpcId(); int cond = st.getCond(); if (npcId == HOLLINT) { if (cond == 1) { htmltext = "30191-1.htm"; } else if (cond == 2) htmltext = "30191-3.htm"; } else if (npcId == ANDY && st.getCond() == 2) { htmltext = "33845-1.htm"; } return htmltext; }
@Override protected boolean thinkActive() { NpcInstance actor = getActor(); Player player; // follow the player double distance; if (targetPlayers != null && targetPlayers.size() > 0 && followTargetIndex > 0) { player = targetPlayers.get(followTargetIndex - 1); // in case the player set to follow is null, fall back to the first player in the list if (player == null) player = targetPlayers.get(0); distance = (int) actor.getDistance(player); if (distance > maxFollowDistance) { if (GeoEngine.canSeeTarget(actor, player, false)) { // in case the NPC can see the player actor.setRunning(); Location loc = new Location( player.getX() + Rnd.get(-60, 60), player.getY() + Rnd.get(-60, 60), player.getZ()); actor.followToCharacter(loc, player, minFollowDistance, false); } else { // in case the NPC cannot see the player, then teleport straight to him actor.teleToLocation(player.getLoc().getRandomLoc(100)); } return true; } } return startAttack(); }
@Override public String onTalk(NpcInstance npc, QuestState st) { int npcId = npc.getNpcId(); int cond = st.getCond(); String htmltext = "noquest"; if (npcId == ENDRIGO) { if (st.isCompleted()) htmltext = "warden_endrigo_q10380_03.htm"; else if (st.isStarted()) { if (cond == 1) htmltext = "warden_endrigo_q10380_07.htm"; else if (cond == 2) htmltext = "warden_endrigo_q10380_08.htm"; } else { if (checkStartCondition(st.getPlayer())) htmltext = "warden_endrigo_q10380_01.htm"; else htmltext = "warden_endrigo_q10380_02.htm"; } } return htmltext; }
// Hack: ToRemove when doors will operate normally in reflections private void blockUnblockNpcs(boolean block, int[] npcArray) { for (NpcInstance n : getNpcs()) if (ArrayUtils.contains(npcArray, n.getNpcId())) { if (block) { n.block(); n.setIsInvul(true); } else { n.unblock(); n.setIsInvul(false); } } }
@Override public void onBypassFeedback(Player player, String command) { if (!canBypassCheck(player, this)) { return; } if (command.equalsIgnoreCase("start")) { Reflection r = player.getActiveReflection(); if (r != null) { if (player.canReenterInstance(VullockInstance)) { player.teleToLocation(r.getTeleportLoc(), r); } } else if (player.canEnterInstance(VullockInstance)) { ReflectionUtils.enterReflection(player, new AltarShilen(), VullockInstance); } } else { super.onBypassFeedback(player, command); } }
@Override public String onTalk(NpcInstance npc, QuestState st) { int _state = st.getState(); int npcId = npc.getNpcId(); if (_state == CREATED) { if (npcId != Jeremy) return "noquest"; if (st.getPlayer().getLevel() < 73) { st.exitCurrentQuest(true); return "jeremy_q0625_0103.htm"; } if (st.getQuestItemsCount(Soy_Sauce_Jar) == 0) { st.exitCurrentQuest(true); return "jeremy_q0625_0102.htm"; } st.setCond(0); return "jeremy_q0625_0101.htm"; } if (_state != STARTED) return "noquest"; int cond = st.getCond(); if (npcId == Jeremy) { if (cond == 1) return "jeremy_q0625_0105.htm"; if (cond == 2) return "jeremy_q0625_0202.htm"; if (cond == 3) return "jeremy_q0625_0201.htm"; } if (npcId == Yetis_Table) { if (ServerVariables.getLong(_625_TheFinestIngredientsPart2.class.getSimpleName(), 0) + 3 * 60 * 60 * 1000 > System.currentTimeMillis()) return "yetis_table_q0625_0204.htm"; if (cond == 1) return "yetis_table_q0625_0101.htm"; if (cond == 2) { if (BumbalumpSpawned()) return "yetis_table_q0625_0202.htm"; ThreadPoolManager.getInstance().schedule(new BumbalumpSpawner(), 1000); return "yetis_table_q0625_0201.htm"; } if (cond == 3) return "yetis_table_q0625_0204.htm"; } return "noquest"; }
@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); }
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 protected boolean thinkActive() { NpcInstance actor = getActor(); Creature target = actor.getFollowTarget(); if (target == null || !(target instanceof Player)) { if (actor != null) actor.deleteMe(); return false; } int npcId = actor.getNpcId(); int[][] coords; NpcString string; NpcString end_String; // Select coords switch (npcId) { case SEARCHING_MYST_POWER_SOLDIER: coords = SMP_COORDS; string = SEARCHING_MYST_POWER_STRING; end_String = NpcString.S1_THAT_MAN_IN_FRONT_IS_IBANE; break; case BACKUP_SEEKERS_ASSASSIN: coords = BS_COORDS; string = BACKUP_SEEKERS_STRING; end_String = NpcString.TALK_TO_THAT_APPRENTICE_AND_GET_ON_KOOKARU; break; case GOING_INTO_REAL_WAR_SOLDIER: double distLeft = target.getDistance(GRW_COORDS_LEFT[0][0], GRW_COORDS_LEFT[0][1], GRW_COORDS_LEFT[0][2]); double distRight = target.getDistance( GRW_COORDS_RIGHT[0][0], GRW_COORDS_RIGHT[0][1], GRW_COORDS_RIGHT[0][2]); if (distLeft <= distRight) coords = GRW_COORDS_LEFT; else coords = GRW_COORDS_RIGHT; string = GOING_INTO_REAL_WAR_STRING; end_String = NpcString.S1_THAT_MAN_IN_FRONT_IS_HOLDEN; break; default: return false; } // Нужно всё это переписать. // This NPC is running actor.setRunning(); if (actor.getDistance(target) < 100 || currentState == 0 || currentState >= coords.length) { if (currentState < coords.length) { actor.moveToLocation( coords[currentState][0], coords[currentState][1], coords[currentState][2], Rnd.get(0, 50), true); if (actor.getDestination() == null) { ++currentState; } } else { Functions.npcSay(actor, end_String, target.getName()); actor.deleteMe(); } } else if (lastSayTime + SAY_INTERVAL < System.currentTimeMillis() && actor.getDestination() == null) { int heading = actor.calcHeading(target.getX(), target.getY()); actor.setHeading(heading); actor.broadcastPacket(new ExRotation(actor.getObjectId(), heading)); lastSayTime = System.currentTimeMillis(); Functions.npcSay(actor, string, target.getName()); } return true; }
@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(); }
@Override public void onBypassFeedback(Player player, String command) { if (!canBypassCheck(player, this)) return; if (command.startsWith("ExitSoloKama")) { Reflection r = getReflection(); if (r.getReturnLoc() != null) player.teleToLocation(r.getReturnLoc(), ReflectionManager.DEFAULT); else player.setReflection(ReflectionManager.DEFAULT); player.unsetVar("backCoords"); r.startCollapseTimer(1000); } else if (command.startsWith("ListPossible")) { if (getNpcId() == 32484 && Config.ALT_KAMALOKA_NIGHTMARES_PREMIUM_ONLY && !player.hasBonus()) { showChatWindow(player, "instance/soloKamaloka/32484-no.htm"); return; } // FIXME [G1ta0] исправить, когда будет реализованы индивидуальные параметры спавна DomainArea domain = MapRegionManager.getInstance().getRegionData(DomainArea.class, this); String htmlpath = "instance/soloKamaloka/" + getNpcId(); if (domain != null) switch (domain.getId()) { case 1: // Town of Gludio htmlpath += "-gludio"; break; case 2: // Town of Dion htmlpath += "-dion"; break; case 4: // Town of Oren htmlpath += "-oren"; break; case 6: // Heine htmlpath += "-heine"; break; case 8: // Rune Township htmlpath += "-rune"; break; case 9: // Town of Schuttgart htmlpath += "-schuttgart"; break; } htmlpath += ".htm"; showChatWindow(player, htmlpath); } else if (command.startsWith("ShowResults")) { String htmlpath = "instance/soloKamaloka/" + getNpcId(); switch (getRewardRank()) { case 0: htmlpath += "-F"; break; case 1: htmlpath += "-D"; break; case 2: htmlpath += "-C"; break; case 3: htmlpath += "-B"; break; case 4: htmlpath += "-A"; break; case 5: htmlpath += "-S"; break; case 6: if (getReflection().getInstancedZoneId() == INSTANCE_75LVL_ID) // G-Grade награда доступна только в соло камалоке 70-80 // уровней. htmlpath += "-G"; else htmlpath += "-S"; break; } htmlpath += ".htm"; showChatWindow(player, htmlpath); } else if (command.startsWith("SoloKamaReward")) { if (!_rewarded) { int[][] rewards = getRewardList(getRewardRank(), getReflection().getInstancedZone()); if (rewards != null) for (int[] item : rewards) if (item != null) { int id = item[0]; int count = item[1]; if (id > 0 && count > 0) Functions.addItem(player, id, count); } _rewarded = true; } showChatWindow(player, 1); } else if (command.startsWith("Chat")) try { int val = Integer.parseInt(command.substring(5)); showChatWindow(player, val); } catch (NumberFormatException nfe) { String filename = command.substring(5).trim(); if (filename.length() == 0) showChatWindow(player, "npcdefault.htm"); else showChatWindow(player, filename); } else if (command.startsWith("solo_kamaloka")) { int val = Integer.parseInt(command.substring(14)); Reflection r = player.getActiveReflection(); if (r != null) { if (player.canReenterInstance(val)) player.teleToLocation(r.getTeleportLoc(), r); } else if (player.canEnterInstance(val)) { ReflectionUtils.enterReflection(player, new KamalokaNightmare(player), val); } } else super.onBypassFeedback(player, command); }
@Override public void onDeath(Creature self, Creature killer) { if (self.isNpc()) { if (self.getNpcId() == HallAlarmDevice) { for (int i = 0; i < hallADoors.length; i++) openDoor(hallADoors[i]); blockUnblockNpcs(false, blockANpcs); for (NpcInstance n : getNpcs()) if (ArrayUtils.contains(blockANpcs, n.getNpcId())) n.getAI() .notifyEvent( CtrlEvent.EVT_AGGRESSION, getPlayers().get(Rnd.get(getPlayers().size())), 200); } else if (ArrayUtils.contains(blockANpcs, self.getNpcId())) { // ToCheck: find easier way for (NpcInstance n : getNpcs()) if (ArrayUtils.contains(blockANpcs, n.getNpcId()) && !n.isDead()) return; for (int i = 0; i < corridorADoors.length; i++) openDoor(corridorADoors[i]); blockUnblockNpcs(true, blockBNpcs); } else if (self.getNpcId() == DarkChoirPlayer) { for (NpcInstance n : getNpcs()) if (n.getNpcId() == DarkChoirPlayer && !n.isDead()) return; for (int i = 0; i < hallBDoors.length; i++) openDoor(hallBDoors[i]); blockUnblockNpcs(false, blockBNpcs); } else if (ArrayUtils.contains(blockBNpcs, self.getNpcId())) { if (Rnd.chance(10)) ((NpcInstance) self).dropItem(killer.getPlayer(), DewdropItem, 1); // ToCheck: find easier way for (NpcInstance n : getNpcs()) if ((ArrayUtils.contains(blockBNpcs, n.getNpcId()) || ArrayUtils.contains(blockANpcs, n.getNpcId())) && !n.isDead()) return; for (int i = 0; i < corridorBDoors.length; i++) openDoor(corridorBDoors[i]); ThreadPoolManager.getInstance().schedule(new FrintezzaStart(), battleStartDelay); } else if (self.getNpcId() == _weakScarletId) { self.decayMe(); return; } else if (self.getNpcId() == _strongScarletId) { ThreadPoolManager.getInstance().schedule(new Die(1), 10); setReenterTime(System.currentTimeMillis()); } } }