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

@@ -0,0 +1,4 @@
<html><body>Alarm System:<br>
As the alarm rings, a window for the passcode pops up. On the screen you see the number 120, which begins counting down. It looks like the alarm system will be activated in about 2 minutes unless the passcode is successfully entered.<br>
<a action="bypass -h Quest Alarm 2">Enter the passcode.</a>
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Alarm System:<br>
The alarm is ringing loudly. You should leave here immediately.<br>
(Another person has already undertaken the quest.)
</body></html>

View File

@@ -0,0 +1,42 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode :|<br>
########################<br>
The first number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 3">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,42 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : *|<br>
########################<br>
The second number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 4">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,42 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : **|<br>
########################<br>
The third number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 5">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,43 @@
<html><body>
Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : ***|<br>
########################<br>
The fourth number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,7 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : ****<br>
########################<br>
Validation completed. Alarm has been disabled.
</body></html>

View File

@@ -0,0 +1,9 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : ****<br>
########################<br>
Validation has failed. <br>
<br>
<a action="bypass -h Quest Alarm 2">Re-enter passcode.</a>
</body></html>

View File

@@ -0,0 +1,42 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode :|<br>
########################<br>
The first number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 3">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_04.html">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,43 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : *|<br>
########################<br>
The second number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 4">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_06.html">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,41 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : **|<br>
########################<br>
The third number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">2</a>
</td> <td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 32367-184_08.html">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 5">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,42 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : ***| <br>
########################<br>
The fourth number is...
<table border="0" border color="white" width="65" height="65">
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">1</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">2</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">3</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">4</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">5</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">6</a>
</td>
</tr>
<tr>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">7</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">8</a>
</td>
<td width="20" height="20" align="center">
<a action="bypass -h Quest Alarm 6">9</a>
</td>
</tr>
</table>
</body></html>

View File

@@ -0,0 +1,7 @@
<html><body>Alarm System:<br>
########################<br>
Enter the passcode for communication.<br>
Passcode : **** <br>
########################<br>
Validation completed. Alarm has been disabled.
</body></html>

View File

@@ -0,0 +1,8 @@
<html><body>Alarm System:<br>
########################<br>
Enter passcode for communication.<br>
Passcode : **** <br>########################<br>
Validation has failed.<br>
<br>
<a action="bypass -h Quest Alarm 2">Re-enter passcode.</a>
</body></html>

View File

@@ -0,0 +1,356 @@
/*
* 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.CrumaTower.Alarm;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.QuestSound;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.network.NpcStringId;
import ai.AbstractNpcAI;
import quests.Q00184_ArtOfPersuasion.Q00184_ArtOfPersuasion;
import quests.Q00185_NikolasCooperation.Q00185_NikolasCooperation;
/**
* Alarm AI for quests Art of Persuasion (184) and Nikola's Cooperation (185).
* @author Zoey76
*/
public final class Alarm extends AbstractNpcAI
{
// NPC
private static final int ALARM = 32367;
// Misc
private static final int ART_OF_PERSUASION_ID = 184;
private static final int NIKOLAS_COOPERATION_ID = 185;
private Alarm()
{
addStartNpc(ALARM);
addTalkId(ALARM);
addFirstTalkId(ALARM);
addSpawnId(ALARM);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = null;
final L2PcInstance player0 = npc.getVariables().getObject("player0", L2PcInstance.class);
final L2Npc npc0 = npc.getVariables().getObject("npc0", L2Npc.class);
switch (event)
{
case "SELF_DESTRUCT_IN_60":
{
startQuestTimer("SELF_DESTRUCT_IN_30", 30000, npc, null);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.THE_ALARM_WILL_SELF_DESTRUCT_IN_60_SECONDS_ENTER_PASSCODE_TO_OVERRIDE);
break;
}
case "SELF_DESTRUCT_IN_30":
{
startQuestTimer("SELF_DESTRUCT_IN_10", 20000, npc, null);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.THE_ALARM_WILL_SELF_DESTRUCT_IN_30_SECONDS_ENTER_PASSCODE_TO_OVERRIDE);
break;
}
case "SELF_DESTRUCT_IN_10":
{
startQuestTimer("RECORDER_CRUSHED", 10000, npc, null);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.THE_ALARM_WILL_SELF_DESTRUCT_IN_10_SECONDS_ENTER_PASSCODE_TO_OVERRIDE);
break;
}
case "RECORDER_CRUSHED":
{
if (npc0 != null)
{
if (npc0.getVariables().getBoolean("SPAWNED"))
{
npc0.getVariables().set("SPAWNED", false);
if (player0 != null)
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.RECORDER_CRUSHED);
if (verifyMemoState(player0, ART_OF_PERSUASION_ID, -1))
{
setMemoState(player0, ART_OF_PERSUASION_ID, 5);
}
else if (verifyMemoState(player0, NIKOLAS_COOPERATION_ID, -1))
{
setMemoState(player0, NIKOLAS_COOPERATION_ID, 5);
}
}
}
}
npc.deleteMe();
break;
}
case "32367-184_04.html":
case "32367-184_06.html":
case "32367-184_08.html":
{
htmltext = event;
break;
}
case "2":
{
if (player0 == player)
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
htmltext = "32367-184_02.html";
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
htmltext = "32367-185_02.html";
}
}
break;
}
case "3":
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
setMemoStateEx(player, ART_OF_PERSUASION_ID, 1, 1);
htmltext = "32367-184_04.html";
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
setMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1, 1);
htmltext = "32367-185_04.html";
}
break;
}
case "4":
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
setMemoStateEx(player, ART_OF_PERSUASION_ID, 1, getMemoStateEx(player, ART_OF_PERSUASION_ID, 1) + 1);
htmltext = "32367-184_06.html";
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
setMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1, getMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1) + 1);
htmltext = "32367-185_06.html";
}
break;
}
case "5":
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
setMemoStateEx(player, ART_OF_PERSUASION_ID, 1, getMemoStateEx(player, ART_OF_PERSUASION_ID, 1) + 1);
htmltext = "32367-184_08.html";
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
setMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1, getMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1) + 1);
htmltext = "32367-185_08.html";
}
break;
}
case "6":
{
if (verifyMemoState(player, ART_OF_PERSUASION_ID, 3))
{
final int i0 = getMemoStateEx(player, ART_OF_PERSUASION_ID, 1);
if (i0 >= 3)
{
if ((npc0 != null) && npc0.getVariables().getBoolean("SPAWNED"))
{
npc0.getVariables().set("SPAWNED", false);
}
npc.deleteMe();
setMemoState(player, ART_OF_PERSUASION_ID, 4);
htmltext = "32367-184_09.html";
}
else
{
setMemoStateEx(player, ART_OF_PERSUASION_ID, 1, 0);
htmltext = "32367-184_10.html";
}
}
else if (verifyMemoState(player, NIKOLAS_COOPERATION_ID, 3))
{
final int i0 = getMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1);
if (i0 >= 3)
{
if ((npc0 != null) && npc0.getVariables().getBoolean("SPAWNED"))
{
npc0.getVariables().set("SPAWNED", false);
}
npc.deleteMe();
setMemoState(player, NIKOLAS_COOPERATION_ID, 4);
htmltext = "32367-185_09.html";
}
else
{
setMemoStateEx(player, NIKOLAS_COOPERATION_ID, 1, 0);
htmltext = "32367-185_10.html";
}
}
break;
}
}
return htmltext;
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance talker)
{
String htmltext = getNoQuestMsg(talker);
if (verifyMemoState(talker, ART_OF_PERSUASION_ID, 3) || verifyMemoState(talker, NIKOLAS_COOPERATION_ID, 3))
{
final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
if (player == talker)
{
htmltext = "32367-01.html";
}
else
{
htmltext = "32367-02.html";
}
}
return htmltext;
}
@Override
public String onSpawn(L2Npc npc)
{
startQuestTimer("SELF_DESTRUCT_IN_60", 60000, npc, null);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.INTRUDER_ALERT_THE_ALARM_WILL_SELF_DESTRUCT_IN_2_MINUTES);
final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
if (player != null)
{
playSound(player, QuestSound.ITEMSOUND_SIREN);
}
return super.onSpawn(npc);
}
/**
* Verifies if the given player has the require memo state.
* @param player the player
* @param questId the quest ID
* @param memoState the memo state, if memo state is less than zero, only quest state is checked
* @return {@code true} if the player has the memo state, {@code false} otherwise
*/
private static final boolean verifyMemoState(L2PcInstance player, int questId, int memoState)
{
QuestState qs = null;
switch (questId)
{
case ART_OF_PERSUASION_ID:
{
qs = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
break;
}
case NIKOLAS_COOPERATION_ID:
{
qs = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
break;
}
}
return (qs != null) && ((memoState < 0) || qs.isMemoState(memoState));
}
/**
* Sets the memo state for the given player and quest.
* @param player the player
* @param questId the quest ID
* @param memoState the memo state
*/
private static final void setMemoState(L2PcInstance player, int questId, int memoState)
{
QuestState qs = null;
switch (questId)
{
case ART_OF_PERSUASION_ID:
{
qs = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
break;
}
case NIKOLAS_COOPERATION_ID:
{
qs = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
break;
}
}
if (qs != null)
{
qs.setMemoState(memoState);
}
}
/**
* Gets the memo state ex for the given player, quest and slot.
* @param player the player
* @param questId the quest ID
* @param slot the slot
* @return the memo state ex
*/
private static final int getMemoStateEx(L2PcInstance player, int questId, int slot)
{
QuestState qs = null;
switch (questId)
{
case ART_OF_PERSUASION_ID:
{
qs = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
break;
}
case NIKOLAS_COOPERATION_ID:
{
qs = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
break;
}
}
return (qs != null) ? qs.getMemoStateEx(slot) : -1;
}
/**
* Sets the memo state ex for the given player and quest.
* @param player the player
* @param questId the quest ID
* @param slot the slot
* @param memoStateEx the memo state ex
*/
private static final void setMemoStateEx(L2PcInstance player, int questId, int slot, int memoStateEx)
{
QuestState qs = null;
switch (questId)
{
case ART_OF_PERSUASION_ID:
{
qs = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
break;
}
case NIKOLAS_COOPERATION_ID:
{
qs = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
break;
}
}
if (qs != null)
{
qs.setMemoStateEx(slot, memoStateEx);
}
}
public static void main(String[] args)
{
new Alarm();
}
}

View File

@@ -0,0 +1,228 @@
/*
* 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.CrumaTower;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import ai.AbstractNpcAI;
/**
* Core AI.
* @author DrLecter, Emperorc
*/
public final class Core extends AbstractNpcAI
{
private static final int CORE = 29006;
private static final int DEATH_KNIGHT = 29007;
private static final int DOOM_WRAITH = 29008;
// private static final int DICOR = 29009;
// private static final int VALIDUS = 29010;
private static final int SUSCEPTOR = 29011;
// private static final int PERUM = 29012;
// private static final int PREMO = 29013;
// Core Status Tracking :
private static final byte ALIVE = 0; // Core is spawned.
private static final byte DEAD = 1; // Core has been killed.
private static boolean _firstAttacked;
private final List<L2Attackable> _minions = new CopyOnWriteArrayList<>();
private Core()
{
registerMobs(CORE, DEATH_KNIGHT, DOOM_WRAITH, SUSCEPTOR);
_firstAttacked = false;
final StatsSet info = GrandBossManager.getInstance().getStatsSet(CORE);
final int status = GrandBossManager.getInstance().getBossStatus(CORE);
if (status == DEAD)
{
// load the unlock date and time for Core from DB
final long temp = (info.getLong("respawn_time") - System.currentTimeMillis());
// if Core is locked until a certain time, mark it so and start the unlock timer
// the unlock time has not yet expired.
if (temp > 0)
{
startQuestTimer("core_unlock", temp, null, null);
}
else
{
// the time has already expired while the server was offline. Immediately spawn Core.
final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0);
GrandBossManager.getInstance().setBossStatus(CORE, ALIVE);
spawnBoss(core);
}
}
else
{
final String test = loadGlobalQuestVar("Core_Attacked");
if (test.equalsIgnoreCase("true"))
{
_firstAttacked = true;
}
final int loc_x = info.getInt("loc_x");
final int loc_y = info.getInt("loc_y");
final int loc_z = info.getInt("loc_z");
final int heading = info.getInt("heading");
final double hp = info.getDouble("currentHP");
final double mp = info.getDouble("currentMP");
final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, loc_x, loc_y, loc_z, heading, false, 0);
core.setCurrentHpMp(hp, mp);
spawnBoss(core);
}
}
@Override
public void onSave()
{
saveGlobalQuestVar("Core_Attacked", Boolean.toString(_firstAttacked));
}
public void spawnBoss(L2GrandBossInstance npc)
{
GrandBossManager.getInstance().addBoss(npc);
npc.broadcastPacket(new PlaySound(1, "BS01_A", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
// Spawn minions
L2Attackable mob;
for (int i = 0; i < 5; i++)
{
final int x = 16800 + (i * 360);
mob = (L2Attackable) addSpawn(DEATH_KNIGHT, x, 110000, npc.getZ(), 280 + getRandom(40), false, 0);
mob.setIsRaidMinion(true);
_minions.add(mob);
mob = (L2Attackable) addSpawn(DEATH_KNIGHT, x, 109000, npc.getZ(), 280 + getRandom(40), false, 0);
mob.setIsRaidMinion(true);
_minions.add(mob);
final int x2 = 16800 + (i * 600);
mob = (L2Attackable) addSpawn(DOOM_WRAITH, x2, 109300, npc.getZ(), 280 + getRandom(40), false, 0);
mob.setIsRaidMinion(true);
_minions.add(mob);
}
for (int i = 0; i < 4; i++)
{
final int x = 16800 + (i * 450);
mob = (L2Attackable) addSpawn(SUSCEPTOR, x, 110300, npc.getZ(), 280 + getRandom(40), false, 0);
mob.setIsRaidMinion(true);
_minions.add(mob);
}
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equalsIgnoreCase("core_unlock"))
{
final L2GrandBossInstance core = (L2GrandBossInstance) addSpawn(CORE, 17726, 108915, -6480, 0, false, 0);
GrandBossManager.getInstance().setBossStatus(CORE, ALIVE);
spawnBoss(core);
}
else if (event.equalsIgnoreCase("spawn_minion"))
{
final L2Attackable mob = (L2Attackable) addSpawn(npc.getId(), npc.getX(), npc.getY(), npc.getZ(), npc.getHeading(), false, 0);
mob.setIsRaidMinion(true);
_minions.add(mob);
}
else if (event.equalsIgnoreCase("despawn_minions"))
{
_minions.forEach(L2Attackable::decayMe);
_minions.clear();
}
return super.onAdvEvent(event, npc, player);
}
@Override
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
{
if (npc.getId() == CORE)
{
if (_firstAttacked)
{
if (getRandom(100) == 0)
{
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.REMOVING_INTRUDERS);
}
}
else
{
_firstAttacked = true;
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.A_NON_PERMITTED_TARGET_HAS_BEEN_DISCOVERED);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.INTRUDER_REMOVAL_SYSTEM_INITIATED);
}
}
return super.onAttack(npc, attacker, damage, isSummon);
}
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
final int npcId = npc.getId();
if (npcId == CORE)
{
npc.broadcastPacket(new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.A_FATAL_ERROR_HAS_OCCURRED);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.SYSTEM_IS_BEING_SHUT_DOWN);
npc.broadcastSay(ChatType.NPC_GENERAL, NpcStringId.EMPTY);
_firstAttacked = false;
GrandBossManager.getInstance().setBossStatus(CORE, DEAD);
// Calculate Min and Max respawn times randomly.
long respawnTime = (Config.CORE_SPAWN_INTERVAL + getRandom(-Config.CORE_SPAWN_RANDOM, Config.CORE_SPAWN_RANDOM)) * 3600000;
respawnTime *= 3600000;
startQuestTimer("core_unlock", respawnTime, null, null);
// also save the respawn time so that the info is maintained past reboots
final StatsSet info = GrandBossManager.getInstance().getStatsSet(CORE);
info.set("respawn_time", (System.currentTimeMillis() + respawnTime));
GrandBossManager.getInstance().setStatsSet(CORE, info);
startQuestTimer("despawn_minions", 20000, null, null);
cancelQuestTimers("spawn_minion");
}
else if ((GrandBossManager.getInstance().getBossStatus(CORE) == ALIVE) && (_minions != null) && _minions.contains(npc))
{
_minions.remove(npc);
startQuestTimer("spawn_minion", 60000, npc, null);
}
return super.onKill(npc, killer, isSummon);
}
@Override
public String onSpawn(L2Npc npc)
{
if (npc.getId() == CORE)
{
npc.setIsImmobilized(true);
}
return super.onSpawn(npc);
}
public static void main(String[] args)
{
new Core();
}
}