l2fater 发布于2021年11月20日 06:11 分享 发布于2021年11月20日 06:11 Index: dist/game/data/scripts/ai/sunriseNpc/EnchantManager/EnchantManager.java =================================================================== --- dist/game/data/scripts/ai/sunriseNpc/EnchantManager/EnchantManager.java (revision 0) +++ dist/game/data/scripts/ai/sunriseNpc/EnchantManager/EnchantManager.java (working copy) @@ -0,0 +1,176 @@ +package ai.sunriseNpc.EnchantManager; + +import l2r.gameserver.data.xml.impl.ItemData; +import l2r.gameserver.model.actor.L2Npc; +import l2r.gameserver.model.actor.instance.L2PcInstance; +import l2r.gameserver.model.itemcontainer.Inventory; +import l2r.gameserver.model.items.instance.L2ItemInstance; +import l2r.gameserver.network.SystemMessageId; +import l2r.gameserver.network.serverpackets.InventoryUpdate; +import l2r.gameserver.network.serverpackets.NpcHtmlMessage; + +import ai.npc.AbstractNpcAI; + +/** + * @author L2fuLL + */ +public final class EnchantManager extends AbstractNpcAI +{ + private static final int NpcId = 576; + private static final int SafeEnchantMax = 6; + private static final int[] IdItemAndCost = + { + 57, // Id Item + 100000000 // Count + }; + + public EnchantManager() + { + super(EnchantManager.class.getSimpleName(), "ai/sunriseNpc"); + addFirstTalkId(NpcId); + addTalkId(NpcId); + addStartNpc(NpcId); + } + + @Override + public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) + { + int armorType = -1; + + if (event.startsWith("safe_seteh")) + { + armorType = Inventory.PAPERDOLL_HEAD; + } + else if (event.startsWith("safe_setec")) + { + armorType = Inventory.PAPERDOLL_CHEST; + } + else if (event.startsWith("safe_seteg")) + { + armorType = Inventory.PAPERDOLL_GLOVES; + } + else if (event.startsWith("safe_seteb")) + { + armorType = Inventory.PAPERDOLL_FEET; + } + else if (event.startsWith("safe_setel")) + { + armorType = Inventory.PAPERDOLL_LEGS; + } + else if (event.startsWith("safe_setew")) + { + armorType = Inventory.PAPERDOLL_RHAND; + } + else if (event.startsWith("safe_setes")) + { + armorType = Inventory.PAPERDOLL_LHAND; + } + else if (event.startsWith("safe_setle")) + { + armorType = Inventory.PAPERDOLL_LEAR; + } + else if (event.startsWith("safe_setre")) + { + armorType = Inventory.PAPERDOLL_REAR; + } + else if (event.startsWith("safe_setlf")) + { + armorType = Inventory.PAPERDOLL_LFINGER; + } + else if (event.startsWith("safe_setrf")) + { + armorType = Inventory.PAPERDOLL_RFINGER; + } + else if (event.startsWith("safe_seten")) + { + armorType = Inventory.PAPERDOLL_NECK; + } + else if (event.startsWith("safe_setun")) + { + armorType = Inventory.PAPERDOLL_UNDER; + } + else if (event.startsWith("safe_setba")) + { + armorType = Inventory.PAPERDOLL_CLOAK; + } + else if (event.startsWith("safe_setbe")) + { + armorType = Inventory.PAPERDOLL_BELT; + } + + if (armorType != -1) + { + setEnchant(player, SafeEnchantMax, armorType); + } + sendMainHtmlWindow(player, npc); + return ""; + } + + @Override + public String onFirstTalk(L2Npc npc, L2PcInstance player) + { + sendMainHtmlWindow(player, npc); + return ""; + } + + private void sendMainHtmlWindow(L2PcInstance player, L2Npc npc) + { + final NpcHtmlMessage html = getHtmlPacket(player, npc, "main.htm"); + html.replace("%player%", player.getName()); + html.replace("%PRICE%", String.valueOf(IdItemAndCost[1])); + html.replace("%ITEM_ID%", ItemData.getInstance().getTemplate(IdItemAndCost[0]).getName()); + + player.sendPacket(html); + } + + private NpcHtmlMessage getHtmlPacket(L2PcInstance player, L2Npc npc, String htmlFile) + { + final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId()); + packet.setHtml(getHtm(player, player.getHtmlPrefix(), htmlFile)); + return packet; + } + + private void setEnchant(L2PcInstance activeChar, int ench, int armorType) + { + // now we need to find the equipped weapon of the targeted character... + int curEnchant = 0; // display purposes only + L2ItemInstance itemInstance = null; + + // only attempt to enchant if there is a weapon equipped + L2ItemInstance parmorInstance = activeChar.getInventory().getPaperdollItem(armorType); + if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType)) + { + itemInstance = parmorInstance; + } + + if (itemInstance != null) + { + curEnchant = itemInstance.getEnchantLevel(); + + // set enchant value + if ((curEnchant < SafeEnchantMax) && !itemInstance.isHeroItem()) + { + if (activeChar.destroyItemByItemId("enchant", IdItemAndCost[0], IdItemAndCost[1], activeChar, true)) + { + activeChar.getInventory().unEquipItemInSlot(armorType); + itemInstance.setEnchantLevel(ench); + activeChar.getInventory().equipItem(itemInstance); + + // send packets + InventoryUpdate iu = new InventoryUpdate(); + iu.addModifiedItem(itemInstance); + activeChar.sendInventoryUpdate(iu); + activeChar.broadcastUserInfo(); + + // informations + activeChar.sendMessageS("Congratulation, You enchanted your item to +" + SafeEnchantMax + "!", 4); + activeChar.sendMessage("Changed enchantment of " + activeChar.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + "."); + } + } + else + { + activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS); + } + } + } +} \ No newline at end of file Index: dist/game/data/scripts/ai/sunriseNpc/EnchantManager/main.htm =================================================================== --- dist/game/data/scripts/ai/sunriseNpc/EnchantManager/main.htm (revision 0) +++ dist/game/data/scripts/ai/sunriseNpc/EnchantManager/main.htm (working copy) @@ -0,0 +1,43 @@ +<html> + <title>Enchant Manager</title> +<body> +<br> + <center> + <img src="L2UI_CH3.herotower_deco" width=256 height=32> + <font color="00FFFF" > <h4>Safe Enchant</h4></font><br> + </center><br> + <center> + Hello <font color="LEVEL">%player%</font>, I can safely enchant your items<br> + This action cost <font color="LEVEL" > %ITEM_ID% %PRICE%</font><br><br> + <table> + <tr> + <td><button action="bypass -h Quest EnchantManager safe_seteh" width=32 height=32 back="icon.armor_circlet_i00" fore="icon.armor_circlet_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_setec" width=32 height=32 back="icon.armor_t96_u_i00" fore="icon.armor_t96_u_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_setel" width=32 height=32 back="icon.armor_t96_l_i00" fore="icon.armor_t96_l_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_seteg" width=32 height=32 back="icon.armor_t96_g_i01" fore="icon.armor_t96_g_i01"></td> + <td><button action="bypass -h Quest EnchantManager safe_seteb" width=32 height=32 back="icon.armor_t96_b_i01" fore="icon.armor_t96_b_i01"></td> + </tr> + </table> + <br> + <table> + <tr> + <td><button action="bypass -h Quest EnchantManager safe_setle" width=32 height=32 back="icon.accessory_earring_of_antaras_i00" fore="icon.accessory_earring_of_antaras_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_setre" width=32 height=32 back="icon.accessory_earring_of_zaken_i00" fore="icon.accessory_earring_of_zaken_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_seten" width=32 height=32 back="icon.accessory_necklace_of_valakas_i00" fore="icon.accessory_necklace_of_valakas_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_setlf" width=32 height=32 back="icon.accessory_ring_of_queen_ant_i00" fore="icon.accessory_ring_of_queen_ant_i00"></td> + <td><button action="bypass -h Quest EnchantManager safe_setrf" width=32 height=32 back="icon.accessory_ring_of_baium_i00" fore="icon.accessory_ring_of_baium_i00"></td> + </tr> + </table> + <br> + <table> + <tr> + <td><button action="bypass -h Quest EnchantManager safe_setew" width=32 height=32 back="icon.weapon_vesper_shaper_i01" fore="icon.weapon_vesper_shaper_i01"></td> + <td><button action="bypass -h Quest EnchantManager safe_setes" width=32 height=32 back="icon.verper_sigil_i01" fore="icon.verper_sigil_i01"></td> + <td><button action="bypass -h Quest EnchantManager safe_setbe" width=32 height=32 back="icon.belt_i03" fore="icon.belt_i03"></td> + <td><button action="bypass -h Quest EnchantManager safe_setun" width=32 height=32 back="icon.etc_stripe_shirts_s_i05" fore="icon.etc_stripe_shirts_s_i05"></td> + </tr> + </table> + <br> +<img src="L2UI_CH3.herotower_deco" width=256 height=32> +</center> +</body></html> Index: dist/game/data/scripts/handlers/SunriseNpcsLoader.java =================================================================== --- dist/game/data/scripts/handlers/SunriseNpcsLoader.java (revision 947) +++ dist/game/data/scripts/handlers/SunriseNpcsLoader.java (working copy) @@ -8,6 +8,7 @@ import ai.sunriseNpc.CastleManager.CastleManager; import ai.sunriseNpc.CommunityNpcs.CommunityNpcs; import ai.sunriseNpc.DelevelManager.DelevelManager; +import ai.sunriseNpc.EnchantManager.EnchantManager; import ai.sunriseNpc.GrandBossManager.GrandBossManager; import ai.sunriseNpc.NoblesseManager.NoblesseManager; import ai.sunriseNpc.PointsManager.PointsManager; @@ -33,6 +34,7 @@ PointsManager.class, PremiumManager.class, ReportManager.class, + EnchantManager.class, }; public SunriseNpcsLoader() Index: dist/game/data/xml/stats/npcs/custom/custom.xml =================================================================== --- dist/game/data/xml/stats/npcs/custom/custom.xml (revision 947) +++ dist/game/data/xml/stats/npcs/custom/custom.xml (working copy) @@ -114,6 +114,12 @@ <height normal="22" /> </collision> </npc> + <npc id="576" displayId="13298" name="Enchant Manager" usingServerSideName="true" title="www.l2jsunrise.com" usingServerSideTitle="true" type="L2Npc"> + <collision> + <radius normal="10" /> + <height normal="22" /> + </collision> + </npc> <npc id="8983" displayId="21804" name="Chest" usingServerSideName="true" title="THunt" usingServerSideTitle="true" type="L2Monster"> <sex>MALE</sex> <stats str="10" int="10" dex="10" wit="10" con="10" men="10"> 引用 意见的链接 分享到其他站点 更多分享选项...
已推荐帖子
参与讨论
你可以现在发布并稍后注册。 如果你有帐户,现在就登录发布帖子。