Merged with released L2J-Unity files.
This commit is contained in:
260
trunk/dist/game/data/scripts/instances/FortressDungeon/FortressDungeon.java
vendored
Normal file
260
trunk/dist/game/data/scripts/instances/FortressDungeon/FortressDungeon.java
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* 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.FortressDungeon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.enums.QuestSound;
|
||||
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.Fort;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
|
||||
import instances.AbstractInstance;
|
||||
import quests.Q00511_AwlUnderFoot.Q00511_AwlUnderFoot;
|
||||
|
||||
/**
|
||||
* <b>Fortress dungeon</b> instance for quest <b>Awl Under Foot (511)</b>
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class FortressDungeon extends AbstractInstance
|
||||
{
|
||||
// NPCs
|
||||
private static final Map<Integer, Integer> NPCS = new HashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
NPCS.put(35666, 22); // Shanty
|
||||
NPCS.put(35698, 23); // Southern
|
||||
NPCS.put(35735, 24); // Hive
|
||||
NPCS.put(35767, 25); // Valley
|
||||
NPCS.put(35804, 26); // Ivory
|
||||
NPCS.put(35835, 27); // Narsell
|
||||
NPCS.put(35867, 28); // Bayou
|
||||
NPCS.put(35904, 29); // White Sands
|
||||
NPCS.put(35936, 30); // Borderland
|
||||
NPCS.put(35974, 31); // Swamp
|
||||
NPCS.put(36011, 32); // Archaic
|
||||
NPCS.put(36043, 33); // Floran
|
||||
NPCS.put(36081, 34); // Cloud Mountain
|
||||
NPCS.put(36118, 35); // Tanor
|
||||
NPCS.put(36149, 36); // Dragonspine
|
||||
NPCS.put(36181, 37); // Antharas
|
||||
NPCS.put(36219, 38); // Western
|
||||
NPCS.put(36257, 39); // Hunter
|
||||
NPCS.put(36294, 40); // Aaru
|
||||
NPCS.put(36326, 41); // Demon
|
||||
NPCS.put(36364, 42); // Monastic
|
||||
}
|
||||
|
||||
// Monsters
|
||||
private static final int[] RAIDS1 =
|
||||
{
|
||||
25572,
|
||||
25575,
|
||||
25578
|
||||
};
|
||||
private static final int[] RAIDS2 =
|
||||
{
|
||||
25579,
|
||||
25582,
|
||||
25585,
|
||||
25588
|
||||
};
|
||||
private static final int[] RAIDS3 =
|
||||
{
|
||||
25589,
|
||||
25592,
|
||||
25593
|
||||
};
|
||||
// Item
|
||||
private static final int MARK = 9797;
|
||||
// Locations
|
||||
private static final Location SPAWN_LOC = new Location(53319, 245814, -6576);
|
||||
// Misc
|
||||
private static final int MARK_COUNT = 2520;
|
||||
private static final long REENTER = 24 * 3600000; // 24 hours
|
||||
private static final Map<Integer, Long> REENETER_HOLDER = new ConcurrentHashMap<>();
|
||||
|
||||
public FortressDungeon()
|
||||
{
|
||||
// NPCs
|
||||
addStartNpc(NPCS.keySet());
|
||||
addTalkId(NPCS.keySet());
|
||||
// Monsters
|
||||
addKillId(RAIDS1);
|
||||
addKillId(RAIDS2);
|
||||
addKillId(RAIDS3);
|
||||
// Instance
|
||||
addInstanceCreatedId(NPCS.values());
|
||||
addInstanceDestroyId(NPCS.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
final int npcId = npc.getId();
|
||||
if (NPCS.containsKey(npcId))
|
||||
{
|
||||
enterInstance(player, npc, NPCS.get(npcId));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
|
||||
{
|
||||
final Instance world = npc.getInstanceWorld();
|
||||
if (world != null)
|
||||
{
|
||||
if (CommonUtil.contains(RAIDS3, npc.getId()))
|
||||
{
|
||||
// Get players with active quest
|
||||
final List<L2PcInstance> members = new ArrayList<>();
|
||||
for (L2PcInstance member : world.getPlayers())
|
||||
{
|
||||
final QuestState qs = member.getQuestState(Q00511_AwlUnderFoot.class.getSimpleName());
|
||||
if ((qs != null) && qs.isCond(1))
|
||||
{
|
||||
members.add(member);
|
||||
}
|
||||
}
|
||||
|
||||
// Distribute marks between them
|
||||
if (!members.isEmpty())
|
||||
{
|
||||
final long itemCount = MARK_COUNT / members.size();
|
||||
for (L2PcInstance member : members)
|
||||
{
|
||||
giveItems(member, MARK, itemCount);
|
||||
playSound(member, QuestSound.ITEMSOUND_QUEST_ITEMGET);
|
||||
}
|
||||
}
|
||||
world.finishInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
world.incStatus();
|
||||
spawnRaid(world);
|
||||
}
|
||||
}
|
||||
return super.onKill(npc, player, isSummon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstanceCreated(Instance instance, L2PcInstance player)
|
||||
{
|
||||
// Put re-enter for instance
|
||||
REENETER_HOLDER.put(instance.getTemplateId(), System.currentTimeMillis() + REENTER);
|
||||
// Schedule spawn of first raid
|
||||
spawnRaid(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean validateConditions(List<L2PcInstance> group, L2Npc npc, InstanceTemplate template)
|
||||
{
|
||||
final L2PcInstance groupLeader = group.get(0);
|
||||
final Fort fort = npc.getFort();
|
||||
if (fort == null)
|
||||
{
|
||||
showHtmlFile(groupLeader, "noProperPledge.html");
|
||||
return false;
|
||||
}
|
||||
else if (fort.getFortState() == 0)
|
||||
{
|
||||
showHtmlFile(groupLeader, "noContractYet.html");
|
||||
return false;
|
||||
}
|
||||
else if (fort.getFortState() == 2)
|
||||
{
|
||||
showHtmlFile(groupLeader, "noCastleContract.html");
|
||||
return false;
|
||||
}
|
||||
else if (REENETER_HOLDER.containsKey(template.getId()))
|
||||
{
|
||||
final long time = REENETER_HOLDER.get(template.getId());
|
||||
if (time > System.currentTimeMillis())
|
||||
{
|
||||
showHtmlFile(groupLeader, "enterRestricted.html");
|
||||
return false;
|
||||
}
|
||||
REENETER_HOLDER.remove(template.getId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstanceDestroy(Instance instance)
|
||||
{
|
||||
// Stop running spawn task
|
||||
final ScheduledFuture<?> task = instance.getParameters().getObject("spawnTask", ScheduledFuture.class);
|
||||
if ((task != null) && !task.isDone())
|
||||
{
|
||||
task.cancel(true);
|
||||
}
|
||||
instance.setParameter("spawnTask", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn raid boss according to instance status.
|
||||
* @param instance instance world where instance should be spawned
|
||||
*/
|
||||
private void spawnRaid(Instance instance)
|
||||
{
|
||||
final ScheduledFuture<?> spawnTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
// Get template id of raid
|
||||
final int npcId;
|
||||
switch (instance.getStatus())
|
||||
{
|
||||
case 0:
|
||||
npcId = RAIDS1[getRandom(RAIDS1.length)];
|
||||
break;
|
||||
case 1:
|
||||
npcId = RAIDS2[getRandom(RAIDS2.length)];
|
||||
break;
|
||||
default:
|
||||
npcId = RAIDS3[getRandom(RAIDS3.length)];
|
||||
}
|
||||
|
||||
// Spawn raid
|
||||
addSpawn(npcId, SPAWN_LOC, false, 0, false, instance.getId());
|
||||
|
||||
// Unset spawn task reference
|
||||
instance.setParameter("spawnTask", null);
|
||||
}, 2, TimeUnit.MINUTES);
|
||||
|
||||
// Save timer to instance world
|
||||
instance.setParameter("spawnTask", spawnTask);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new FortressDungeon();
|
||||
}
|
||||
}
|
||||
4
trunk/dist/game/data/scripts/instances/FortressDungeon/enterRestricted.html
vendored
Normal file
4
trunk/dist/game/data/scripts/instances/FortressDungeon/enterRestricted.html
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<html><body>Training is currently closed.<br>
|
||||
You can undertake training once every 24 hours with your clan.<br>
|
||||
If training is closed, check with your clan members to see when the last training session started.
|
||||
</body></html>
|
||||
3
trunk/dist/game/data/scripts/instances/FortressDungeon/hasReenter.html
vendored
Normal file
3
trunk/dist/game/data/scripts/instances/FortressDungeon/hasReenter.html
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><body>
|
||||
Only a party may enter the camp. Once you begin the training session, you may not attend another one for at least 24 hours.
|
||||
</body></html>
|
||||
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noCastleContract.html
vendored
Normal file
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noCastleContract.html
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><body>Off limits! Lord's orders.<br>
|
||||
(You cannot enter the camp with a contract related to the castle.)
|
||||
</body></html>
|
||||
4
trunk/dist/game/data/scripts/instances/FortressDungeon/noContractYet.html
vendored
Normal file
4
trunk/dist/game/data/scripts/instances/FortressDungeon/noContractYet.html
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<html><body>
|
||||
The fortress is currently in an unsettled state because our relationship with the castle lord must be clearly determined.<br>
|
||||
(Entry into the camps is only possible after gaining independence from the main castle.)
|
||||
</body></html>
|
||||
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noParty.html
vendored
Normal file
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noParty.html
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><body>
|
||||
To enter the Detention Camp, your party must include at least 2 people.
|
||||
</body></html>
|
||||
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noProperPledge.html
vendored
Normal file
3
trunk/dist/game/data/scripts/instances/FortressDungeon/noProperPledge.html
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><body>
|
||||
The clan does not possess this fortress.
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user