Jump to content

Question

Posted

Kalhspera paidia exw ena provlima me to instance mpenw kanonika to timer doulevi mia xara alla ta mobs den kanoun spawn kai otan spawnaro to last rb kai to skotono teleiwnei to instance opote den nomizw na exei kapio la8os edw kai to code

package net.sf.l2j.gameserver.instances.Tsarka;

import net.sf.l2j.gameserver.instancemanager.InstanceManager;
import net.sf.l2j.gameserver.instancemanager.InstanceManager.InstanceWorld;
import net.sf.l2j.gameserver.model.L2Party;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.L2Summon;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

public class Tsarka extends Quest
{
//NPCs
private static int Kourampies = 96012;
private static int EXIT_TELEPORTER = 90013;

//BOSSES
private static final int[] BOSSES = {95602,95622,95623,95624,95644};

//final bosses
private static final int[] GRAND_BOSSES = {95634,95117};

//MOBS
private static final int[] MOBS   = {22528,95132,22526,22363,21395,95107};

private static String qn = "Tsarka";
private static final int INSTANCEID = 2001;

//REQUIREMENTS
private static boolean debug = false;
private static int levelReq = 86;
private static int pvpReq = 100;
private static int fameReq = 0;
private static int pkReq = 0;


private class teleCoord {int instanceId; int x; int y; int z;}

public class TsarkaWorld extends InstanceWorld
{
public TsarkaWorld()
{
	InstanceManager.getInstance().super();
}
}

public Tsarka(int questId, String name, String descr)
{
	super(questId, name, descr);
	
	addStartNpc(Kourampies);
	addTalkId(Kourampies);
	addTalkId(EXIT_TELEPORTER);
	
	for (int boss : BOSSES)
		addKillId(boss);
	
	for (int mob : MOBS)
		addKillId(mob);
	
	for (int mob : GRAND_BOSSES)
		addKillId(mob);
}

public static void main(String[] args)
{
	new Tsarka(-1, qn, "instances");
}

private boolean checkConditions(L2PcInstance player, boolean single)
{
	if (debug || player.isGM())
		return true;
	else
	{
		final L2Party party = player.getParty();
		
		if (!single && (party == null || party.getMemberCount() < 4 || party.getMemberCount() > 7))
		{
			player.sendMessage("This is a 4-7 player party instance, so you must have a party of 4-7 people");
			return false;
		}
		if (!single && party.getPartyLeaderOID() != player.getObjectId())
		{
			player.sendPacket(new SystemMessage(2185));
			return false;
		}
		
		if (!single)
		{
			/*if (!checkIPs(party))
				return false;*/
			
			boolean canEnter = true;
			
			for (L2PcInstance ptm : party.getPartyMembers())
			{
				if (ptm == null) return false;
				
				if (ptm.getLevel() < levelReq)
				{
					ptm.sendMessage("You must be level "+levelReq+" to enter this instance");
					canEnter = false;
				}
				else if (ptm.getPvpKills() < pvpReq)
				{
					ptm.sendMessage("You must have "+pvpReq+" PvPs to enter this instance");
					canEnter = false;
				}
				else if (ptm.getPvpKills() < pkReq)
				{
					ptm.sendMessage("You must have "+pkReq+" PKs to enter this instance");
					canEnter = false;
				}
				else if (ptm.getPvpKills() < fameReq)
				{
					ptm.sendMessage("You must have "+fameReq+" fame to enter this instance");
					canEnter = false;
				}
				else if (ptm.getPvpFlag() != 0 || ptm.getKarma() > 0)
				{
					ptm.sendMessage("You can't enter the instance while in PVP mode or have karma");
					canEnter = false;
				}
				else if (ptm.isInFunEvent())
				{
					ptm.sendMessage("You can't enter the instance while in an event");
					canEnter = false;
				}
				else if (ptm.isInDuel() || ptm.isInOlympiadMode() || Olympiad.getInstance().isRegistered(ptm))
				{
					ptm.sendMessage("You can't enter the instance while in duel/oly");
					canEnter = false;
				}
				else if (System.currentTimeMillis() < InstanceManager.getInstance().getInstanceTime(ptm.getAccountName(), INSTANCEID))
				{
					ptm.sendMessage("You can only enter this instance once every day, wait until the next 12AM");
					canEnter = false;
				}
				else if (!ptm.isInsideRadius(player, 500, true, false))
				{
					ptm.sendMessage("You're too far away from your party leader");
					player.sendMessage("One of your party members is too far away");
					canEnter = false;
				}
				else
				{
					final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
					
					if (world != null)
					{
						ptm.sendMessage("You can't enter because you have entered into another instance that hasn't expired yet, try waiting 5 min");
						canEnter = false;
					}
				}
				
				if (!canEnter)
				{
					ptm.sendMessage("You're preventing your party from entering an instance");
					if (ptm != player)
						player.sendMessage(ptm.getName()+" is preventing you from entering the instance");
					return false;
				}
			}
		}
		else
		{
			if (player.getLevel() < levelReq)
			{
				player.sendMessage("You must be level "+levelReq+" to enter this instance");
				return false;
			}
			else if (player.getPvpKills() < pvpReq)
			{
				player.sendMessage("You must have "+pvpReq+" PvPs to enter this instance");
				return false;
			}
			else if (player.getPvpFlag() != 0 || player.getKarma() > 0)
			{
				player.sendMessage("You can't enter the instance while in PVP mode or have karma");
				return false;
			}
			else if (player.isInFunEvent())
			{
				player.sendMessage("You can't enter the instance while in an event");
				return false;
			}
			else if (player.isInDuel() || player.isInOlympiadMode() || Olympiad.getInstance().isRegistered(player))
			{
				player.sendMessage("You can't enter the instance while in duel/oly");
				return false;
			}
		}
		
		return true;
	}
}

private void teleportplayer(L2PcInstance player, teleCoord teleto)
{
	player.setInstanceId(teleto.instanceId);
	player.teleToLocation(teleto.x, teleto.y, teleto.z);
	L2Summon pet = player.getPet();
	if (pet != null)
	{
		pet.setInstanceId(teleto.instanceId);
		pet.teleToLocation(teleto.x, teleto.y, teleto.z);
	}
}

protected int enterInstance(L2PcInstance player, String template, teleCoord teleto)
{
	int instanceId = 0;
	
	//check for existing instances for this player
	InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
	//existing instance
	if (world != null)
	{
		if (world.templateId != INSTANCEID)
		{
			player.sendPacket(new SystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
			return 0;
		}
		
		if (!checkConditions(player, true))
			return 0;
		
		teleto.instanceId = world.instanceId;
		teleportplayer(player,teleto);
		return instanceId;
	}
	else  //New instance
	{
		if (!checkConditions(player, false))
			return 0;
		
		instanceId = InstanceManager.getInstance().createDynamicInstance(template);
		world = new TsarkaWorld();
		world.instanceId = instanceId;
		world.templateId = INSTANCEID;
		InstanceManager.getInstance().addWorld(world);
		_log.info("Tsarka: new " + template + " Instance: " + instanceId + " created by player: " + player.getName());
		
		// teleport players
		teleto.instanceId = instanceId;
		
		L2Party party = player.getParty();
		
		if (party == null)
		{
			if (!player.isGM())
				return 0;
			
			// this can happen only if debug is true
			InstanceManager.getInstance().setInstanceTime(player.getAccountName(), INSTANCEID, getNextInstanceTime(TWODAYS));
			world.allowed.add(player.getObjectId());
			auditInstances(player, template, instanceId);
			teleportplayer(player,teleto);
		}
		else
		{
			for (L2PcInstance partyMember : party.getPartyMembers())
			{
				partyMember.sendMessage("You have entered the Dragon Valley Caves");
				InstanceManager.getInstance().setInstanceTime(partyMember.getAccountName(), INSTANCEID, getNextInstanceTime(TWODAYS));
				world.allowed.add(partyMember.getObjectId());
				auditInstances(partyMember, template, instanceId);
				teleportplayer(partyMember,teleto);
			}
			
			spawnExitGK((TsarkaWorld) world, player);
		}
		
		return instanceId;
	}
	
}

protected void exitInstance(L2PcInstance player, teleCoord tele)
{
	player.setInstanceId(0);
	player.teleToLocation(tele.x, tele.y, tele.z);
	
	L2Summon pet = player.getPet();
	if (pet != null)
	{
		pet.setInstanceId(0);
		pet.teleToLocation(tele.x, tele.y, tele.z);
	}
}

@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
	final int npcId = npc.getNpcId();
	
	QuestState st = player.getQuestState(qn);
	
	if (st == null)
		st = newQuestState(player);
	
	if (npcId == Kourampies)
	{
		teleCoord teleto = new teleCoord();
		teleto.x = 131175;
		teleto.y = 114415;
		teleto.z = -3715;
		enterInstance(player, "Tsarka.xml", teleto);
	}
	else if (npcId == EXIT_TELEPORTER)
	{
		final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
		
		if (world == null || !(world instanceof TsarkaWorld))
			return null;
		
		teleCoord teleto = new teleCoord();
		teleto.x = -82993;
		teleto.y = 150860;
		teleto.z = -3129;
		
		if (player.getParty() == null)
		{
			exitInstance(player, teleto);
			player.sendPacket(new ExShowScreenMessage("You have completed the Tsarka instance", 6000));
		}
		else
		{
			for (L2PcInstance ptm : player.getParty().getPartyMembers())
			{
				exitInstance(ptm, teleto);
				player.sendPacket(new ExShowScreenMessage("You have completed the Tsarka instance", 6000));
			}
		}
		
		st.exitQuest(true);
	}
	
	return null;
}
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
{
	return null;
}
public void spawnExitGK(TsarkaWorld world, L2PcInstance player)
{
	addSpawn(EXIT_TELEPORTER, 153073, 122107, -3805, 0, false, 0, false, world.instanceId);
}
}

