Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -1,621 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import java.util.Calendar;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.Instance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.instancezone.InstanceWorld;
import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Util;
import instances.AbstractInstance;
/**
* Chambers of Delusion superclass.
* @author GKR
*/
abstract class Chamber extends AbstractInstance
{
private class CDWorld extends InstanceWorld
{
int currentRoom;
final L2Party partyInside;
final ScheduledFuture<?> _banishTask;
private ScheduledFuture<?> _roomChangeTask;
CDWorld(L2Party party)
{
currentRoom = 0;
partyInside = party;
_banishTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new BanishTask(), 60000, 60000);
}
L2Party getPartyInside()
{
return partyInside;
}
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 = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeRoomTask(), nextInterval - 5000);
}
}
void stopBanishTask()
{
_banishTask.cancel(true);
}
void stopRoomChangeTask()
{
_roomChangeTask.cancel(true);
}
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() && ((partyInside == null) || !pl.isInParty() || (partyInside != pl.getParty())))
{
exitInstance(pl);
}
}
}
}
}
class ChangeRoomTask implements Runnable
{
@Override
public void run()
{
try
{
earthQuake(CDWorld.this);
Thread.sleep(5000);
changeRoom(CDWorld.this);
}
catch (Exception e)
{
_log.log(Level.WARNING, getClass().getSimpleName() + " ChangeRoomTask exception : " + e.getMessage(), e);
}
}
}
}
// Items
private static final int ENRIA = 4042;
private static final int ASOFE = 4043;
private static final int THONS = 4044;
private static final int LEONARD = 9628;
private static final int DELUSION_MARK = 15311;
// NPCs
private final int ENTRANCE_GATEKEEPER;
private final int ROOM_GATEKEEPER_FIRST;
private final int ROOM_GATEKEEPER_LAST;
private final int AENKINEL;
private final int BOX;
// Skills
private static final SkillHolder SUCCESS_SKILL = new SkillHolder(5758, 1);
private static final SkillHolder FAIL_SKILL = new SkillHolder(5376, 4);
private static final int ROOM_CHANGE_INTERVAL = 480; // 8 min
private static final int ROOM_CHANGE_RANDOM_TIME = 120; // 2 min
// Instance restart time
private static final int RESET_HOUR = 6;
private static final int RESET_MIN = 30;
// Following values vary between scripts
private final int INSTANCEID;
private final String INSTANCE_TEMPLATE;
protected Location[] ROOM_ENTER_POINTS;
// Misc
private static final String RETURN = Chamber.class.getSimpleName() + "_return";
protected Chamber(String name, String descr, int instanceId, String instanceTemplateName, int entranceGKId, int roomGKFirstId, int roomGKLastId, int aenkinelId, int boxId)
{
super(name, descr);
INSTANCEID = instanceId;
INSTANCE_TEMPLATE = instanceTemplateName;
ENTRANCE_GATEKEEPER = entranceGKId;
ROOM_GATEKEEPER_FIRST = roomGKFirstId;
ROOM_GATEKEEPER_LAST = roomGKLastId;
AENKINEL = aenkinelId;
BOX = boxId;
addStartNpc(ENTRANCE_GATEKEEPER);
addTalkId(ENTRANCE_GATEKEEPER);
for (int i = ROOM_GATEKEEPER_FIRST; i <= ROOM_GATEKEEPER_LAST; i++)
{
addStartNpc(i);
addTalkId(i);
}
addKillId(AENKINEL);
addAttackId(BOX);
addSpellFinishedId(BOX);
addEventReceivedId(BOX);
}
private boolean isBigChamber()
{
return (INSTANCEID == 131) || (INSTANCEID == 132);
}
private boolean isBossRoom(CDWorld world)
{
return world.currentRoom == (ROOM_ENTER_POINTS.length - 1);
}
@Override
protected boolean checkConditions(L2PcInstance player)
{
final L2Party party = player.getParty();
if (party == null)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_CURRENTLY_IN_A_PARTY_SO_YOU_CANNOT_ENTER));
return false;
}
if (party.getLeader() != player)
{
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ONLY_A_PARTY_LEADER_CAN_MAKE_THE_REQUEST_TO_ENTER));
return false;
}
for (L2PcInstance partyMember : party.getMembers())
{
if (partyMember.getLevel() < 80)
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_S_LEVEL_DOES_NOT_CORRESPOND_TO_THE_REQUIREMENTS_FOR_ENTRY);
sm.addPcName(partyMember);
party.broadcastPacket(sm);
return false;
}
if (!Util.checkIfInRange(1000, player, partyMember, true))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_LOCATION_WHICH_CANNOT_BE_ENTERED_THEREFORE_IT_CANNOT_BE_PROCESSED);
sm.addPcName(partyMember);
party.broadcastPacket(sm);
return false;
}
if (isBigChamber() && (System.currentTimeMillis() < InstanceManager.getInstance().getInstanceTime(partyMember.getObjectId(), INSTANCEID)))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_RE_ENTER_YET);
sm.addPcName(partyMember);
party.broadcastPacket(sm);
return false;
}
}
return true;
}
private void markRestriction(InstanceWorld world)
{
if (world instanceof CDWorld)
{
final Calendar reenter = Calendar.getInstance();
final Calendar now = Calendar.getInstance();
reenter.set(Calendar.MINUTE, RESET_MIN);
reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
if (reenter.before(now))
{
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()));
// 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());
player.sendPacket(sm);
}
}
}
}
void changeRoom(CDWorld world)
{
final L2Party party = world.getPartyInside();
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
if ((party == null) || (inst == null))
{
return;
}
int newRoom = world.currentRoom;
// Do nothing, if there are raid room of Square or Tower Chamber
if (isBigChamber() && isBossRoom(world))
{
return;
}
// Teleport to raid room 10 min or lesser before instance end time for Tower and Square Chambers
else if (isBigChamber() && ((inst.getInstanceEndTime() - System.currentTimeMillis()) < 600000))
{
newRoom = ROOM_ENTER_POINTS.length - 1;
}
// 10% chance for teleport to raid room if not here already for Northern, Southern, Western and Eastern Chambers
else if (!isBigChamber() && !isBossRoom(world) && (getRandom(100) < 10))
{
newRoom = ROOM_ENTER_POINTS.length - 1;
}
else
{
while (newRoom == world.currentRoom) // otherwise teleport to another room, except current
{
newRoom = getRandom(ROOM_ENTER_POINTS.length - 1);
}
}
for (L2PcInstance partyMember : party.getMembers())
{
if (world.getInstanceId() == partyMember.getInstanceId())
{
partyMember.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
teleportPlayer(partyMember, ROOM_ENTER_POINTS[newRoom], world.getInstanceId());
}
}
world.currentRoom = newRoom;
// Do not schedule room change for Square and Tower Chambers, if raid room is reached
if (isBigChamber() && isBossRoom(world))
{
inst.setDuration((int) ((inst.getInstanceEndTime() - System.currentTimeMillis()) + 1200000)); // Add 20 min to instance time if raid room is reached
for (L2Npc npc : inst.getNpcs())
{
if (npc.getId() == ROOM_GATEKEEPER_LAST)
{
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NpcStringId.MINUTES_ARE_ADDED_TO_THE_REMAINING_TIME_IN_THE_INSTANT_ZONE));
}
}
}
else
{
world.scheduleRoomChange(false);
}
}
private void enter(CDWorld world)
{
final L2Party party = world.getPartyInside();
if (party == null)
{
return;
}
for (L2PcInstance partyMember : party.getMembers())
{
if (hasQuestItems(partyMember, DELUSION_MARK))
{
takeItems(partyMember, DELUSION_MARK, -1);
}
if (party.isLeader(partyMember))
{
giveItems(partyMember, DELUSION_MARK, 1);
}
// Save location for teleport back into main hall
partyMember.getVariables().set(RETURN, Integer.toString(partyMember.getX()) + ";" + Integer.toString(partyMember.getY()) + ";" + Integer.toString(partyMember.getZ()));
partyMember.setInstanceId(world.getInstanceId());
world.addAllowed(partyMember.getObjectId());
}
changeRoom(world);
}
void earthQuake(CDWorld world)
{
final L2Party party = world.getPartyInside();
if (party == null)
{
return;
}
for (L2PcInstance partyMember : party.getMembers())
{
if (world.getInstanceId() == partyMember.getInstanceId())
{
partyMember.sendPacket(new Earthquake(partyMember.getX(), partyMember.getY(), partyMember.getZ(), 20, 10));
}
}
}
@Override
public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
{
if (firstEntrance)
{
enter((CDWorld) world);
}
else
{
teleportPlayer(player, ROOM_ENTER_POINTS[((CDWorld) world).currentRoom], world.getInstanceId());
}
}
void exitInstance(L2PcInstance player)
{
if ((player == null) || !player.isOnline() || (player.getInstanceId() == 0))
{
return;
}
final Instance inst = InstanceManager.getInstance().getInstance(player.getInstanceId());
final Location ret = inst.getExitLoc();
final String return_point = player.getVariables().getString(RETURN, null);
if (return_point != null)
{
final String[] coords = return_point.split(";");
if (coords.length == 3)
{
try
{
ret.setLocation(new Location(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])));
}
catch (Exception e)
{
}
}
}
teleportPlayer(player, ret, 0);
final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
if (world != null)
{
world.removeAllowed(player.getObjectId());
}
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = "";
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
if ((player != null) && (tmpworld != null) && (tmpworld instanceof CDWorld) && (npc.getId() >= ROOM_GATEKEEPER_FIRST) && (npc.getId() <= ROOM_GATEKEEPER_LAST))
{
final CDWorld world = (CDWorld) tmpworld;
// Change room from dialog
if (event.equals("next_room"))
{
if (player.getParty() == null)
{
htmltext = getHtm(player.getHtmlPrefix(), "scripts/instances/ChambersOfDelusion/no_party.html");
}
else if (player.getParty().getLeaderObjectId() != player.getObjectId())
{
htmltext = getHtm(player.getHtmlPrefix(), "scripts/instances/ChambersOfDelusion/no_leader.html");
}
else if (hasQuestItems(player, DELUSION_MARK))
{
takeItems(player, DELUSION_MARK, 1);
world.stopRoomChangeTask();
changeRoom(world);
}
else
{
htmltext = getHtm(player.getHtmlPrefix(), "scripts/instances/ChambersOfDelusion/no_item.html");
}
}
else if (event.equals("go_out"))
{
if (player.getParty() == null)
{
htmltext = getHtm(player.getHtmlPrefix(), "scripts/instances/ChambersOfDelusion/no_party.html");
}
else if (player.getParty().getLeaderObjectId() != player.getObjectId())
{
htmltext = getHtm(player.getHtmlPrefix(), "scripts/instances/ChambersOfDelusion/no_leader.html");
}
else
{
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
world.stopRoomChangeTask();
world.stopBanishTask();
for (L2PcInstance partyMember : player.getParty().getMembers())
{
exitInstance(partyMember);
}
inst.setEmptyDestroyTime(0);
}
}
else if (event.equals("look_party") && (player.getParty() != null) && (player.getParty() == world.getPartyInside()))
{
teleportPlayer(player, ROOM_ENTER_POINTS[world.currentRoom], world.getInstanceId(), false);
}
}
return htmltext;
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, Skill skill)
{
if (!npc.isBusy() && (npc.getCurrentHp() < (npc.getMaxHp() / 10)))
{
npc.setBusy(true);
if (getRandom(100) < 25) // 25% chance to reward
{
if (getRandom(100) < 33)
{
npc.dropItem(attacker, ENRIA, (int) (3 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 50)
{
npc.dropItem(attacker, THONS, (int) (4 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 50)
{
npc.dropItem(attacker, ASOFE, (int) (4 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 16)
{
npc.dropItem(attacker, LEONARD, (int) (2 * Config.RATE_QUEST_DROP));
}
npc.broadcastEvent("SCE_LUCKY", 2000, null);
npc.doCast(SUCCESS_SKILL.getSkill());
}
else
{
npc.broadcastEvent("SCE_DREAM_FIRE_IN_THE_HOLE", 2000, null);
}
}
return super.onAttack(npc, attacker, damage, isPet, skill);
}
@Override
public String onEventReceived(String eventName, L2Npc sender, L2Npc receiver, L2Object reference)
{
switch (eventName)
{
case "SCE_LUCKY":
{
receiver.setBusy(true);
receiver.doCast(SUCCESS_SKILL.getSkill());
break;
}
case "SCE_DREAM_FIRE_IN_THE_HOLE":
{
receiver.setBusy(true);
receiver.doCast(FAIL_SKILL.getSkill());
break;
}
}
return null;
}
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
if (tmpworld instanceof CDWorld)
{
final CDWorld world = (CDWorld) tmpworld;
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
if (isBigChamber())
{
markRestriction(world); // Set reenter restriction
if ((inst.getInstanceEndTime() - System.currentTimeMillis()) > 300000)
{
inst.setDuration(300000); // Finish instance in 5 minutes
}
}
else
{
world.stopRoomChangeTask();
world.scheduleRoomChange(true);
}
inst.spawnGroup("boxes");
}
return super.onKill(npc, player, isPet);
}
@Override
public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
{
if ((npc.getId() == BOX) && ((skill.getId() == 5376) || (skill.getId() == 5758)) && !npc.isDead())
{
npc.doDie(player);
}
return super.onSpellFinished(npc, player, skill);
}
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
final int npcId = npc.getId();
QuestState qs = getQuestState(player, false);
if (qs == null)
{
qs = newQuestState(player);
}
if ((npcId == ENTRANCE_GATEKEEPER) && checkConditions(player))
{
enterInstance(player, new CDWorld(player.getParty()), INSTANCE_TEMPLATE, INSTANCEID);
}
return "";
}
}

View File

@@ -0,0 +1,449 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.stream.IntStream;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import instances.AbstractInstance;
/**
* Chambers of Delusion.
* @author GKR
*/
public final class ChamberOfDelusion extends AbstractInstance
{
// NPCs
private static final Map<Integer, Integer> ENTRANCE_GATEKEEPER = new HashMap<>();
private static final int[] ROOM_GATEKEEPERS = IntStream.range(32664, 32702).toArray();
private static final int[] AENKINEL =
{
25690, // East
25691, // West
25692, // South
25693, // North
25694, // Square
25695, // Tower
};
private static final int[] BOX =
{
18838, // East, West, South, North
18820, // Square
18823, // Tower
};
// Items
private static final int ENRIA = 4042;
private static final int ASOFE = 4043;
private static final int THONS = 4044;
private static final int LEONARD = 9628;
private static final int DELUSION_MARK = 15311;
// Skills
private static final SkillHolder SUCCESS_SKILL = new SkillHolder(5758, 1);
private static final SkillHolder FAIL_SKILL = new SkillHolder(5376, 4);
// Timers
private static final int ROOM_CHANGE_INTERVAL = 480; // 8 min
private static final int ROOM_CHANGE_RANDOM_TIME = 120; // 2 min
static
{
ENTRANCE_GATEKEEPER.put(32658, 127); // East
ENTRANCE_GATEKEEPER.put(32659, 128); // West
ENTRANCE_GATEKEEPER.put(32660, 129); // South
ENTRANCE_GATEKEEPER.put(32661, 130); // North
ENTRANCE_GATEKEEPER.put(32662, 131); // Square
ENTRANCE_GATEKEEPER.put(32663, 132); // Tower
}
public ChamberOfDelusion()
{
addStartNpc(ENTRANCE_GATEKEEPER.keySet());
addStartNpc(ROOM_GATEKEEPERS);
addTalkId(ENTRANCE_GATEKEEPER.keySet());
addTalkId(ROOM_GATEKEEPERS);
addKillId(AENKINEL);
addAttackId(BOX);
addSpellFinishedId(BOX);
addEventReceivedId(BOX);
addInstanceCreatedId(ENTRANCE_GATEKEEPER.values());
addInstanceDestroyId(ENTRANCE_GATEKEEPER.values());
}
@Override
public void onInstanceCreated(Instance instance, L2PcInstance player)
{
// Choose start room
changeRoom(instance);
// Start banish task
final ScheduledFuture<?> banishTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
{
if (instance.getRemainingTime() < 60000)
{
final ScheduledFuture<?> task = instance.getParameters().getObject("banishTask", ScheduledFuture.class);
task.cancel(false);
}
else
{
for (int objId : instance.getAllowed())
{
final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
if ((pl != null) && pl.isOnline() && !pl.isInParty())
{
instance.finishInstance(0);
break;
}
}
}
}, 60000, 60000);
instance.setParameter("banishTask", banishTask);
}
@Override
public void onInstanceDestroy(Instance instance)
{
// Stop room change task
stopRoomChangeTask(instance);
// Stop banish task
final ScheduledFuture<?> banish = instance.getParameters().getObject("banishTask", ScheduledFuture.class);
if (banish != null)
{
banish.cancel(true);
instance.setParameter("banishTask", null);
}
}
@Override
protected void onEnter(L2PcInstance player, Instance instance, boolean firstEnter)
{
// Teleport player to instance
super.onEnter(player, instance, firstEnter);
// Take items
if (firstEnter)
{
if (hasQuestItems(player, DELUSION_MARK))
{
takeItems(player, DELUSION_MARK, -1);
}
if (player.getParty().isLeader(player))
{
giveItems(player, DELUSION_MARK, 1);
}
}
}
@Override
protected void teleportPlayerIn(L2PcInstance player, Instance instance)
{
final int room = instance.getParameters().getInt("currentRoom");
final Location loc = instance.getEnterLocations().get(room);
player.teleToLocation(loc, instance);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = null;
final Instance world = npc.getInstanceWorld();
if ((player != null) && (world != null) && CommonUtil.contains(ROOM_GATEKEEPERS, npc.getId()))
{
switch (event)
{
case "next_room":
{
if (player.isInParty())
{
htmltext = "no_party.html";
}
else if (player.getParty().isLeader(player))
{
htmltext = "no_leader.html";
}
else if (!hasQuestItems(player, DELUSION_MARK))
{
htmltext = "no_item.html";
}
else
{
takeItems(player, DELUSION_MARK, 1);
stopRoomChangeTask(world);
changeRoom(world);
}
break;
}
case "go_out":
{
if (player.isInParty())
{
htmltext = "no_party.html";
}
else if (player.getParty().isLeader(player))
{
htmltext = "no_leader.html";
}
else
{
world.finishInstance(0);
}
break;
}
case "look_party":
{
if (player.isInParty() && world.isAllowed(player))
{
teleportPlayerIn(player, world);
}
break;
}
}
}
return htmltext;
}
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
final int npcId = npc.getId();
if (ENTRANCE_GATEKEEPER.containsKey(npcId))
{
enterInstance(player, npc, ENTRANCE_GATEKEEPER.get(npcId));
}
return null;
}
@Override
public String onSpellFinished(L2Npc npc, L2PcInstance player, Skill skill)
{
if (!npc.isDead() && CommonUtil.contains(BOX, npc.getId()) && ((skill.getId() == FAIL_SKILL.getSkillId()) || (skill.getId() == SUCCESS_SKILL.getSkillId())))
{
npc.doDie(player);
}
return super.onSpellFinished(npc, player, skill);
}
@Override
public String onEventReceived(String eventName, L2Npc sender, L2Npc receiver, L2Object reference)
{
switch (eventName)
{
case "SCE_LUCKY":
receiver.setBusy(true);
receiver.doCast(SUCCESS_SKILL.getSkill());
break;
case "SCE_DREAM_FIRE_IN_THE_HOLE":
receiver.setBusy(true);
receiver.doCast(FAIL_SKILL.getSkill());
break;
}
return null;
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, Skill skill)
{
if (!npc.isBusy() && (npc.getCurrentHp() < (npc.getMaxHp() / 10)))
{
npc.setBusy(true);
if (getRandom(100) < 25) // 25% chance to reward
{
if (getRandom(100) < 33)
{
npc.dropItem(attacker, ENRIA, (int) (3 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 50)
{
npc.dropItem(attacker, THONS, (int) (4 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 50)
{
npc.dropItem(attacker, ASOFE, (int) (4 * Config.RATE_QUEST_DROP));
}
if (getRandom(100) < 16)
{
npc.dropItem(attacker, LEONARD, (int) (2 * Config.RATE_QUEST_DROP));
}
npc.broadcastEvent("SCE_LUCKY", 2000, null);
npc.doCast(SUCCESS_SKILL.getSkill());
}
else
{
npc.broadcastEvent("SCE_DREAM_FIRE_IN_THE_HOLE", 2000, null);
}
}
return super.onAttack(npc, attacker, damage, isPet, skill);
}
@Override
public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
{
final Instance world = player.getInstanceWorld();
if (world != null)
{
if (isBigChamber(world))
{
world.setReenterTime();
if (world.getRemainingTime() > (Config.INSTANCE_FINISH_TIME * 60000))
{
world.finishInstance();
}
}
else
{
stopRoomChangeTask(world);
scheduleRoomChange(world, true);
}
world.spawnGroup("boxes");
}
return super.onKill(npc, player, isPet);
}
private boolean isBigChamber(Instance world)
{
return world.getTemplateParameters().getBoolean("isBigRoom");
}
private boolean isBossRoom(Instance world, int room)
{
return room == (world.getEnterLocations().size() - 1);
}
protected void changeRoom(Instance world)
{
final StatsSet params = world.getParameters();
final List<Location> locations = world.getEnterLocations();
int newRoom = params.getInt("currentRoom", 0);
if (isBigChamber(world))
{
// Do nothing, if there are raid room of Sqare or Tower Chamber
if (isBossRoom(world, newRoom))
{
return;
}
// Teleport to raid room 10 min or lesser before instance end time for Tower and Square Chambers
else if (world.getRemainingTime() < 600000)
{
newRoom = locations.size() - 1;
}
}
// 10% chance for teleport to raid room if not here already for Northern, Southern, Western and Eastern Chambers
else if (!isBossRoom(world, newRoom) && (getRandom(100) < 10))
{
newRoom = locations.size() - 1;
}
else
{
// otherwise teleport to another room, except current
while (newRoom == params.getInt("currentRoom", 0))
{
newRoom = getRandom(locations.size() - 1);
}
}
world.setParameter("currentRoom", newRoom);
// Teleport players into new room
world.getPlayers().forEach(p -> teleportPlayerIn(p, world));
// Do not schedule room change for Square and Tower Chambers, if raid room is reached
if (isBigChamber(world) && isBossRoom(world, newRoom))
{
// Add 20 min to instance time if raid room is reached
world.setDuration((int) (TimeUnit.MILLISECONDS.toMinutes(world.getRemainingTime() + 1200000)));
// Broadcast instance duration change (NPC message)
final int raidGatekeeper = world.getTemplateParameters().getInt("raidGatekeeper");
final L2Npc gatekeeper = world.getNpc(raidGatekeeper);
if (gatekeeper != null)
{
gatekeeper.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.MINUTES_ARE_ADDED_TO_THE_REMAINING_TIME_IN_THE_INSTANT_ZONE);
}
}
else
{
scheduleRoomChange(world, false);
}
}
protected void scheduleRoomChange(Instance world, boolean bossRoom)
{
// Schedule next room change only if remaining time is enough
final long nextInterval = (bossRoom) ? 60000L : (ROOM_CHANGE_INTERVAL + getRandom(ROOM_CHANGE_RANDOM_TIME)) * 1000L;
if (world.getRemainingTime() > nextInterval)
{
final ScheduledFuture<?> roomChangeTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
{
try
{
// Send earthquake packet
for (L2PcInstance player : world.getPlayers())
{
player.sendPacket(new Earthquake(player, 20, 10));
}
// Wait for a while
Thread.sleep(5000);
// Change room
changeRoom(world);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Error occured in room change task: ", e);
}
}, nextInterval - 5000);
world.setParameter("roomChangeTask", roomChangeTask);
}
}
protected void stopRoomChangeTask(Instance world)
{
final ScheduledFuture<?> task = world.getParameters().getObject("roomChangeTask", ScheduledFuture.class);
if (task != null)
{
task.cancel(true);
world.setParameter("roomChangeTask", null);
}
}
public static void main(String[] args)
{
new ChamberOfDelusion();
}
}

View File

@@ -1,51 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion East.
* @author GKR
*/
public final class ChamberOfDelusionEast extends Chamber
{
// NPCs
private static final int ENTRANCE_GATEKEEPER = 32658;
private static final int ROOM_GATEKEEPER_FIRST = 32664;
private static final int ROOM_GATEKEEPER_LAST = 32668;
private static final int AENKINEL = 25690;
private static final int BOX = 18838;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-122368, -218972, -6720),
new Location(-122352, -218044, -6720),
new Location(-122368, -220220, -6720),
new Location(-121440, -218444, -6720),
new Location(-121424, -220124, -6720), // Raid room
};
private static final int INSTANCEID = 127;
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionEast.xml";
public ChamberOfDelusionEast()
{
super(ChamberOfDelusionEast.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}

View File

@@ -1,51 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion North.
* @author GKR
*/
public final class ChamberOfDelusionNorth extends Chamber
{
// NPC's
private static final int ENTRANCE_GATEKEEPER = 32661;
private static final int ROOM_GATEKEEPER_FIRST = 32679;
private static final int ROOM_GATEKEEPER_LAST = 32683;
private static final int AENKINEL = 25693;
private static final int BOX = 18838;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-108976, -207772, -6720),
new Location(-108976, -206972, -6720),
new Location(-108960, -209164, -6720),
new Location(-108048, -207340, -6720),
new Location(-108048, -209020, -6720), // Raid room
};
private static final int INSTANCEID = 130; // this is the client number
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionNorth.xml";
public ChamberOfDelusionNorth()
{
super(ChamberOfDelusionNorth.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}

View File

@@ -1,51 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion South.
* @author GKR
*/
public final class ChamberOfDelusionSouth extends Chamber
{
// NPC's
private static final int ENTRANCE_GATEKEEPER = 32660;
private static final int ROOM_GATEKEEPER_FIRST = 32674;
private static final int ROOM_GATEKEEPER_LAST = 32678;
private static final int AENKINEL = 25692;
private static final int BOX = 18838;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-122368, -207820, -6720),
new Location(-122368, -206940, -6720),
new Location(-122368, -209116, -6720),
new Location(-121456, -207356, -6720),
new Location(-121440, -209004, -6720), // Raid room
};
private static final int INSTANCEID = 129; // this is the client number
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionSouth.xml";
public ChamberOfDelusionSouth()
{
super(ChamberOfDelusionSouth.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}

View File

@@ -1,55 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion Square.
* @author GKR
*/
public final class ChamberOfDelusionSquare extends Chamber
{
// NPC's
private static final int ENTRANCE_GATEKEEPER = 32662;
private static final int ROOM_GATEKEEPER_FIRST = 32684;
private static final int ROOM_GATEKEEPER_LAST = 32692;
private static final int AENKINEL = 25694;
private static final int BOX = 18820;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-122368, -153388, -6688),
new Location(-122368, -152524, -6688),
new Location(-120480, -155116, -6688),
new Location(-120480, -154236, -6688),
new Location(-121440, -151212, -6688),
new Location(-120464, -152908, -6688),
new Location(-122368, -154700, -6688),
new Location(-121440, -152908, -6688),
new Location(-121440, -154572, -6688), // Raid room
};
private static final int INSTANCEID = 131;
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionSquare.xml";
public ChamberOfDelusionSquare()
{
super(ChamberOfDelusionSquare.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}

View File

@@ -1,55 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion Tower.
* @author GKR
*/
public final class ChamberOfDelusionTower extends Chamber
{
// NPC's
private static final int ENTRANCE_GATEKEEPER = 32663;
private static final int ROOM_GATEKEEPER_FIRST = 32693;
private static final int ROOM_GATEKEEPER_LAST = 32701;
private static final int AENKINEL = 25695;
private static final int BOX = 18823;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-108976, -153372, -6688),
new Location(-108960, -152524, -6688),
new Location(-107088, -155052, -6688),
new Location(-107104, -154236, -6688),
new Location(-108048, -151244, -6688),
new Location(-107088, -152956, -6688),
new Location(-108992, -154604, -6688),
new Location(-108032, -152892, -6688),
new Location(-108048, -154572, -6688), // Raid room
};
private static final int INSTANCEID = 132; // this is the client number
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionTower.xml";
public ChamberOfDelusionTower()
{
super(ChamberOfDelusionTower.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}

View File

@@ -1,51 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package instances.ChambersOfDelusion;
import com.l2jmobius.gameserver.model.Location;
/**
* Chamber of Delusion West.
* @author GKR
*/
public final class ChamberOfDelusionWest extends Chamber
{
// NPC's
private static final int ENTRANCE_GATEKEEPER = 32659;
private static final int ROOM_GATEKEEPER_FIRST = 32669;
private static final int ROOM_GATEKEEPER_LAST = 32673;
private static final int AENKINEL = 25691;
private static final int BOX = 18838;
// Misc
private static final Location[] ENTER_POINTS = new Location[]
{
new Location(-108960, -218892, -6720),
new Location(-108976, -218028, -6720),
new Location(-108960, -220204, -6720),
new Location(-108032, -218428, -6720),
new Location(-108032, -220140, -6720), // Raid room
};
private static final int INSTANCEID = 128; // this is the client number
private static final String INSTANCE_TEMPLATE = "ChamberOfDelusionWest.xml";
public ChamberOfDelusionWest()
{
super(ChamberOfDelusionWest.class.getSimpleName(), "instances", INSTANCEID, INSTANCE_TEMPLATE, ENTRANCE_GATEKEEPER, ROOM_GATEKEEPER_FIRST, ROOM_GATEKEEPER_LAST, AENKINEL, BOX);
ROOM_ENTER_POINTS = ENTER_POINTS;
}
}