How to add your quests or subsystems to an assembly

Deazer

Head Developer
Staff member

An example of a simple code is in the video. I'll also add custom quests to this section and how to do them with the description.
Be sure to remember that to properly load your jar the name should be *.ext.jar
 
Hi!, I'd like to know how to register a custom ByPassHandler.
I want to be able to call my bypass from <a action="bypass -h custombypass.CustomClass:customMethod">

Thanks!
 
Hi!, I'd like to know how to register a custom ByPassHandler.
I want to be able to call my bypass from <a action="bypass -h custombypass.CustomClass:customMethod">

Thanks!
I already send ALOT of examples, that is last time. Look on code
Bypasses for call this script will look like that. Call
<button width=100 height=18 action="bypass -h scripts_services.MyCustomService:myCustomBypassToHtml" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="MyCustomService">
After we show scripts/services/my_custom_service_page.htm (look at code)
at page my_custom_service_page.htm we have bypass to my_custom_functions
<button width=100 height=18 action="bypass -h scripts_services.MyCustomService:my_custom_functions" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="Make me BlaBlaBla">

Where MyCustomService is class name
myCustomBypassToHtml - method for calling my_custom_service_page.htm
my_custom_functions - method call actions that will change to the player

Also you can call directrly code without showing myCustomBypassToHtml, that is example for replacement at HTML
msg.replace("%item_id%", String.valueOf(Config.MY_CUSTOM_SERVICE_ITEM));
msg.replace("%item_count%", String.valueOf(Config.MY_CUSTOM_SERVICE_PRICE));

This code you can send from any npc or bbs or else, also look how the bypass should look in Community Board at gudes if you call your own service from it

Java:
package services;

import l2.gameserver.Config;
import l2.gameserver.model.Player;
import l2.gameserver.network.l2.components.SystemMsg;
import l2.gameserver.network.l2.s2c.NpcHtmlMessage;
import l2.gameserver.scripts.Functions;
import l2.gameserver.templates.item.ItemTemplate;
import l2.gameserver.utils.ItemFunctions;

public class MyCustomService extends Functions
{
  public void myCustomBypassToHtml()
  {
    Player player = getSelf();
    if(player == null)
      return;

    if(!Config.MY_CUSTOM_SERVICE) // If that is disabled we send service_disabled.htm
    {
      player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_disabled.htm"));
      return;
    }

    NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("scripts/services/my_custom_service_page.htm");
    msg.replace("%item_id%", String.valueOf(Config.MY_CUSTOM_SERVICE_ITEM));
    msg.replace("%item_count%", String.valueOf(Config.MY_CUSTOM_SERVICE_PRICE));
    player.sendPacket(msg);
  }

  public void my_custom_functions()
  {
    Player player = getSelf();
    if(player == null || !CheckPlayerConditions(player)) // Check null and basic condition
      return;

    if(!Config.MY_CUSTOM_SERVICE) // If that is disabled we send service_disabled.htm
    {
      player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_disabled.htm"));
      return;
    }

    if(!player.isInPeaceZone() || !player.getReflection().isDefault()) // If need check at zone peace or not
    {
      player.sendPacket(new NpcHtmlMessage(5).setFile("scripts/services/service_peace_zone.htm"));
      return;
    }

    if(ItemFunctions.getItemCount(player, Config.MY_CUSTOM_SERVICE_ITEM) < Config.MY_CUSTOM_SERVICE_PRICE) // Check and take items
    {
      if(Config.MY_CUSTOM_SERVICE_ITEM == ItemTemplate.ITEM_ID_ADENA)
        player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      else
        player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
      return;
    }

    ItemFunctions.removeItem(player, Config.MY_CUSTOM_SERVICE_ITEM, Config.MY_CUSTOM_SERVICE_PRICE, true);
 
    // HERE IS make any own code and change status or any else
    player.sendMessage(new CustomMessage("my_custom_functions send Bla bla bla", player));
    player.setHairColor(0);
    player.setHairStyle(0);
    player.setFace(0);
    player.setBlaBlaBla(100500);

  }
}
 
Thanks @Deazer , your guides are very usefull.
I have no experience with Java, but with your guide im able to create my own simple custom quests.

Maybe someone can see if there is some issues ? it works, but more experienced people could see issues in the future.

Java:
package services;


import l2.gameserver.Config;
import l2.gameserver.model.Player;
import l2.gameserver.model.instances.NpcInstance;
import l2.gameserver.network.l2.components.SystemMsg;
import l2.gameserver.network.l2.s2c.NpcHtmlMessage;
import l2.gameserver.scripts.Functions;
import l2.gameserver.templates.item.ItemTemplate;
import l2.gameserver.utils.ItemFunctions;
import l2.gameserver.network.l2.s2c.PlaySound;


public class Simplecode extends Functions
{

public void custom_quest_001()
    {

//all req items and rewards
        int start_item_id = 1879; //what item need to have to start the quest (cokes example)
        int in_progress_item_id = 1867; //get this item to change quest state to in progress (animal skin example)
        int bring_item_id = 1872; //items needed to complete quest (animal bone example)
        int bring_item_count = 10; //item needed to complete ammount

        int[] reward_item_ids = {57,57}; //reward item IDs, can be one or multiple, as many as need
        int[] reward_item_counts = {100000, 10}; //quantities

        Player player = getSelf();
               if(player == null)
                   return;

         if  (ItemFunctions.getItemCount(player, start_item_id) < 1 && ItemFunctions.getItemCount(player, in_progress_item_id) < 1) //if dont have any quest items
            {
                player.sendPacket(new NpcHtmlMessage(5).setFile("custom_quests/no_talk.htm"));
                    return;
            }
       else {
             if (ItemFunctions.getItemCount(player, start_item_id) == 1) {  //start state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_1.htm");
                player.sendPacket(msg);
                 player.sendPacket(new PlaySound("ItemSound.quest_accept")); //accept  middle finish itemGet
                ItemFunctions.removeItem(player, start_item_id, 1, true);
                 ItemFunctions.addItem(player, in_progress_item_id, 1, true);
            }

        else if (ItemFunctions.getItemCount(player, in_progress_item_id) == 1 && ItemFunctions.getItemCount(player, bring_item_id) < bring_item_count) { //in progress state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_2.htm");
                player.sendPacket(msg);
                 player.sendPacket(new PlaySound("ItemSound.quest_middle"));
            }

         else if (ItemFunctions.getItemCount(player, in_progress_item_id) == 1 && ItemFunctions.getItemCount(player, bring_item_id) >= bring_item_count) { //quest finish state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_3.htm");
                player.sendPacket(msg);
                player.sendPacket(new PlaySound("ItemSound.quest_finish"));
                ItemFunctions.removeItem(player, in_progress_item_id, 1, true);
                long itemCount = ItemFunctions.getItemCount(player, bring_item_id);
                 ItemFunctions.removeItem(player, bring_item_id, itemCount, true);

            for (int i = 0; i < reward_item_ids.length; i++) {
                ItemFunctions.addItem(player, reward_item_ids[i], reward_item_counts[i], true);
                  }
            }
        }
    }
}


<npc id="40034" name="Santa Girl" title="Merry Christmas!">
<set name="aggroRange" value="0" />
<set name="ai_type" value="CharacterAI" />
<set name="baseAtkRange" value="40" />
<set name="baseCON" value="43" />
<set name="baseCritRate" value="40" />
<set name="baseDEX" value="30" />
<set name="baseHpMax" value="2444.468" />
<set name="baseHpRate" value="1" />
<set name="baseHpReg" value="7.5" />
<set name="baseINT" value="21" />
<set name="baseMAtk" value="780" />
<set name="baseMAtkSpd" value="333" />
<set name="baseMDef" value="382" />
<set name="baseMEN" value="20" />
<set name="baseMpMax" value="1345.8" />
<set name="baseMpReg" value="2.7" />
<set name="basePAtk" value="1303" />
<set name="basePAtkSpd" value="253" />
<set name="basePDef" value="471" />
<set name="baseRunSpd" value="180" />
<set name="baseSTR" value="40" />
<set name="baseShldDef" value="0" />
<set name="baseShldRate" value="0" />
<set name="baseWIT" value="20" />
<set name="baseWalkSpd" value="110" />
<set name="collision_height" value="10" />
<set name="collision_radius" value="6.5" />
<set name="level" value="85" />
<set name="rewardExp" value="0" />
<set name="rewardRp" value="0" />
<set name="rewardSp" value="0" />
<set name="shots" value="NONE" />
<set name="texture" value="" />
<set name="displayId" value="40034"/>
<set name="type" value="Npc" />
<set name="htm_root" value="custom_quests/" />
<skills>
<skill id="4416" level="14" /> <!--Humans-->
</skills>
<attributes>
<defence attribute="fire" value="20" />
<defence attribute="water" value="20" />
<defence attribute="wind" value="20" />
<defence attribute="earth" value="20" />
<defence attribute="holy" value="20" />
<defence attribute="unholy" value="20" />
</attributes>
</npc>

