[How to]Create custom Instance

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
METALLAS
Posts: 19
Joined: Thu Dec 27, 2007 9:22 am

[How to]Create custom Instance

Post by METALLAS »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:
Hi,
I would like to ask you how its possible to create a custom instance ?I created an xxxx.xml file as the other instances and i added it into instancemanager.xml but it don't work.!
burrito
Posts: 276
Joined: Wed Apr 15, 2009 6:41 am

Re: [How to]Create custom Instance

Post by burrito »

you didnt show your revision numbers.... but this should help viewtopic.php?f=13&t=12909&hilit=solo+instance+event, some things like the sql files are outdated though (we use different columns now) but ya, read it :)
User avatar
LasTravel
Posts: 888
Joined: Tue Jan 05, 2010 12:08 am
Location: Spain

Re: [How to]Create custom Instance

Post by LasTravel »

What you mean with custom instance? You can create any xml but what you want? Instance script or what?
BUDU_KRATOK
Posts: 51
Joined: Sat Apr 10, 2010 8:13 am
Location: Russia
Contact:

Re: [How to]Create custom Instance

Post by BUDU_KRATOK »

H1 all!
How to create instance-zone with no time limit? And limited this instance-zone? P.ex. trade instance a-la Giran Marketplace from demo instance, but only in Giran Town Zone.

Just spawn doors it's not correct solution :D


Added: No time limit is <activityTime val="0" /> and <emptyDestroyTime val="0" /> ? But how limited area of instance?
And how create npc who will teleport to this instance?
User avatar
TeNaCiOuS
Posts: 10
Joined: Mon May 23, 2011 12:17 pm
Location: Chile

Re: [How to]Create custom Instance

Post by TeNaCiOuS »

how i can make a instance farm zone or level up zone, without time limit, and npc teleport to instance?
burrito
Posts: 276
Joined: Wed Apr 15, 2009 6:41 am

Re: [How to]Create custom Instance

Post by burrito »

burrito wrote:you didnt show your revision numbers.... but this should help viewtopic.php?f=13&t=12909&hilit=solo+instance+event, some things like the sql files are outdated though (we use different columns now) but ya, read it :)
the link in my previous post can be used to learn what you need to do, make the xml for the instance have no time limit as talked about in the above post, and then put all the spawns in the xml for your farmzone. The link shows a code to port someone to an instance, like so

Code: Select all

        player.setInstanceId(instanceId);            player.teleToLocation(x,y,z);
The instance must already exist though.
User avatar
TeNaCiOuS
Posts: 10
Joined: Mon May 23, 2011 12:17 pm
Location: Chile

Re: [How to]Create custom Instance

Post by TeNaCiOuS »

ty for reply, i don't know how create instance global, auto create on server load, and enter every people like another world, respanwn on die into instance, respawn on soe into instance.

i modify the xml, but i need info of the .py
User avatar
TeNaCiOuS
Posts: 10
Joined: Mon May 23, 2011 12:17 pm
Location: Chile

Re: [How to]Create custom Instance

Post by TeNaCiOuS »

I was able to modify the "rose instance" and make my farm area, but every time I create an instance dynamic (id: 300000 +)

How I can do to make the instance is global for all, with the id 200 fixed?
Would I could help with the function "enterInstance (self, player, template, teleto)"?

