public static void breakWeapons(Player player, int weaponToBreakUniqueId) { Item weaponToBreak = player.getInventory().getItemByObjId(weaponToBreakUniqueId); if (weaponToBreak == null) weaponToBreak = player.getEquipment().getEquippedItemByObjId(weaponToBreakUniqueId); if (weaponToBreak == null || !(player.getTarget() instanceof Npc)) return; if (!weaponToBreak.hasFusionedItem()) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_DECOMPOUND_ERROR_NOT_AVAILABLE(weaponToBreak.getNameID())); return; } weaponToBreak.setFusionedItem(0); ItemService.removeAllFusionStone(player, weaponToBreak); DAOManager.getDAO(InventoryDAO.class).store(weaponToBreak, player.getObjectId()); PacketSendUtility.sendPacket(player, new SM_UPDATE_ITEM(weaponToBreak)); PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_COMPOUNDED_ITEM_DECOMPOUND_SUCCESS(weaponToBreak.getNameID())); }
@Override protected void onFailureFinish() { PacketSendUtility.sendPacket( requestor, new SM_CRAFT_UPDATE( recipeTemplate.getSkillid(), itemTemplate, currentSuccessValue, currentFailureValue, 6)); PacketSendUtility.broadcastPacket( requestor, new SM_CRAFT_ANIMATION(requestor.getObjectId(), responder.getObjectId(), 0, 3), true); PacketSendUtility.sendPacket( requestor, SM_SYSTEM_MESSAGE.STR_COMBINE_FAIL( new DescriptionId( ItemService.getItemTemplate(recipeTemplate.getProductid()).getNameId()))); }
@Override public boolean onDialogEvent(QuestCookie env) { final Player player = env.getPlayer(); final 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.REWARD) { if (targetId == 798927) { if (env.getDialogId() == -1) return sendQuestDialog(env, 10002); else if (env.getDialogId() == 1009) return sendQuestDialog(env, 5); else return defaultQuestEndDialog(env); } return false; } else if (qs.getStatus() == QuestStatus.COMPLETE) { if (targetId == 799022) { if (env.getDialogId() == -1) return sendQuestDialog(env, 2376); else if (env.getDialogId() == 10004) { if (player.getPlayerGroup() == null) { WorldMapTemplate world = DataManager.WORLD_MAPS_DATA.getTemplate(300190000); int mapname = DataManager.WORLD_MAPS_DATA.getTemplate(300190000).getMapNameId(); if (!InstanceService.canEnterInstance(player, world.getInstanceMapId(), 0)) { int timeinMinutes = InstanceService.getTimeInfo(player).get(world.getInstanceMapId()) / 60; if (timeinMinutes >= 60) PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_ENTER_INSTANCE_COOL_TIME_HOUR( mapname, timeinMinutes / 60)); else PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_MSG_CANNOT_ENTER_INSTANCE_COOL_TIME_MIN( mapname, timeinMinutes)); return false; } if (!hasItem(player, 182206627)) { if (!ItemService.addItems( player, Collections.singletonList(new QuestItems(182206627, 1)))) return true; } if (!hasItem(player, 182206628)) { if (!ItemService.addItems( player, Collections.singletonList(new QuestItems(182206628, 1)))) return true; } WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300190000); InstanceService.registerPlayerWithInstance(newInstance, player); TeleportService.teleportTo( player, 300190000, newInstance.getInstanceId(), 198.82353f, 221.40387f, 1098.4879f, (byte) 41); PortalController.setInstanceCooldown(player, 300190000, newInstance.getInstanceId()); return true; } else return sendQuestDialog(env, 2546); } else return defaultQuestStartDialog(env); } else if (targetId == 799503) { switch (env.getDialogId()) { case 26: if (var == 1) return sendQuestDialog(env, 4080); case 1013: case 10000: if (var == 1) { PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 0)); TeleportService.teleportTo( player, 210050000, 2888.9226f, 359.70108f, 298.73184f, (byte) 56); return true; } } } } else if (qs.getStatus() != QuestStatus.START) { return false; } if (targetId == 798927) // Versetti { switch (env.getDialogId()) { case 26: if (var == 0) return sendQuestDialog(env, 1011); 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; } } } else if (targetId == 798954) // Tialla { switch (env.getDialogId()) { case 26: if (var == 1) return sendQuestDialog(env, 1352); else if (var == 8) return sendQuestDialog(env, 3057); case 10001: if (var == 1) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } case 10255: if (var == 8) { qs.setQuestVarById(0, 11); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } } else if (targetId == 799022) // Lothas { switch (env.getDialogId()) { case -1: if (var == 2) return sendQuestDialog(env, 1779); else if (var > 2 && var < 3) return sendQuestDialog(env, 2461); break; case 26: if (var == 3) { if (qs.getQuestVarById(1) == 0) return sendQuestDialog(env, 1693); else return sendQuestDialog(env, 2375); } else if (var == 7) { if (player.getInventory().getItemCountByItemId(182206602) == 0) return sendQuestDialog(env, 2461); else return sendQuestDialog(env, 2716); } else if (var == 14) return sendQuestDialog(env, 4336); case 10002: if (var == 14) { qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } case 10003: if (var == 2) { qs.setQuestVarById(0, var + 1); updateQuestStatus(env); } PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; case 10004: if (var == 3 || var < 7) { if (player.getPlayerGroup() == null) { if (!hasItem(player, 182206627)) { if (!ItemService.addItems( player, Collections.singletonList(new QuestItems(182206627, 1)))) return true; } if (!hasItem(player, 182206628)) { if (!ItemService.addItems( player, Collections.singletonList(new QuestItems(182206628, 1)))) return true; } if (var < 7) { qs.setQuestVarById(1, 0); // clear killed Brohums qs.setQuestVarById(2, 0); // clear used Tears qs.setQuestVarById(0, 5); updateQuestStatus(env); } WorldMapInstance newInstance = InstanceService.getNextAvailableInstance(300190000); InstanceService.registerPlayerWithInstance(newInstance, player); TeleportService.teleportTo( player, 300190000, newInstance.getInstanceId(), 198.82353f, 221.40387f, 1098.4879f, (byte) 41); return true; } else return sendQuestDialog(env, 2546); } case 34: if (var == 7) { if (QuestService.collectItemCheck(env, true)) { long itemCount = player.getInventory().getItemCountByItemId(164000099); player.getInventory().removeFromBagByItemId(164000099, itemCount); qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return sendQuestDialog(env, 10000); } else return sendQuestDialog(env, 10001); } } } else if (targetId == 730008 && var == 11) // Daminu { switch (env.getDialogId()) { case 26: return sendQuestDialog(env, 3398); case 10007: qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } else if (targetId == 730019 && var == 12) // Lodas { switch (env.getDialogId()) { case 26: return sendQuestDialog(env, 3739); case 10008: qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } else if (targetId == 730024 && var == 13) // Trajanus { switch (env.getDialogId()) { case 26: return sendQuestDialog(env, 4080); case 10009: qs.setQuestVarById(0, var + 1); updateQuestStatus(env); PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(env.getVisibleObject().getObjectId(), 10)); return true; } } return false; }
public static void fusionWeapons(Player player, int firstItemUniqueId, int secondItemUniqueId) { Item firstItem = player.getInventory().getItemByObjId(firstItemUniqueId); if (firstItem == null) firstItem = player.getEquipment().getEquippedItemByObjId(firstItemUniqueId); Item secondItem = player.getInventory().getItemByObjId(secondItemUniqueId); if (secondItem == null) secondItem = player.getEquipment().getEquippedItemByObjId(secondItemUniqueId); /* * Need to have items in bag, and target the fusion NPC */ if (firstItem == null || secondItem == null || !(player.getTarget() instanceof Npc)) return; if (!MathUtil.isIn3dRange(player.getTarget(), player, 10)) return; /* * Both have to be 2h weapons */ if (!firstItem.getItemTemplate().isWeapon() || !secondItem.getItemTemplate().isWeapon()) { Logger.getLogger(ArmsfusionService.class) .info("[AUDIT]Player: " + player.getName() + " trying to fusion non-weapon. Hacking!"); return; } if (firstItem.getItemTemplate().getWeaponType() == null || secondItem.getItemTemplate().getWeaponType() == null) return; else { switch (firstItem.getItemTemplate().getWeaponType()) { case DAGGER_1H: case MACE_1H: case SWORD_1H: case TOOLHOE_1H: Logger.getLogger(ArmsfusionService.class) .info("[AUDIT]Player: " + player.getName() + " trying to fusion 1h weapon. Hacking!"); return; } switch (secondItem.getItemTemplate().getWeaponType()) { case DAGGER_1H: case MACE_1H: case SWORD_1H: case TOOLHOE_1H: Logger.getLogger(ArmsfusionService.class) .info("[AUDIT]Player: " + player.getName() + " trying to fusion 1h weapon. Hacking!"); return; } } // check if both items are fusionable if (!firstItem.getItemTemplate().isCanFuse() || !secondItem.getItemTemplate().isCanFuse()) return; double rarity = rarityRate(firstItem.getItemTemplate().getItemQuality()); double priceRate = player.getPrices().getGlobalPrices(player.getCommonData().getRace()) * .01; double taxRate = player.getPrices().getTaxes(player.getCommonData().getRace()) * .01; int priceMod = player.getPrices().getGlobalPricesModifier() * 2; int level = firstItem.getItemTemplate().getLevel(); int price = (int) (priceMod * priceRate * taxRate * rarity * level * level); log.debug( "Rarity: " + rarity + " Price Rate: " + priceRate + " Tax Rate: " + taxRate + " Price Mod: " + priceMod + " Weapon Level: " + level); log.debug("Price: " + price); if (player.getInventory().getKinahItem().getItemCount() < price) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_COMPOUND_ERROR_NOT_ENOUGH_MONEY( firstItem.getNameID(), secondItem.getNameID())); return; } /* * Fusioned weapons must have same type */ if (firstItem.getItemTemplate().getWeaponType() != secondItem.getItemTemplate().getWeaponType()) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_COMPOUND_ERROR_DIFFERENT_TYPE); return; } /* * Second weapon must have inferior or equal lvl. in relation to first weapon */ if (secondItem.getItemTemplate().getLevel() > firstItem.getItemTemplate().getLevel()) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_COMPOUND_ERROR_MAIN_REQUIRE_HIGHER_LEVEL); return; } boolean decreaseResult = player.getInventory().decreaseKinah(price); if (!decreaseResult) return; boolean removeResult = player.getInventory().removeFromBagByObjectId(secondItemUniqueId, 1); if (!removeResult) return; firstItem.setFusionedItem(secondItem.getItemTemplate().getTemplateId()); ItemService.removeAllFusionStone(player, firstItem); if (secondItem.hasOptionalSocket()) { firstItem.setOptionalFusionSocket(secondItem.getOptionalSocket()); } else { firstItem.setOptionalFusionSocket(0); } Set<ManaStone> manastones = secondItem.getItemStones(); for (ManaStone stone : manastones) ItemService.addFusionStone(firstItem, stone.getItemId()); if (firstItem.getPersistentState() != PersistentState.NEW && firstItem.getPersistentState() != PersistentState.UPDATE_REQUIRED) firstItem.setPersistentState(PersistentState.UPDATE_REQUIRED); DAOManager.getDAO(InventoryDAO.class).store(firstItem, player.getObjectId()); PacketSendUtility.sendPacket(player, new SM_DELETE_ITEM(secondItemUniqueId)); PacketSendUtility.sendPacket(player, new SM_UPDATE_ITEM(firstItem)); PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_COMPOUND_SUCCESS(firstItem.getNameID(), secondItem.getNameID())); }
/** Handle dialog */ @Override public void onDialogSelect(int dialogId, final Player player, int questId) { Npc npc = getOwner(); int targetObjectId = npc.getObjectId(); if (QuestEngine.getInstance().onDialog(new QuestCookie(npc, player, questId, dialogId))) return; switch (dialogId) { case 2: PacketSendUtility.sendPacket( player, new SM_TRADELIST( npc, TradeService.getTradeListData().getTradeListTemplate(npc.getNpcId()), player.getPrices().getVendorBuyModifier(), player)); break; case 3: PacketSendUtility.sendPacket( player, new SM_SELL_ITEM( targetObjectId, player.getPrices().getVendorSellModifier(player.getCommonData().getRace()))); break; case 4: // stigma PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 1)); break; case 5: // create legion if (MathUtil.isInRange( npc, player, 10)) // avoiding exploit with sending fake dialog_select packet { PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 2)); } else { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.LEGION_CREATE_TOO_FAR_FROM_NPC()); } break; case 6: // disband legion if (MathUtil.isInRange( npc, player, 10)) // avoiding exploit with sending fake dialog_select packet { LegionService.getInstance().requestDisbandLegion(npc, player); } else { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.LEGION_DISPERSE_TOO_FAR_FROM_NPC()); } break; case 7: // recreate legion if (MathUtil.isInRange( npc, player, 10)) // voiding exploit with sending fake client dialog_select // packet { LegionService.getInstance().recreateLegion(npc, player); } else { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.LEGION_DISPERSE_TOO_FAR_FROM_NPC()); } break; case 20: // warehouse if (MathUtil.isInRange( npc, player, 10)) // voiding exploit with sending fake client dialog_select // packet { if (!RestrictionsManager.canUseWarehouse(player)) return; PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 26)); WarehouseService.sendWarehouseInfo(player, true); } break; case 25: // TODO hotfix to prevent opening the legion wh when a quest returns false. break; case 27: // Consign trade?? npc karinerk, koorunerk PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 13)); break; case 29: // soul healing final long expLost = player.getCommonData().getExpRecoverable(); if (expLost == 0) player.getEffectController().removeEffect(8291); final double factor = (expLost < 1000000 ? 0.25 - (0.00000015 * expLost) : 0.1); final int price = (int) (expLost * factor * CustomConfig.SOULHEALING_PRICE_MULTIPLIER); RequestResponseHandler responseHandler = new RequestResponseHandler(npc) { @Override public void acceptRequest(Creature requester, Player responder) { if (player.getInventory().getKinahItem().getItemCount() >= price) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.EXP(String.valueOf(expLost))); PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.SOUL_HEALED()); player.getCommonData().resetRecoverableExp(); player.getInventory().decreaseKinah(price); player.getEffectController().removeEffect(8291); } else { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.NOT_ENOUGH_KINAH(price)); } } @Override public void denyRequest(Creature requester, Player responder) { // no message } }; if (player.getCommonData().getExpRecoverable() > 0) { boolean result = player .getResponseRequester() .putRequest(SM_QUESTION_WINDOW.STR_SOUL_HEALING, responseHandler); if (result) { PacketSendUtility.sendPacket( player, new SM_QUESTION_WINDOW( SM_QUESTION_WINDOW.STR_SOUL_HEALING, 0, String.valueOf(price))); } } else { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.DONT_HAVE_RECOVERED_EXP()); } break; case 30: switch (npc.getNpcId()) { // Triniel Arena (Enter) case 204089: TeleportService.teleportTo(player, 120010000, 1, 984f, 1543f, 222.1f, 0); ArenaService.getInstance().registerPlayerForTriniel(player); break; // Coliseum (Enter) case 203764: TeleportService.teleportTo(player, 110010000, 1, 1462.5f, 1326.1f, 564.1f, 0); ArenaService.getInstance().registerPlayerForColiseum(player); break; // Eracus Temple (Enter) case 203981: TeleportService.teleportTo(player, 210020000, 1, 439.3f, 422.2f, 274.3f, 0); break; } break; case 31: switch (npc.getNpcId()) { // Triniel Arena (Leave) case 204087: TeleportService.teleportTo(player, 120010000, 1, 1005.1f, 1528.9f, 222.1f, 0); ArenaService.getInstance().unregister(player); break; // Coliseum (Leave) case 203875: TeleportService.teleportTo(player, 110010000, 1, 1470.3f, 1343.5f, 563.7f, 21); ArenaService.getInstance().unregister(player); break; // Eracus Temple (Leave) case 203982: TeleportService.teleportTo(player, 210020000, 1, 446.2f, 431.1f, 274.5f, 0); break; } break; case 35: // Godstone socketing PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 21)); break; case 36: // remove mana stone PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 20)); break; case 37: // modify appearance PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 19)); break; case 38: // flight and teleport TeleportService.showMap(player, targetObjectId, npc.getNpcId()); break; case 39: // improve extraction case 40: // learn tailoring armor smithing etc... CraftSkillUpdateService.getInstance().learnSkill(player, npc); break; case 41: // expand cube CubeExpandService.expandCube(player, npc); break; case 42: WarehouseService.expandWarehouse(player, npc); break; case 47: // legion warehouse if (LegionConfig.LEGION_WAREHOUSE) if (MathUtil.isInRange(npc, player, 10)) LegionService.getInstance().openLegionWarehouse(player); break; case 50: // WTF??? Quest dialog packet break; case 52: if (MathUtil.isInRange( npc, player, 10)) // avoiding exploit with sending fake dialog_select packet { PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 28)); } break; case 53: // coin reward PacketSendUtility.sendPacket( player, new SM_MESSAGE(0, null, "This feature is not available yet", ChatType.ANNOUNCEMENTS)); break; case 55: case 56: byte changesex = 0; // 0 plastic surgery, 1 gender switch byte check_ticket = 2; // 2 no ticket, 1 have ticket if (dialogId == 56) { // Gender Switch changesex = 1; if (player.getInventory().getItemCountByItemId(169660000) > 0 || player.getInventory().getItemCountByItemId(169660001) > 0) check_ticket = 1; } else { // Plastic Surgery if (player.getInventory().getItemCountByItemId(169650000) > 0 || player.getInventory().getItemCountByItemId(169650001) > 0) check_ticket = 1; } PacketSendUtility.sendPacket( player, new SM_PLASTIC_SURGERY(player, check_ticket, changesex)); player.setEditMode(true); break; case 60: // armsfusion PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 29)); break; case 61: // armsbreaking PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 30)); break; case 64: // repurchase PacketSendUtility.sendPacket(player, new SM_REPURCHASE(npc, player)); break; case 65: // adopt pet PacketSendUtility.sendPacket(player, new SM_PET(6)); break; case 66: // surrender pet PacketSendUtility.sendPacket(player, new SM_PET(7)); break; case 10000: // generic npc reply (most are teleporters) TeleporterTemplate template = DataManager.TELEPORTER_DATA.getTeleporterTemplate(npc.getNpcId()); if (template != null) { TeleportLocation loc = template.getTeleLocIdData().getTelelocations().get(0); if (loc != null) { player.getInventory().decreaseKinah(loc.getPrice()); TelelocationTemplate tlt = DataManager.TELELOCATION_DATA.getTelelocationTemplate(loc.getLocId()); TeleportService.teleportTo( player, tlt.getMapId(), tlt.getX(), tlt.getY(), tlt.getZ(), 1000); } } break; default: if (questId > 0) PacketSendUtility.sendPacket( player, new SM_DIALOG_WINDOW(targetObjectId, dialogId, questId)); else PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, dialogId)); break; } }