<html>
<title> Santa Girl: </title>
<body>
<center>
Hey adventurer,
isn't it a great day?
<button width=100 height=18 action="bypass -h scripts_services.Simplecode:custom_quest_001" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="Quests"></button><br>
<img src=icon.skill0143 width=32 height=32 align=left>
</center>
</body>
</html>

<html>
<title> Santa Girl: </title>
<body>
<center>
Hello adventurer, please kill gremlins and bring me 3 of their bones!

<img src=icon.skill0141 width=32 height=32 align=left>
</center>
</body>
</html>

=====================================
<html>
<title> Santa Girl: </title>
<body>
<center>
Hey there,
you still have to kills some gremlins.

<img src=icon.skill0143 width=32 height=32 align=left>
</center>
</body>
</html>

=======================================

<html>
<title> Santa Girl: </title>
<body>
<center>
Well done !
Take your reward, and go see another npc.

<img src=icon.skill0144 width=32 height=32 align=left>
</center>
</body>
</html>


 
Last edited:
Trying to learn more about java, is there a way to update this java ext to check:

if (monster killed = required mob by quest){
drop quest item;
}
 
Thanks @Deazer , your guides are very usefull.
I have no experience with Java, but with your guide im able to create my own simple custom quests.

Maybe someone can see if there is some issues ? it works, but more experienced people could see issues in the future.

Java:
package services;


import l2.gameserver.Config;
import l2.gameserver.model.Player;
import l2.gameserver.model.instances.NpcInstance;
import l2.gameserver.network.l2.components.SystemMsg;
import l2.gameserver.network.l2.s2c.NpcHtmlMessage;
import l2.gameserver.scripts.Functions;
import l2.gameserver.templates.item.ItemTemplate;
import l2.gameserver.utils.ItemFunctions;
import l2.gameserver.network.l2.s2c.PlaySound;


public class Simplecode extends Functions
{

public void custom_quest_001()
    {

//all req items and rewards
        int start_item_id = 1879; //what item need to have to start the quest (cokes example)
        int in_progress_item_id = 1867; //get this item to change quest state to in progress (animal skin example)
        int bring_item_id = 1872; //items needed to complete quest (animal bone example)
        int bring_item_count = 10; //item needed to complete ammount

        int[] reward_item_ids = {57,57}; //reward item IDs, can be one or multiple, as many as need
        int[] reward_item_counts = {100000, 10}; //quantities

        Player player = getSelf();
               if(player == null)
                   return;

         if  (ItemFunctions.getItemCount(player, start_item_id) < 1 && ItemFunctions.getItemCount(player, in_progress_item_id) < 1) //if dont have any quest items
            {
                player.sendPacket(new NpcHtmlMessage(5).setFile("custom_quests/no_talk.htm"));
                    return;
            }
       else {
             if (ItemFunctions.getItemCount(player, start_item_id) == 1) {  //start state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_1.htm");
                player.sendPacket(msg);
                 player.sendPacket(new PlaySound("ItemSound.quest_accept")); //accept  middle finish itemGet
                ItemFunctions.removeItem(player, start_item_id, 1, true);
                 ItemFunctions.addItem(player, in_progress_item_id, 1, true);
            }

        else if (ItemFunctions.getItemCount(player, in_progress_item_id) == 1 && ItemFunctions.getItemCount(player, bring_item_id) < bring_item_count) { //in progress state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_2.htm");
                player.sendPacket(msg);
                 player.sendPacket(new PlaySound("ItemSound.quest_middle"));
            }

         else if (ItemFunctions.getItemCount(player, in_progress_item_id) == 1 && ItemFunctions.getItemCount(player, bring_item_id) >= bring_item_count) { //quest finish state
                NpcHtmlMessage msg = new NpcHtmlMessage(5).setFile("custom_quests/quest_001_3.htm");
                player.sendPacket(msg);
                player.sendPacket(new PlaySound("ItemSound.quest_finish"));
                ItemFunctions.removeItem(player, in_progress_item_id, 1, true);
                long itemCount = ItemFunctions.getItemCount(player, bring_item_id);
                 ItemFunctions.removeItem(player, bring_item_id, itemCount, true);

            for (int i = 0; i < reward_item_ids.length; i++) {
                ItemFunctions.addItem(player, reward_item_ids[i], reward_item_counts[i], true);
                  }
            }
        }
    }
}


