Jump to content

^Wyatt

Members
  • Posts

    1,418
  • Joined

  • Last visited

  • Days Won

    2
  • Feedback

    0%

Everything posted by ^Wyatt

  1. Even if you pay me, I don't wanna look for it. Interlude bothers me. Stop it here it has no sense.
  2. The code is fine. You are just messing up something. I said to you, don't put the zone inside a town zone, you're doing mistakes. Don't spam more with that, I don't have time to look for that kinda mistakes, help section is not here. The code is ok.
  3. I think that he's saying "it doesn't work for me" Seems that google translator is kidding around xd
  4. isInOlympiadMode() maybe? Depends on your h5 rev.
  5. Try with if player.InOlympiadMode() :
  6. Lawl I forgot the () getPlayer()
  7. delete this and this: And change this: with st = player.getQuestState(QUEST_LOADING_INFO) if st.getPlayer.InOlympiadMode() : (Use Tab here)return showText(st,"info","You can't use the scheme buffer while you're registered for the Olympiad Games!","False","Return","main")
  8. Yea. This error is common. 90% of cases is a class or nullpointer exception inside doDie() task of L2PcInstance.
  9. The question should be... what did you change in l2pcinstance?... Or which code did you add?
  10. I know but I wanted to block the player and also immobilize while the npc was acting, in order to prevent exploits. Also I got tired with the visual bug and I didn't want to spend more time on it T_T. btw ty x'D
  11. Sorry but no, he isn't wrong. Anyway good share, but could be much better doing a little cleanup of the code.
  12. Well, hi, this is an auto enchanter Npc, but as title says, it's a little different of the others that are already shared. How it works: you have a field where you specify the number of scrolls that you want to use, then you push the button of the item that you want to enchant (Inventory slot, so you must have this item equipped. Armor, weapon, jewel, belt or shirt.), then the npc will use the number of enchants that you've already specified with the item you set. For every enchant, the npc is taking the % rate of success of your server, so it can brake if it's not inside the minimum safe enchant range. Also when npc is using the number of enchants that you specified, it shows you the animation. Here it comes a visual bug that I couldn't solve. The image of the item that npc is enchanting is little buggy and shows you the image of the last item that you enchanted manually. But it's only this, a visual bug, the process is fine. I think it's useful in custom servers that have safe enchant +10 or similar, and every time you want to enchant an item you have to use 10 times an scroll, 10 times move the item to the enchant slot, push the button... and it's boring. So the npc helps you with that, or whatever you want to enchant. About the visual bug if someone knows how to solve it I'll appreciate. I spent much time trying to solve it but I couldn't. So I decided to share as it's now and no more. Here's a preview: Coded for High Five ### Eclipse Workspace Patch 1.0 #P L2JH_Server Index: java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java =================================================================== --- java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java (revision 0) +++ java/com/l2jserver/gameserver/model/actor/instance/L2EnchanterInstance.java (revision 0) @@ -0,0 +1,384 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.l2jserver.gameserver.model.actor.instance; + +import java.util.NoSuchElementException; +import java.util.StringTokenizer; +import javolution.text.TextBuilder; +import com.l2jserver.Config; +import com.l2jserver.gameserver.datatables.EnchantItemTable; +import com.l2jserver.gameserver.datatables.SkillTable; +import com.l2jserver.gameserver.model.EnchantScroll; +import com.l2jserver.gameserver.model.L2Skill; +import com.l2jserver.gameserver.model.L2World; +import com.l2jserver.gameserver.model.actor.L2Npc; +import com.l2jserver.gameserver.model.item.L2Armor; +import com.l2jserver.gameserver.model.item.L2Item; +import com.l2jserver.gameserver.model.item.instance.L2ItemInstance; +import com.l2jserver.gameserver.network.SystemMessageId; +import com.l2jserver.gameserver.network.serverpackets.ChooseInventoryItem; +import com.l2jserver.gameserver.network.serverpackets.EnchantResult; +//import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantTargetItemResult; +import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate; +import com.l2jserver.gameserver.network.serverpackets.ItemList; +import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse; +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate; +import com.l2jserver.gameserver.network.serverpackets.SystemMessage; +import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; +import com.l2jserver.gameserver.util.Util; +import com.l2jserver.util.Rnd; + +/** + * + * @author Wyatt + * TODO:FIXME visual bug related with target item + * + */ +public final class L2EnchanterInstance extends L2Npc +{ + boolean w = false; + + public L2EnchanterInstance(int objectId, L2NpcTemplate template) + { + super(objectId, template); + setInstanceType(InstanceType.L2EnchanterInstance); + } + + @Override + public void onBypassFeedback(L2PcInstance activeChar, String actualCommand) + { + StringTokenizer st = new StringTokenizer(actualCommand, " "); + actualCommand = st.nextToken(); + + if (actualCommand.equalsIgnoreCase("enchant") && !activeChar.isImmobilized()) + { + int i = Integer.parseInt(st.nextToken()); + int q; + try + { + q = Integer.parseInt(st.nextToken()); + } + catch(NumberFormatException enf) + { + activeChar.sendMessage("Enter a valid number."); + return; + } + catch(NoSuchElementException enf) + { + activeChar.sendMessage("Enter a valid number."); + return; + } + if(i == 5) + w = true; + else + w = false; + L2ItemInstance t = activeChar.getInventory().getPaperdollItem(i); + + if(t == null) + { + activeChar.sendMessage("You must have equiped an item in order to enchant it."); + return; + } + + int l = t.getItem().getCrystalType(); + int d = 0; + + switch(l) + { + case 1: + if (w) + d = 955; + else + d = 956; + break; + case 2: + if (w) + d = 951; + else + d = 952; + break; + case 3: + if (w) + d = 947; + else + d = 948; + break; + case 4: + if (w) + d = 729; + else + d = 730; + break; + case 5: + if (w) + d = 959; + else + d = 960; + break; + case 6: + if (w) + d = 959; + else + d = 960; + break; + case 7: + if (w) + d = 959; + else + d = 960; + break; + } + + if(d == 0) + { + activeChar.sendMessage("The item grade is not enchantable."); + return; + } + + if(activeChar.getInventory().getInventoryItemCount(d, -1) < q) + { + activeChar.sendMessage("You don't have enough scrolls of enchant."); + return; + } + + try + { + activeChar.setIsImmobilized(true); + activeChar.setIsEnchanting(true); + for(int u=0;u<q;u++) + { + if(!enchant(activeChar, i, d)) + continue; + Thread.sleep(2000); + } + activeChar.setIsImmobilized(false); + activeChar.setIsEnchanting(false); + } + catch (InterruptedException e) + { + } + } + else + super.onBypassFeedback(activeChar, actualCommand); + } + + @Override + public void showChatWindow(L2PcInstance player) + { + NpcHtmlMessage page = new NpcHtmlMessage(5); + TextBuilder replyMSG = new TextBuilder(); + replyMSG.append("<html><title>Enchanter Menu</title><body>"); + replyMSG.append("<br>Hi "+player.getName()+"! This is a Npc Enchanter that will automatic land the number of enchants that you specify here in your weapon/jewel/armor. It's not a safe enchant npc, so for every enchant it will takes the % chance of success of your server (if its ++ of the safe enchant value).<br>"); + replyMSG.append("<center><table width=270><tr><td><font color=LEVEL>Number of enchants:</font></td><td><edit var=\"qbox\" width=80 height=15></td></tr></table><br>"); + replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"Weapon\" action=\"bypass -h npc_"+getObjectId()+"_enchant 5 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Shield\" action=\"bypass -h npc_"+getObjectId()+"_enchant 7 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Helmet\" action=\"bypass -h npc_"+getObjectId()+"_enchant 1 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Chest\" action=\"bypass -h npc_"+getObjectId()+"_enchant 6 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>"); + replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"Leggings\" action=\"bypass -h npc_"+getObjectId()+"_enchant 11 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Gloves\" action=\"bypass -h npc_"+getObjectId()+"_enchant 10 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Boots\" action=\"bypass -h npc_"+getObjectId()+"_enchant 12 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"Necklace\" action=\"bypass -h npc_"+getObjectId()+"_enchant 4 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>"); + replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td><center><button value=\"L. Earring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 9 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"R. Earring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 8 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"L. Ring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 14 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td><center><button value=\"R. Ring\" action=\"bypass -h npc_"+getObjectId()+"_enchant 13 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td></tr></table><br>"); + replyMSG.append("<center><table width=290 border=0 bgcolor=444444><tr><td width=72></td><td width=72><center><button value=\"Shirt\" action=\"bypass -h npc_"+getObjectId()+"_enchant 0 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td width=72><center><button value=\"Belt\" action=\"bypass -h npc_"+getObjectId()+"_enchant 24 $qbox\" width=65 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center></td><td width=72></td></tr></table><br>"); + replyMSG.append("<br><br><center><img src=\"l2ui.squaregray\" width=290 height=1></center><br><center><table width=270><tr><td width=270><center><font color=444444>By Wyatt</color><br></center></td></tr></table></center>"); + replyMSG.append("</body></html>"); + page.setHtml(replyMSG.toString()); + player.sendPacket(page); + } + + private static boolean enchant(L2PcInstance activeChar, int i, int d) throws InterruptedException + { + L2ItemInstance t = activeChar.getInventory().getPaperdollItem(i); + if(t == null) + return false; + L2ItemInstance s = activeChar.getInventory().getItemByItemId(d); + activeChar.setActiveEnchantItem(s); + activeChar.sendPacket(new ChooseInventoryItem(s.getItemId())); + //activeChar.sendPacket(new ExPutEnchantTargetItemResult(7575)); TODO:Target item icon not done. It shows you the last item you enchanted through normal method. + Thread.sleep(1000); + enchantproccess(activeChar, t.getObjectId(), t, d); + return true; + } + + private static void enchantproccess(L2PcInstance activeChar, int _objectId, L2ItemInstance t, int d) + { + if (activeChar == null || _objectId == 0) + return; + + if (!activeChar.isOnline() || activeChar.getClient().isDetached()) + { + activeChar.setActiveEnchantItem(null); + return; + } + + if (activeChar.isProcessingTransaction() || activeChar.isInStoreMode()) + { + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE)); + activeChar.setActiveEnchantItem(null); + return; + } + + L2ItemInstance item = t; + L2ItemInstance scroll = activeChar.getActiveEnchantItem(); + + if (item == null || scroll == null) + { + activeChar.setActiveEnchantItem(null); + return; + } + + EnchantScroll scrollTemplate = EnchantItemTable.getInstance().getEnchantScroll(scroll); + if (scrollTemplate == null) + return; + + synchronized (item) + { + double chance = scrollTemplate.getChance(item, null); + L2Skill enchant4Skill = null; + L2Item it = item.getItem(); + if (item.getOwnerId() != activeChar.getObjectId() || item.isEnchantable() == 0 || chance < 0) + { + activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION); + activeChar.setActiveEnchantItem(null); + activeChar.sendPacket(new EnchantResult(2, 0, 0)); + return; + } + + if (Rnd.get(100) < chance) + { + item.setEnchantLevel(item.getEnchantLevel() + 1); + item.updateDatabase(); + activeChar.sendPacket(new EnchantResult(0, 0, 0)); + int minEnchantAnnounce = item.isArmor() ? 6 : 7; + int maxEnchantAnnounce = item.isArmor() ? 0 : 15; + if (item.getEnchantLevel() == minEnchantAnnounce || item.getEnchantLevel() == maxEnchantAnnounce) + { + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3); + sm.addCharName(activeChar); + sm.addNumber(item.getEnchantLevel()); + sm.addItemName(item); + activeChar.broadcastPacket(sm); + + L2Skill skill = SkillTable.FrequentSkill.FIREWORK.getSkill(); + if (skill != null) + activeChar.broadcastPacket(new MagicSkillUse(activeChar, activeChar, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay())); + } + + if (it instanceof L2Armor && item.getEnchantLevel() == 4 && activeChar.getInventory().getItemByObjectId(item.getObjectId()).isEquipped()) + { + enchant4Skill = ((L2Armor)it).getEnchant4Skill(); + if (enchant4Skill != null) + { + activeChar.addSkill(enchant4Skill, false); + activeChar.sendSkillList(); + } + } + } + else + { + if (scrollTemplate.isSafe()) + { + activeChar.sendPacket(new EnchantResult(5, 0, 0)); + } + else + { + if (item.isEquipped()) + { + if (item.getEnchantLevel() > 0) + { + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED); + sm.addNumber(item.getEnchantLevel()); + sm.addItemName(item); + activeChar.sendPacket(sm); + } + else + { + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED); + sm.addItemName(item); + activeChar.sendPacket(sm); + } + + L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot()); + InventoryUpdate iu = new InventoryUpdate(); + for (L2ItemInstance itm : unequiped) + iu.addModifiedItem(itm); + + activeChar.sendPacket(iu); + activeChar.broadcastUserInfo(); + } + + if (scrollTemplate.isBlessed()) + { + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.BLESSED_ENCHANT_FAILED)); + item.setEnchantLevel(0); + item.updateDatabase(); + activeChar.sendPacket(new EnchantResult(3, 0, 0)); + } + else + { + int crystalId = item.getItem().getCrystalItemId(); + int count = item.getCrystalCount() - (item.getItem().getCrystalCount() + 1) / 2; + if (count < 1) + count = 1; + + L2ItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null); + if (destroyItem == null) + { + Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH); + activeChar.setActiveEnchantItem(null); + activeChar.sendPacket(new EnchantResult(2, 0, 0)); + return; + } + + L2ItemInstance crystals = null; + if (crystalId != 0) + { + crystals = activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem); + + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S); + sm.addItemName(crystals); + sm.addItemNumber(count); + activeChar.sendPacket(sm); + } + + if (!Config.FORCE_INVENTORY_UPDATE) + { + InventoryUpdate iu = new InventoryUpdate(); + if (destroyItem.getCount() == 0) + iu.addRemovedItem(destroyItem); + else + iu.addModifiedItem(destroyItem); + + if (crystals != null) + iu.addItem(crystals); + + activeChar.sendPacket(iu); + } + else + activeChar.sendPacket(new ItemList(activeChar, true)); + L2World world = L2World.getInstance(); + world.removeObject(destroyItem); + if (crystalId == 0) + activeChar.sendPacket(new EnchantResult(4, 0, 0)); + else + activeChar.sendPacket(new EnchantResult(1, crystalId, count)); + } + } + } + activeChar.destroyItemByItemId("Echanter Npc", d, 1, activeChar, true); + StatusUpdate su = new StatusUpdate(activeChar); + su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad()); + activeChar.sendPacket(su); + activeChar.sendPacket(new ItemList(activeChar, false)); + activeChar.broadcastUserInfo(); + activeChar.setActiveEnchantItem(null); + } + } +} \ No newline at end of file Index: java/com/l2jserver/gameserver/model/L2Object.java =================================================================== --- java/com/l2jserver/gameserver/model/L2Object.java (revision 167) +++ java/com/l2jserver/gameserver/model/L2Object.java (working copy) @@ -183,8 +183,8 @@ L2EventNpcInstance(L2Npc), L2WeddingManagerInstance(L2Npc), L2EventMobInstance(L2Npc), - L2BirthdayCakeInstance(L2Npc); - + L2BirthdayCakeInstance(L2Npc), + L2EnchanterInstance(L2Npc); private final InstanceType _parent; private final long _typeL; private final long _typeH; Credits: Wyatt
  13. Wasn't you complaining about people that said to you that you was mr.annonymous?... And the reason, I think you tried to scam a Mod.
  14. Now you should remove your quote... lmao..
  15. Suggestion, change it: public void giveItems(boolean dagger,boolean sagi,boolean mage,boolean duelist,boolean tit,boolean nixas,boolean paladin) with public void giveItems(int class) and then use a switch to check, is cleaner. switch(class) { }
  16. hahah no worries, ty. Update! Added patch for L2jServer H5 Beta, rev core:5639 datapack:9185 ty to valanths1990
  17. O_o... it's already done in my code
  18. Yes, but remains in private. Topic can be locked.
  19. In fact you're right, there is not packet when you select one item from the list, in IL. But it can be done without it. Now yes, but not shared.
  20. @dunot22 ? If you mean if has it implemented an antibot system... yes, captcha. If you are only spaming, please stop it :D Update! Added Fame points for Seven Signs Festival Added Voiced Store Off/On to avoid graphical lag on players with no so good PC. Fixed minor bug in PKHunting event Fixed elegia leather & heavy stats Typo fixes in clan_hall_zones.xml Added different PartyWindow when inside an Event Added option to enable/disable antifeed protection inside events Fixed H5 A Grade RaidBoss weapons stats Fixed H5 S Grade RaidBoss weapons stats Fixed H5 S80 Grade RaidBoss weapons stats Fixed H5 S84 Grade RaidBoss weapons stats Fixed Cursed of Divinity formula Added half kill to monsters
  21. not at all, we're currently testing...
  22. Update V.1.2 ! also corrected an error of interlude patch Now I see that config names should be different but nvm...
  23. Really dunno how it works on interlude but... why to not try something like that. ### Eclipse Workspace Patch 1.0 #P L2jFrozen_GameServer Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java =================================================================== --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java (revision 948) +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestEnchantItem.java (working copy) @@ -76,6 +76,8 @@ }; private int _objectId; + private int counter = 0; + L2ItemInstance itemc = null; @Override protected void readImpl() @@ -544,6 +546,21 @@ { chance = (Integer) aChance; } + + if(counter == 0 || itemc != item) + { + activeChar.sendMessage("There is "+chance+"% chance of success!, please press the button again."); + activeChar.sendPacket(new ItemList(activeChar, true)); + itemc = item; + counter = 1; + return; + } + else if (counter == 1 && itemc == item) + { + counter = 0; + itemc = null; + } + synchronized (item) { if(rndValue < chance)
  24. if you have problems when adapting... post your code and your problem in the correct section here pd: looking for someone with this patch added and working to help me testing one thing, send pm plz
  25. insert the ids inside npcaidata.sql ....
×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock