Wormhole AI.

Contributed by gigilo1968.
This commit is contained in:
MobiusDev 2016-08-28 15:28:11 +00:00
parent f38f0f2428
commit 35674970ae
5 changed files with 129 additions and 3 deletions

View File

@ -0,0 +1,5 @@
<html><body>Wormhole:<br>
(This wormhole seems to lead to where Beleth was last seen.)<br>
(Between %min% and %max% memebers can enter.)<br>
<Button ALIGN=LEFT ICON="TELEPORT" action="bypass -h Quest Wormhole teleport">"Well then, time to pay Beleth a visit!"</Button>
</body></html>

View File

@ -0,0 +1,3 @@
<html><body>Wormhole:<br>
(A command channel needs at least %min% members to challenge Beleth.)
</body></html>

View File

@ -0,0 +1,4 @@
<html><body>Wormhole:<br>
You are overcome by a voice, a voice so powerful you are helpless as it speaks:<br>
(The players who belong to an association can only enter through the Association Leader.)
</body></html>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<L2PcInstance> 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();
}
}

View File

@ -23,7 +23,6 @@
</collision>
</npc>
<npc id="33901" level="99" type="L2Npc" name="Wormhole" title="">
<!-- AUTO GENERATED NPC TODO: FIX IT -->
<race>ETC</race>
<sex>FEMALE</sex>
<stats str="88" int="79" dex="55" wit="78" con="82" men="78">
@ -35,13 +34,13 @@
<attack physical="1950.2231755595" magical="1331.5869440987" critical="4" attackSpeed="253" range="40" />
<defence physical="405.85106382979" magical="297.0297029703" />
</stats>
<status attackable="false" />
<status attackable="false" showName="false" />
<skill_list>
<skill id="4045" level="1" /> <!-- Full Magic Attack Resistance -->
</skill_list>
<collision>
<radius normal="40" />
<height normal="40" />
<height normal="60" />
</collision>
</npc>
<npc id="33902" level="99" type="L2Teleporter" name="Warp Gate" title="">