<npc id="40034" name="Santa Girl" title="Merry Christmas!">
<set name="aggroRange" value="0" />
<set name="ai_type" value="CharacterAI" />
<set name="baseAtkRange" value="40" />
<set name="baseCON" value="43" />
<set name="baseCritRate" value="40" />
<set name="baseDEX" value="30" />
<set name="baseHpMax" value="2444.468" />
<set name="baseHpRate" value="1" />
<set name="baseHpReg" value="7.5" />
<set name="baseINT" value="21" />
<set name="baseMAtk" value="780" />
<set name="baseMAtkSpd" value="333" />
<set name="baseMDef" value="382" />
<set name="baseMEN" value="20" />
<set name="baseMpMax" value="1345.8" />
<set name="baseMpReg" value="2.7" />
<set name="basePAtk" value="1303" />
<set name="basePAtkSpd" value="253" />
<set name="basePDef" value="471" />
<set name="baseRunSpd" value="180" />
<set name="baseSTR" value="40" />
<set name="baseShldDef" value="0" />
<set name="baseShldRate" value="0" />
<set name="baseWIT" value="20" />
<set name="baseWalkSpd" value="110" />
<set name="collision_height" value="10" />
<set name="collision_radius" value="6.5" />
<set name="level" value="85" />
<set name="rewardExp" value="0" />
<set name="rewardRp" value="0" />
<set name="rewardSp" value="0" />
<set name="shots" value="NONE" />
<set name="texture" value="" />
<set name="displayId" value="40034"/>
<set name="type" value="Npc" />
<set name="htm_root" value="custom_quests/" />
<skills>
<skill id="4416" level="14" /> <!--Humans-->
</skills>
<attributes>
<defence attribute="fire" value="20" />
<defence attribute="water" value="20" />
<defence attribute="wind" value="20" />
<defence attribute="earth" value="20" />
<defence attribute="holy" value="20" />
<defence attribute="unholy" value="20" />
</attributes>
</npc>

<html>
<title> Santa Girl: </title>
<body>
<center>
Hey adventurer,
isn't it a great day?
<button width=100 height=18 action="bypass -h scripts_services.Simplecode:custom_quest_001" back="L2UI_CH3.bigbutton2_down" fore="L2UI_CH3.bigbutton2" value="Quests"></button><br>
<img src=icon.skill0143 width=32 height=32 align=left>
</center>
</body>
</html>

<html>
<title> Santa Girl: </title>
<body>
<center>
Hello adventurer, please kill gremlins and bring me 3 of their bones!

<img src=icon.skill0141 width=32 height=32 align=left>
</center>
</body>
</html>

=====================================
<html>
<title> Santa Girl: </title>
<body>
<center>
Hey there,
you still have to kills some gremlins.

<img src=icon.skill0143 width=32 height=32 align=left>
</center>
</body>
</html>

=======================================

<html>
<title> Santa Girl: </title>
<body>
<center>
Well done !
Take your reward, and go see another npc.

<img src=icon.skill0144 width=32 height=32 align=left>
</center>
</body>
</html>


that is trash. Soon I will make a guide about quests and basic AI.
 
Back
Top