New constructors, functions and use of parameters for instances.

This commit is contained in:
MobiusDev 2018-04-29 20:35:06 +00:00
parent 0e496c0519
commit a12296a16b
60 changed files with 1380 additions and 1421 deletions

View File

@ -4,6 +4,10 @@
<allowSummon val="false" />
<emptyDestroyTime val="900" />
<exitPoint x="-248717" y="250260" z="4337" />
<reenter additionStyle="ON_FINISH" >
<reset day="Wednesday" hour="6" minute="30" />
<reset day="Saturday" hour="6" minute="30" />
</reenter>
<doorlist>
<door id="12240001" />
<door id="12240002" />

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<instance id="110" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/instance.xsd">
<activityTime val="130" />
<allowSummon val="false" />
<emptyDestroyTime val="900" />
<exitPoint x="-248717" y="250260" z="4337" />
<reenter additionStyle="ON_FINISH" >
<reset day="Wednesday" hour="6" minute="30" />
<reset day="Saturday" hour="6" minute="30" />
</reenter>
<doorlist>
<door id="12240001" />
<door id="12240002" />
<door id="12240003" />
<door id="12240004" />
<door id="12240005" />
<door id="12240006" />
<door id="12240007" />
<door id="12240008" />
<door id="12240009" />
<door id="12240010" />
<door id="12240011" />
<door id="12240012" />
<door id="12240013" />
<door id="12240014" />
<door id="12240015" />
<door id="12240016" />
<door id="12240017" />
<door id="12240018" />
<door id="12240019" />
<door id="12240020" />
<door id="12240021" />
<door id="12240022" />
<door id="12240023" />
<door id="12240024" />
<door id="12240025" />
<door id="12240026" />
<door id="12240027" />
<door id="12240028" />
<door id="12240029" />
<door id="12240030" />
<door id="12240031" />
</doorlist>
</instance>

View File

@ -1,4 +1,4 @@
<html><body>Jinia:<br>
Be careful. Should anything happen, we'll try to help you.<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle enterEasy">"Thanks, Jinia."</a>
<a action="bypass -h Quest IceQueensCastleBattle enterEasy">"Thanks, Jinia."</a>
</body></html>

View File

@ -1,5 +1,5 @@
<html><body>Jinia:<br>
Her power is without equal. She truly is a frozen goddess. Are you sure you're ready?<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle enterHardcore">"It's now or never."</a><br>
<a action="bypass -h Quest IceQueensCastleBattle enterHardcore">"It's now or never."</a><br>
<a action="bypass -h Quest Jinia 32781-08.html">"Perhaps I'll think again."</a>
</body></html>

View File

@ -1,5 +1,5 @@
<html><body>Jinia:<br>
Alright, we'll depart now. Keep those nerves of steel!<br>
<a action="bypass -h npc_%objectId%_Quest IceQueensCastleNormalBattle enterEasy">Enter the Ice Queen's Castle.</a><br>
<a action="bypass -h npc_%objectId%_Quest IceQueensCastleBattle enterEasy">Enter the Ice Queen's Castle.</a><br>
<a action="bypass -h Quest Jinia 32781-11.html">"Wait a moment, I'm not ready."</a>
</body></html>

View File

@ -1,4 +1,4 @@
<html><body>Sirra:<br>
This is the way to the Ice Queen's Throne room, where she awaits. As I've told you, Freya is powerful beyond all comprehension and can destroy you with a mere thought. I keep telling other would-be heroes this, but they keep going anyway. It's actually getting rather fun. But I'm SURE you're different than they were! You shall succeed where they failed. Hahahaha...<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle openDoor">Open door</a>
<a action="bypass -h Quest IceQueensCastleBattle openDoor">Open door</a>
</body></html>

View File

@ -1,4 +1,4 @@
<html><body>Sirra:<br>
Beyond this door the Ice Queen Freya is making ice sculptures from foolish adventurers. You're not trying to join them, are you? Tsk tsk. The smart ones run screaming about now.<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle portInside">I will go in.</a>
<a action="bypass -h Quest IceQueensCastleBattle portInside">I will go in.</a>
</body></html>

View File

@ -1,4 +1,4 @@
<html><body>Sirra:<br>
This is the way to the Ice Queen's Throne room, where she awaits. As I've told you, Freya is powerful beyond all comprehension and can destroy you with a mere thought. I keep telling other would-be heroes this, but they keep going anyway. It's actually getting rather fun. But I'm SURE you're different than they were! You shall succeed where they failed. Hahahaha...<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle openDoor">Open door</a>
<a action="bypass -h Quest IceQueensCastleBattle openDoor">Open door</a>
</body></html>

View File

@ -1,4 +1,4 @@
<html><body>Sirra:<br>
Beyond this door the Ice Queen Freya is making ice sculptures from foolish adventurers. You're not trying to join them, are you? Tsk tsk. The smart ones run screaming about now.<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle portInside">I will go in.</a>
<a action="bypass -h Quest IceQueensCastleBattle portInside">I will go in.</a>
</body></html>

View File

@ -43,13 +43,13 @@ public final class Sirra extends AbstractNpcAI
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if ((world != null) && (world.getTemplateId() == FREYA_INSTID))
if ((world != null) && (world.getInstance().getTemplateId() == FREYA_INSTID))
{
return (world.isStatus(0)) ? "32762-easy.html" : "32762-easyfight.html";
}
else if ((world != null) && (world.getTemplateId() == FREYA_HARD_INSTID))
else if ((world != null) && (world.getInstance().getTemplateId() == FREYA_HARD_INSTID))
{
return (world.isStatus(0)) ? "32762-hard.html" : "32762-hardfight.html";
}

View File

@ -328,9 +328,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
if (checkConditions(player))
{
world = new HEAWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
((HEAWorld) world).startTime = System.currentTimeMillis();
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Hall Of Erosion Attack started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -457,7 +455,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
@Override
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEAWorld)
{
final HEAWorld world = (HEAWorld) tmpworld;
@ -477,7 +475,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEAWorld)
{
final HEAWorld world = (HEAWorld) tmpworld;
@ -488,14 +486,14 @@ public class HallOfErosionAttack extends AbstractNpcAI
reenter.add(Calendar.HOUR, INSTANCEPENALTY);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(tmpworld.getTemplateId());
sm.addInstanceName(INSTANCEID);
for (int objectId : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -513,7 +511,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
npc.setIsImmobilized(true);
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEAWorld)
{
final HEAWorld world = (HEAWorld) tmpworld;
@ -533,7 +531,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
if (npc.getId() == TUMOR_DEAD)
{
final int tag = world.getParameters().getInt("tag", -1);
world.getParameters().set("tag", tag + 1);
world.setParameter("tag", tag + 1);
}
}
return super.onSpawn(npc);
@ -542,7 +540,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEAWorld)
{
final HEAWorld world = (HEAWorld) tmpworld;
@ -615,14 +613,14 @@ public class HallOfErosionAttack extends AbstractNpcAI
reenter.set(Calendar.HOUR_OF_DAY, 6);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(world.getTemplateId());
sm.addInstanceName(INSTANCEID);
for (int objectId : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
obj.sendPacket(sm);
}
}
@ -655,7 +653,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
_world.npcList.add(tumor);
_deadTumor.deleteMe();
final int tag = _world.getParameters().getInt("tag", -1);
_world.getParameters().set("tag", tag - 1);
_world.setParameter("tag", tag - 1);
}
}

View File

@ -329,9 +329,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
if (checkConditions(player))
{
world = new HEDWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
((HEDWorld) world).startTime = System.currentTimeMillis();
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Hall Of Erosion Defence started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -478,7 +476,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
@Override
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEDWorld)
{
final HEDWorld world = (HEDWorld) tmpworld;
@ -509,14 +507,14 @@ public class HallOfErosionDefence extends AbstractNpcAI
((L2QuestGuardInstance) npc).setPassive(true);
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEDWorld)
{
final HEDWorld world = (HEDWorld) tmpworld;
if (npc.getId() == TUMOR_DEAD)
{
final int tag = world.getParameters().getInt("tag", -1);
world.getParameters().set("tag", tag + 1);
world.setParameter("tag", tag + 1);
}
}
return super.onSpawn(npc);
@ -525,7 +523,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEDWorld)
{
final HEDWorld world = (HEDWorld) tmpworld;
@ -556,7 +554,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
public String onKillByMob(L2Npc npc, L2Npc killer)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HEDWorld)
{
final HEDWorld world = (HEDWorld) tmpworld;

View File

@ -226,9 +226,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
if (checkConditions(player))
{
world = new HSAWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
((HSAWorld) world).storeTime[0] = System.currentTimeMillis();
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Hall Of Suffering Attack started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -373,7 +371,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSAWorld)
{
final HSAWorld world = (HSAWorld) tmpworld;
@ -436,7 +434,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSAWorld)
{
final HSAWorld world = (HSAWorld) tmpworld;
@ -447,7 +445,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
reenter.add(Calendar.HOUR, INSTANCEPENALTY);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(tmpworld.getTemplateId());
sm.addInstanceName(INSTANCEID);
// set instance reenter time for all allowed players
for (int objectId : tmpworld.getAllowed())
@ -455,7 +453,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -489,7 +487,7 @@ public class HallOfSufferingAttack extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSAWorld)
{
final HSAWorld world = (HSAWorld) tmpworld;
@ -523,43 +521,43 @@ public class HallOfSufferingAttack extends AbstractNpcAI
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{
world.getParameters().set("tag", 13777);
world.setParameter("tag", 13777);
}
else if (finishDiff < 1380000)
{
world.getParameters().set("tag", 13778);
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.getParameters().set("tag", 13779);
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.getParameters().set("tag", 13780);
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.getParameters().set("tag", 13781);
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.getParameters().set("tag", 13782);
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.getParameters().set("tag", 13783);
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.getParameters().set("tag", 13784);
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.getParameters().set("tag", 13785);
world.setParameter("tag", 13785);
}
else
{
world.getParameters().set("tag", 13786);
world.setParameter("tag", 13786);
}
world.klanikus = null;

View File

@ -226,9 +226,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
if (checkConditions(player))
{
world = new HSDWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
((HSDWorld) world).storeTime[0] = System.currentTimeMillis();
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Hall Of Suffering Defence started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -373,7 +371,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSDWorld)
{
final HSDWorld world = (HSDWorld) tmpworld;
@ -436,7 +434,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSDWorld)
{
final HSDWorld world = (HSDWorld) tmpworld;
@ -447,7 +445,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
reenter.add(Calendar.HOUR, INSTANCEPENALTY);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(tmpworld.getTemplateId());
sm.addInstanceName(INSTANCEID);
// set instance reenter time for all allowed players
for (int objectId : tmpworld.getAllowed())
@ -455,7 +453,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -489,7 +487,7 @@ public class HallOfSufferingDefence extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HSDWorld)
{
final HSDWorld world = (HSDWorld) tmpworld;
@ -523,43 +521,43 @@ public class HallOfSufferingDefence extends AbstractNpcAI
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{
world.getParameters().set("tag", 13777);
world.setParameter("tag", 13777);
}
else if (finishDiff < 1380000)
{
world.getParameters().set("tag", 13778);
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.getParameters().set("tag", 13779);
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.getParameters().set("tag", 13780);
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.getParameters().set("tag", 13781);
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.getParameters().set("tag", 13782);
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.getParameters().set("tag", 13783);
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.getParameters().set("tag", 13784);
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.getParameters().set("tag", 13785);
world.setParameter("tag", 13785);
}
else
{
world.getParameters().set("tag", 13786);
world.setParameter("tag", 13786);
}
world.klanikus = null;

View File

@ -314,9 +314,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
if (checkConditions(player))
{
world = new HIAWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Heart Infinity Attack started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -495,7 +493,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
@Override
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIAWorld)
{
final HIAWorld world = (HIAWorld) tmpworld;
@ -515,7 +513,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIAWorld)
{
final HIAWorld world = (HIAWorld) tmpworld;
@ -526,14 +524,14 @@ public class HeartInfinityAttack extends AbstractNpcAI
reenter.add(Calendar.HOUR, INSTANCEPENALTY);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(tmpworld.getTemplateId());
sm.addInstanceName(INSTANCEID);
for (int objectId : tmpworld.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, tmpworld.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
@ -567,7 +565,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
npc.setIsImmobilized(true);
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIAWorld)
{
final HIAWorld world = (HIAWorld) tmpworld;
@ -580,7 +578,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
if (npc.getId() == DEADTUMOR)
{
final int tag = world.getParameters().getInt("tag", -1);
world.getParameters().set("tag", tag + 1);
world.setParameter("tag", tag + 1);
}
}
return super.onSpawn(npc);
@ -589,7 +587,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIAWorld)
{
final HIAWorld world = (HIAWorld) tmpworld;
@ -657,7 +655,7 @@ public class HeartInfinityAttack extends AbstractNpcAI
_world.npcList.add(alivetumor);
_deadTumor.deleteMe();
final int tag = _world.getParameters().getInt("tag", -1);
_world.getParameters().set("tag", tag - 1);
_world.setParameter("tag", tag - 1);
}
}

View File

@ -333,9 +333,7 @@ public class HeartInfinityDefence extends AbstractNpcAI
if (checkConditions(player))
{
world = new HIDWorld();
world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
world.setTemplateId(INSTANCEID);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCEID));
InstanceManager.getInstance().addWorld(world);
LOGGER.info("Heart Infinity Defence started " + INSTANCEID + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
@ -536,7 +534,7 @@ public class HeartInfinityDefence extends AbstractNpcAI
@Override
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIDWorld)
{
final HIDWorld world = (HIDWorld) tmpworld;
@ -562,7 +560,7 @@ public class HeartInfinityDefence extends AbstractNpcAI
npc.setIsImmobilized(true);
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIDWorld)
{
if (npc.getId() == SOULWAGON)
@ -577,7 +575,7 @@ public class HeartInfinityDefence extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIDWorld)
{
final HIDWorld world = (HIDWorld) tmpworld;
@ -746,7 +744,7 @@ public class HeartInfinityDefence extends AbstractNpcAI
if (character instanceof L2Attackable)
{
final L2Attackable npc = (L2Attackable) character;
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIDWorld)
{
final HIDWorld world = (HIDWorld) tmpworld;

View File

@ -927,13 +927,11 @@ public class SeedOfDestruction extends AbstractNpcAI
{
return 0;
}
final int instanceId = InstanceManager.getInstance().createDynamicInstance(INSTANCE_ID);
world = new SODWorld(System.currentTimeMillis() + 5400000);
world.setTemplateId(INSTANCE_ID);
world.setInstanceId(instanceId);
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCE_ID));
InstanceManager.getInstance().addWorld(world);
spawnState((SODWorld) world);
final int instanceId = world.getInstanceId();
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(instanceId).getDoors())
{
if (contains(ATTACKABLE_DOORS, door.getId()))
@ -1267,7 +1265,7 @@ public class SeedOfDestruction extends AbstractNpcAI
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof SODWorld)
{
final SODWorld world = (SODWorld) tmpworld;
@ -1308,11 +1306,11 @@ public class SeedOfDestruction extends AbstractNpcAI
if (npc != null)
{
tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
tmpworld = InstanceManager.getInstance().getWorld(npc);
}
else
{
tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
tmpworld = InstanceManager.getInstance().getWorld(player);
}
if (tmpworld instanceof SODWorld)
@ -1542,7 +1540,7 @@ public class SeedOfDestruction extends AbstractNpcAI
cancelQuestTimer("Spawn", npc, null);
return "";
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof SODWorld)
{
final SODWorld world = (SODWorld) tmpworld;
@ -1654,7 +1652,7 @@ public class SeedOfDestruction extends AbstractNpcAI
}
else if (npcId == TELEPORT)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof SODWorld)
{
final SODWorld world = (SODWorld) tmpworld;
@ -1679,7 +1677,7 @@ public class SeedOfDestruction extends AbstractNpcAI
if (npc.getId() == TELEPORT)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof SODWorld)
{
final SODWorld world = (SODWorld) tmpworld;
@ -1707,7 +1705,7 @@ public class SeedOfDestruction extends AbstractNpcAI
{
if (character instanceof L2PcInstance)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof SODWorld)
{
final SODWorld world = (SODWorld) tmpworld;

View File

@ -36,11 +36,6 @@ import instances.AbstractInstance;
*/
public final class DemonPrinceFloor extends AbstractInstance
{
protected class DPFWorld extends InstanceWorld
{
}
// NPCs
private static final int GK_4 = 32748;
private static final int CUBE = 32375;
@ -81,13 +76,13 @@ public final class DemonPrinceFloor extends AbstractInstance
if (htmltext == null)
{
enterInstance(player, new DPFWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
}
}
else if (npc.getId() == CUBE)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (world instanceof DPFWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
world.removeAllowed(player.getObjectId());
teleportPlayer(player, EXIT_POINT, 0);
@ -103,7 +98,7 @@ public final class DemonPrinceFloor extends AbstractInstance
if (instanceId > 0)
{
final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
inst.setExitLoc(EXIT_POINT);
finishInstance(world);

View File

@ -36,11 +36,6 @@ import instances.AbstractInstance;
*/
public final class RankuFloor extends AbstractInstance
{
protected class RFWorld extends InstanceWorld
{
}
// NPCs
private static final int GK_9 = 32752;
private static final int CUBE = 32374;
@ -82,13 +77,13 @@ public final class RankuFloor extends AbstractInstance
if (htmltext == null)
{
enterInstance(player, new RFWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
}
}
else if (npc.getId() == CUBE)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (world instanceof RFWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
teleportPlayer(player, EXIT_POINT, 0);
}
@ -103,7 +98,7 @@ public final class RankuFloor extends AbstractInstance
if (instanceId > 0)
{
final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
inst.setExitLoc(EXIT_POINT);
finishInstance(world);
addSpawn(CUBE, -19056, 278732, -15000, 0, false, 0, false, instanceId);

View File

@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2QuestGuardInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
@ -47,13 +46,6 @@ import instances.AbstractInstance;
*/
public final class UrbanArea extends AbstractInstance
{
protected class UrbanAreaWorld extends InstanceWorld
{
protected L2MonsterInstance spawnedAmaskari;
protected ScheduledFuture<?> activeAmaskariCall = null;
protected boolean isAmaskariDead = false;
}
// NPCs
private static final int TOMBSTONE = 32343;
private static final int KANAF = 32346;
@ -129,16 +121,14 @@ public final class UrbanArea extends AbstractInstance
if (htmltext == null)
{
enterInstance(player, new UrbanAreaWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
}
}
else if (npc.getId() == TOMBSTONE)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
final L2Party party = player.getParty();
if (party == null)
@ -182,20 +172,18 @@ public final class UrbanArea extends AbstractInstance
@Override
public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
if (npc.getId() == DOWNTOWN_NATIVE)
{
if (event.equalsIgnoreCase("rebuff") && !world.isAmaskariDead)
if (event.equalsIgnoreCase("rebuff") && !world.getParameters().getBoolean("isAmaskariDead", false))
{
STONE.getSkill().applyEffects(npc, npc);
}
else if (event.equalsIgnoreCase("break_chains"))
{
if (!npc.isAffectedBySkill(STONE.getSkillId()) || world.isAmaskariDead)
if (!npc.isAffectedBySkill(STONE.getSkillId()) || world.getParameters().getBoolean("isAmaskariDead", false))
{
npc.broadcastSay(ChatType.NPC_GENERAL, NATIVES_NPCSTRING_ID[0]);
npc.broadcastSay(ChatType.NPC_GENERAL, NATIVES_NPCSTRING_ID[2]);
@ -213,14 +201,15 @@ public final class UrbanArea extends AbstractInstance
HellboundEngine.getInstance().updateTrust(10, true);
npc.scheduleDespawn(3000);
// Try to call Amaskari
if ((world.spawnedAmaskari != null) && !world.spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(5000, npc, world.spawnedAmaskari, false))
final L2Npc spawnedAmaskari = world.getParameters().getObject("spawnedAmaskari", L2Npc.class);
if ((spawnedAmaskari != null) && !spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(5000, npc, spawnedAmaskari, false))
{
if (world.activeAmaskariCall != null)
final ScheduledFuture<?> activeAmaskariCall = world.getParameters().getObject("activeAmaskariCall", ScheduledFuture.class);
if (activeAmaskariCall != null)
{
world.activeAmaskariCall.cancel(true);
activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPool.schedule(new CallAmaskari(npc), 25000);
world.setParameter("activeAmaskariCall", ThreadPool.schedule(new CallAmaskari(npc), 25000));
}
}
}
@ -250,23 +239,23 @@ public final class UrbanArea extends AbstractInstance
@Override
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
if (!npc.isBusy())
{
npc.broadcastSay(ChatType.NPC_GENERAL, NPCSTRING_ID[0]);
npc.setBusy(true);
if ((world.spawnedAmaskari != null) && !world.spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(1000, npc, world.spawnedAmaskari, false))
final L2Npc spawnedAmaskari = world.getParameters().getObject("spawnedAmaskari", L2Npc.class);
if ((spawnedAmaskari != null) && !spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(1000, npc, spawnedAmaskari, false))
{
if (world.activeAmaskariCall != null)
final ScheduledFuture<?> activeAmaskariCall = world.getParameters().getObject("activeAmaskariCall", ScheduledFuture.class);
if (activeAmaskariCall != null)
{
world.activeAmaskariCall.cancel(true);
activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPool.schedule(new CallAmaskari(npc), 25000);
world.setParameter("activeAmaskariCall", ThreadPool.schedule(new CallAmaskari(npc), 25000));
}
}
}
@ -276,12 +265,10 @@ public final class UrbanArea extends AbstractInstance
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
if (!world.isAmaskariDead && !(npc.getBusyMessage().equalsIgnoreCase("atk") || npc.isBusy()))
if (!world.getParameters().getBoolean("isAmaskariDead", false) && !(npc.getBusyMessage().equalsIgnoreCase("atk") || npc.isBusy()))
{
int msgId;
int range;
@ -312,13 +299,15 @@ public final class UrbanArea extends AbstractInstance
npc.setBusy(true);
npc.setBusyMessage("atk");
if ((world.spawnedAmaskari != null) && !world.spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(range, npc, world.spawnedAmaskari, false))
final L2Npc spawnedAmaskari = world.getParameters().getObject("spawnedAmaskari", L2Npc.class);
if ((spawnedAmaskari != null) && !spawnedAmaskari.isDead() && (getRandom(1000) < 25) && Util.checkIfInRange(range, npc, spawnedAmaskari, false))
{
if (world.activeAmaskariCall != null)
final ScheduledFuture<?> activeAmaskariCall = world.getParameters().getObject("activeAmaskariCall", ScheduledFuture.class);
if (activeAmaskariCall != null)
{
world.activeAmaskariCall.cancel(true);
activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPool.schedule(new CallAmaskari(npc), 25000);
world.setParameter("activeAmaskariCall", ThreadPool.schedule(new CallAmaskari(npc), 25000));
}
}
}
@ -328,11 +317,10 @@ public final class UrbanArea extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
world.isAmaskariDead = true;
world.setParameter("isAmaskariDead", true);
}
return super.onKill(npc, killer, isSummon);
}
@ -394,7 +382,7 @@ public final class UrbanArea extends AbstractInstance
world.addAllowed(partyMember.getObjectId());
}
}
((UrbanAreaWorld) world).spawnedAmaskari = (L2MonsterInstance) addSpawn(AMASKARI, AMASKARI_SPAWN_POINT, false, 0, false, world.getInstanceId());
world.setParameter("spawnedAmaskari", addSpawn(AMASKARI, AMASKARI_SPAWN_POINT, false, 0, false, world.getInstanceId()));
}
else
{
@ -416,15 +404,14 @@ public final class UrbanArea extends AbstractInstance
{
if ((_caller != null) && !_caller.isDead())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(_caller.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof UrbanAreaWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(_caller);
if (world != null)
{
final UrbanAreaWorld world = (UrbanAreaWorld) tmpworld;
if ((world.spawnedAmaskari != null) && !world.spawnedAmaskari.isDead())
final L2Npc spawnedAmaskari = world.getParameters().getObject("spawnedAmaskari", L2Npc.class);
if ((spawnedAmaskari != null) && !spawnedAmaskari.isDead())
{
world.spawnedAmaskari.teleToLocation(_caller.getLocation());
world.spawnedAmaskari.broadcastPacket(new NpcSay(world.spawnedAmaskari.getObjectId(), ChatType.NPC_GENERAL, world.spawnedAmaskari.getId(), NpcStringId.I_LL_MAKE_YOU_FEEL_SUFFERING_LIKE_A_FLAME_THAT_IS_NEVER_EXTINGUISHED));
spawnedAmaskari.teleToLocation(_caller.getLocation());
spawnedAmaskari.broadcastPacket(new NpcSay(spawnedAmaskari.getObjectId(), ChatType.NPC_GENERAL, spawnedAmaskari.getId(), NpcStringId.I_LL_MAKE_YOU_FEEL_SUFFERING_LIKE_A_FLAME_THAT_IS_NEVER_EXTINGUISHED));
}
}
}
@ -434,9 +421,9 @@ public final class UrbanArea extends AbstractInstance
private class ExitInstance implements Runnable
{
private final L2Party _party;
private final UrbanAreaWorld _world;
private final InstanceWorld _world;
public ExitInstance(L2Party party, UrbanAreaWorld world)
public ExitInstance(L2Party party, InstanceWorld world)
{
_party = party;
_world = world;

View File

@ -87,7 +87,7 @@ public class AdminInstance implements IAdminCommandHandler
if (world != null)
{
counter++;
activeChar.sendMessage("Id: " + instance.getId() + " Name: " + InstanceManager.getInstance().getInstanceIdName(world.getTemplateId()));
activeChar.sendMessage("Id: " + instance.getId() + " Name: " + InstanceManager.getInstance().getInstanceIdName(world.getInstance().getTemplateId()));
}
}
if (counter == 0)

View File

@ -51,10 +51,10 @@ public class InstanceZone implements IUserCommandHandler
}
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(activeChar);
if ((world != null) && (world.getTemplateId() >= 0))
if ((world != null) && (world.getInstance().getTemplateId() >= 0))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_CURRENTLY_IN_USE_S1);
sm.addInstanceName(world.getTemplateId());
sm.addInstanceName(world.getInstance().getTemplateId());
activeChar.sendPacket(sm);
}

View File

@ -49,16 +49,11 @@ public abstract class AbstractInstance extends AbstractNpcAI
}
protected void enterInstance(L2PcInstance player, int templateId)
{
enterInstance(player, new InstanceWorld(), templateId);
}
protected void enterInstance(L2PcInstance player, InstanceWorld instance, int templateId)
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (world.getTemplateId() == templateId)
if (world.getInstance().getTemplateId() == templateId)
{
onEnterInstance(player, world, false);
@ -75,9 +70,8 @@ public abstract class AbstractInstance extends AbstractNpcAI
if (checkConditions(player))
{
instance.setInstanceId(InstanceManager.getInstance().createDynamicInstance(templateId));
instance.setTemplateId(templateId);
instance.setStatus(0);
final InstanceWorld instance = new InstanceWorld();
instance.setInstance(InstanceManager.getInstance().createDynamicInstance(templateId));
InstanceManager.getInstance().addWorld(instance);
onEnterInstance(player, instance, true);
@ -209,11 +203,11 @@ public abstract class AbstractInstance extends AbstractNpcAI
{
for (int objectId : world.getAllowed())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), time);
InstanceManager.getInstance().setInstanceTime(objectId, world.getInstance().getTemplateId(), time);
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE).addString(InstanceManager.getInstance().getInstanceIdName(world.getTemplateId())));
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE).addString(InstanceManager.getInstance().getInstanceIdName(world.getInstance().getTemplateId())));
}
}
}

