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

    • ⚔️ DRAGON-NETWORK LEGACY x15 ⚔️ INTERLUDE+ • SUBSTACK • STAGE PROGRESSION 🔥 GRAND OPENING: OCTOBER 2, 2026 🕖 19:00 UTC+2 🌐 https://dragon-network.eu ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ THE LEGACY RETURNS. YOUR STORY BEGINS. The battlefield is calling once again! Dragon-Network returns with LEGACY x15, delivering a unique Interlude+ Substack experience featuring competitive PvP, expanded content, and progressive gameplay. Forge your build. Gather your clan. Conquer your enemies. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚙️ SERVER INFORMATION • Chronicle: Interlude+ • Gameplay: Substack • EXP / SP: x15 • Adena: x10 • Drop / Spoil: x10 • Seal Stones: x10 • Raid Boss Drops: x5 • Epic Drops: x1 • Maximum Level: 85 • Box Limit: 1 Main + 2 Boxes ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚔️ SUBSTACK SYSTEM Create your own playstyle and explore unique class combinations. ✓ Free starting Golkonda Horn ✓ First Stack Sub from level 40 ✓ Additional horns obtainable through gameplay ✓ Custom class and skill adjustments Your build. Your strategy. Your legacy. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🌍 INTERLUDE+ CONTENT Experience the classic world of Lineage II with additional content and expanded progression. ✓ Kamaloka & Labyrinth ✓ Pailaka Quests ✓ Hellbound Island ✓ Isle of Prayer ✓ Improved Pets ✓ S80 Equipment ✓ Attribute System ✓ Siegeable Fortresses Content is introduced progressively through server stages. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏆 PVP & EVENTS Prepare for competitive battles and valuable rewards! ✓ Daily Team vs Team events ✓ Event Coins and exclusive rewards ✓ Epic jewelry reward opportunities ✓ Weekly Olympiad cycles ✓ Castle Sieges ✓ Clan competition Fight for glory. Earn your rewards. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🛡️ FAIR PLAY & QUALITY OF LIFE ✓ DragonGuard Anti-Cheat ✓ Custom Anti-Bot CAPTCHA ✓ No Pay-to-Win philosophy ✓ Improved class balance ✓ Progressive NPC Buffer ✓ 1-hour buffs ✓ Offline Shops ✓ Community Board skill learning ✓ Shift+Click monster drop information ✓ Combo Songs & Dances ✓ Tattoo System ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📅 SERVER ROADMAP OCT 02 — GRAND OPENING OCT 05 — Seven Signs Quest Period OCT 07 — Team vs Team Begins OCT 12 — Olympiad & Seal Validation OCT 17–18 — First Castle Sieges OCT 19 — First Heroes OCT 28 — Stage 2: Dynasty & Attribute Stones ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔥 THE COUNTDOWN HAS BEGUN! Old rivalries will return. New alliances will rise. Legends will be written. Will you be part of the next chapter? ⚔️ DRAGON-NETWORK LEGACY x15 📅 OCTOBER 2, 2026 — 19:00 UTC+2 🌐 OFFICIAL WEBSITE https://dragon-network.eu 📜 SERVER FEATURES https://dragon-network.eu/features 🔧 SEASON IMPROVEMENTS https://dragon-network.eu/whats-new DRAGON-NETWORK — FORGE YOUR LEGACY.
    • Clan: BeMyFrag (BMF) Clan Leader: AresQQ (Ares / PapaSmurf) Type: EU PvP clan, English-speaking (Polish and other EU languages inside) Recruiting: YES — open until launch, target 80–120 active players Where are we playing now? Eigis Odyssey Season 3 — opens 9 October 2026, 8:00 PM. Full server briefing: https://bemyfrag.com/eigis/ How many members? target 80–120 at launch. Which servers have we played? Playing together for over a decade. Last season: The Cult  What we offer: Organised mass PvP and castle sieges every Sunday (Aden/Goddard alternating) TeamSpeak 3 (bmf.ts3.so) + in-client voice for parties DKP ranking with reward codes for active players Fair loot rules and disputes — no drama Maintained server FAQ, so you don’t figure out Eigis alone Multigaming Discord community beyond L2 Clan rules: Be on TeamSpeak for mass PvP and sieges Party up before launch — no solo drifting competitive and casual both welcome Join: https://discord.gg/2UweQ3RYTZ → channel #l2eigis-apply → ask for rights.
  • Topics

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