From 35674970aef9eb609c28f7787cfd31f4946a67f9 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 28 Aug 2016 15:28:11 +0000 Subject: [PATCH] Wormhole AI. Contributed by gigilo1968. --- .../HellboundIsland/Wormhole/33901-1.html | 5 + .../HellboundIsland/Wormhole/33901-2.html | 3 + .../HellboundIsland/Wormhole/33901-3.html | 4 + .../HellboundIsland/Wormhole/Wormhole.java | 115 ++++++++++++++++++ .../dist/game/data/stats/npcs/33900-33999.xml | 5 +- 5 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-1.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-2.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-3.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/Wormhole.java diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-1.html b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-1.html new file mode 100644 index 0000000000..ed25592d45 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-1.html @@ -0,0 +1,5 @@ +Wormhole:
+(This wormhole seems to lead to where Beleth was last seen.)
+(Between %min% and %max% memebers can enter.)
+ + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-2.html b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-2.html new file mode 100644 index 0000000000..95fe9fe9a5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-2.html @@ -0,0 +1,3 @@ +Wormhole:
+(A command channel needs at least %min% members to challenge Beleth.) + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-3.html b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-3.html new file mode 100644 index 0000000000..3fa9eb3903 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/33901-3.html @@ -0,0 +1,4 @@ +Wormhole:
+You are overcome by a voice, a voice so powerful you are helpless as it speaks:
+(The players who belong to an association can only enter through the Association Leader.) + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/Wormhole.java b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/Wormhole.java new file mode 100644 index 0000000000..d6b4b66b69 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/ai/areas/HellboundIsland/Wormhole/Wormhole.java @@ -0,0 +1,115 @@ +/* + * 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 . + */ +package ai.areas.HellboundIsland.Wormhole; + +import java.util.List; + +import com.l2jmobius.gameserver.model.L2Party; +import com.l2jmobius.gameserver.model.actor.L2Npc; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; + +import ai.AbstractNpcAI; + +/** + * Wormhole AI (33901). + * @author gigi + */ +public final class Wormhole extends AbstractNpcAI +{ + // NPCs + private static final int WORMHOLE = 33901; + // Minimum and maximum command channel members + private static final int MIN_MEMBERS = 49; + private static final int MAX_MEMBERS = 350; + + public Wormhole() + { + addFirstTalkId(WORMHOLE); + addTalkId(WORMHOLE); + } + + @Override + public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) + { + String htmltext = null; + switch (event) + { + case "teleport": + { + if (!player.isInParty()) + { + final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId()); + packet.setHtml(getHtm(player.getHtmlPrefix(), "33901-2.html")); + packet.replace("%min%", Integer.toString(MIN_MEMBERS)); + player.sendPacket(packet); + break; + } + else if (player.isInParty()) + { + final L2Party party = player.getParty(); + final boolean isInCC = party.isInCommandChannel(); + final List members = (isInCC) ? party.getCommandChannel().getMembers() : party.getMembers(); + final boolean isPartyLeader = (isInCC) ? party.getCommandChannel().isLeader(player) : party.isLeader(player); + if (!isPartyLeader) + { + htmltext = "33901-3.html"; + break; + + } + else if ((members.size() < MIN_MEMBERS) || (members.size() > MAX_MEMBERS)) + { + final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId()); + packet.setHtml(getHtm(player.getHtmlPrefix(), "33901-2.html")); + packet.replace("%min%", Integer.toString(MIN_MEMBERS)); + player.sendPacket(packet); + break; + } + else + { + for (L2PcInstance member : members) + { + if (member.isInsideRadius(npc, 1000, true, false)) + { + // TODO: need teleport in instance? + member.teleToLocation(-17556 + getRandom(700), 245951 + getRandom(700), -832); + } + } + } + } + break; + } + } + return htmltext; + } + + @Override + public String onFirstTalk(L2Npc npc, L2PcInstance player) + { + final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId()); + packet.setHtml(getHtm(player.getHtmlPrefix(), "33901-1.html")); + packet.replace("%min%", Integer.toString(MIN_MEMBERS)); + packet.replace("%max%", Integer.toString(MAX_MEMBERS)); + player.sendPacket(packet); + return null; + } + + public static void main(String[] args) + { + new Wormhole(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/stats/npcs/33900-33999.xml b/L2J_Mobius_Underground/dist/game/data/stats/npcs/33900-33999.xml index c47d0299de..b439e2e99b 100644 --- a/L2J_Mobius_Underground/dist/game/data/stats/npcs/33900-33999.xml +++ b/L2J_Mobius_Underground/dist/game/data/stats/npcs/33900-33999.xml @@ -23,7 +23,6 @@ - ETC FEMALE @@ -35,13 +34,13 @@ - + - +