NPC shows current GrandBoss status and respawn time (if dead).
1. Create file BossRespawn.java in gameserver\data\scripts\custom
- BossRespawn.java:
- package custom;
import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.datatables.NpcTable;
public class BossRespawn extends Quest
{
private static final int NPC_ID = YOUR_ID;
private static final int[] BOSSES = {12001, 12052, 12169, 12374, 12372, 12211, 12899};
public BossRespawn(int questid, String name, String descr)
{
super(questid, name, descr);
addFirstTalkId(NPC_ID);
}
public String onFirstTalk(L2NpcInstance npc, L2PcInstance pc)
{
if(npc == null || pc == null)
return null;
if(npc.getNpcId() == NPC_ID)
{
sendInfo(pc);
}
return null;
}
private void sendInfo(L2PcInstance activeChar)
{
StringBuilder html1 = new StringBuilder();
html1.append("<html><body><center><br>");
for(int boss : BOSSES)
{
String name = NpcTable.getInstance().getTemplate(boss).getName();
long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");
if (delay <= System.currentTimeMillis())
{
html1.append(" " + name + " is <font color=\"00FF00\">alive</font><br>");
}
else
{
int hours = (int) ((delay - System.currentTimeMillis()) / 1000 / 60 / 60);
int mins = (int) (((delay - (hours * 60 * 60 * 1000)) - System.currentTimeMillis()) / 1000 / 60);
int seconts = (int) (((delay - ((hours * 60 * 60 * 1000) + (mins * 60 * 1000))) - System.currentTimeMillis()) / 1000);
html1.append(" " + name + " is <font color=\"FF0000\">dead</font> " +" " + "(respawn in:" + " " + " " + hours + "h " + mins + "m " + seconts + "s)" + "<br>");
}
}
html1.append("</center></body></html>");
NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
msg.setHtml(html1.toString());
activeChar.sendPacket(msg);
}
public static void main(String[] args)
{
new BossRespawn(-1, "BossRespawn", "custom");
}
}
3. Add the following line to gameserver\data\scripts.cfg
- Code:
custom/BossRespawn.java
- Code:
public String getName()
{
return name;
}
Tested with build 714.
Based on custom NPC for L2jServer and Voice Command by jmd.
Last edited by improvise on 14th February 2020, 08:52; edited 1 time in total