Jump to content

Matim

Legendary Member
  • Posts

    4,504
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    0%

Everything posted by Matim

  1. Wrong section, it should be posted at Offtopic section. Read latest rules next time before posting.
  2. Wrong section, it should be posted at Offtopic section. Read latest rules next time before posting.
  3. Creating new Npc Instance Hello, someone sent me request via pm, thats why I decided to post this Guide. I will show you, and explain few simple steps about how to create own Npc Instance, how does it work etc. It may be useful for someone who would like to create new kinds of L2 Npc Types. Of course, for single/simple tasks handling, it would be better to make quest bassed Npc instead of new Instance. Hope you know how to compile/use eclipse generaly because I won't explain basic steps here. Guide created with latest Freya clean L2JServer source. 1. Firstly, it would be good to analyze code: L2Npc class at least, available functions etc. 2. Create new class: (com/l2jserver/gameserver/model/actor/instance package) You will have to add "Instance" word at the end of class name Sample: L2TestNpcInstance.java 3. Class body, at begining: package com.l2jserver.gameserver.model.actor.instance; public class L2TestNpcInstance { } 4. Select extender of your new Npc Instance: You will have to select proper extender - superclass. A Java superclass is a class which gives a method or methods to a Java subclass. A Java class may be either a subclass, a superclass, both, or neither. Lets say you want to create some kind of Monster Npc type, so you should choose L2Attackable for example. For educational purposes, we will extend basic Npc Type class - L2Npc (by using extends L2Npc) package com.l2jserver.gameserver.model.actor.instance; import com.l2jserver.gameserver.model.actor.L2Npc; public class L2TestNpcInstance extends L2Npc { } Now you will have to add constructor: package com.l2jserver.gameserver.model.actor.instance; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; public class L2TestNpcInstance extends L2Npc { public L2TestNpcInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } } Even now you would be able to use this Npc Instance (it would work as a standard L2Npc type, nothing changed, nothing new) Its up to you, to choice what exactly this NPC should do, for example handle some kind of event etc. Since you extended L2Npc class, you may use functions/booleans etc from this class. Most important: onSpawn() - actions after NPC ingame spawn onBypassFeedback() - handling html bypass functions showChatWindow - handle showing chat window onAction() - determinate what exactly should happen while clicking at Npc, for example show chat/attack etc doDie() - handle NPC death, for example what should happen after npc death Of course, there are plenty of useful codes (...) simply check L2Npc class. Now, I will show few example, about how to use those things from extended class. 5. Handling NPC spawn: Lets say, we will create npc, which will say something after his spawn, for example "Hello World!" You will have to use and Override onSpawn() function by adding @Override addannotation. And use proper code to broadcast NPC say packet. Take a look at code: package com.l2jserver.gameserver.model.actor.instance; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.network.serverpackets.NpcSay; import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; public class L2TestNpcInstance extends L2Npc { public L2TestNpcInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } @Override public void onSpawn() { super.onSpawn(); // Broadcast new Npc Say Packet this.broadcastPacket(new NpcSay(this.getObjectId(), 0, this.getNpcId(),"Hello World!")); } } 6. Bypass Handling: Its important, when for example you want to handle bypass actions from npc html window. Lets say, you want to add new button in npc chat, and after pressing it, player will receive short message. @Override public void onBypassFeedback(L2PcInstance player, String command) { if (player == null || player.getLastFolkNPC() == null || player.getLastFolkNPC().getObjectId() != this.getObjectId()) { return; } if (command.startsWith("showMessage")) { player.sendMessage("Hello " + player.getName()); } } By adding this code (guess its self explanatory), you may use button bypass with bypass "etiquette" - showMessage You will receive message after pressing button with this bypass (of course, while using this NPC type) Of course, you can easily add new bypasses by using else if (command.startsWith("blabla") 7. Showing Chat Window: First of all, since you extended L2Npc class, you really don't have to create any methods to show npc html window. Why? Because this code already exist in L2Npc class (which is our extender in this sample) But lets say, you would like to modify it a little bit (for example using html generated with java instead of showing htm file from DP) It may be pointless sample, but its just to explain about how does it work. You will have to Override showChatWindow() method. @Override public void showChatWindow(L2PcInstance player, int val) { TextBuilder tb = new TextBuilder(); tb.append("<html><title>Test Npc</title><body><center><br>"); if (player.getLevel() > 60) tb.append("Hello " + player.getName() + "! How are you?"); else tb.append("Sorry " + player.getName() + "! You need level 60 or above!"); NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId()); msg.setHtml(tb.toString()); msg.replace("%objectId%", String.valueOf(this.getObjectId())); player.sendPacket(msg); } While using this sample code, after talking with NPC, there will be window, and If player is level 60 or above, he will see this: And if player is level > 60 8. How to use new Npc Instance: Lets say to made it, and you already compiled it. Now you will have to create new Npc (new npc in database) With proper NPC type, its simple, since our class name is: L2TestNpcInstance so type is L2TestNpc Its like L2Npc, L2Buffer, L2Merchant, L2Teleporter etc. This is just a basic introduction, hope you find it useful. Of course its for beginners. So posts like "Lol, I know it already" or "Nothing new for master of java like me" are pointless.. Thanks, if there is something wrong, leave reply, something could go wrong.
  4. Simply check L2Emu forum, there are guides about how to setup everything.
  5. First and main thing, take a look at GameServer console logs, there should be some kind of info about whats wrong (in most cases) For example wrong protocol, or something else.
  6. You should decide, should olimpiad be disabled in this case? Create something like Olympiad, some kind of manager, which will add/remove new heroes regularly. Based on the number of some kind of points which players might gain (from RaidBosses for example) Those points should be stored in database of course.
  7. I can hardly understand your question. You want just to set Zoombie HP/MP/CP stats to be full? If yes, its really simple, sample: private void setHpMpCpFull(L2PcInstance player) { player.setCurrentHp(player.getMaxHp()); player.setCurrentMp(player.getMaxMp(); player.setCurrentCp(player.getMacCp(); } Correct me if I was wrong.
  8. You can make a way to store it in database, but whats the point ?
  9. "no custom" Means that you are requesting for clean tatoo without any additional stats. Explain your question better, what exactly would you like to add.
  10. Use links from above (...) everything is well explained.
  11. Click - How do I increase the heap size available to Eclipse?
  12. You can change skill type (by editing stats from data/stats/skills) But it would require additional work aswell
  13. You can increase Memory ammount for Eclipse aswell.
  14. And? Rules are clear. You started with calling me wannabe without reason (in fact, I don't really care for this opinion, or even position in staff) So I've got a right also to do it. No idea what does it mean, but what ever.
  15. Wannabe? Haha - cool, something else to add? Yes, with your wannabe brain. Just point out someone else mistake (yours for example) and instantly become attacked. - childishness, really.
  16. Wrong Section, it should be posted at Offtopic section. Locked until someone will move it.
  17. Creating english language thread and then starting using greek, pro and smart move.
  18. @Sido, at least you could remove this "signature"
  19. Thanks to Hellish for his work :)
  20. Hello, since development status of my www.l2ephion.com server is mostly done, and I would like to start advertisement phase soon and my Photoshop skills are not... enough. I would like to request some images/logos/banners/ what ever you guys can do. If someone can do something, would be great. Some info: I just need some random logos/banners/images for advertisement (like with L2Ephion server name etc) Edit by Noble: Unsticked - matims request
  21. Mysterious Elven Ruins Mod: There may be only one party inside at the same time. You can stay there only for ten minutes, after this time your party will be teleported back. 1) Only Party Leader may use teleport button 2) You need party with 5 members at least 3) Each member should be level 82 or above 2. Everything is well described in game (nice tutorial about how does it work etc) 3. If this loction is not empty (another party is inside, there is proper info) If location is not empty, nobody may enter, after 10 minutes, party will be teleported back, and location will be empty again. By default, there are spawned 50 monsters (randomly) and only one has treasure, players goal is to find and kill this "special" monster - they have to do it fast, they have only 10 minutes. They may enter once again, but there will be new, different position of Monsters, also special monster with treasure will be selected again. This mod may be easily modified - with your ideas. ???
  22. This ENGLISH section!
  23. Im not sure about that, but my friend had problems with similar modifications.
  24. Take into consideration that it may induce client problems (such as Errors)
  25. Its reading those classes from core - and its .jar file. To make sure that your imports are correct, compare them with class pathes from core.
×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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