View File

@ -41,11 +41,6 @@ import instances.AbstractInstance;
*/
public final class CastleDungeon extends AbstractInstance
{
protected class CDWorld extends InstanceWorld
{
}
// Locations
private static final Location[] ENTER_LOC =
{
@ -130,8 +125,7 @@ public final class CastleDungeon extends AbstractInstance
}
}
world.setStatus(0);
spawnRaid((CDWorld) world);
spawnRaid(world);
}
else
{
@ -148,10 +142,9 @@ public final class CastleDungeon extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof CDWorld)
InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
CDWorld world = (CDWorld) tmpworld;
if (Util.contains(RAIDS3, npc.getId()))
{
finishInstance(world);
@ -207,11 +200,11 @@ public final class CastleDungeon extends AbstractInstance
}
}
enterInstance(player, new CDWorld(), CASTLE_DUNGEON.get(npc.getId()));
enterInstance(player, CASTLE_DUNGEON.get(npc.getId()));
return super.onTalk(npc, player);
}
protected void spawnRaid(CDWorld world)
protected void spawnRaid(InstanceWorld world)
{
int spawnId;
if (world.getStatus() == 0)

View File

@ -39,17 +39,6 @@ import instances.AbstractInstance;
*/
public final class CavernOfThePirateCaptain extends AbstractInstance
{
protected class CavernOfThePirateCaptainWorld extends InstanceWorld
{
protected List<L2PcInstance> playersInside = new ArrayList<>();
protected L2Attackable _zaken;
protected long storeTime = 0;
protected boolean _is83;
protected boolean _isNight;
protected int _zakenRoom;
protected int _blueFounded;
}
// NPCs
private static final int PATHFINDER = 32713; // Pathfinder Worker
private static final int ZAKEN_60 = 29176; // Zaken
@ -168,30 +157,34 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
{
if (firstEntrance)
{
final CavernOfThePirateCaptainWorld curworld = (CavernOfThePirateCaptainWorld) world;
curworld._is83 = curworld.getTemplateId() == TEMPLATE_ID_83;
curworld._isNight = curworld.getTemplateId() == TEMPLATE_ID_60_NIGHT;
curworld.storeTime = System.currentTimeMillis();
world.setParameter("is83", world.getInstance().getTemplateId() == TEMPLATE_ID_83);
world.setParameter("isNight", world.getInstance().getTemplateId() == TEMPLATE_ID_60_NIGHT);
world.setParameter("storeTime", System.currentTimeMillis());
final List<L2PcInstance> playersInside = new ArrayList<>();
if (!player.isInParty())
{
managePlayerEnter(player, curworld);
playersInside.add(player);
managePlayerEnter(player, world);
}
else if (player.getParty().isInCommandChannel())
{
for (L2PcInstance players : player.getParty().getCommandChannel().getMembers())
for (L2PcInstance member : player.getParty().getCommandChannel().getMembers())
{
managePlayerEnter(players, curworld);
playersInside.add(member);
managePlayerEnter(member, world);
}
}
else
{
for (L2PcInstance players : player.getParty().getMembers())
for (L2PcInstance member : player.getParty().getMembers())
{
managePlayerEnter(players, curworld);
playersInside.add(member);
managePlayerEnter(member, world);
}
}
manageNpcSpawn(curworld);
world.setParameter("playersInside", playersInside);
manageNpcSpawn(world);
}
else
{
@ -199,9 +192,8 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
}
}
private void managePlayerEnter(L2PcInstance player, CavernOfThePirateCaptainWorld world)
private void managePlayerEnter(L2PcInstance player, InstanceWorld world)
{
world.playersInside.add(player);
world.addAllowed(player.getObjectId());
teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
}
@ -292,31 +284,28 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
{
if (checkConditions(player, TEMPLATE_ID_60))
{
enterInstance(player, new CavernOfThePirateCaptainWorld(), TEMPLATE_ID_60);
enterInstance(player, TEMPLATE_ID_60);
}
}
else if (event.equals("enter60night"))
{
if (checkConditions(player, TEMPLATE_ID_60_NIGHT))
{
enterInstance(player, new CavernOfThePirateCaptainWorld(), TEMPLATE_ID_60_NIGHT);
enterInstance(player, TEMPLATE_ID_60_NIGHT);
}
}
else if (event.equals("enter83"))
{
if (checkConditions(player, TEMPLATE_ID_83))
{
enterInstance(player, new CavernOfThePirateCaptainWorld(), TEMPLATE_ID_83);
enterInstance(player, TEMPLATE_ID_83);
}
}
else
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
switch (event)
{
case "BURN_BLUE":
@ -325,7 +314,7 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
{
npc.setRHandId(FIRE);
startQuestTimer("BURN_BLUE2", 3000, npc, player);
if (world._blueFounded == 4)
if (world.getParameters().getInt("blueFounded", 0) == 4)
{
startQuestTimer("SHOW_ZAKEN", 5000, npc, player);
}
@ -356,24 +345,24 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
final int room = getRoomByCandle(npc);
npc.setRHandId(RED);
manageScreenMsg(world, NpcStringId.THE_CANDLES_CAN_LEAD_YOU_TO_ZAKEN_DESTROY_HIM);
spawnNpc(world._is83 ? DOLL_BLADER_83 : DOLL_BLADER_60, room, player, world);
spawnNpc(world._is83 ? VALE_MASTER_83 : VALE_MASTER_60, room, player, world);
spawnNpc(world._is83 ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, room, player, world);
spawnNpc(world._is83 ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, room, player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? DOLL_BLADER_83 : DOLL_BLADER_60, room, player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? VALE_MASTER_83 : VALE_MASTER_60, room, player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, room, player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, room, player, world);
}
break;
}
case "SHOW_ZAKEN":
{
if (world._is83)
if (world.getParameters().getBoolean("is83", false))
{
manageScreenMsg(world, NpcStringId.WHO_DARES_AWAKEN_THE_MIGHTY_ZAKEN);
}
world._zaken.setInvisible(false);
world._zaken.setIsParalyzed(false);
spawnNpc(world._is83 ? DOLL_BLADER_83 : DOLL_BLADER_60, world._zakenRoom, player, world);
spawnNpc(world._is83 ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, world._zakenRoom, player, world);
spawnNpc(world._is83 ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, world._zakenRoom, player, world);
world.getParameters().getObject("zaken", L2Npc.class).setInvisible(false);
world.getParameters().getObject("zaken", L2Npc.class).setIsParalyzed(false);
spawnNpc(world.getParameters().getBoolean("is83", false) ? DOLL_BLADER_83 : DOLL_BLADER_60, world.getParameters().getInt("zakenRoom", 0), player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? PIRATES_ZOMBIE_83 : PIRATES_ZOMBIE_60, world.getParameters().getInt("zakenRoom", 0), player, world);
spawnNpc(world.getParameters().getBoolean("is83", false) ? PIRATES_ZOMBIE_CAPTAIN_83 : PIRATES_ZOMBIE_CAPTAIN_60, world.getParameters().getInt("zakenRoom", 0), player, world);
break;
}
}
@ -385,19 +374,16 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
if (npc.getId() == ZAKEN_83)
{
for (L2PcInstance playersInside : world.playersInside)
for (L2PcInstance playersInside : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((playersInside != null) && ((playersInside.getInstanceId() == world.getInstanceId()) && playersInside.isInsideRadius(npc, 1500, true, true)))
{
final long time = System.currentTimeMillis() - world.storeTime;
final long time = System.currentTimeMillis() - world.getParameters().getLong("storeTime", 0);
if (time <= 300000) // 5 minutes
{
if (getRandomBoolean())
@ -430,18 +416,18 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof CavernOfThePirateCaptainWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final CavernOfThePirateCaptainWorld world = (CavernOfThePirateCaptainWorld) tmpworld;
final boolean isBlue = npc.getVariables().getInt("isBlue", 0) == 1;
if (npc.isScriptValue(0))
{
if (isBlue)
{
world._blueFounded++;
int blueFounded = world.getParameters().getInt("blueFounded", 0);
blueFounded++;
world.setParameter("blueFounded", blueFounded);
startQuestTimer("BURN_BLUE", 500, npc, player);
}
else
@ -481,9 +467,9 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
return 0;
}
private void manageScreenMsg(CavernOfThePirateCaptainWorld world, NpcStringId stringId)
private void manageScreenMsg(InstanceWorld world, NpcStringId stringId)
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
{
@ -492,7 +478,7 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
}
}
private L2Attackable spawnNpc(int npcId, int roomId, L2PcInstance player, CavernOfThePirateCaptainWorld world)
private L2Attackable spawnNpc(int npcId, int roomId, L2PcInstance player, InstanceWorld world)
{
if ((player != null) && (npcId != ZAKEN_60) && (npcId != ZAKEN_83))
{
@ -503,10 +489,10 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
return (L2Attackable) addSpawn(npcId, ROOM_DATA[roomId - 1][0], ROOM_DATA[roomId - 1][1], ROOM_DATA[roomId - 1][2], 0, false, 0, false, world.getInstanceId());
}
private void manageNpcSpawn(CavernOfThePirateCaptainWorld world)
private void manageNpcSpawn(InstanceWorld world)
{
final List<L2Npc> candles = new ArrayList<>();
world._zakenRoom = getRandom(1, 15);
world.setParameter("zakenRoom", getRandom(1, 15));
for (int i = 0; i < 36; i++)
{
@ -517,11 +503,12 @@ public final class CavernOfThePirateCaptain extends AbstractInstance
for (int i = 3; i < 7; i++)
{
candles.get(ROOM_DATA[world._zakenRoom - 1][i] - 1).getVariables().set("isBlue", 1);
candles.get(ROOM_DATA[world.getParameters().getInt("zakenRoom", 0) - 1][i] - 1).getVariables().set("isBlue", 1);
}
world._zaken = spawnNpc(world._is83 ? ZAKEN_83 : world._isNight ? ZAKEN_60_NIGHT : ZAKEN_60, world._zakenRoom, null, world);
world._zaken.setInvisible(true);
world._zaken.setIsParalyzed(true);
final L2Npc zaken = spawnNpc(world.getParameters().getBoolean("is83", false) ? ZAKEN_83 : world.getParameters().getBoolean("isNight", false) ? ZAKEN_60_NIGHT : ZAKEN_60, world.getParameters().getInt("zakenRoom", 0), null, world);
zaken.setInvisible(true);
zaken.setIsParalyzed(true);
world.setParameter("zaken", zaken);
}
public static void main(String[] args)

View File

@ -50,94 +50,6 @@ import instances.AbstractInstance;
*/
public abstract class Chamber extends AbstractInstance
{
protected class CDWorld extends InstanceWorld
{
protected int currentRoom;
protected final L2Party partyInside;
protected final ScheduledFuture<?> _banishTask;
protected ScheduledFuture<?> _roomChangeTask;
protected CDWorld(L2Party party)
{
currentRoom = 0;
partyInside = party;
_banishTask = ThreadPool.scheduleAtFixedRate(new BanishTask(), 60000, 60000);
}
protected L2Party getPartyInside()
{
return partyInside;
}
protected void scheduleRoomChange(boolean bossRoom)
{
final Instance inst = InstanceManager.getInstance().getInstance(getInstanceId());
final long nextInterval = bossRoom ? 60000L : (ROOM_CHANGE_INTERVAL + getRandom(ROOM_CHANGE_RANDOM_TIME)) * 1000L;
// Schedule next room change only if remaining time is enough
if ((inst.getInstanceEndTime() - System.currentTimeMillis()) > nextInterval)
{
_roomChangeTask = ThreadPool.schedule(new ChangeRoomTask(), nextInterval - 5000);
}
}
protected void stopBanishTask()
{
_banishTask.cancel(true);
}
protected void stopRoomChangeTask()
{
_roomChangeTask.cancel(true);
}
protected class BanishTask implements Runnable
{
@Override
public void run()
{
final Instance inst = InstanceManager.getInstance().getInstance(getInstanceId());
if ((inst == null) || ((inst.getInstanceEndTime() - System.currentTimeMillis()) < 60000))
{
_banishTask.cancel(false);
}
else
{
for (int objId : inst.getPlayers())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline())
{
if ((partyInside == null) || !pl.isInParty() || (partyInside != pl.getParty()))
{
exitInstance(pl);
}
}
}
}
}
}
protected class ChangeRoomTask implements Runnable
{
@Override
public void run()
{
try
{
earthQuake(CDWorld.this);
Thread.sleep(5000);
changeRoom(CDWorld.this);
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + " ChangeRoomTask exception : " + e.getMessage(), e);
}
}
}
}
// Items
private static final int ENRIA = 4042;
private static final int ASOFE = 4043;
@ -197,9 +109,9 @@ public abstract class Chamber extends AbstractInstance
return ((INSTANCEID == 131) || (INSTANCEID == 132));
}
private boolean isBossRoom(CDWorld world)
private boolean isBossRoom(InstanceWorld world)
{
return (world.currentRoom == (ROOM_ENTER_POINTS.length - 1));
return (world.getParameters().getInt("currentRoom", 0) == (ROOM_ENTER_POINTS.length - 1));
}
@Override
@ -255,7 +167,7 @@ public abstract class Chamber extends AbstractInstance
private void markRestriction(InstanceWorld world)
{
if (world instanceof CDWorld)
if (world != null)
{
final Calendar reenter = Calendar.getInstance();
final Calendar now = Calendar.getInstance();
@ -266,23 +178,23 @@ public abstract class Chamber extends AbstractInstance
reenter.add(Calendar.DAY_OF_WEEK, 1);
}
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addString(InstanceManager.getInstance().getInstanceIdName(world.getTemplateId()));
sm.addString(InstanceManager.getInstance().getInstanceIdName(world.getInstance().getTemplateId()));
// set instance reenter time for all allowed players
for (int objectId : world.getAllowed())
{
final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
if ((player != null) && player.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, world.getInstance().getTemplateId(), reenter.getTimeInMillis());
player.sendPacket(sm);
}
}
}
}
protected void changeRoom(CDWorld world)
protected void changeRoom(InstanceWorld world)
{
final L2Party party = world.getPartyInside();
final L2Party party = world.getParameters().getObject("PartyInside", L2Party.class);
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
if ((party == null) || (inst == null))
@ -290,7 +202,7 @@ public abstract class Chamber extends AbstractInstance
return;
}
int newRoom = world.currentRoom;
int newRoom = world.getParameters().getInt("currentRoom", 0);
// Do nothing, if there are raid room of Sqare or Tower Chamber
if (isBigChamber() && isBossRoom(world))
@ -312,7 +224,7 @@ public abstract class Chamber extends AbstractInstance
else
{
while (newRoom == world.currentRoom) // otherwise teleport to another room, except current
while (newRoom == world.getParameters().getInt("currentRoom", 0)) // otherwise teleport to another room, except current
{
newRoom = getRandom(ROOM_ENTER_POINTS.length - 1);
}
@ -327,7 +239,7 @@ public abstract class Chamber extends AbstractInstance
}
}
world.currentRoom = newRoom;
world.setParameter("currentRoom", newRoom);
// Do not schedule room change for Square and Tower Chambers, if raid room is reached
if (isBigChamber() && isBossRoom(world))
@ -344,13 +256,13 @@ public abstract class Chamber extends AbstractInstance
}
else
{
world.scheduleRoomChange(false);
scheduleRoomChange(world, false);
}
}
private void enter(CDWorld world)
private void enter(InstanceWorld world)
{
final L2Party party = world.getPartyInside();
final L2Party party = world.getParameters().getObject("PartyInside", L2Party.class);
if (party == null)
{
@ -379,9 +291,9 @@ public abstract class Chamber extends AbstractInstance
changeRoom(world);
}
protected void earthQuake(CDWorld world)
protected void earthQuake(InstanceWorld world)
{
final L2Party party = world.getPartyInside();
final L2Party party = world.getParameters().getObject("PartyInside", L2Party.class);
if (party == null)
{
@ -402,12 +314,13 @@ public abstract class Chamber extends AbstractInstance
{
if (firstEntrance)
{
enter((CDWorld) world);
world.setParameter("PartyInside", player.getParty());
world.setParameter("banishTask", ThreadPool.scheduleAtFixedRate(new BanishTask(world), 60000, 60000));
enter(world);
}
else
{
final CDWorld currentWorld = (CDWorld) world;
teleportPlayer(player, ROOM_ENTER_POINTS[currentWorld.currentRoom], world.getInstanceId());
teleportPlayer(player, ROOM_ENTER_POINTS[world.getParameters().getInt("currentRoom", 0)], world.getInstanceId());
}
}
@ -450,12 +363,10 @@ public abstract class Chamber extends AbstractInstance
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = "";
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if ((player != null) && (tmpworld != null) && (tmpworld instanceof CDWorld) && (npc.getId() >= ROOM_GATEKEEPER_FIRST) && (npc.getId() <= ROOM_GATEKEEPER_LAST))
if ((player != null) && (world != null) && (npc.getId() >= ROOM_GATEKEEPER_FIRST) && (npc.getId() <= ROOM_GATEKEEPER_LAST))
{
final CDWorld world = (CDWorld) tmpworld;
// Change room from dialog
if (event.equals("next_room"))
{
@ -463,19 +374,16 @@ public abstract class Chamber extends AbstractInstance
{
htmltext = getHtm(player.getHtmlPrefix(), "data/scripts/instances/ChambersOfDelusion/no_party.html");
}
else if (player.getParty().getLeaderObjectId() != player.getObjectId())
{
htmltext = getHtm(player.getHtmlPrefix(), "data/scripts/instances/ChambersOfDelusion/no_leader.html");
}
else if (hasQuestItems(player, DELUSION_MARK))
{
takeItems(player, DELUSION_MARK, 1);
world.stopRoomChangeTask();
stopRoomChangeTask(world);
changeRoom(world);
}
else
{
htmltext = getHtm(player.getHtmlPrefix(), "data/scripts/instances/ChambersOfDelusion/no_item.html");
@ -495,8 +403,8 @@ public abstract class Chamber extends AbstractInstance
{
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
world.stopRoomChangeTask();
world.stopBanishTask();
stopRoomChangeTask(world);
stopBanishTask(world);
for (L2PcInstance partyMember : player.getParty().getMembers())
{
@ -508,9 +416,9 @@ public abstract class Chamber extends AbstractInstance
}
else if (event.equals("look_party"))
{
if ((player.getParty() != null) && (player.getParty() == world.getPartyInside()))
if ((player.getParty() != null) && (player.getParty() == world.getParameters().getObject("PartyInside", L2Party.class)))
{
teleportPlayer(player, ROOM_ENTER_POINTS[world.currentRoom], world.getInstanceId(), false);
teleportPlayer(player, ROOM_ENTER_POINTS[world.getParameters().getInt("currentRoom", 0)], world.getInstanceId(), false);
}
}
}
@ -573,17 +481,15 @@ public abstract class Chamber extends AbstractInstance
break;
}
}
return null;
}
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if ((tmpworld != null) && (tmpworld instanceof CDWorld))
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
final CDWorld world = (CDWorld) tmpworld;
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
if (isBigChamber())
@ -596,8 +502,8 @@ public abstract class Chamber extends AbstractInstance
}
else
{
world.stopRoomChangeTask();
world.scheduleRoomChange(true);
stopRoomChangeTask(world);
scheduleRoomChange(world, true);
}
inst.spawnGroup("boxes");
@ -626,11 +532,108 @@ public abstract class Chamber extends AbstractInstance
{
if (checkConditions(player))
{
final L2Party party = player.getParty();
enterInstance(player, new CDWorld(party), INSTANCEID);
enterInstance(player, INSTANCEID);
}
}
return "";
}
protected L2Party getPartyInside(InstanceWorld world)
{
return world.getParameters().getObject("PartyInside", L2Party.class);
}
protected void scheduleRoomChange(InstanceWorld world, boolean bossRoom)
{
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
final long nextInterval = bossRoom ? 60000L : (ROOM_CHANGE_INTERVAL + getRandom(ROOM_CHANGE_RANDOM_TIME)) * 1000L;
// Schedule next room change only if remaining time is enough
if ((inst.getInstanceEndTime() - System.currentTimeMillis()) > nextInterval)
{
world.setParameter("roomChangeTask", ThreadPool.schedule(new ChangeRoomTask(world), nextInterval - 5000));
}
}
protected void stopBanishTask(InstanceWorld world)
{
final ScheduledFuture<?> banishTask = world.getParameters().getObject("banishTask", ScheduledFuture.class);
if (banishTask != null)
{
banishTask.cancel(true);
}
}
protected void stopRoomChangeTask(InstanceWorld world)
{
final ScheduledFuture<?> roomChangeTask = world.getParameters().getObject("roomChangeTask", ScheduledFuture.class);
if (roomChangeTask != null)
{
roomChangeTask.cancel(true);
}
}
protected class BanishTask implements Runnable
{
final InstanceWorld _world;
public BanishTask(InstanceWorld world)
{
_world = world;
}
@Override
public void run()
{
final Instance inst = InstanceManager.getInstance().getInstance(_world.getInstanceId());
if ((inst == null) || ((inst.getInstanceEndTime() - System.currentTimeMillis()) < 60000))
{
final ScheduledFuture<?> banishTask = _world.getParameters().getObject("banishTask", ScheduledFuture.class);
if (banishTask != null)
{
banishTask.cancel(true);
}
}
else
{
for (int objId : inst.getPlayers())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline())
{
final L2Party party = _world.getParameters().getObject("PartyInside", L2Party.class);
if ((party == null) || !pl.isInParty() || (party != pl.getParty()))
{
exitInstance(pl);
}
}
}
}
}
}
protected class ChangeRoomTask implements Runnable
{
final InstanceWorld _world;
public ChangeRoomTask(InstanceWorld world)
{
_world = world;
}
@Override
public void run()
{
try
{
earthQuake(_world);
Thread.sleep(5000);
changeRoom(_world);
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + " ChangeRoomTask exception : " + e.getMessage(), e);
}
}
}
}