Code: Select all

 from java.lang                                                 import Systemfrom java.sql                                                  import Connectionfrom java.sql                                                  import PreparedStatementfrom java.sql                                                  import ResultSetfrom java.util.logging                                         import Levelfrom java.util.logging                                         import Logger from com.l2jserver                                             import L2DatabaseFactoryfrom com.l2jserver.gameserver.instancemanager                  import InstanceManagerfrom com.l2jserver.gameserver.instancemanager.InstanceManager  import InstanceWorldfrom com.l2jserver.gameserver.model                            import L2ItemInstancefrom com.l2jserver.gameserver.model                            import L2Objectfrom com.l2jserver.gameserver.model                            import L2Worldfrom com.l2jserver.gameserver.model.actor                      import L2Characterfrom com.l2jserver.gameserver.model.actor                      import L2Summonfrom com.l2jserver.gameserver.model.entity                     import Instancefrom com.l2jserver.gameserver.model.itemcontainer              import PcInventoryfrom com.l2jserver.gameserver.model.quest                      import Statefrom com.l2jserver.gameserver.model.quest                      import QuestStatefrom com.l2jserver.gameserver.model.quest.jython               import QuestJython as JQuestfrom com.l2jserver.gameserver.network.serverpackets            import CreatureSayfrom com.l2jserver.gameserver.network.serverpackets            import InventoryUpdatefrom com.l2jserver.gameserver.network.serverpackets            import MagicSkillUsefrom com.l2jserver.gameserver.network.serverpackets            import SystemMessagefrom com.l2jserver.gameserver.network.serverpackets            import ExShowScreenMessagefrom com.l2jserver.gameserver.network.serverpackets            import Earthquakefrom com.l2jserver.gameserver.network                          import SystemMessageIdfrom com.l2jserver.gameserver.util                             import Utilfrom com.l2jserver.util                                        import Rnd qn = "Farmeo1" #CondicionesMINLVL  = 83KEYS_COUNT  = 10 #NPCsGK  = 200010GK2 = 200003PORTERO = 200011 #ItemsCOIN_ID = 900003 #Gold Coins xTsKEY_ID  = 900004 #Vote Coins xTs #Drop CountCOINS_MAGE  = 1000COINS_GUARD = 2000COINS_BOSS  = 2000 #MonstersMAGE    = 220001GUARD   = 220002BOSS    = 220003 #Instance IdINSTANCEID = 200 # HTML inicialInitialHtml     = "1.htm" print "importando instancia: Farmeo1      OK" class PyObject:    pass def checkConditions(player, new):    st = player.getQuestState(qn)    reentertime = InstanceManager.getInstance().getInstanceTime(player.getObjectId(), INSTANCEID);    party = player.getParty()    if not player.getLevel() >= MINLVL:        player.sendPacket(SystemMessage.sendString("You must be level " + str(MINLVL) + " or higher to enter."))        return False    else:        return True def teleportplayer(self,player,teleto):    player.setInstanceId(teleto.instanceId)    player.teleToLocation(teleto.x, teleto.y, teleto.z)    pet = player.getPet()    if pet != None :        pet.setInstanceId(teleto.instanceId)        pet.teleToLocation(teleto.x, teleto.y, teleto.z)    return  def enterInstance(self,player,template,teleto):    instanceId = 0    party = player.getParty()    if party :        for partyMember in party.getPartyMembers().toArray():            st = partyMember.getQuestState(qn)            if not st : st = self.newQuestState(partyMember)            if partyMember.getInstanceId()!=0:                instanceId = partyMember.getInstanceId()    else :        if player.getInstanceId()!=0:            instanceId = player.getInstanceId()    if instanceId != 0:        if not checkConditions(player,False):            return 0        foundworld = False        for worldid in self.world_ids:            if worldid == instanceId:                foundworld = True        if not foundworld:            player.sendPacket(SystemMessage.sendString("You have entered another zone, therefore you cannot enter this one."))            return 0        teleto.instanceId = instanceId        teleportplayer(self,player,teleto)        return instanceId    else:        if not checkConditions(player,True):            return 0        instanceId = InstanceManager.getInstance().createDynamicInstance(template)        if not instanceId in self.world_ids:            world = PyObject()            world.rewarded=[]            world.instanceId = instanceId            world.templateId = INSTANCEID            self.worlds[instanceId]=world            self.world_ids.append(instanceId)            print "Instance Farmeo1.xml Started: " +str(instanceId) + " created by " + str(player.getName())        st = player.getQuestState(qn)        teleto.instanceId = instanceId        teleportplayer(self,player,teleto)        return instanceId    return instanceId def exitInstance(player,tele):    player.setInstanceId(0)    player.teleToLocation(tele.x, tele.y, tele.z)    pet = player.getPet()    if pet != None :        pet.setInstanceId(0)        pet.teleToLocation(tele.x, tele.y, tele.z) class Farmeo1(JQuest):    def __init__(self,id,name,descr):        JQuest.__init__(self,id,name,descr)        self.worlds = {}        self.world_ids = []     def onTalk (self,npc,player):        st = player.getQuestState(qn)        npcId = npc.getNpcId()        if npcId == GK :            tele = PyObject()            tele.x = 145136            tele.y = 147270            tele.z = -12116            enterInstance(self, player, "Farmeo1.xml", tele)        if npcId == GK2 :            tele = PyObject()            tele.x = 147450            tele.y = 26012            tele.z = -2015            exitInstance(player,tele)        return     def onKill(self,npc,player,isPet):        st = player.getQuestState(qn)        npcId = npc.getNpcId()        if npcId == MAGE :            if npc.getInstanceId() in self.worlds:                world = self.worlds[npc.getInstanceId()]                st.giveItems(COIN_ID,COINS_MAGE)         elif npcId == GUARD :            if npc.getInstanceId() in self.worlds:                world = self.worlds[npc.getInstanceId()]                st.giveItems(COIN_ID,COINS_GUARD)        elif npcId == BOSS :            if npc.getInstanceId() in self.worlds:                world = self.worlds[npc.getInstanceId()]                st.playSound("ItemSound.quest_middle")                st.giveItems(COIN_ID,COINS_BOSS)        return QUEST = Farmeo1(-1, qn, "Farmeo1")QUEST.addStartNpc(GK)QUEST.addTalkId(GK)QUEST.addTalkId(PORTERO) QUEST.addKillId(MAGE)QUEST.addKillId(GUARD)QUEST.addKillId(BOSS)
HorridoJoho
L2j Senior Developer
L2j Senior Developer
Posts: 795
Joined: Sun Aug 14, 2005 11:27 am

Re: [How to]Create custom Instance

Post by HorridoJoho »

I highly recommend using java for an instance script.

You want an instance which is only once there? and all players can go in there and see each other?
What you can do, is to create the instance when loading the script.