1 answer to this question

Recommended Posts

Guest
This topic is now closed to further replies.


  • Posts

    • Our sales are ongoing. Bump. 02 July 2025 Telegram: ContactDiscordAccS
    • Our sales are ongoing. Bump. 02 July 2025 Telegram: ContactDiscordAccS
    • just with this extender that I have shared it is not possible to start with c4 client, you have to make some changes to the extender and it works with c4 client perfectly. regarding the updates in this last revision   🔹dll is not packaged with vmprotect   New custom zone types have been added: 🔹 NO_NOBLESS begin MinX=84638 MaxX=92616 MinY=-87170 MaxY=-82018 MinZ=-6000 MaxZ=0 Type=NO_NOBLESS KickOutPos=83007/148057/-3464 end   ▶️ This zone checks if the character is noble. If it does not meet the condition, it will be automatically kicked to the indicated position (KickOutPos). 🔹 CUSTOM_SPAWN_ZONE begin MinX=77275 MaxX=85704 MinY=10122 MaxY=18066 MinZ=-8000 MaxZ=5000 Type=CUSTOM_SPAWN_ZONE OutPos=83007/148057/-3464 Spawns={{82984/18066/-5256}};{{79275/15147/-5248}};{{82922/14263/-5256}};{{83704/10122/-5288}} end ▶️ This zone allows characters, upon death, to respawn with full buff, CP, HP and MP if they press “Fixed”. They will only be able to revive in one of the positions defined in Spawns. 🔧 Both zones are fully configurable from territorydata.txt 🔧 Development Repository (SVN) GX-EXT supports open, collaborative, and professional development. That’s why we provide access to our public SVN repository where you can:   ✅ Compile your own version of the project ✅ Optimize and extend its features ✅ Learn from real production-quality source code   🔒 Delayed access: The repository is always 2 months behind the latest commercial release to prevent unauthorized reselling.   🔗 SVN URL: https://svn.l2servers.com.ar/!/#GX-EXT_INTERLUDE Username: gx Password: gx   You can use tools like TortoiseSVN to download and work with the code.
    • Could you tell me what changed in this update?   more one question: Is it possible to log in through the c4 client instead of interlude? That would be great  
    • ➡ Discount for your purchase: JULY2025 (11% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • 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