View File

@ -26,6 +26,7 @@ import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.InstanceReenterType;
import com.l2jmobius.gameserver.enums.TrapAction;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
@ -862,19 +863,12 @@ public final class CrystalCaverns extends AbstractInstance
return true;
}
/*
* protected void runBaylorRoom(CCWorld world) { world.status = 30; addSpawn(29101,152758,143479,-12706,52961,false,0,false,world.getInstanceId(),0);//up power addSpawn(29101,151951,142078,-12706,65203,false,0,false,world.getInstanceId(),0);//up power
* addSpawn(29101,154396,140667,-12706,22197,false,0,false,world.getInstanceId(),0);//up power addSpawn(29102,152162,141249,-12706,5511,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,153571,140458,-12706,16699,false,0,false,world.getInstanceId(),0);//down power
* addSpawn(29102,154976,141265,-12706,26908,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,155203,142071,-12706,31560,false,0,false,world.getInstanceId(),0);//down power addSpawn(29102,154380,143468,-12708,43943,false,0,false,world.getInstanceId(),0);//down power
* addSpawn(32271,153573,142069,-9722,11175,false,0,false,world.getInstanceId()); world.Baylor = addSpawn(BAYLOR,153557,142089,-12735,11175,false,0,false,world.getInstanceId(),0); }
*/
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
if (npc.getId() == ORACLE_GUIDE_1)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -888,7 +882,7 @@ public final class CrystalCaverns extends AbstractInstance
}
else if ((npc.getId() >= 32275) && (npc.getId() <= 32277))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -902,7 +896,7 @@ public final class CrystalCaverns extends AbstractInstance
}
else if (npc.getId() == 32274)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
return "no.htm"; // TODO: Missing HTML.
@ -963,7 +957,7 @@ public final class CrystalCaverns extends AbstractInstance
if ((npc.getId() >= 32275) && (npc.getId() <= 32277) && (skill.getId() != 2360) && (skill.getId() != 2369))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if ((tmpworld instanceof CCWorld) && (getRandom(100) < 15))
{
for (L2Npc oracle : ((CCWorld) tmpworld).oracles.keySet())
@ -982,7 +976,7 @@ public final class CrystalCaverns extends AbstractInstance
{
return super.onSkillSee(npc, caster, skill, targets, isSummon);
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1009,7 +1003,7 @@ public final class CrystalCaverns extends AbstractInstance
}
else if (npc.isInvul() && (npc.getId() == TEARS) && (skill.getId() == 2369) && (caster != null))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1040,7 +1034,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if (npc.getId() == TEARS)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1119,7 +1113,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if ((npc.getId() == BAYLOR) && (skill.getId() == 5225))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
((CCWorld) tmpworld)._raidStatus++;
@ -1131,7 +1125,7 @@ public final class CrystalCaverns extends AbstractInstance
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1520,7 +1514,7 @@ public final class CrystalCaverns extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1771,11 +1765,41 @@ public final class CrystalCaverns extends AbstractInstance
}
if (npcId == ORACLE_GUIDE_1)
{
enterInstance(player, new CCWorld(System.currentTimeMillis() + 5400000), TEMPLATE_ID);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (world.getInstance().getTemplateId() == TEMPLATE_ID)
{
onEnterInstance(player, world, false);
return "";
}
player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANCE_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
return "";
}
if (checkConditions(player))
{
final InstanceWorld instance = new CCWorld(System.currentTimeMillis() + 5400000);
instance.setInstance(InstanceManager.getInstance().createDynamicInstance(TEMPLATE_ID));
InstanceManager.getInstance().addWorld(instance);
onEnterInstance(player, instance, true);
final Instance inst = InstanceManager.getInstance().getInstance(instance.getInstanceId());
if (inst.getReenterType() == InstanceReenterType.ON_ENTER)
{
handleReenterTime(instance);
}
if (inst.isRemoveBuffEnabled())
{
handleRemoveBuffs(instance);
}
}
return "";
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1965,7 +1989,7 @@ public final class CrystalCaverns extends AbstractInstance
@Override
public String onTrapAction(L2TrapInstance trap, L2Character trigger, TrapAction action)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(trap);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -1990,7 +2014,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if (character instanceof L2PcInstance)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;
@ -2057,7 +2081,7 @@ public final class CrystalCaverns extends AbstractInstance
{
if (character instanceof L2PcInstance)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof CCWorld)
{
final CCWorld world = (CCWorld) tmpworld;

View File

@ -18,8 +18,6 @@ package instances.DarkCloudMansion;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
@ -43,11 +41,6 @@ import instances.AbstractInstance;
*/
public final class DarkCloudMansion extends AbstractInstance
{
protected class DMCWorld extends InstanceWorld
{
protected Map<String, DMCRoom> rooms = new ConcurrentHashMap<>();
}
// NPCs
private static int YIYEN = 32282;
private static int SOFaith = 32288; // Symbol of Faith
@ -279,7 +272,7 @@ public final class DarkCloudMansion extends AbstractInstance
{
if (firstEntrance)
{
runStartRoom((DMCWorld) world);
runStartRoom(world);
final L2Party party = player.getParty();
if (party != null)
{
@ -300,7 +293,7 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
protected void runStartRoom(DMCWorld world)
protected void runStartRoom(InstanceWorld world)
{
world.setStatus(0);
final DMCRoom StartRoom = new DMCRoom();
@ -321,14 +314,14 @@ public final class DarkCloudMansion extends AbstractInstance
{
thisnpc.npc.setIsNoRndWalk(true);
}
world.rooms.put("StartRoom", StartRoom);
world.setParameter("StartRoom", StartRoom);
}
protected void spawnHall(DMCWorld world)
protected void spawnHall(InstanceWorld world)
{
final DMCRoom Hall = new DMCRoom();
DMCNpc thisnpc;
world.rooms.remove("Hall"); // remove room instance to avoid adding mob every time
world.getParameters().remove("Hall"); // remove room instance to avoid adding mob every time
thisnpc = new DMCNpc();
thisnpc.npc = addSpawn(BM[1], 147217, 180112, -6117, 0, false, 0, false, world.getInstanceId());
@ -394,17 +387,17 @@ public final class DarkCloudMansion extends AbstractInstance
}
Hall.npcList.add(thisnpc);
world.rooms.put("Hall", Hall);
world.setParameter("Hall", Hall);
}
protected void runHall(DMCWorld world)
protected void runHall(InstanceWorld world)
{
spawnHall(world);
world.setStatus(1);
openDoor(D1, world.getInstanceId());
}
protected void runFirstRoom(DMCWorld world)
protected void runFirstRoom(InstanceWorld world)
{
final DMCRoom FirstRoom = new DMCRoom();
DMCNpc thisnpc;
@ -441,19 +434,19 @@ public final class DarkCloudMansion extends AbstractInstance
}
FirstRoom.npcList.add(thisnpc);
world.rooms.put("FirstRoom", FirstRoom);
world.setParameter("FirstRoom", FirstRoom);
world.setStatus(2);
openDoor(D2, world.getInstanceId());
}
protected void runHall2(DMCWorld world)
protected void runHall2(InstanceWorld world)
{
addSpawn(SOFaith, 147818, 179643, -6117, 0, false, 0, false, world.getInstanceId());
spawnHall(world);
world.setStatus(3);
}
protected void runSecondRoom(DMCWorld world)
protected void runSecondRoom(InstanceWorld world)
{
final DMCRoom SecondRoom = new DMCRoom();
DMCNpc thisnpc;
@ -498,19 +491,19 @@ public final class DarkCloudMansion extends AbstractInstance
thisnpc.order = MonolithOrder[i][5];
SecondRoom.npcList.add(thisnpc);
world.rooms.put("SecondRoom", SecondRoom);
world.setParameter("SecondRoom", SecondRoom);
world.setStatus(4);
openDoor(D3, world.getInstanceId());
}
protected void runHall3(DMCWorld world)
protected void runHall3(InstanceWorld world)
{
addSpawn(SOAdversity, 147808, 181281, -6117, 16383, false, 0, false, world.getInstanceId());
spawnHall(world);
world.setStatus(5);
}
protected void runThirdRoom(DMCWorld world)
protected void runThirdRoom(InstanceWorld world)
{
final DMCRoom ThirdRoom = new DMCRoom();
final DMCNpc thisnpc = new DMCNpc();
@ -551,12 +544,12 @@ public final class DarkCloudMansion extends AbstractInstance
thisnpc.npc.setIsNoRndWalk(true);
}
ThirdRoom.npcList.add(thisnpc);
world.rooms.put("ThirdRoom", ThirdRoom);
world.setParameter("ThirdRoom", ThirdRoom);
world.setStatus(6);
openDoor(D4, world.getInstanceId());
}
protected void runThirdRoom2(DMCWorld world)
protected void runThirdRoom2(InstanceWorld world)
{
addSpawn(SOAdventure, 148910, 178397, -6117, 16383, false, 0, false, world.getInstanceId());
final DMCRoom ThirdRoom = new DMCRoom();
@ -598,11 +591,11 @@ public final class DarkCloudMansion extends AbstractInstance
thisnpc.npc.setIsNoRndWalk(true);
}
ThirdRoom.npcList.add(thisnpc);
world.rooms.put("ThirdRoom2", ThirdRoom);
world.setParameter("ThirdRoom2", ThirdRoom);
world.setStatus(8);
}
protected void runForthRoom(DMCWorld world)
protected void runForthRoom(InstanceWorld world)
{
final DMCRoom ForthRoom = new DMCRoom();
ForthRoom.counter = 0;
@ -644,19 +637,19 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
world.rooms.put("ForthRoom", ForthRoom);
world.setParameter("ForthRoom", ForthRoom);
world.setStatus(7);
openDoor(D5, world.getInstanceId());
}
protected void runFifthRoom(DMCWorld world)
protected void runFifthRoom(InstanceWorld world)
{
spawnFifthRoom(world);
world.setStatus(9);
openDoor(D6, world.getInstanceId());
}
private void spawnFifthRoom(DMCWorld world)
private void spawnFifthRoom(InstanceWorld world)
{
int idx = 0;
int temp[] = new int[6];
@ -688,7 +681,7 @@ public final class DarkCloudMansion extends AbstractInstance
idx++;
}
world.rooms.put("FifthRoom", FifthRoom);
world.setParameter("FifthRoom", FifthRoom);
}
protected boolean checkKillProgress(L2Npc npc, DMCRoom room)
@ -709,7 +702,7 @@ public final class DarkCloudMansion extends AbstractInstance
return cont;
}
protected void spawnRndGolem(DMCWorld world, DMCNpc npc)
protected void spawnRndGolem(InstanceWorld world, DMCNpc npc)
{
if (npc.golem != null)
{
@ -728,7 +721,7 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
protected void checkStone(L2Npc npc, int order[], DMCNpc npcObj, DMCWorld world)
protected void checkStone(L2Npc npc, int order[], DMCNpc npcObj, InstanceWorld world)
{
for (int i = 1; i < 7; i++)
{
@ -749,16 +742,22 @@ public final class DarkCloudMansion extends AbstractInstance
spawnRndGolem(world, npcObj);
}
protected void endInstance(DMCWorld world)
protected void endInstance(InstanceWorld world)
{
world.setStatus(10);
addSpawn(SOTruth, 148911, 181940, -6117, 16383, false, 0, false, world.getInstanceId());
world.rooms.clear();
world.getParameters().remove("StartRoom");
world.getParameters().remove("Hall");
world.getParameters().remove("FirstRoom");
world.getParameters().remove("SecondRoom");
world.getParameters().remove("ThirdRoom");
world.getParameters().remove("ForthRoom");
world.getParameters().remove("FifthRoom");
}
protected void checkBelethSample(DMCWorld world, L2Npc npc, L2PcInstance player)
protected void checkBelethSample(InstanceWorld world, L2Npc npc, L2PcInstance player)
{
final DMCRoom FifthRoom = world.rooms.get("FifthRoom");
final DMCRoom FifthRoom = world.getParameters().getObject("FifthRoom", DMCRoom.class);
for (DMCNpc mob : FifthRoom.npcList)
{
@ -789,10 +788,10 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
protected void killedBelethSample(DMCWorld world, L2Npc npc)
protected void killedBelethSample(InstanceWorld world, L2Npc npc)
{
int decayedSamples = 0;
final DMCRoom FifthRoom = world.rooms.get("FifthRoom");
final DMCRoom FifthRoom = world.getParameters().getObject("FifthRoom", DMCRoom.class);
for (DMCNpc mob : FifthRoom.npcList)
{
@ -839,9 +838,9 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
protected boolean allStonesDone(DMCWorld world)
protected boolean allStonesDone(InstanceWorld world)
{
final DMCRoom SecondRoom = world.rooms.get("SecondRoom");
final DMCRoom SecondRoom = world.getParameters().getObject("SecondRoom", DMCRoom.class);
for (DMCNpc mob : SecondRoom.npcList)
{
@ -855,9 +854,9 @@ public final class DarkCloudMansion extends AbstractInstance
return true;
}
protected void removeMonoliths(DMCWorld world)
protected void removeMonoliths(InstanceWorld world)
{
final DMCRoom SecondRoom = world.rooms.get("SecondRoom");
final DMCRoom SecondRoom = world.getParameters().getObject("SecondRoom", DMCRoom.class);
for (DMCNpc mob : SecondRoom.npcList)
{
@ -865,9 +864,9 @@ public final class DarkCloudMansion extends AbstractInstance
}
}
protected void chkShadowColumn(DMCWorld world, L2Npc npc)
protected void chkShadowColumn(InstanceWorld world, L2Npc npc)
{
final DMCRoom ForthRoom = world.rooms.get("ForthRoom");
final DMCRoom ForthRoom = world.getParameters().getObject("ForthRoom", DMCRoom.class);
for (DMCNpc mob : ForthRoom.npcList)
{
@ -897,20 +896,15 @@ public final class DarkCloudMansion extends AbstractInstance
return "";
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final DMCWorld world;
if (tmpworld instanceof DMCWorld)
{
world = (DMCWorld) tmpworld;
}
else
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world == null)
{
return "";
}
if (world.rooms.containsKey("FifthRoom"))
final DMCRoom FifthRoom = world.getParameters().getObject("FifthRoom", DMCRoom.class);
if (FifthRoom != null)
{
final DMCRoom FifthRoom = world.rooms.get("FifthRoom");
if (event.equalsIgnoreCase("decayMe"))
{
for (DMCNpc mob : FifthRoom.npcList)
@ -959,42 +953,40 @@ public final class DarkCloudMansion extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final DMCWorld world;
if (tmpworld instanceof DMCWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
world = (DMCWorld) tmpworld;
if (world.getStatus() == 0)
{
if (checkKillProgress(npc, world.rooms.get("StartRoom")))
if (checkKillProgress(npc, world.getParameters().getObject("StartRoom", DMCRoom.class)))
{
runHall(world);
}
}
if (world.getStatus() == 1)
{
if (checkKillProgress(npc, world.rooms.get("Hall")))
if (checkKillProgress(npc, world.getParameters().getObject("Hall", DMCRoom.class)))
{
runFirstRoom(world);
}
}
if (world.getStatus() == 2)
{
if (checkKillProgress(npc, world.rooms.get("FirstRoom")))
if (checkKillProgress(npc, world.getParameters().getObject("FirstRoom", DMCRoom.class)))
{
runHall2(world);
}
}
if (world.getStatus() == 3)
{
if (checkKillProgress(npc, world.rooms.get("Hall")))
if (checkKillProgress(npc, world.getParameters().getObject("Hall", DMCRoom.class)))
{
runSecondRoom(world);
}
}
if (world.getStatus() == 4)
{
final DMCRoom SecondRoom = world.rooms.get("SecondRoom");
final DMCRoom SecondRoom = world.getParameters().getObject("SecondRoom", DMCRoom.class);
for (DMCNpc mob : SecondRoom.npcList)
{
if (mob.golem == npc)
@ -1005,14 +997,14 @@ public final class DarkCloudMansion extends AbstractInstance
}
if (world.getStatus() == 5)
{
if (checkKillProgress(npc, world.rooms.get("Hall")))
if (checkKillProgress(npc, world.getParameters().getObject("Hall", DMCRoom.class)))
{
runThirdRoom(world);
}
}
if (world.getStatus() == 6)
{
if (checkKillProgress(npc, world.rooms.get("ThirdRoom")))
if (checkKillProgress(npc, world.getParameters().getObject("ThirdRoom", DMCRoom.class)))
{
runForthRoom(world);
}
@ -1023,7 +1015,7 @@ public final class DarkCloudMansion extends AbstractInstance
}
if (world.getStatus() == 8)
{
if (checkKillProgress(npc, world.rooms.get("ThirdRoom2")))
if (checkKillProgress(npc, world.getParameters().getObject("ThirdRoom2", DMCRoom.class)))
{
runFifthRoom(world);
}
@ -1039,14 +1031,12 @@ public final class DarkCloudMansion extends AbstractInstance
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final DMCWorld world;
if (tmpworld instanceof DMCWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
world = (DMCWorld) tmpworld;
if (world.getStatus() == 7)
{
final DMCRoom ForthRoom = world.rooms.get("ForthRoom");
final DMCRoom ForthRoom = world.getParameters().getObject("ForthRoom", DMCRoom.class);
for (DMCNpc mob : ForthRoom.npcList)
{
if (mob.npc == npc)
@ -1070,14 +1060,12 @@ public final class DarkCloudMansion extends AbstractInstance
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
DMCWorld world;
if (tmpworld instanceof DMCWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
world = (DMCWorld) tmpworld;
if (world.getStatus() == 4)
{
final DMCRoom SecondRoom = world.rooms.get("SecondRoom");
final DMCRoom SecondRoom = world.getParameters().getObject("SecondRoom", DMCRoom.class);
for (DMCNpc mob : SecondRoom.npcList)
{
if (mob.npc == npc)
@ -1113,17 +1101,12 @@ public final class DarkCloudMansion extends AbstractInstance
final int npcId = npc.getId();
if (npcId == YIYEN)
{
enterInstance(player, new DMCWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
}
else
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
DMCWorld world;
if (tmpworld instanceof DMCWorld)
{
world = (DMCWorld) tmpworld;
}
else
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world == null)
{
return "";
}

View File

@ -41,11 +41,6 @@ import quests.Q10285_MeetingSirra.Q10285_MeetingSirra;
*/
public final class IceQueensCastle extends AbstractInstance
{
protected class IQCWorld extends InstanceWorld
{
L2PcInstance player = null;
}
// NPCs
private static final int FREYA = 18847;
private static final int BATTALION_LEADER = 18848;
@ -168,15 +163,13 @@ public final class IceQueensCastle extends AbstractInstance
@Override
public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof IQCWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCWorld world = (IQCWorld) tmpworld;
if ((skill == ETHERNAL_BLIZZARD.getSkill()) && (world.player != null))
final L2PcInstance leader = world.getParameters().getObject("player", L2PcInstance.class);
if ((skill == ETHERNAL_BLIZZARD.getSkill()) && (leader != null))
{
startQuestTimer("TIMER_SCENE_21", 1000, npc, world.player);
startQuestTimer("TIMER_SCENE_21", 1000, npc, leader);
}
}
return super.onSpellFinished(npc, player, skill);
@ -185,7 +178,7 @@ public final class IceQueensCastle extends AbstractInstance
@Override
public String onTalk(L2Npc npc, L2PcInstance talker)
{
enterInstance(talker, new IQCWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
return super.onTalk(npc, talker);
}
@ -195,7 +188,7 @@ public final class IceQueensCastle extends AbstractInstance
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
((IQCWorld) world).player = player;
world.setParameter("player", player);
openDoor(ICE_QUEEN_DOOR, world.getInstanceId());
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);

View File

@ -0,0 +1,6 @@
<html><body>Kegor:<br>
Without you, we would have failed. I can't thank you enough.<br>
Freya's last breath will flutter against your blade, I can feel it!<br>
<a action="bypass -h Quest IceQueensCastleBattle killFreya">Rest in peace!</a><br>
<a action="bypass -h Quest IceQueensCastleBattle 18851-01.html">Can I have a second with you?</a>
</body></html>

View File

@ -14,12 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.IceQueensCastleNormalBattle;
package instances.IceQueensCastleBattle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
@ -30,11 +29,12 @@ import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2QuestGuardInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2RaidBossInstance;
@ -61,23 +61,9 @@ import quests.Q10286_ReunionWithSirra.Q10286_ReunionWithSirra;
* Ice Queen's Castle (Normal Battle) instance zone.
* @author St3eT
*/
public final class IceQueensCastleNormalBattle extends AbstractInstance
public final class IceQueensCastleBattle extends AbstractInstance
{
protected class IQCNBWorld extends InstanceWorld
{
protected List<L2PcInstance> playersInside = new ArrayList<>();
protected List<L2Npc> knightStatues = new ArrayList<>();
protected List<L2Attackable> spawnedMobs = new CopyOnWriteArrayList<>();
protected L2NpcInstance controller = null;
protected L2GrandBossInstance freya = null;
protected L2QuestGuardInstance supp_Jinia = null;
protected L2QuestGuardInstance supp_Kegor = null;
protected boolean isSupportActive = false;
protected boolean canSpawnMobs = true;
protected boolean isHardCore = false;
}
// Npcs
// NPCs
private static final int FREYA_THRONE = 29177; // First freya
private static final int FREYA_SPELLING = 29178; // Second freya
private static final int FREYA_STAND_EASY = 29179; // Last freya - Easy mode
@ -179,7 +165,7 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
23140216,
};
private IceQueensCastleNormalBattle()
private IceQueensCastleBattle()
{
addStartNpc(SIRRA, SUPP_KEGOR, SUPP_JINIA);
addFirstTalkId(SUPP_KEGOR, SUPP_JINIA);
@ -194,19 +180,20 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
{
if (event.equals("enterEasy"))
{
enterInstance(player, new IQCNBWorld(), TEMPLATE_ID_EASY);
enterInstance(player, TEMPLATE_ID_EASY);
}
else if (event.equals("enterHardcore"))
{
enterInstance(player, new IQCNBWorld(), TEMPLATE_ID_HARD);
enterInstance(player, TEMPLATE_ID_HARD);
}
else
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof IQCNBWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCNBWorld world = (IQCNBWorld) tmpworld;
final StatsSet params = world.getParameters();
final L2Npc controller = params.getObject("controller", L2Npc.class);
final L2Npc freya = params.getObject("freya", L2Npc.class);
switch (event)
{
case "openDoor":
@ -215,19 +202,18 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
{
npc.setScriptValue(1);
openDoor(DOOR_ID, world.getInstanceId());
world.controller = (L2NpcInstance) addSpawn(INVISIBLE_NPC, CONTROLLER_LOC, false, 0, true, world.getInstanceId());
final L2Npc control = addSpawn(INVISIBLE_NPC, CONTROLLER_LOC, false, 0, true, world.getInstanceId());
for (Location loc : STATUES_LOC)
{
if (loc.getZ() == -11168)
{
final L2Npc statue = addSpawn(INVISIBLE_NPC, loc, false, 0, false, world.getInstanceId());
world.knightStatues.add(statue);
addSpawn(INVISIBLE_NPC, loc, false, 0, false, world.getInstanceId());
}
}
if (!world.isHardCore)
if (!params.getBoolean("isHardCore", false))
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : params.getList("playersInside", L2PcInstance.class))
{
if ((players != null) && !players.isDead() && (players.getInstanceId() == world.getInstanceId()))
{
@ -239,7 +225,8 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
}
startQuestTimer("STAGE_1_MOVIE", 60000, world.controller, null);
world.setParameter("controller", control);
startQuestTimer("STAGE_1_MOVIE", 60000, control, null);
}
break;
}
@ -256,11 +243,11 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
qs.setMemoState(10);
qs.setCond(7, true);
}
world.supp_Kegor.deleteMe();
world.freya.decayMe();
world.getNpc(SUPP_KEGOR).deleteMe();
freya.decayMe();
manageMovie(world, 20);
cancelQuestTimer("FINISH_WORLD", world.controller, null);
startQuestTimer("FINISH_WORLD", 58500, world.controller, null);
cancelQuestTimer("FINISH_WORLD", controller, null);
startQuestTimer("FINISH_WORLD", 58500, controller, null);
break;
}
case "18851-01.html":
@ -272,80 +259,86 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
closeDoor(DOOR_ID, world.getInstanceId());
world.setStatus(1);
manageMovie(world, 15);
startQuestTimer("STAGE_1_START", 53500, world.controller, null);
startQuestTimer("STAGE_1_START", 53500, controller, null);
break;
}
case "STAGE_1_START":
{
world.freya = (L2GrandBossInstance) addSpawn(FREYA_THRONE, FREYA_SPAWN, false, 0, true, world.getInstanceId());
world.freya.setIsMortal(false);
final L2Npc frey = addSpawn(FREYA_THRONE, FREYA_SPAWN, false, 0, true, world.getInstanceId());
frey.setIsMortal(false);
manageScreenMsg(world, NpcStringId.BEGIN_STAGE_1);
startQuestTimer("CAST_BLIZZARD", 50000, world.controller, null);
startQuestTimer("STAGE_1_SPAWN", 2000, world.freya, null);
startQuestTimer("CAST_BLIZZARD", 50000, controller, null);
world.setParameter("freya", frey);
startQuestTimer("STAGE_1_SPAWN", 2000, freya, null);
world.setParameter("freya", frey);
break;
}
case "STAGE_1_SPAWN":
{
notifyEvent("START_SPAWN", world.controller, null);
notifyEvent("START_SPAWN", controller, null);
break;
}
case "STAGE_1_FINISH":
{
world.freya.deleteMe();
world.freya = null;
manageDespawnMinions(world);
manageMovie(world, 16);
startQuestTimer("STAGE_1_PAUSE", 24100 - 1000, world.controller, null);
if (freya != null)
{
world.setParameter("freya", null);
freya.deleteMe();
manageDespawnMinions(world);
manageMovie(world, 16);
startQuestTimer("STAGE_1_PAUSE", 24100 - 1000, controller, null);
}
break;
}
case "STAGE_1_PAUSE":
{
world.freya = (L2GrandBossInstance) addSpawn(FREYA_SPELLING, FREYA_SPELLING_SPAWN, false, 0, true, world.getInstanceId());
world.freya.setIsInvul(true);
world.freya.disableCoreAI(true);
final L2GrandBossInstance frey = (L2GrandBossInstance) addSpawn(FREYA_SPELLING, FREYA_SPELLING_SPAWN, false, 0, true, world.getInstanceId());
frey.setIsInvul(true);
frey.disableCoreAI(true);
manageTimer(world, 60, NpcStringId.TIME_REMAINING_UNTIL_NEXT_BATTLE);
world.setStatus(2);
startQuestTimer("STAGE_2_START", 60000, world.controller, null);
world.setParameter("freya", frey);
startQuestTimer("STAGE_2_START", 60000, controller, null);
break;
}
case "STAGE_2_START":
{
world.canSpawnMobs = true;
notifyEvent("START_SPAWN", world.controller, null);
world.setParameter("canSpawnMobs", true);
notifyEvent("START_SPAWN", controller, null);
manageScreenMsg(world, NpcStringId.BEGIN_STAGE_2);
if (world.isHardCore)
if (params.getBoolean("isHardCore", false))
{
startQuestTimer("STAGE_2_FAILED", 360000, world.controller, null);
startQuestTimer("STAGE_2_FAILED", 360000, controller, null);
manageTimer(world, 360, NpcStringId.BATTLE_END_LIMIT_TIME);
world.controller.getVariables().set("TIMER_END", System.currentTimeMillis() + 360000);
controller.getVariables().set("TIMER_END", System.currentTimeMillis() + 360000);
}
break;
}
case "STAGE_2_MOVIE":
{
manageMovie(world, 23);
startQuestTimer("STAGE_2_GLAKIAS", 7000, world.controller, null);
startQuestTimer("STAGE_2_GLAKIAS", 7000, controller, null);
break;
}
case "STAGE_2_GLAKIAS":
{
final boolean isHardMode = params.getBoolean("isHardCore", false);
for (Location loc : STATUES_LOC)
{
if (loc.getZ() == -10960)
{
final L2Npc statue = addSpawn(INVISIBLE_NPC, loc, false, 0, false, world.getInstanceId());
world.knightStatues.add(statue);
startQuestTimer("SPAWN_KNIGHT", 5000, statue, null);
}
}
final L2RaidBossInstance glakias = (L2RaidBossInstance) addSpawn((world.isHardCore ? GLAKIAS_HARD : GLAKIAS_EASY), GLAKIAS_SPAWN, false, 0, true, world.getInstanceId());
final L2RaidBossInstance glakias = (L2RaidBossInstance) addSpawn((isHardMode ? GLAKIAS_HARD : GLAKIAS_EASY), GLAKIAS_SPAWN, false, 0, true, world.getInstanceId());
startQuestTimer("LEADER_DELAY", 5000, glakias, null);
if (world.isHardCore)
if (isHardMode)
{
startQuestTimer("SHOW_GLAKIAS_TIMER", 3000, world.controller, null);
startQuestTimer("SHOW_GLAKIAS_TIMER", 3000, controller, null);
}
break;
}
@ -363,12 +356,13 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
case "STAGE_3_MOVIE":
{
manageMovie(world, 17);
startQuestTimer("STAGE_3_START", 21500, world.controller, null);
startQuestTimer("STAGE_3_START", 21500, controller, null);
break;
}
case "STAGE_3_START":
{
for (L2PcInstance players : world.playersInside)
final boolean isHardMode = params.getBoolean("isHardCore", false);
for (L2PcInstance players : params.getList("playersInside", L2PcInstance.class))
{
if (players != null)
{
@ -380,164 +374,164 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
}
freya.deleteMe();
final L2Npc frey = addSpawn((isHardMode ? FREYA_STAND_HARD : FREYA_STAND_EASY), FREYA_SPAWN, false, 0, true, world.getInstanceId());
world.setStatus(4);
world.freya.deleteMe();
world.canSpawnMobs = true;
world.freya = (L2GrandBossInstance) addSpawn((world.isHardCore ? FREYA_STAND_HARD : FREYA_STAND_EASY), FREYA_SPAWN, false, 0, true, world.getInstanceId());
world.controller.getVariables().set("FREYA_MOVE", 0);
notifyEvent("START_SPAWN", world.controller, null);
startQuestTimer("START_MOVE", 10000, world.controller, null);
startQuestTimer("CAST_BLIZZARD", 50000, world.controller, null);
world.setParameter("canSpawnMobs", true);
world.setParameter("freya", frey);
controller.getVariables().set("FREYA_MOVE", 0);
notifyEvent("START_SPAWN", controller, null);
startQuestTimer("START_MOVE", 10000, controller, null);
startQuestTimer("CAST_BLIZZARD", 50000, controller, null);
manageScreenMsg(world, NpcStringId.BEGIN_STAGE_3);
if (world.isHardCore)
if (isHardMode)
{
world.freya.doCast(FREYA_ANGER.getSkill());
startQuestTimer("FREYA_BUFF", 15000, world.controller, null);
frey.doCast(FREYA_ANGER.getSkill());
startQuestTimer("FREYA_BUFF", 15000, controller, null);
}
break;
}
case "FREYA_BUFF":
{
world.freya.doCast(FREYA_BUFF.getSkill());
startQuestTimer("FREYA_BUFF", 15000, world.controller, null);
freya.doCast(FREYA_BUFF.getSkill());
startQuestTimer("FREYA_BUFF", 15000, controller, null);
break;
}
case "START_MOVE":
{
if (npc.getVariables().getInt("FREYA_MOVE") == 0)
{
world.controller.getVariables().set("FREYA_MOVE", 1);
world.freya.setRunning();
world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
controller.getVariables().set("FREYA_MOVE", 1);
freya.setRunning();
freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
}
break;
}
case "CAST_BLIZZARD":
{
if (!world.freya.isInvul())
final boolean isHardMode = params.getBoolean("isHardCore", false);
if (!freya.isInvul())
{
final int manaBurnUse = world.controller.getVariables().getInt("MANA_BURN_USE", 0);
if (world.isHardCore && (manaBurnUse < 4) && (world.freya.getCurrentHp() < (world.freya.getMaxHp() * (0.8 - (0.2 * manaBurnUse)))))
final int manaBurnUse = controller.getVariables().getInt("MANA_BURN_USE", 0);
if (isHardMode && (manaBurnUse < 4) && (freya.getCurrentHp() < (freya.getMaxHp() * (0.8 - (0.2 * manaBurnUse)))))
{
world.controller.getVariables().set("MANA_BURN_USE", manaBurnUse + 1);
world.freya.doCast(BLIZZARD_FORCE.getSkill());
startQuestTimer("MANA_BURN", 7000, world.controller, null);
controller.getVariables().set("MANA_BURN_USE", manaBurnUse + 1);
freya.doCast(BLIZZARD_FORCE.getSkill());
startQuestTimer("MANA_BURN", 7000, controller, null);
manageScreenMsg(world, NpcStringId.MAGIC_POWER_SO_STRONG_THAT_IT_COULD_MAKE_YOU_LOSE_YOUR_MIND_CAN_BE_FELT_FROM_SOMEWHERE);
}
else
{
final Skill skill = (world.isHardCore ? BLIZZARD_HARD.getSkill() : BLIZZARD_EASY.getSkill());
world.freya.doCast(skill);
final Skill skill = (isHardMode ? BLIZZARD_HARD.getSkill() : BLIZZARD_EASY.getSkill());
freya.doCast(skill);
manageScreenMsg(world, NpcStringId.STRONG_MAGIC_POWER_CAN_BE_FELT_FROM_SOMEWHERE);
}
}
final int time = (world.isHardCore ? getRandom(35, 40) : getRandom(55, 60)) * 1000;
startQuestTimer("CAST_BLIZZARD", time, world.controller, null);
final int time = (isHardMode ? getRandom(35, 40) : getRandom(55, 60)) * 1000;
startQuestTimer("CAST_BLIZZARD", time, controller, null);
for (L2Attackable minion : world.spawnedMobs)
for (L2Npc minion : world.getNpcs(BREATH, GLACIER, KNIGHT_EASY, KNIGHT_HARD))
{
if ((minion != null) && !minion.isDead() && !minion.isInCombat())
{
manageRandomAttack(world, minion);
manageRandomAttack(world, (L2Attackable) minion);
}
}
break;
}
case "SPAWN_SUPPORT":
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : params.getList("playersInside", L2PcInstance.class))
{
players.setIsInvul(false);
}
world.freya.setIsInvul(false);
world.freya.disableCoreAI(false);
freya.setIsInvul(false);
freya.disableCoreAI(false);
manageScreenMsg(world, NpcStringId.BEGIN_STAGE_4);
world.supp_Jinia = (L2QuestGuardInstance) addSpawn(SUPP_JINIA, SUPP_JINIA_SPAWN, false, 0, true, world.getInstanceId());
world.supp_Jinia.setRunning();
world.supp_Jinia.setIsInvul(true);
world.supp_Jinia.setCanReturnToSpawnPoint(false);
world.supp_Jinia.reduceCurrentHp(1, world.freya, null); // TODO: Find better way for attack
world.freya.reduceCurrentHp(1, world.supp_Jinia, null);
world.supp_Kegor = (L2QuestGuardInstance) addSpawn(SUPP_KEGOR, SUPP_KEGOR_SPAWN, false, 0, true, world.getInstanceId());
world.supp_Kegor.setRunning();
world.supp_Kegor.setIsInvul(true);
world.supp_Kegor.setCanReturnToSpawnPoint(false);
world.supp_Kegor.reduceCurrentHp(1, world.freya, null); // TODO: Find better way for attack
world.freya.reduceCurrentHp(1, world.supp_Kegor, null);
startQuestTimer("GIVE_SUPPORT", 1000, world.controller, null);
final L2QuestGuardInstance jinia = (L2QuestGuardInstance) addSpawn(SUPP_JINIA, SUPP_JINIA_SPAWN, false, 0, true, world.getInstanceId());
jinia.setRunning();
jinia.setIsInvul(true);
jinia.setCanReturnToSpawnPoint(false);
jinia.reduceCurrentHp(1, freya, null); // TODO: Find better way for attack
freya.reduceCurrentHp(1, jinia, null);
final L2QuestGuardInstance kegor = (L2QuestGuardInstance) addSpawn(SUPP_KEGOR, SUPP_KEGOR_SPAWN, false, 0, true, world.getInstanceId());
kegor.setRunning();
kegor.setIsInvul(true);
kegor.setCanReturnToSpawnPoint(false);
kegor.reduceCurrentHp(1, freya, null); // TODO: Find better way for attack
freya.reduceCurrentHp(1, kegor, null);
startQuestTimer("GIVE_SUPPORT", 1000, controller, null);
break;
}
case "GIVE_SUPPORT":
{
if (world.isSupportActive)
if (params.getBoolean("isSupportActive", false))
{
world.supp_Jinia.doCast(JINIA_SUPPORT.getSkill());
world.supp_Kegor.doCast(KEGOR_SUPPORT.getSkill());
startQuestTimer("GIVE_SUPPORT", 25000, world.controller, null);
world.getNpc(SUPP_JINIA).doCast(JINIA_SUPPORT.getSkill());
world.getNpc(SUPP_KEGOR).doCast(KEGOR_SUPPORT.getSkill());
startQuestTimer("GIVE_SUPPORT", 25000, controller, null);
}
break;
}
case "FINISH_STAGE":
{
world.supp_Jinia.deleteMe();
world.supp_Jinia = null;
world.freya.teleToLocation(FREYA_CORPSE);
world.supp_Kegor.teleToLocation(KEGOR_FINISH);
freya.teleToLocation(FREYA_CORPSE);
world.getNpc(SUPP_JINIA).deleteMe();
world.getNpc(SUPP_KEGOR).teleToLocation(KEGOR_FINISH);
break;
}
case "START_SPAWN":
{
for (L2Npc statues : world.knightStatues)
for (L2Npc statues : getKnightStatues(world))
{
notifyEvent("SPAWN_KNIGHT", statues, null);
}
for (Location loc : KNIGHTS_LOC)
{
final L2Attackable knight = (L2Attackable) addSpawn((world.isHardCore ? KNIGHT_HARD : KNIGHT_EASY), loc, false, 0, false, world.getInstanceId());
final L2Attackable knight = (L2Attackable) addSpawn((params.getBoolean("isHardCore", false) ? KNIGHT_HARD : KNIGHT_EASY), loc, false, 0, false, world.getInstanceId());
knight.disableCoreAI(true);
knight.setDisplayEffect(1);
knight.getSpawn().setLocation(loc);
world.spawnedMobs.add(knight);
startQuestTimer("ICE_RUPTURE", getRandom(2, 5) * 1000, knight, null);
}
for (int i = 0; i < world.getStatus(); i++)
{
notifyEvent("SPAWN_GLACIER", world.controller, null);
notifyEvent("SPAWN_GLACIER", controller, null);
}
break;
}
case "SPAWN_KNIGHT":
{
if (world.canSpawnMobs)
if (params.getBoolean("canSpawnMobs", true))
{
final boolean isHardMode = params.getBoolean("isHardCore", false);
final Location loc = new Location(MIDDLE_POINT.getX() + getRandom(-1000, 1000), MIDDLE_POINT.getY() + getRandom(-1000, 1000), MIDDLE_POINT.getZ());
final L2Attackable knight = (L2Attackable) addSpawn(world.isHardCore ? KNIGHT_HARD : KNIGHT_EASY, npc.getLocation(), false, 0, false, world.getInstanceId());
final L2Attackable knight = (L2Attackable) addSpawn(isHardMode ? KNIGHT_HARD : KNIGHT_EASY, npc.getLocation(), false, 0, false, world.getInstanceId());
knight.getVariables().set("SPAWNED_NPC", npc);
knight.disableCoreAI(true);
knight.setIsImmobilized(true);
knight.setDisplayEffect(1);
knight.getSpawn().setLocation(loc);
world.spawnedMobs.add(knight);
final int time = (world.isHardCore ? getRandom(5, 10) : getRandom(15, 20)) * 1000;
final int time = (isHardMode ? getRandom(5, 10) : getRandom(15, 20)) * 1000;
startQuestTimer("ICE_RUPTURE", time, knight, null);
}
break;
}
case "SPAWN_GLACIER":
{
if (world.canSpawnMobs)
if (params.getBoolean("canSpawnMobs", true))
{
final Location loc = new Location(MIDDLE_POINT.getX() + getRandom(-1000, 1000), MIDDLE_POINT.getY() + getRandom(-1000, 1000), MIDDLE_POINT.getZ());
final L2Attackable glacier = (L2Attackable) addSpawn(GLACIER, loc, false, 0, false, world.getInstanceId());
glacier.setDisplayEffect(1);
glacier.disableCoreAI(true);
glacier.setIsImmobilized(true);
world.spawnedMobs.add(glacier);
startQuestTimer("CHANGE_STATE", 1400, glacier, null);
}
break;
@ -620,12 +614,12 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
case "FINISH_WORLD":
{
if (world.freya != null)
if (freya != null)
{
world.freya.decayMe();
freya.decayMe();
}
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : params.getList("playersInside", L2PcInstance.class))
{
if ((players != null))
{
@ -705,7 +699,6 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
breath.addDamageHate(mob.getMostHated(), 0, 999);
breath.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, mob.getMostHated());
startQuestTimer("BLIZZARD", 20000, breath, null);
world.spawnedMobs.add(breath);
}
break;
}
@ -723,13 +716,13 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
case "SHOW_GLAKIAS_TIMER":
{
final int time = (int) ((world.controller.getVariables().getLong("TIMER_END", 0) - System.currentTimeMillis()) / 1000);
final int time = (int) ((controller.getVariables().getLong("TIMER_END", 0) - System.currentTimeMillis()) / 1000);
manageTimer(world, time, NpcStringId.BATTLE_END_LIMIT_TIME);
break;
}
case "MANA_BURN":
{
for (L2PcInstance temp : world.playersInside)
for (L2PcInstance temp : params.getList("playersInside", L2PcInstance.class))
{
if ((temp != null) && (temp.getInstanceId() == world.getInstanceId()))
{
@ -748,12 +741,9 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof IQCNBWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCNBWorld world = (IQCNBWorld) tmpworld;
if (npc.getId() == SUPP_JINIA)
{
player.sendPacket(ActionFailed.STATIC_PACKET);
@ -761,7 +751,7 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
else if (npc.getId() == SUPP_KEGOR)
{
if (world.isSupportActive)
if (world.getParameters().getBoolean("isSupportActive", false))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
@ -776,27 +766,28 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof IQCNBWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCNBWorld world = (IQCNBWorld) tmpworld;
final StatsSet params = world.getParameters();
switch (npc.getId())
{
case FREYA_THRONE:
{
if ((world.controller.getVariables().getInt("FREYA_MOVE") == 0) && world.isStatus(1))
final L2Npc controller = params.getObject("controller", L2Npc.class);
final L2Npc freya = params.getObject("freya", L2Npc.class);
if ((controller.getVariables().getInt("FREYA_MOVE") == 0) && world.isStatus(1))
{
world.controller.getVariables().set("FREYA_MOVE", 1);
controller.getVariables().set("FREYA_MOVE", 1);
manageScreenMsg(world, NpcStringId.FREYA_HAS_STARTED_TO_MOVE);
world.freya.setRunning();
world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
freya.setRunning();
freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
}
if (npc.getCurrentHp() < (npc.getMaxHp() * 0.02))
{
notifyEvent("STAGE_1_FINISH", world.controller, null);
cancelQuestTimer("CAST_BLIZZARD", world.controller, null);
notifyEvent("STAGE_1_FINISH", controller, null);
cancelQuestTimer("CAST_BLIZZARD", controller, null);
}
else
{
@ -864,25 +855,27 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
case FREYA_STAND_EASY:
case FREYA_STAND_HARD:
{
if (world.controller.getVariables().getInt("FREYA_MOVE") == 0)
final L2Npc controller = params.getObject("controller", L2Npc.class);
final L2Npc freya = params.getObject("freya", L2Npc.class);
if (controller.getVariables().getInt("FREYA_MOVE") == 0)
{
world.controller.getVariables().set("FREYA_MOVE", 1);
world.freya.setRunning();
world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
controller.getVariables().set("FREYA_MOVE", 1);
freya.setRunning();
freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
}
if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.2)) && !world.isSupportActive)
if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.2)) && !params.getBoolean("isSupportActive", false))
{
world.isSupportActive = true;
world.freya.setIsInvul(true);
world.freya.disableCoreAI(true);
for (L2PcInstance players : world.playersInside)
world.setParameter("isSupportActive", true);
freya.setIsInvul(true);
freya.disableCoreAI(true);
for (L2PcInstance players : params.getList("playersInside", L2PcInstance.class))
{
players.setIsInvul(true);
players.abortAttack();
}
manageMovie(world, 18);
startQuestTimer("SPAWN_SUPPORT", 27000, world.controller, null);
startQuestTimer("SPAWN_SUPPORT", 27000, controller, null);
}
if ((attacker.getMountType() == MountType.STRIDER) && !attacker.isAffectedBySkill(ANTI_STRIDER.getSkillId()) && !npc.isCastingNow())
@ -1076,12 +1069,9 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
@Override
public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof IQCNBWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCNBWorld world = (IQCNBWorld) tmpworld;
switch (npc.getId())
{
case GLACIER:
@ -1101,7 +1091,6 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
{
manageRandomAttack(world, breath);
}
world.spawnedMobs.add(breath);
startQuestTimer("BLIZZARD", 20000, breath, null);
}
notifyEvent("SUICIDE", npc, null);
@ -1124,11 +1113,11 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof IQCNBWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final IQCNBWorld world = (IQCNBWorld) tmpworld;
final StatsSet params = world.getParameters();
final L2Npc controller = params.getObject("controller", L2Npc.class);
switch (npc.getId())
{
case GLAKIAS_EASY:
@ -1136,38 +1125,40 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
{
manageDespawnMinions(world);
manageTimer(world, 60, NpcStringId.TIME_REMAINING_UNTIL_NEXT_BATTLE);
cancelQuestTimer("STAGE_2_FAILED", world.controller, null);
startQuestTimer("STAGE_3_MOVIE", 60000, world.controller, null);
cancelQuestTimer("STAGE_2_FAILED", controller, null);
startQuestTimer("STAGE_3_MOVIE", 60000, controller, null);
break;
}
case FREYA_STAND_EASY:
case FREYA_STAND_HARD:
{
world.isSupportActive = false;
world.setParameter("isSupportActive", false);
manageMovie(world, 19);
manageDespawnMinions(world);
finishInstance(world);
DecayTaskManager.getInstance().cancel(world.freya);
cancelQuestTimer("GIVE_SUPPORT", world.controller, null);
cancelQuestTimer("CAST_BLIZZARD", world.controller, null);
cancelQuestTimer("FREYA_BUFF", world.controller, null);
startQuestTimer("FINISH_STAGE", 16000, world.controller, null);
startQuestTimer("FINISH_WORLD", 300000, world.controller, null);
DecayTaskManager.getInstance().cancel(npc);
cancelQuestTimer("GIVE_SUPPORT", controller, null);
cancelQuestTimer("CAST_BLIZZARD", controller, null);
cancelQuestTimer("FREYA_BUFF", controller, null);
startQuestTimer("FINISH_STAGE", 16000, controller, null);
startQuestTimer("FINISH_WORLD", 300000, controller, null);
break;
}
case KNIGHT_EASY:
case KNIGHT_HARD:
{
final L2Npc spawnedBy = npc.getVariables().getObject("SPAWNED_NPC", L2Npc.class);
final NpcVariables var = world.controller.getVariables();
final NpcVariables var = controller.getVariables();
int knightCount = var.getInt("KNIGHT_COUNT");
if ((var.getInt("FREYA_MOVE") == 0) && world.isStatus(1))
{
var.set("FREYA_MOVE", 1);
manageScreenMsg(world, NpcStringId.FREYA_HAS_STARTED_TO_MOVE);
world.freya.setRunning();
world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
final L2Npc freya = params.getObject("freya", L2Npc.class);
freya.setRunning();
freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MIDDLE_POINT);
}
if ((knightCount < 10) && (world.isStatus(2)))
@ -1177,28 +1168,21 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
if (knightCount == 10)
{
notifyEvent("STAGE_2_MOVIE", world.controller, null);
notifyEvent("STAGE_2_MOVIE", controller, null);
world.setStatus(3);
}
}
if (spawnedBy != null)
{
final int time = (world.isHardCore ? getRandom(30, 60) : getRandom(50, 60)) * 1000;
final int time = (params.getBoolean("isHardCore", false) ? getRandom(30, 60) : getRandom(50, 60)) * 1000;
startQuestTimer("SPAWN_KNIGHT", time, spawnedBy, null);
}
world.spawnedMobs.remove(npc);
break;
}
case GLACIER:
{
startQuestTimer("SPAWN_GLACIER", getRandom(30, 60) * 1000, world.controller, null);
world.spawnedMobs.remove(npc);
break;
}
case BREATH:
{
world.spawnedMobs.remove(npc);
startQuestTimer("SPAWN_GLACIER", getRandom(30, 60) * 1000, controller, null);
break;
}
}
@ -1211,29 +1195,32 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
{
if (firstEntrance)
{
final IQCNBWorld curworld = (IQCNBWorld) world;
curworld.isHardCore = curworld.getTemplateId() == TEMPLATE_ID_HARD;
world.setParameter("isHardCore", world.getInstance().getTemplateId() == TEMPLATE_ID_HARD);
final List<L2PcInstance> playersInside = new ArrayList<>();
if (!player.isInParty())
{
managePlayerEnter(player, curworld);
playersInside.add(player);
managePlayerEnter(player, world);
}
else if (player.getParty().isInCommandChannel())
{
for (L2PcInstance players : player.getParty().getCommandChannel().getMembers())
for (L2PcInstance member : player.getParty().getCommandChannel().getMembers())
{
managePlayerEnter(players, curworld);
playersInside.add(member);
managePlayerEnter(member, world);
}
}
else
{
for (L2PcInstance players : player.getParty().getMembers())
for (L2PcInstance member : player.getParty().getMembers())
{
managePlayerEnter(players, curworld);
playersInside.add(member);
managePlayerEnter(member, world);
}
}
for (L2PcInstance players : curworld.playersInside)
for (L2PcInstance players : playersInside)
{
if (players != null)
{
@ -1245,6 +1232,8 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
}
world.setParameter("playersInside", playersInside);
}
else
{
@ -1252,9 +1241,8 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
private void managePlayerEnter(L2PcInstance player, IQCNBWorld world)
private void managePlayerEnter(L2PcInstance player, InstanceWorld world)
{
world.playersInside.add(player);
world.addAllowed(player.getObjectId());
teleportPlayer(player, ENTER_LOC[getRandom(ENTER_LOC.length)], world.getInstanceId(), false);
}
@ -1324,10 +1312,10 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
return true;
}
private void manageRandomAttack(IQCNBWorld world, L2Attackable mob)
private void manageRandomAttack(InstanceWorld world, L2Attackable mob)
{
final List<L2PcInstance> players = new ArrayList<>();
for (L2PcInstance player : world.playersInside)
for (L2PcInstance player : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((player != null) && !player.isDead() && (player.getInstanceId() == world.getInstanceId()) && !player.isInvisible())
{
@ -1349,21 +1337,18 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
private void manageDespawnMinions(IQCNBWorld world)
private void manageDespawnMinions(InstanceWorld world)
{
world.canSpawnMobs = false;
for (L2Attackable mobs : world.spawnedMobs)
world.setParameter("canSpawnMobs", false);
for (L2MonsterInstance mobs : world.getAliveNpcs(L2MonsterInstance.class, BREATH, GLACIER, KNIGHT_EASY, KNIGHT_HARD))
{
if ((mobs != null) && !mobs.isDead())
{
mobs.doDie(null);
}
mobs.doDie(null);
}
}
private void manageTimer(IQCNBWorld world, int time, NpcStringId npcStringId)
private void manageTimer(InstanceWorld world, int time, NpcStringId npcStringId)
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
{
@ -1372,9 +1357,9 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
private void manageScreenMsg(IQCNBWorld world, NpcStringId stringId)
private void manageScreenMsg(InstanceWorld world, NpcStringId stringId)
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
{
@ -1383,9 +1368,9 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
private void manageMovie(IQCNBWorld world, int movie)
private void manageMovie(InstanceWorld world, int movie)
{
for (L2PcInstance players : world.playersInside)
for (L2PcInstance players : world.getParameters().getList("playersInside", L2PcInstance.class))
{
if ((players != null) && (players.getInstanceId() == world.getInstanceId()))
{
@ -1394,8 +1379,16 @@ public final class IceQueensCastleNormalBattle extends AbstractInstance
}
}
private List<L2Npc> getKnightStatues(InstanceWorld world)
{
final L2Npc controller = world.getParameters().getObject("controller", L2Npc.class);
final List<L2Npc> invis = world.getNpcs(INVISIBLE_NPC);
invis.remove(controller);
return invis;
}
public static void main(String[] args)
{
new IceQueensCastleNormalBattle();
new IceQueensCastleBattle();
}
}

View File

@ -1,6 +0,0 @@
<html><body>Kegor:<br>
Without you, we would have failed. I can't thank you enough.<br>
Freya's last breath will flutter against your blade, I can feel it!<br>
<a action="bypass -h Quest IceQueensCastleNormalBattle killFreya">Rest in peace!</a><br>
<a action="bypass -h Quest IceQueensCastleNormalBattle 18851-01.html">Can I have a second with you?</a>
</body></html>

View File

@ -551,7 +551,7 @@ public final class Kamaloka extends AbstractInstance
if (world != null)
{
// but not in kamaloka
if (!(world instanceof KamaWorld) || (world.getTemplateId() != templateId))
if (!(world instanceof KamaWorld) || (world.getInstance().getTemplateId() != templateId))
{
player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANCE_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
return;
@ -579,25 +579,21 @@ public final class Kamaloka extends AbstractInstance
return;
}
// Creating dynamic instance without template
final int instanceId = InstanceManager.getInstance().createDynamicInstance(templateId);
final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
// set return location
inst.setExitLoc(new Location(player));
// disable summon friend into instance
inst.setAllowSummon(false);
// set duration and empty destroy time
inst.setDuration(DURATION[index] * 60000);
inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
// Creating new instanceWorld, using our instanceId and templateId
world = new KamaWorld();
world.setInstanceId(instanceId);
world.setTemplateId(templateId);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(templateId));
// set return location
world.getInstance().setExitLoc(new Location(player));
// disable summon friend into instance
world.getInstance().setAllowSummon(false);
// set duration and empty destroy time
world.getInstance().setDuration(DURATION[index] * 60000);
world.getInstance().setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
// set index for easy access to the arrays
((KamaWorld) world).index = index;
InstanceManager.getInstance().addWorld(world);
world.setStatus(0);
// spawn npcs
spawnKama((KamaWorld) world);
@ -607,7 +603,7 @@ public final class Kamaloka extends AbstractInstance
{
world.addAllowed(partyMember.getObjectId());
removeBuffs(partyMember);
teleportPlayer(partyMember, TELEPORTS[index], instanceId);
teleportPlayer(partyMember, TELEPORTS[index], world.getInstanceId());
}
return;
}
@ -631,7 +627,7 @@ public final class Kamaloka extends AbstractInstance
reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(world.getTemplateId());
sm.addInstanceName(world.getInstance().getTemplateId());
// set instance reenter time for all allowed players
for (int objectId : world.getAllowed())
@ -639,7 +635,7 @@ public final class Kamaloka extends AbstractInstance
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, world.getInstance().getTemplateId(), reenter.getTimeInMillis());
obj.sendPacket(sm);
}
}
@ -760,7 +756,7 @@ public final class Kamaloka extends AbstractInstance
// only party leader can talk with escape teleporter
if ((party != null) && party.isLeader(player))
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world instanceof KamaWorld)
{
// party members must be in the instance
@ -808,7 +804,7 @@ public final class Kamaloka extends AbstractInstance
@Override
public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc);
if (tmpWorld instanceof KamaWorld)
{
final KamaWorld world = (KamaWorld) tmpWorld;

View File

@ -39,11 +39,6 @@ import quests.Q10284_AcquisitionOfDivineSword.Q10284_AcquisitionOfDivineSword;
*/
public final class MithrilMine extends AbstractInstance
{
protected class MMWorld extends InstanceWorld
{
protected int _count = 0;
}
// NPCs
private static final int KEGOR = 18846;
private static final int MITHRIL_MILLIPEDE = 22766;
@ -78,7 +73,7 @@ public final class MithrilMine extends AbstractInstance
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
switch (event)
{
@ -94,7 +89,7 @@ public final class MithrilMine extends AbstractInstance
}
case "TIMER":
{
if (world instanceof MMWorld)
if (world != null)
{
for (Location loc : MOB_SPAWNS)
{
@ -156,8 +151,7 @@ public final class MithrilMine extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final MMWorld _world = ((MMWorld) world);
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (npc.getId() == KEGOR)
{
@ -168,10 +162,11 @@ public final class MithrilMine extends AbstractInstance
{
if (npc.isScriptValue(1))
{
_world._count++;
final int count = world.getParameters().getInt("count", 0);
world.setParameter("count", count + 1);
}
if (_world._count >= 5)
if (world.getParameters().getInt("count", 0) >= 5)
{
final QuestState qs = player.getQuestState(Q10284_AcquisitionOfDivineSword.class.getSimpleName());
if ((qs != null) && qs.isMemoState(2))
@ -202,7 +197,7 @@ public final class MithrilMine extends AbstractInstance
giveItems(talker, COLD_RESISTANCE_POTION, 1);
}
qs.setCond(4, true);
enterInstance(talker, new MMWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
}
break;
}

View File

@ -229,7 +229,7 @@ public final class NornilsGarden extends AbstractInstance
private void exitInstance(L2PcInstance player)
{
final InstanceWorld inst = InstanceManager.getInstance().getWorld(player.getInstanceId());
final InstanceWorld inst = InstanceManager.getInstance().getWorld(player);
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
@ -243,7 +243,7 @@ public final class NornilsGarden extends AbstractInstance
InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (!(world instanceof NornilsWorld) || (world.getTemplateId() != TEMPLATE_ID))
if (!(world instanceof NornilsWorld) || (world.getInstance().getTemplateId() != TEMPLATE_ID))
{
player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANCE_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
return null;
@ -271,16 +271,14 @@ public final class NornilsGarden extends AbstractInstance
return result;
}
final int instanceId = InstanceManager.getInstance().createDynamicInstance(TEMPLATE_ID);
final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
inst.setExitLoc(new Location(player));
inst.setAllowSummon(false);
inst.setDuration(DURATION_TIME * 60000);
inst.setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
world = new NornilsWorld();
world.setInstanceId(instanceId);
world.setTemplateId(TEMPLATE_ID);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(TEMPLATE_ID));
InstanceManager.getInstance().addWorld(world);
world.getInstance().setExitLoc(new Location(player));
world.getInstance().setAllowSummon(false);
world.getInstance().setDuration(DURATION_TIME * 60000);
world.getInstance().setEmptyDestroyTime(EMPTY_DESTROY_TIME * 60000);
final int instanceId = world.getInstanceId();
LOGGER.info("Nornils Garden: started, Instance: " + instanceId + " created by player: " + player.getName());
prepareInstance((NornilsWorld) world);
@ -312,7 +310,7 @@ public final class NornilsGarden extends AbstractInstance
private void spawn1(L2Npc npc)
{
final InstanceWorld inst = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld inst = InstanceManager.getInstance().getWorld(npc);
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
@ -330,7 +328,7 @@ public final class NornilsGarden extends AbstractInstance
private void spawn2(L2Npc npc)
{
final InstanceWorld inst = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld inst = InstanceManager.getInstance().getWorld(npc);
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
@ -348,7 +346,7 @@ public final class NornilsGarden extends AbstractInstance
private void spawn3(L2Character cha)
{
final InstanceWorld inst = InstanceManager.getInstance().getWorld(cha.getInstanceId());
final InstanceWorld inst = InstanceManager.getInstance().getWorld(cha);
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
@ -366,7 +364,7 @@ public final class NornilsGarden extends AbstractInstance
private void spawn4(L2Character cha)
{
final InstanceWorld inst = InstanceManager.getInstance().getWorld(cha.getInstanceId());
final InstanceWorld inst = InstanceManager.getInstance().getWorld(cha);
if (inst instanceof NornilsWorld)
{
final NornilsWorld world = ((NornilsWorld) inst);
@ -385,7 +383,7 @@ public final class NornilsGarden extends AbstractInstance
public void openDoor(QuestState st, L2PcInstance player, int doorId)
{
st.unset("correct");
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player);
if (tmpworld instanceof NornilsWorld)
{
openDoor(doorId, tmpworld.getInstanceId());
@ -469,7 +467,7 @@ public final class NornilsGarden extends AbstractInstance
{
if ((character instanceof L2PcInstance) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof NornilsWorld)
{
for (int _auto[] : _auto_gates)
@ -618,7 +616,7 @@ public final class NornilsGarden extends AbstractInstance
// Check if gatekeeper should open bridge, and open it
if (_gk[2] > 0)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player);
if (tmpworld instanceof NornilsWorld)
{
openDoor(_gk[2], tmpworld.getInstanceId());

View File

@ -32,11 +32,6 @@ import quests.Q00236_SeedsOfChaos.Q00236_SeedsOfChaos;
*/
public final class NornilsGardenQuest extends AbstractInstance
{
protected static final class NornilsGardenQuestWorld extends InstanceWorld
{
protected Location ORIGIN_LOC;
}
// NPCs
private static final int RODENPICULA = 32237;
private static final int MOTHER_NORNIL = 32239;
@ -70,9 +65,9 @@ public final class NornilsGardenQuest extends AbstractInstance
{
if (checkConditions(player))
{
final NornilsGardenQuestWorld world = new NornilsGardenQuestWorld();
world.ORIGIN_LOC = player.getLocation();
enterInstance(player, world, TEMPLATE_ID);
final Location originLoc = player.getLocation();
enterInstance(player, TEMPLATE_ID);
InstanceManager.getInstance().getPlayerWorld(player).setParameter("ORIGIN_LOC", originLoc);
q236.setCond(16, true);
htmltext = "32190-02.html";
}
@ -86,12 +81,11 @@ public final class NornilsGardenQuest extends AbstractInstance
{
if ((q236 != null) && q236.isCompleted())
{
final NornilsGardenQuestWorld world = (NornilsGardenQuestWorld) InstanceManager.getInstance().getPlayerWorld(player);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
world.removeAllowed(player.getObjectId());
finishInstance(world, 5000);
player.setInstanceId(0);
player.teleToLocation(world.ORIGIN_LOC);
player.teleToLocation(world.getParameters().getLocation("ORIGIN_LOC"));
htmltext = "32239-03.html";
}
break;

View File

@ -16,8 +16,8 @@
*/
package instances.PailakaDevilsLegacy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
@ -43,12 +43,6 @@ import quests.Q00129_PailakaDevilsLegacy.Q00129_PailakaDevilsLegacy;
*/
public final class PailakaDevilsLegacy extends AbstractInstance
{
protected class DIWorld extends InstanceWorld
{
protected L2Attackable _lematanNpc = null;
protected List<L2Attackable> _followerslist = new CopyOnWriteArrayList<>();
}
// NPCs
private static final int LEMATAN = 18633; // Lematan
private static final int SURVIVOR = 32498; // Devil's Isle Survivor
@ -105,13 +99,13 @@ public final class PailakaDevilsLegacy extends AbstractInstance
@Override
public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
String htmltext = null;
if (event.equals("enter"))
{
final QuestState qs = player.getQuestState(Q00129_PailakaDevilsLegacy.class.getSimpleName());
enterInstance(player, new DIWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
if (qs.isCond(1))
{
qs.setCond(2, true);
@ -122,22 +116,21 @@ public final class PailakaDevilsLegacy extends AbstractInstance
htmltext = "32498-02.htm";
}
}
else if ((tmpworld != null) && (tmpworld instanceof DIWorld))
else if (world != null)
{
final DIWorld world = (DIWorld) tmpworld;
switch (event)
{
case "FOLLOWER_CAST":
{
if ((world._lematanNpc != null) && !world._lematanNpc.isDead())
final L2Npc lematanNpc = world.getParameters().getObject("lematanNpc", L2Npc.class);
if ((lematanNpc != null) && !lematanNpc.isDead())
{
for (L2Attackable follower : world._followerslist)
for (L2Npc follower : world.getParameters().getList("followerslist", L2Npc.class, new ArrayList<>()))
{
follower.setTarget(world._lematanNpc);
follower.setTarget(lematanNpc);
follower.doCast(ENERGY.getSkill());
}
startQuestTimer("FOLLOWER_CAST", 15000, world._lematanNpc, null);
startQuestTimer("FOLLOWER_CAST", 15000, lematanNpc, null);
}
break;
}
@ -148,14 +141,16 @@ public final class PailakaDevilsLegacy extends AbstractInstance
npc.teleToLocation(LEMATAN_PORT);
npc.getVariables().set("ON_SHIP", 1);
npc.getSpawn().setLocation(LEMATAN_PORT);
final List<L2Npc> followerslist = world.getParameters().getList("followerslist", L2Npc.class, new ArrayList<>());
for (Location loc : FOLLOWERS_LOC)
{
final L2Attackable follower = (L2Attackable) addSpawn(FOLLOWERS, loc, false, 0, false, world.getInstanceId());
final L2Npc follower = addSpawn(FOLLOWERS, loc, false, 0, false, world.getInstanceId());
follower.disableCoreAI(true);
follower.setIsImmobilized(true);
world._followerslist.add(follower);
followerslist.add(follower);
}
startQuestTimer("FOLLOWER_CAST", 4000, world._lematanNpc, null);
world.setParameter("followerslist", followerslist);
startQuestTimer("FOLLOWER_CAST", 4000, world.getParameters().getObject("lematanNpc", L2Npc.class), null);
break;
}
case "TELEPORT":
@ -176,9 +171,8 @@ public final class PailakaDevilsLegacy extends AbstractInstance
@Override
public final String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof DIWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
switch (npc.getId())
{
@ -260,20 +254,14 @@ public final class PailakaDevilsLegacy extends AbstractInstance
@Override
public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((tmpworld != null) && (tmpworld instanceof DIWorld))
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final DIWorld world = (DIWorld) tmpworld;
if (world._followerslist != null)
for (L2Npc _follower : world.getParameters().getList("followerslist", L2Npc.class, new ArrayList<>()))
{
for (L2Npc _follower : world._followerslist)
{
_follower.deleteMe();
}
world._followerslist.clear();
_follower.deleteMe();
}
world.getParameters().remove("followerslist");
addSpawn(ADVENTURER2, ADVENTURER_LOC, false, 0, false, npc.getInstanceId());
}
return super.onKill(npc, player, isSummon);
@ -284,10 +272,10 @@ public final class PailakaDevilsLegacy extends AbstractInstance
{
if ((character.isPlayer()) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(character.getInstanceId());
if ((world != null) && (world.getTemplateId() == TEMPLATE_ID))
final InstanceWorld world = InstanceManager.getInstance().getWorld(character);
if ((world != null) && (world.getInstance().getTemplateId() == TEMPLATE_ID))
{
startQuestTimer("TELEPORT", 1000, ((DIWorld) world)._lematanNpc, (L2PcInstance) character);
startQuestTimer("TELEPORT", 1000, world.getParameters().getObject("lematanNpc", L2Npc.class), (L2PcInstance) character);
}
}
return super.onEnterZone(character, zone);
@ -332,7 +320,7 @@ public final class PailakaDevilsLegacy extends AbstractInstance
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
((DIWorld) world)._lematanNpc = (L2Attackable) addSpawn(LEMATAN, LEMATAN_SPAWN, false, 0, false, world.getInstanceId());
world.setParameter("lematanNpc", addSpawn(LEMATAN, LEMATAN_SPAWN, false, 0, false, world.getInstanceId()));
}
teleportPlayer(player, TELEPORT, world.getInstanceId());
}

View File

@ -169,8 +169,8 @@ public final class PailakaSongOfIceAndFire extends AbstractInstance
{
if ((character.isPlayer()) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(character.getInstanceId());
if ((world != null) && (world.getTemplateId() == TEMPLATE_ID))
final InstanceWorld world = InstanceManager.getInstance().getWorld(character);
if ((world != null) && (world.getInstance().getTemplateId() == TEMPLATE_ID))
{
startQuestTimer("TELEPORT", 1000, null, (L2PcInstance) character);
}

View File

@ -43,13 +43,6 @@ import quests.Q00196_SevenSignsSealOfTheEmperor.Q00196_SevenSignsSealOfTheEmpero
*/
public final class SSQDisciplesNecropolisPast extends AbstractInstance
{
protected class DNPWorld extends InstanceWorld
{
protected final List<L2Npc> anakimGroup = new ArrayList<>();
protected final List<L2Npc> lilithGroup = new ArrayList<>();
protected int countKill = 0;
}
// NPCs
private static final int SEAL_DEVICE = 27384;
private static final int PROMISE_OF_MAMMON = 32585;
@ -130,24 +123,27 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
addTalkId(PROMISE_OF_MAMMON, SHUNAIMAN, LEON, DISCIPLES_GATEKEEPER);
}
protected void spawnNPC(DNPWorld world)
protected void spawnNPC(InstanceWorld world)
{
final List<L2Npc> lilithGroup = new ArrayList<>();
for (Map.Entry<Integer, Location> entry : LILITH_SPAWN.entrySet())
{
final L2Npc npc = addSpawn(entry.getKey(), entry.getValue(), false, 0, false, world.getInstanceId());
world.lilithGroup.add(npc);
lilithGroup.add(addSpawn(entry.getKey(), entry.getValue(), false, 0, false, world.getInstanceId()));
}
world.setParameter("lilithGroup", lilithGroup);
final List<L2Npc> anakimGroup = new ArrayList<>();
for (Map.Entry<Integer, Location> entry : ANAKIM_SPAWN.entrySet())
{
final L2Npc enpc = addSpawn(entry.getKey(), entry.getValue(), false, 0, false, world.getInstanceId());
world.anakimGroup.add(enpc);
anakimGroup.add(addSpawn(entry.getKey(), entry.getValue(), false, 0, false, world.getInstanceId()));
}
world.getParameters().set("anakimGroup", anakimGroup);
}
private synchronized void checkDoors(L2Npc npc, DNPWorld world)
private synchronized void checkDoors(L2Npc npc, InstanceWorld world)
{
world.countKill++;
switch (world.countKill)
final int countKill = world.getParameters().getInt("countKill", 0) + 1;
world.setParameter("countKill", countKill);
switch (countKill)
{
case 4:
{
@ -182,7 +178,7 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
{
if (firstEntrance)
{
spawnNPC((DNPWorld) world);
spawnNPC(world);
world.addAllowed(player.getObjectId());
}
teleportPlayer(player, ENTER, world.getInstanceId());
@ -200,10 +196,9 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof DNPWorld)
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
final DNPWorld world = (DNPWorld) tmpworld;
switch (event)
{
case "FINISH":
@ -222,11 +217,13 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
}
case "FIGHT":
{
for (L2Npc caster : world.anakimGroup)
final List<L2Npc> anakimGroup = world.getParameters().getList("anakimGroup", L2Npc.class, new ArrayList<>());
final List<L2Npc> lilithGroup = world.getParameters().getList("lilithGroup", L2Npc.class, new ArrayList<>());
for (L2Npc caster : anakimGroup)
{
if ((caster != null) && !caster.isCastingNow())
{
makeCast(caster, world.lilithGroup);
makeCast(caster, lilithGroup);
}
if ((caster != null) && (caster.getId() == ANAKIM))
{
@ -241,11 +238,11 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
}
}
}
for (L2Npc caster : world.lilithGroup)
for (L2Npc caster : lilithGroup)
{
if ((caster != null) && !caster.isCastingNow())
{
makeCast(caster, world.anakimGroup);
makeCast(caster, anakimGroup);
}
if ((caster != null) && (caster.getId() == 32715))
{
@ -352,8 +349,8 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
@Override
public String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof DNPWorld)
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (npc.isScriptValue(0))
{
@ -383,10 +380,9 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof DNPWorld)
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
final DNPWorld world = (DNPWorld) tmpworld;
checkDoors(npc, world);
}
@ -437,7 +433,7 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
{
if (qs.isCond(3) || qs.isCond(4))
{
enterInstance(talker, new DNPWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
return "";
}
break;
@ -458,10 +454,9 @@ public final class SSQDisciplesNecropolisPast extends AbstractInstance
{
if (qs.getCond() >= 3)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof DNPWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final DNPWorld world = (DNPWorld) tmpworld;
openDoor(DISCIPLES_NECROPOLIS_DOOR, world.getInstanceId());
talker.showQuestMovie(12);
startQuestTimer("FIGHT", 1000, null, talker);

View File

@ -35,11 +35,6 @@ import quests.Q10296_SevenSignsOneWhoSeeksThePowerOfTheSeal.Q10296_SevenSignsOne
*/
public final class SSQElcadiasTent extends AbstractInstance
{
protected class ETWorld extends InstanceWorld
{
}
// NPCs
private static final int ELCADIA = 32784;
private static final int GRUFF_LOOKING_MAN = 32862;
@ -71,7 +66,7 @@ public final class SSQElcadiasTent extends AbstractInstance
|| ((Q10293 != null) && Q10293.isCompleted() && (Q10294 == null)) //
|| ((Q10296 != null) && (Q10296.getMemoState() > 2) && (Q10296.getMemoState() < 4)))
{
enterInstance(talker, new ETWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
}
else
{

View File

@ -29,11 +29,6 @@ import instances.AbstractInstance;
*/
public final class SSQHideoutOfTheDawn extends AbstractInstance
{
protected class HotDWorld extends InstanceWorld
{
}
// NPCs
private static final int WOOD = 32593;
private static final int JAINA = 32617;
@ -71,7 +66,7 @@ public final class SSQHideoutOfTheDawn extends AbstractInstance
}
case "32593-01.html":
{
enterInstance(player, new HotDWorld(), TEMPLATE_ID);
enterInstance(player, TEMPLATE_ID);
htmltext = event;
}
}

View File

@ -32,11 +32,6 @@ import instances.AbstractInstance;
*/
public final class SSQLibraryOfSages extends AbstractInstance
{
protected class LoSWorld extends InstanceWorld
{
protected L2Npc elcadia = null;
}
// NPCs
private static final int SOPHIA1 = 32596;
private static final int PILE_OF_BOOKS1 = 32809;
@ -72,23 +67,22 @@ public final class SSQLibraryOfSages extends AbstractInstance
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof LoSWorld)
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
final LoSWorld world = (LoSWorld) tmpworld;
switch (event)
{
case "TELEPORT2":
{
teleportPlayer(player, LIBRARY_LOC, world.getInstanceId());
world.elcadia.teleToLocation(LIBRARY_LOC.getX(), LIBRARY_LOC.getY(), LIBRARY_LOC.getZ(), 0, world.getInstanceId());
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(LIBRARY_LOC.getX(), LIBRARY_LOC.getY(), LIBRARY_LOC.getZ(), 0, world.getInstanceId());
break;
}
case "exit":
{
cancelQuestTimer("FOLLOW", npc, player);
player.teleToLocation(EXIT_LOC);
world.elcadia.deleteMe();
world.getParameters().getObject("elcadia", L2Npc.class).deleteMe();
break;
}
case "FOLLOW":
@ -103,7 +97,7 @@ public final class SSQLibraryOfSages extends AbstractInstance
{
cancelQuestTimer("FOLLOW", npc, player);
teleportPlayer(player, START_LOC, world.getInstanceId());
world.elcadia.teleToLocation(START_LOC.getX(), START_LOC.getY(), START_LOC.getZ(), 0, world.getInstanceId());
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(START_LOC.getX(), START_LOC.getY(), START_LOC.getZ(), 0, world.getInstanceId());
break;
}
}
@ -114,7 +108,7 @@ public final class SSQLibraryOfSages extends AbstractInstance
@Override
public String onTalk(L2Npc npc, L2PcInstance talker)
{
enterInstance(talker, new LoSWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
return super.onTalk(npc, talker);
}
@ -126,17 +120,18 @@ public final class SSQLibraryOfSages extends AbstractInstance
world.addAllowed(player.getObjectId());
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
spawnElcadia(player, (LoSWorld) world);
spawnElcadia(player, world);
}
private void spawnElcadia(L2PcInstance player, LoSWorld world)
private void spawnElcadia(L2PcInstance player, InstanceWorld world)
{
if (world.elcadia != null)
final L2Npc elcadia = world.getParameters().getObject("elcadia", L2Npc.class);
if (elcadia != null)
{
world.elcadia.deleteMe();
elcadia.deleteMe();
}
world.elcadia = addSpawn(ELCADIA_INSTANCE, player, false, 0, false, player.getInstanceId());
startQuestTimer("FOLLOW", 3000, world.elcadia, player);
world.setParameter("elcadia", addSpawn(ELCADIA_INSTANCE, player, false, 0, false, player.getInstanceId()));
startQuestTimer("FOLLOW", 3000, elcadia, player);
}
public static void main(String[] args)

View File

@ -39,13 +39,6 @@ import quests.Q10296_SevenSignsOneWhoSeeksThePowerOfTheSeal.Q10296_SevenSignsOne
*/
public final class SSQMonasteryOfSilence extends AbstractInstance
{
protected static final class MoSWorld extends InstanceWorld
{
protected L2Npc elcadia = null;
protected int deadTombGuardianCount = 0;
protected int deadSolinaGuardianCount = 0;
}
// NPCs
private static final int ELCADIA_INSTANCE = 32787;
private static final int ERIS_EVIL_THOUGHTS = 32792;
@ -199,22 +192,21 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
world.addAllowed(player.getObjectId());
}
teleportPlayer(player, START_LOC, world.getInstanceId(), false);
spawnElcadia(player, (MoSWorld) world);
spawnElcadia(player, world);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof MoSWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final MoSWorld world = (MoSWorld) tmpworld;
switch (event)
{
case "TELE2":
{
teleportPlayer(player, CENTRAL_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(CENTRAL_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(CENTRAL_ROOM_LOC, world.getInstanceId(), 0);
startQuestTimer("START_MOVIE", 2000, npc, player);
break;
}
@ -223,7 +215,7 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
cancelQuestTimer("FOLLOW", npc, player);
cancelQuestTimer("DIALOG", npc, player);
teleportPlayer(player, EXIT_LOC, 0);
world.elcadia.deleteMe();
world.getParameters().getObject("elcadia", L2Npc.class).deleteMe();
break;
}
case "START_MOVIE":
@ -234,37 +226,37 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case "BACK":
{
teleportPlayer(player, BACK_LOC, world.getInstanceId());
world.elcadia.teleToLocation(BACK_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(BACK_LOC, world.getInstanceId(), 0);
break;
}
case "EAST":
{
teleportPlayer(player, EAST_WATCHERS_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(EAST_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(EAST_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "WEST":
{
teleportPlayer(player, WEST_WATCHERS_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(WEST_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(WEST_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "NORTH":
{
teleportPlayer(player, NORTH_WATCHERS_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(NORTH_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(NORTH_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "SOUTH":
{
teleportPlayer(player, SOUTH_WATCHERS_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(SOUTH_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(SOUTH_WATCHERS_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "CENTER":
{
teleportPlayer(player, CENTRAL_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(CENTRAL_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(CENTRAL_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "FOLLOW":
@ -296,7 +288,7 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case "ENTER_Q10295":
{
teleportPlayer(player, START_LOC_Q10295, world.getInstanceId());
world.elcadia.teleToLocation(START_LOC_Q10295, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(START_LOC_Q10295, world.getInstanceId(), 0);
startQuestTimer("START_MOVIE_Q10295", 2000, npc, player);
break;
}
@ -308,19 +300,19 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case "CASKET_ROOM":
{
teleportPlayer(player, CASKET_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(CASKET_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(CASKET_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "SOLINAS_RESTING_PLACE":
{
teleportPlayer(player, SOLINAS_RESTING_PLACE_LOC, world.getInstanceId());
world.elcadia.teleToLocation(SOLINAS_RESTING_PLACE_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(SOLINAS_RESTING_PLACE_LOC, world.getInstanceId(), 0);
break;
}
case "ERIS_OFFICE":
{
teleportPlayer(player, START_LOC, world.getInstanceId());
world.elcadia.teleToLocation(START_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(START_LOC, world.getInstanceId(), 0);
break;
}
case "OPEN_DOORS":
@ -334,7 +326,7 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case "DIRECTORS_ROOM":
{
teleportPlayer(player, DIRECTORS_ROOM_LOC, world.getInstanceId());
world.elcadia.teleToLocation(DIRECTORS_ROOM_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(DIRECTORS_ROOM_LOC, world.getInstanceId(), 0);
break;
}
case "USE_SCROLL":
@ -437,19 +429,19 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
{
player.showQuestMovie(29);
startQuestTimer("TELEPORT_SPACE", 60000, npc, player);
world.elcadia.teleToLocation(ELCADIA_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(ELCADIA_LOC, world.getInstanceId(), 0);
break;
}
case "TELEPORT_SPACE":
{
teleportPlayer(player, SPACE_LOC, world.getInstanceId());
world.elcadia.teleToLocation(SPACE_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(SPACE_LOC, world.getInstanceId(), 0);
addSpawn(ETIS_VAN_ETINA, ETIS_VAN_ETINA_LOC, false, 0, false, world.getInstanceId());
break;
}
case "TELEPORT_TO_PLAYER":
{
world.elcadia.teleToLocation(player.getX(), player.getY(), player.getZ(), 0, world.getInstanceId());
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(player.getX(), player.getY(), player.getZ(), 0, world.getInstanceId());
break;
}
}
@ -460,10 +452,9 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof MoSWorld)
InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
MoSWorld world = (MoSWorld) tmpworld;
switch (npc.getId())
{
case GUARDIAN_OF_THE_TOMB_1:
@ -471,8 +462,9 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case GUARDIAN_OF_THE_TOMB_3:
case GUARDIAN_OF_THE_TOMB_4:
{
world.deadTombGuardianCount++;
if (world.deadTombGuardianCount == 4)
final int deadTombGuardianCount = world.getParameters().getInt("deadTombGuardianCount", 0) + 1;
world.setParameter("deadTombGuardianCount", deadTombGuardianCount);
if (deadTombGuardianCount == 4)
{
openDoor(TOMB_DOOR, world.getInstanceId());
final QuestState st = player.getQuestState(Q10295_SevenSignsSolinasTomb.class.getSimpleName());
@ -488,8 +480,9 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case SOLINAS_GUARDIAN_3:
case SOLINAS_GUARDIAN_4:
{
world.deadSolinaGuardianCount++;
if (world.deadSolinaGuardianCount == 4)
final int deadSolinaGuardianCount = world.getParameters().getInt("deadSolinaGuardianCount", 0) + 1;
world.setParameter("deadSolinaGuardianCount", deadSolinaGuardianCount);
if (deadSolinaGuardianCount == 4)
{
player.showQuestMovie(27);
final QuestState st = player.getQuestState(Q10295_SevenSignsSolinasTomb.class.getSimpleName());
@ -503,7 +496,7 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
case ETIS_VAN_ETINA:
{
player.showQuestMovie(30);
world.elcadia.teleToLocation(ELCADIA_LOC, world.getInstanceId(), 0);
world.getParameters().getObject("elcadia", L2Npc.class).teleToLocation(ELCADIA_LOC, world.getInstanceId(), 0);
startQuestTimer("TELEPORT_TO_PLAYER", 63000, npc, player);
final QuestState st = player.getQuestState(Q10296_SevenSignsOneWhoSeeksThePowerOfTheSeal.class.getSimpleName());
if ((st != null) && st.isMemoState(2))
@ -542,20 +535,21 @@ public final class SSQMonasteryOfSilence extends AbstractInstance
{
if (npc.getId() == ODD_GLOBE)
{
enterInstance(talker, new MoSWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
}
return super.onTalk(npc, talker);
}
protected void spawnElcadia(L2PcInstance player, MoSWorld world)
protected void spawnElcadia(L2PcInstance player, InstanceWorld world)
{
if (world.elcadia != null)
if (world.getParameters().getObject("elcadia", L2Npc.class) != null)
{
world.elcadia.deleteMe();
world.getParameters().getObject("elcadia", L2Npc.class).deleteMe();
}
world.elcadia = addSpawn(ELCADIA_INSTANCE, player.getX(), player.getY(), player.getZ(), 0, false, 0, false, world.getInstanceId());
startQuestTimer("FOLLOW", 5000, world.elcadia, player);
startQuestTimer("DIALOG", 10000, world.elcadia, player);
final L2Npc elcadia = addSpawn(ELCADIA_INSTANCE, player.getX(), player.getY(), player.getZ(), 0, false, 0, false, world.getInstanceId());
world.setParameter("elcadia", elcadia);
startQuestTimer("FOLLOW", 5000, elcadia, player);
startQuestTimer("DIALOG", 10000, elcadia, player);
}
public static void main(String[] args)

View File

@ -16,11 +16,6 @@
*/
package instances.SSQSanctumOfTheLordsOfDawn;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2World;
@ -43,17 +38,6 @@ import quests.Q00195_SevenSignsSecretRitualOfThePriests.Q00195_SevenSignsSecretR
*/
public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
{
protected static final class HSWorld extends InstanceWorld
{
protected int doorst = 0;
protected static final Map<Integer, List<L2Npc>> _save_point = new HashMap<>();
public static Map<Integer, List<L2Npc>> getMonsters()
{
return _save_point;
}
}
// NPCs
private static final int GUARDS_OF_THE_DAWN = 18834;
private static final int GUARDS_OF_THE_DAWN_2 = 18835;
@ -97,10 +81,9 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
{
case "spawn":
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof HSWorld)
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
final HSWorld world = (HSWorld) tmpworld;
spawnGroup("high_priest_of_dawn", world.getInstanceId());
player.sendPacket(SystemMessageId.BY_USING_THE_SKILL_OF_EINHASAD_S_HOLY_SWORD_DEFEAT_THE_EVIL_LILIMS);
}
@ -127,14 +110,52 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
}
}
OUTTER: for (Entry<Integer, List<L2Npc>> entry : HSWorld._save_point.entrySet())
InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
for (L2Npc monster : entry.getValue())
boolean teleported = false;
for (L2Npc monster : world.getParameters().getList("save_point1", L2Npc.class))
{
if (monster.getObjectId() == npc.getObjectId())
if ((monster != null) && (monster.getObjectId() == npc.getObjectId()))
{
player.teleToLocation(SAVE_POINT[entry.getKey()]);
break OUTTER;
teleported = true;
player.teleToLocation(SAVE_POINT[1]);
break;
}
}
if (!teleported)
{
for (L2Npc monster : world.getParameters().getList("save_point2", L2Npc.class))
{
if ((monster != null) && (monster.getObjectId() == npc.getObjectId()))
{
teleported = true;
player.teleToLocation(SAVE_POINT[2]);
break;
}
}
}
if (!teleported)
{
for (L2Npc monster : world.getParameters().getList("save_point3", L2Npc.class))
{
if ((monster != null) && (monster.getObjectId() == npc.getObjectId()))
{
teleported = true;
player.teleToLocation(SAVE_POINT[3]);
break;
}
}
}
if (!teleported)
{
for (L2Npc monster : world.getParameters().getList("save_point4", L2Npc.class))
{
if ((monster != null) && (monster.getObjectId() == npc.getObjectId()))
{
player.teleToLocation(SAVE_POINT[4]);
break;
}
}
}
}
@ -149,11 +170,10 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
if (firstEntrance)
{
world.addAllowed(player.getObjectId());
final Map<Integer, List<L2Npc>> save_point = HSWorld.getMonsters();
save_point.put(0, spawnGroup("save_point1", world.getInstanceId()));
save_point.put(1, spawnGroup("save_point2", world.getInstanceId()));
save_point.put(2, spawnGroup("save_point3", world.getInstanceId()));
save_point.put(3, spawnGroup("save_point4", world.getInstanceId()));
world.setParameter("save_point1", spawnGroup("save_point1", world.getInstanceId()));
world.setParameter("save_point2", spawnGroup("save_point2", world.getInstanceId()));
world.setParameter("save_point3", spawnGroup("save_point3", world.getInstanceId()));
world.setParameter("save_point4", spawnGroup("save_point4", world.getInstanceId()));
}
teleportPlayer(player, ENTER, world.getInstanceId());
}
@ -168,32 +188,32 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
final QuestState qs = talker.getQuestState(Q00195_SevenSignsSecretRitualOfThePriests.class.getSimpleName());
if ((qs != null) && qs.isCond(3) && hasQuestItems(talker, IDENTITY_CARD) && (talker.getTransformationId() == 113))
{
enterInstance(talker, new HSWorld(), TEMPLATE_ID);
enterInstance(talker, TEMPLATE_ID);
return "32575-01.html";
}
return "32575-02.html";
}
case IDENTITY_CONFIRM_DEVICE:
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmpworld instanceof HSWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
if (hasQuestItems(talker, IDENTITY_CARD) && (talker.getTransformationId() == 113))
{
final HSWorld world = (HSWorld) tmpworld;
if (world.doorst == 0)
final int doorst = world.getParameters().getInt("doorst", 0);
if (doorst == 0)
{
openDoor(DOOR_ONE, world.getInstanceId());
talker.sendPacket(SystemMessageId.BY_USING_THE_INVISIBLE_SKILL_SNEAK_INTO_THE_DAWN_S_DOCUMENT_STORAGE);
talker.sendPacket(SystemMessageId.MALE_GUARDS_CAN_DETECT_THE_CONCEALMENT_BUT_THE_FEMALE_GUARDS_CANNOT);
talker.sendPacket(SystemMessageId.FEMALE_GUARDS_NOTICE_THE_DISGUISES_FROM_FAR_AWAY_BETTER_THAN_THE_MALE_GUARDS_DO_SO_BEWARE);
world.doorst++;
world.setParameter("doorst", doorst + 1);
npc.decayMe();
}
else if (world.doorst == 1)
else if (doorst == 1)
{
openDoor(DOOR_TWO, world.getInstanceId());
world.doorst++;
world.setParameter("doorst", doorst + 1);
npc.decayMe();
for (int objId : world.getAllowed())
{
@ -213,10 +233,9 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
}
case PASSWORD_ENTRY_DEVICE:
{
final InstanceWorld tmworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if (tmworld instanceof HSWorld)
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
if (world != null)
{
final HSWorld world = (HSWorld) tmworld;
openDoor(DOOR_THREE, world.getInstanceId());
return "32577-01.html";
}
@ -231,7 +250,7 @@ public final class SSQSanctumOfTheLordsOfDawn extends AbstractInstance
}
case SHELF:
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld world = InstanceManager.getInstance().getWorld(npc);
InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
talker.teleToLocation(-75925, 213399, -7128);
return "32580-01.html";

View File

@ -870,8 +870,8 @@ public class Q00144_PailakaInjuredDragon extends Quest
{
if ((character instanceof L2PcInstance) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(character.getInstanceId());
if ((world != null) && (world.getTemplateId() == INSTANCE_ID))
final InstanceWorld world = InstanceManager.getInstance().getWorld(character);
if ((world != null) && (world.getInstance().getTemplateId() == INSTANCE_ID))
{
// If a player wants to go by a mob wall without kill it, he will be returned back to a spawn point.
final int[] zoneTeleport = NOEXIT_ZONES.get(zone.getId());
@ -939,7 +939,7 @@ public class Q00144_PailakaInjuredDragon extends Quest
InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
if (world.getTemplateId() != INSTANCE_ID)
if (world.getInstance().getTemplateId() != INSTANCE_ID)
{
player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_ANOTHER_INSTANCE_ZONE_THEREFORE_YOU_CANNOT_ENTER_CORRESPONDING_DUNGEON);
return;
@ -953,17 +953,15 @@ public class Q00144_PailakaInjuredDragon extends Quest
// New instance.
else
{
final int instanceId = InstanceManager.getInstance().createDynamicInstance(INSTANCE_ID);
world = new InstanceWorld();
world.setInstanceId(instanceId);
world.setTemplateId(INSTANCE_ID);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(INSTANCE_ID));
InstanceManager.getInstance().addWorld(world);
// Check max summon levels.
checkMaxSummonLevel(player);
world.addAllowed(player.getObjectId());
teleportPlayer(player, TELEPORT, instanceId);
teleportPlayer(player, TELEPORT, world.getInstanceId());
}
}

View File

@ -286,15 +286,12 @@ public final class Q00511_AwlUnderFoot extends Quest
return ret;
}
final L2Party party = player.getParty();
final int instanceId = InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId());
final Instance ins = InstanceManager.getInstance().getInstance(instanceId);
ins.setExitLoc(new Location(player));
world = new FAUWorld();
world.setInstanceId(instanceId);
world.setTemplateId(dungeon.getInstanceId());
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId()));
world.getInstance().setExitLoc(new Location(player));
dungeon.setReEnterTime(System.currentTimeMillis() + REENTERTIME);
InstanceManager.getInstance().addWorld(world);
final int instanceId = world.getInstanceId();
LOGGER.info("Fortress AwlUnderFoot started " + dungeon.getInstanceId() + " Instance: " + instanceId + " created by player: " + player.getName());
ThreadPool.schedule(new spawnRaid((FAUWorld) world), RAID_SPAWN_DELAY);
@ -373,7 +370,7 @@ public final class Q00511_AwlUnderFoot extends Quest
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof FAUWorld)
{
final FAUWorld world = (FAUWorld) tmpworld;

View File

@ -36,6 +36,7 @@ public final class Q00694_BreakThroughTheHallOfSuffering extends Quest
private static final int TEPIOS2 = 32530;
private static final int MARK = 13691;
private static final int SOE = 736;
private static final int TEMPLATE_ID = 115;
public Q00694_BreakThroughTheHallOfSuffering()
{
@ -97,7 +98,7 @@ public final class Q00694_BreakThroughTheHallOfSuffering extends Quest
case TEPIOS2:
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if ((world != null) && (world.getTemplateId() == 115))
if ((world != null) && (world.getInstance().getTemplateId() == TEMPLATE_ID))
{
final int tag = world.getParameters().getInt("tag", -1);
if (tag == -1)
@ -290,14 +291,14 @@ public final class Q00694_BreakThroughTheHallOfSuffering extends Quest
reenter.set(Calendar.HOUR_OF_DAY, 6);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(world.getTemplateId());
sm.addInstanceName(TEMPLATE_ID);
for (int objectId : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, TEMPLATE_ID, reenter.getTimeInMillis());
obj.sendPacket(sm);
}
}

View File

@ -36,6 +36,7 @@ public final class Q00695_DefendTheHallOfSuffering extends Quest
private static final int TEPIOS = 32603;
private static final int TEPIOS2 = 32530;
private static final int SOE = 736;
private static final int TEMPLATE_ID = 116;
public Q00695_DefendTheHallOfSuffering()
{
@ -106,7 +107,7 @@ public final class Q00695_DefendTheHallOfSuffering extends Quest
{
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if ((world != null) && (world.getTemplateId() == 116))
if ((world != null) && (world.getInstance().getTemplateId() == TEMPLATE_ID))
{
final int tag = world.getParameters().getInt("tag", -1);
if (tag == -1)
@ -259,14 +260,14 @@ public final class Q00695_DefendTheHallOfSuffering extends Quest
reenter.set(Calendar.HOUR_OF_DAY, 6);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_S_ENTRY_HAS_BEEN_RESTRICTED_YOU_CAN_CHECK_THE_NEXT_POSSIBLE_ENTRY_TIME_BY_USING_THE_COMMAND_INSTANCEZONE);
sm.addInstanceName(world.getTemplateId());
sm.addInstanceName(TEMPLATE_ID);
for (int objectId : world.getAllowed())
{
final L2PcInstance obj = L2World.getInstance().getPlayer(objectId);
if ((obj != null) && obj.isOnline())
{
InstanceManager.getInstance().setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
InstanceManager.getInstance().setInstanceTime(objectId, TEMPLATE_ID, reenter.getTimeInMillis());
obj.sendPacket(sm);
}
}

View File

@ -214,7 +214,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
return null;
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof PAWORLD)
{
final PAWORLD world = (PAWORLD) tmpworld;
@ -272,20 +272,16 @@ public class Q00726_LightWithinTheDarkness extends Quest
return ret;
}
final L2Party party = player.getParty();
final int instanceId = InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId());
final Instance ins = InstanceManager.getInstance().getInstance(instanceId);
ins.setExitLoc(new Location(player));
world = new PAWORLD();
world.setInstanceId(instanceId);
world.setTemplateId(dungeon.getInstanceId());
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId()));
world.getInstance().setExitLoc(new Location(player));
dungeon.setReEnterTime(System.currentTimeMillis() + 14400000);
InstanceManager.getInstance().addWorld(world);
ThreadPool.schedule(new spawnNpcs((PAWORLD) world), 10000);
for (L2PcInstance partyMember : party.getMembers())
{
teleportPlayer(partyMember, coords, instanceId);
teleportPlayer(partyMember, coords, world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
if (partyMember.getQuestState(getName()) == null)
{

View File

@ -216,7 +216,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
}
else if (event.equalsIgnoreCase("suicide"))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
tmpworld.setStatus(5);
final Instance inst = InstanceManager.getInstance().getInstance(npc.getInstanceId());
if (inst != null)
@ -297,7 +297,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player);
if (tmpworld instanceof CAUWorld)
{
final CAUWorld world = (CAUWorld) tmpworld;
@ -327,7 +327,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
if ((npc.getId() >= NPC_KNIGHT) && (npc.getId() <= NPC_WARRIOR))
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(player);
if ((tmpworld != null) && (tmpworld instanceof CAUWorld))
{
final CAUWorld world = (CAUWorld) tmpworld;
@ -443,7 +443,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
return null;
}
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof CAUWorld)
{
final CAUWorld world = (CAUWorld) tmpworld;
@ -624,13 +624,10 @@ public class Q00727_HopeWithinTheDarkness extends Quest
}
final L2Party party = player.getParty();
final int instanceId = InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId());
final Instance ins = InstanceManager.getInstance().getInstance(instanceId);
ins.setExitLoc(new Location(player));
world = new CAUWorld();
world.setInstanceId(instanceId);
world.setTemplateId(dungeon.getInstanceId());
world.setStatus(0);
world.setInstance(InstanceManager.getInstance().createDynamicInstance(dungeon.getInstanceId()));
world.getInstance().setExitLoc(new Location(player));
final int instanceId = world.getInstanceId();
dungeon.setReEnterTime(System.currentTimeMillis() + REENTER_INTERVAL);
InstanceManager.getInstance().addWorld(world);
ThreadPool.schedule(new spawnNpcs((CAUWorld) world), INITIAL_SPAWN_DELAY);

View File

@ -30,6 +30,7 @@ import org.w3c.dom.Node;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.instancezone.InstanceWorld;
@ -251,6 +252,15 @@ public final class InstanceManager implements IGameXmlReader
return _instanceWorlds.get(instanceId);
}
/**
* @param object
* @return the InstanceWorld of the object
*/
public InstanceWorld getWorld(L2Object object)
{
return _instanceWorlds.get(object.getInstanceId());
}
/**
* Check if the player have a World Instance where it's allowed to enter.
* @param player the player to check
@ -353,7 +363,7 @@ public final class InstanceManager implements IGameXmlReader
* @param templateId the instance template id
* @return
*/
public int createDynamicInstance(int templateId)
public Instance createDynamicInstance(int templateId)
{
while (getInstance(_dynamic) != null)
{
@ -372,7 +382,7 @@ public final class InstanceManager implements IGameXmlReader
instance.spawnDoors();
instance.spawnGroup("general");
}
return _dynamic;
return instance;
}
/**

View File

@ -55,6 +55,6 @@ public class ConditionPlayerInstanceId extends Condition
}
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(effector.getActingPlayer());
return (world != null) && (world.getInstanceId() == instanceId) && _instanceIds.contains(world.getTemplateId());
return (world != null) && (world.getInstanceId() == instanceId) && _instanceIds.contains(world.getInstance().getTemplateId());
}
}

View File

@ -594,7 +594,7 @@ public class Duel
return;
}
_duelInstanceId = InstanceManager.getInstance().createDynamicInstance(Rnd.get(147, 150)); // Random Olympiad arena.
_duelInstanceId = InstanceManager.getInstance().createDynamicInstance(Rnd.get(147, 150)).getId(); // Random Olympiad arena.
final L2OlympiadStadiumZone zone = ZoneManager.getInstance().getZone(InstanceManager.getInstance().getInstance(_duelInstanceId).getNpcs().get(0), L2OlympiadStadiumZone.class);
if (zone == null)
{

View File

@ -268,7 +268,7 @@ public class TvTEvent
{
try
{
_TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_ID);
_TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_ID).getId();
InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
InstanceManager.getInstance().getInstance(_TvTEventInstance).setIsPvP(true);
InstanceManager.getInstance().getInstance(_TvTEventInstance).setEmptyDestroyTime((Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000L);

View File

@ -69,6 +69,7 @@ public final class Instance
private static final Logger LOGGER = Logger.getLogger(Instance.class.getName());
private final int _id;
private int _templateId = -1;
private int _ejectTime = Config.EJECT_DEAD_PLAYER_TIME;
/** Allow random walk for NPCs, global parameter. */
private boolean _allowRandomWalk = true;
@ -112,6 +113,15 @@ public final class Instance
return _id;
}
/**
* Get template ID of instance world.
* @return instance template ID
*/
public int getTemplateId()
{
return _templateId;
}
/**
* @return the eject time
*/
@ -484,6 +494,7 @@ public final class Instance
private void parseInstance(Node n) throws Exception
{
_templateId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
Node a = n.getAttributes().getNamedItem("ejectTime");
if (a != null)
{

View File

@ -18,10 +18,13 @@ package com.l2jmobius.gameserver.model.instancezone;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
@ -31,8 +34,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class InstanceWorld
{
private int _instanceId;
private int _templateId = -1;
private Instance _instance;
private final List<Integer> _allowed = new CopyOnWriteArrayList<>();
private final StatsSet _parameters = new StatsSet();
@ -56,40 +58,31 @@ public class InstanceWorld
return _allowed.contains(id);
}
/**
* Sets the instance.
* @param instance the instance
*/
public void setInstance(Instance instance)
{
_instance = instance;
}
/**
* Gets the instance.
* @return the instance
*/
public Instance getInstance()
{
return _instance;
}
/**
* Gets the dynamically generated instance ID.
* @return the instance ID
*/
public int getInstanceId()
{
return _instanceId;
}
/**
* Sets the instance ID.
* @param instanceId the instance ID
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
}
/**
* Gets the client's template instance ID.
* @return the template ID
*/
public int getTemplateId()
{
return _templateId;
}
/**
* Sets the template ID.
* @param templateId the template ID
*/
public void setTemplateId(int templateId)
{
_templateId = templateId;
return _instance.getId();
}
/**
@ -177,4 +170,78 @@ public class InstanceWorld
victim.getActingPlayer().sendPacket(sm);
instance.addEjectDeadTask(victim.getActingPlayer());
}
/**
* Get spawned NPCs from instance.
* @return set of NPCs from instance
*/
public List<L2Npc> getNpcs()
{
return _instance.getNpcs();
}
/**
* Get alive NPCs from instance.
* @return set of NPCs from instance
*/
public List<L2Npc> getAliveNpcs()
{
return getNpcs().stream().filter(n -> n.getCurrentHp() > 0).collect(Collectors.toList());
}
/**
* Get spawned NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
public List<L2Npc> getNpcs(int... id)
{
return getNpcs().stream().filter(n -> CommonUtil.contains(id, n.getId())).collect(Collectors.toList());
}
/**
* Get spawned NPCs from instance with specific IDs and class type.
* @param <T>
* @param clazz
* @param ids IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
@SafeVarargs
public final <T extends L2Character> List<T> getNpcs(Class<T> clazz, int... ids)
{
return getNpcs().stream().filter(n -> (ids.length == 0) || CommonUtil.contains(ids, n.getId())).filter(clazz::isInstance).map(clazz::cast).collect(Collectors.toList());
}
/**
* Get spawned and alive NPCs from instance with specific IDs and class type.
* @param <T>
* @param clazz
* @param ids IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
@SafeVarargs
public final <T extends L2Character> List<T> getAliveNpcs(Class<T> clazz, int... ids)
{
return getNpcs().stream().filter(n -> ((ids.length == 0) || CommonUtil.contains(ids, n.getId())) && (n.getCurrentHp() > 0)).filter(clazz::isInstance).map(clazz::cast).collect(Collectors.toList());
}
/**
* Get alive NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
public List<L2Npc> getAliveNpcs(int... id)
{
return getNpcs().stream().filter(n -> (n.getCurrentHp() > 0) && CommonUtil.contains(id, n.getId())).collect(Collectors.toList());
}
/**
* Get first found spawned NPC with specific ID.
* @param id ID of NPC to be found
* @return first found NPC with specified ID, otherwise {@code null}
*/
public L2Npc getNpc(int id)
{
return getNpcs().stream().filter(n -> n.getId() == id).findFirst().orElse(null);
}
}

View File

@ -53,22 +53,22 @@ public class OlympiadGameManager implements Runnable
{
case "Grassy Arena":
{
instanceId = InstanceManager.getInstance().createDynamicInstance(147);
instanceId = InstanceManager.getInstance().createDynamicInstance(147).getId();
break;
}
case "Three Bridges Arena":
{
instanceId = InstanceManager.getInstance().createDynamicInstance(148);
instanceId = InstanceManager.getInstance().createDynamicInstance(148).getId();
break;
}
case "Heros's Vestiges Arena":
{
instanceId = InstanceManager.getInstance().createDynamicInstance(149);
instanceId = InstanceManager.getInstance().createDynamicInstance(149).getId();
break;
}
case "Orbis Arena":
{
instanceId = InstanceManager.getInstance().createDynamicInstance(150);
instanceId = InstanceManager.getInstance().createDynamicInstance(150).getId();
break;
}
}

View File

@ -201,8 +201,8 @@ public abstract class L2ZoneType extends ListenersContainer
// Check instance
if (_instanceTemplateId > 0)
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(character.getInstanceId());
if ((world != null) && (world.getTemplateId() != _instanceTemplateId))
final InstanceWorld world = InstanceManager.getInstance().getWorld(character);
if ((world != null) && (world.getInstance().getTemplateId() != _instanceTemplateId))
{
return false;
}