Here is an example for this. You have to work through the few TODO's in the code. Also relocate the class into a, for you, meaningfull package.

Code: Select all

 /* * Copyright (C) 2004-2013 L2J DataPack *  * This file is part of L2J DataPack. *  * L2J DataPack 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. *  * L2J DataPack 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/>. */ import com.l2jserver.gameserver.instancemanager.InstanceManager;import com.l2jserver.gameserver.model.Location;import com.l2jserver.gameserver.model.actor.L2Npc;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;import com.l2jserver.gameserver.model.entity.Instance;import com.l2jserver.gameserver.model.interfaces.IPositionable;import com.l2jserver.gameserver.scripting.scriptengine.impl.L2Script; /** * @author FBIagent */public final class GlobalInstance extends L2Script{    // TODO: Put correct npc to teleport into instance    private static final int _ENTER_NPC_ID = 0;    // TODO: Put correct npc to teleport out of instance    private static final int _LEAVE_NPC_ID = 1;    // TODO: Put correct instance xml template fila name    private static final String _INSTANCE_TEMPLATE_FILE = "";    // TODO: Put your instance name    private static final String _INSTANCE_NAME = "GlobalInstance";    // TODO: Fill destroy eject location when script is reloaded(x,y,z,heading)    private static final Location _DESTROY_EJECT_LOCATION = new Location(0, 0, 0, 0);    // TODO: Fill instance enter position(x,y,z,heading)    private static final IPositionable _ENTER_LOCATION = new Location(0, 0, 0, 0);        private final Instance _instance;        public static void main(String[] args)    {        GlobalInstance globalInstance = new GlobalInstance();                // enter npc        globalInstance.addFirstTalkId(_ENTER_NPC_ID);        globalInstance.addStartNpc(_ENTER_NPC_ID);        globalInstance.addTalkId(_ENTER_NPC_ID);                // leave npc        globalInstance.addFirstTalkId(_LEAVE_NPC_ID);        globalInstance.addTalkId(_LEAVE_NPC_ID);    }        private GlobalInstance()    {        super(_INSTANCE_NAME, "");        int instanceId = InstanceManager.getInstance().createDynamicInstance(_INSTANCE_TEMPLATE_FILE);        _instance = InstanceManager.getInstance().getInstance(instanceId);        _instance.setSpawnLoc(_DESTROY_EJECT_LOCATION);    }        @Override    public boolean unload()    {        _log.info(_INSTANCE_NAME + ": Destroying duo to script unloading.");        InstanceManager.getInstance().destroyInstance(_instance.getId());        return super.unload();    }        @Override    public String onFirstTalk(L2Npc npc, L2PcInstance player)    {        if (npc == null)        {            return null;        }                // TODO: Create "enter_first_talk.html" and "leave_first_talk.html" in instance script folder with bypass "bypass -h npc_%objectId%_Quest GlobalInstance"        switch (npc.getId())        {            case _ENTER_NPC_ID:                return "enter_first_talk.html";            case _LEAVE_NPC_ID:                return "leave_first_talk.html";            default:                return null;        }    }        @Override    public String onTalk(L2Npc npc, L2PcInstance talker)    {        if (npc == null)        {            return null;        }                switch (npc.getId())        {            case _ENTER_NPC_ID:                // TODO: Create "enter_talk.html" in instance script folder with bypass "bypass -h Quest GlobalInstance enter"                return "enter_talk.html";            case _LEAVE_NPC_ID:                // TODO: Create "leave_talk.html" in instance script folder with bypass "bypass -h Quest GlobalInstance leave"                return "leave_talk.html";            default:                return null;        }    }        @Override    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)    {        if (npc == null)        {            return null;        }                switch (npc.getId())        {            case _ENTER_NPC_ID:                if ("enter".equals(event))                {                    Location leaveLoc = player.getLocation();                    player.getQuestState(_INSTANCE_NAME).set("leave_loc", leaveLoc.getX() + ";" + leaveLoc.getY() + ";" + leaveLoc.getZ() + ";" + leaveLoc.getHeading() + ";" + leaveLoc.getInstanceId());                    // this is triggered when player clicks on the bypass on "enter_talk.html"                    player.teleToLocation(_ENTER_LOCATION.getX(), _ENTER_LOCATION.getY(), _ENTER_LOCATION.getZ(), _ENTER_LOCATION.getHeading(), _instance.getId());                }                break;            case _LEAVE_NPC_ID:                if ("leave".equals(event))                {                    // this is triggered when player clicks on the bypass on "leave_talk.html"                    if (player.getInstanceId() == _instance.getId())                    {                        String[] leaveLoc = player.getQuestState(_INSTANCE_NAME).get("leave_loc").split(";");                        player.teleToLocation(Integer.parseInt(leaveLoc[0]), Integer.parseInt(leaveLoc[1]), Integer.parseInt(leaveLoc[2]), Integer.parseInt(leaveLoc[3]), Integer.parseInt(leaveLoc[4]));                    }                }                break;        }                return null;    }}  
Post Reply