Jump to content

Recommended Posts

Posted

Alloha one more time there, like most times, i would like to share one of my NPC's which is being created today. It is not something special, but some months ago some people were saying that to observe raidbosses is kinda impossible. So, i prooved to all, that this is kinda easy with this topic. People loved it so, i decided to make a small upgrade to it. Upgrade will give more & better choices to players.

 

With this NPC players can do (configurable by the code easily) 5 things:

• Check if Grand Boss is online (exists) or offline.

• Check how many players are in Grand Boss Zone & trying to kill the Grand Boss.

• Check how many parties are in Grand Boss Zone & trying to kill the Grand Boss.

• Select To Teleport in the Grand Boss Zone.

• Observe The GrandBoss Zone.

 

Preview (HTM Dialog):

 

initialp.pngvalakasd.png

 

How to install:

 

1. Create a new java file on data/scripts/custom/RaidObserver/RaidObserver.java

 

Paste this code:

package custom.RaidObserver;
import javolution.text.TextBuilder;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;

/**
* @author `Heroin
* Made For Maxcheaters.com
*/
public class RaidObserver extends Quest
{
private static final int _Baium = 29020;
private static final int _Antharas = 29068;
private static final int _Valakas = 29028;
private static final int _AntQueen = 29001;
private static final int npcid = 36650; // npc id
private static final boolean EnableObservation = true; // Set it true to allow players to observe raidbosses
private static final boolean EnableTeleport = true; // Set it true to allow players to teleport to raidbosses
private static final int ObservationAdena = 5000;  
private static String htm = "data/scripts/custom/RaidObserver/1.htm"; //html location
private int x = 0; //Dont Change
private int y = 0;//Dont Change
private int z = 0;//Dont Change

public RaidObserver(int questId, String name, String descr)
{
	super(questId, name, descr);
	addFirstTalkId(npcid);
	addTalkId(npcid);
	addStartNpc(npcid);
}

@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
	if (event.startsWith("Valakas"))
	{
		RaidInfo(event, npc, player, event);
	}
	if (event.startsWith("tp_Valakas"))//location of the teleport
	{
		player.teleToLocation(213447, -115136, -1636);
	}
	if (event.startsWith("Baium"))
	{
		RaidInfo(event, npc, player, event);
	}
	if (event.startsWith("tp_Baium"))
	{
		player.teleToLocation(115213, 16623, 10085);//location of the teleport
	}
	if (event.startsWith("Antharas"))
	{
		RaidInfo(event, npc, player, event);
	}
	if (event.startsWith("tp_Antharas"))   
	{
		player.teleToLocation(179864, 114819, -7711);//location of the teleport
	}
	if (event.startsWith("AntQueen"))
	{
		RaidInfo(event, npc, player, event);
	}
	if (event.startsWith("tp_AntQueen"))
	{
		player.teleToLocation(-21514, 181871, -5722); //location of the teleport
	}
	if (event.startsWith("Back"))//Back Button Dont Chant
	{
		Back(event, npc, player, event);
	}
	  
	return "";
}


private void checkxyz(String command) // Selecting Location for Observing each raidboss
{
	if (command.equals("Baium"))
	{
		x=115213;
		y=16623;
		z = 10085;
	}
	if (command.equals("Valakas"))
	{
		x=213447;
		y=-115136;
		z = -1636;
	}
	if (command.equals("AntQueen")) // , 181871, -5722
	{
		x=-21514;
		y= 181871;
		z = -5722;
	}
	if (command.equals("Antharas"))
	{
		x=179864;
		y=114819;
		z = -7711;
	}	
}  


private int checkppl(String command, L2PcInstance player)//Calculating players inside boss area
{
	if (command.equals("Baium"))
	{
		int ppl = getPlayerInside(12002);
		return ppl;
	}
	if (command.equals("Valakas"))
	{
		int ppl = getPlayerInside(12010);
		return ppl;
	}
	if (command.equals("AntQueen"))
	{
		int ppl = getPlayerInside(12012);
		return ppl;
	}
	if (command.equals("Antharas"))
	{
		int ppl = getPlayerInside(12001);
		return ppl;
	}
	return 0;

}
private int checkpts(String command, L2PcInstance player)//Calculating parties inside boss area
{
	if (command.equals("Baium"))
	{
		int pts = getPartiesInside(12002);
		return pts;
	}
	if (command.equals("Valakas"))
	{
		int pts = getPartiesInside(12010);
		return pts;
	}
	if (command.equals("AntQueen"))
	{
		int pts = getPartiesInside(12012);
		return pts;
	}
	if (command.equals("Antharas"))
	{
		int pts = getPartiesInside(12001);
		return pts;
	}
	return 0;
}
private boolean israidon(String name)//Checks if raid is online/offline
{
	int id = 0;
	if (name.equals("Baium"))
		id = _Baium;
	if (name.equals("Valakas"))
		id = _Valakas;
	if (name.equals("AntQueen"))
		id = _AntQueen;
	if (name.equals("Antharas"))
		id = _Antharas;
	int status = GrandBossManager.getInstance().getBossStatus(id);
	if (status == 2)
		return false;
	else if (status == 1)
		return true;
	else
		return false;
}

@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
	final int npcId = npc.getNpcId();
	if (player.getQuestState(getName()) == null)
	{
		newQuestState(player);
	}
	if (npcId == npcid)
	{
		String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htm);
		html = html.replaceAll("%player%", player.getName());		
		html = html.replaceAll("%teleport%", EnableTeleport ? "<font color=\"00FF00\">Enabled</font>" : "<font color=\"FF0000\">Disabled</font>");
		html = html.replaceAll("%observation%", EnableObservation ? "Observation: <font color=\"00FF00\">Enabled</font><br>Observation Adena Price: <font color=\"LEVEL\">"+ObservationAdena+"</font>" 
				: "<font color=\"FF0000\">Observation: Disabled</font>");

		NpcHtmlMessage npcHtml = new NpcHtmlMessage(0);
		npcHtml.setHtml(html);
		player.sendPacket(npcHtml);
	}
	return "";
}

public static void main(final String[] args)
{
	new RaidObserver(-1, RaidObserver.class.getSimpleName(), "custom");
	System.out.println("De Level Manager by `Heroin has been loaded successfully!");
}
private void Back(String event, L2Npc npc, L2PcInstance player, String command)
{

	try
	{

			String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htm);
			html = html.replaceAll("%player%", player.getName());		
			html = html.replaceAll("%teleport%", EnableTeleport ? "<font color=\"00FF00\">Enabled</font>" : "<font color=\"FF0000\">Disabled</font>");
			html = html.replaceAll("%observation%", EnableObservation ? "Observation: <font color=\"00FF00\">Enabled</font><br>Observation Adena Price: <font color=\"LEVEL\">"+ObservationAdena+"</font>" 
					: "<font color=\"FF0000\">Observation: Disabled</font>");

			NpcHtmlMessage npcHtml = new NpcHtmlMessage(0);
			npcHtml.setHtml(html);
			player.sendPacket(npcHtml);

	}
	catch (Exception e)
	{
		player.sendMessage("Something went wrong try again.");
	}
}
@SuppressWarnings("deprecation")
public int getPlayerInside(int zoneId)//Calculating players inside party area.
    {
        int i = 0;
        for (L2ZoneType zone : ZoneManager.getInstance().getAllZones())
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside().values())
                    if (character instanceof L2PcInstance && (!((L2PcInstance) character).getClient().isDetached()))
                        i++;
            }
return i;
} 
private void RaidInfo(String event, L2Npc npc, L2PcInstance player, String command)
{

	try
	{
		int playersin = checkppl(command, player); 
		int partiesin = checkpts(command, player); 
		boolean status = israidon(command);
		checkxyz(command);
		String color = status ? "<font color=\"00FF00\">Online</font>" : "<font color=\"FF0000\">Offline</font>";
		NpcHtmlMessage nhm = new NpcHtmlMessage(5);
		TextBuilder tb = new TextBuilder("");
		tb.append("<html><head><title>"+player.getName()+"</title></head><body><center>");
		tb.append("<br><tr><td><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32></td></tr><br>");//image
		tb.append("<font color=\"FFA500\">"+command+" Information</font><br>");
		tb.append("<table bgcolor=444444 width= 280>");
		tb.append("<tr><td align=center><font color=\"C0C0C0\">Players Inside "+command+" Zone: "+playersin+"</font></td></tr>");
		tb.append("<tr><td align=center><img src=\"L2UI.SquareWhite\" width=90 height=1></td></tr>");
		tb.append("<tr><td align=center><img src=\"L2UI.SquareBlank\" width=90 height=1></td></tr>");
		tb.append("<tr><td align=center><img src=\"L2UI.SquareBlank\" width=90 height=1></td></tr>");
		tb.append("<tr><td align=center><font color=\"C0C0C0\">Parties Inside "+command+" Zone: "+partiesin+"</font></td></tr>");
		tb.append("</table><br>");
		tb.append("<table width= 280>");
		tb.append("<tr><td align=center>Raid Boss Status: "+color+"</td></tr></table><br><BR>");
		tb.append("<table bgcolor=444444 width=50>");
		tb.append("<tr><td><button value=\"Teleport To "+command+
				"\" action=\"bypass -h Quest RaidObserver tp_"+command+"\" width=150 height=22 back=\"L2UI_ct1.Button_DF_Calculator_Down\" fore=\"L2UI_ct1.Button_DF_Calculator\"></td></tr>");
		if (EnableObservation)
		{
		tb.append("<tr><td><button value=\"Observe "+command+
				"\" action=\"bypass -h npc_"+npc.getObjectId()+"_observe "+ObservationAdena+" "+x+" "+y+" "+z+"\" width=150 height=22 back=\"L2UI_ct1.Button_DF_Calculator_Down\" fore=\"L2UI_ct1.Button_DF_Calculator\"></td></tr>");
		}
		tb.append("<tr><td><button value=\"Back\" action=\"bypass -h Quest RaidObserver Back\" width=150 height=22 back=\"L2UI_ct1.Button_DF_Calculator_Down\" fore=\"L2UI_ct1.Button_DF_Calculator\"></td></tr>");

		tb.append("</table><br><br><br><br>");
		tb.append("<tr><td><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32></td></tr><br>");
		tb.append("</body></html>");
		nhm.setHtml(tb.toString());
		player.sendPacket(nhm);
	}
	catch (Exception e)
	{
		player.sendMessage("Something went wrong try again.");
	}
}
@SuppressWarnings("deprecation")
public int getPartiesInside(int zoneId)//Calculating parties inside party area.
    {
        int i = 0;
        for (L2ZoneType zone : ZoneManager.getInstance().getAllZones())
            if (zone.getId() == zoneId)
            {
                for (L2Character character : zone.getCharactersInside().values())
                    if (character instanceof L2PcInstance && (!((L2PcInstance) character).getClient().isDetached()) && 
                    		((L2PcInstance) character).getParty() != null && 
                    		((L2PcInstance) character).getParty().isLeader((L2PcInstance) character))
                        i++;
            }
        return i;
    }
}

 

2.Create a new htm file on data/scripts/custom/RaidObserver/1.htm

 

Paste this code ont it:

<title>%player%</title>
<center><br>
<tr><td><img src="L2UI_CH3.herotower_deco" width=256 height=32></td></tr><br>
<center><font color="CC9900">Grand Raid Boss Informaton</font></text></center>
<br>
<table>
<tr>
<td align=center><img src="icon.accessory_ring_of_baium_i00" width=32 height=32>
</td>
<td align=center><button value="Baium" action="bypass -h Quest RaidObserver Baium" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
</td>
<td align=center><button value="Valakas" action="bypass -h Quest RaidObserver Valakas" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
</td>
<td align=center><img src="icon.accessory_necklace_of_valakas_i00" width=32 height=32>
</td>
</table>
<br><img src="L2UI.SquareGray" width=155 height=1><br>
<table>
<tr>
<td align=center><img src="icon.accessory_earring_of_antaras_i00" width=32 height=32>
</td>
<td align=center><button value="Antharas" action="bypass -h Quest RaidObserver Antharas" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
</td>
<td align=center><button value="Queen Ant" action="bypass -h Quest RaidObserver AntQueen" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
</td>
<td align=center><img src="icon.accessory_ring_of_queen_ant_i00" width=32 height=32>
</td>
</table><br><img src="L2UI.SquareGray" width=155 height=1><br><BR><BR>
Teleport: %teleport%<br>
%observation%<br>
<tr><td><img src="L2UI_CH3.herotower_deco" width=256 height=32></td></tr><br>

 

3. Add script on scripts.cfg file:

custom/RaidObserver/RaidObserver.java

 

4. Run this query on your database or install the NPC by yourself.

INSERT INTO `npc` VALUES ('36650', '13173', 'RaidObserver', '1', 'MaxCheaters.com', '1', 'LineageNPC.clear_npc', '8.00', '19.00', '85', 'male', 'L2Npc', null, null, null, null, null, '40', '43', '30', '21', '20', '20', '0', '0', null, null, null, null, '230', '1', '0', '333', '0', '0', '0', '60.00000', '120.00000', '1', '1', '0', '0');

 

How to Modify:

 

Check Variables on code:

private static final int _Baium = 29020;
private static final int _Antharas = 29068;
private static final int _Valakas = 29028;
private static final int _AntQueen = 29001;
private static final int npcid = 36650; // npc id
private static final boolean EnableObservation = true; // Set it true to allow players to observe raidbosses
private static final boolean EnableTeleport = true; // Set it true to allow players to teleport to raidbosses
private static final int ObservationAdena = 5000;  //Adena required to observe a grand boss
private static String htm = "data/scripts/custom/RaidObserver/1.htm"; //html location

 

How to Add More Grand Bosses in list:

 

Index: L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/
===================================================================
--- L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/RaidObserver.java
+++ L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/RaidObserver.java

@@ +142, 7 - 144 , 9 @@
private static final int _AntQueen = 29001;
+	private static final int _YourRaidBoss = 12345;
private static final int npcid = 36650; // npc id


@@ +219,8 -222 , 6 @@
                 if (event.startsWith("tp_Valakas"))//location of the teleport
	{
		player.teleToLocation(213447, -115136, -1636);
	}
+		if (event.startsWith("YourRaidBoss"))
+		{
+			RaidInfo(event, npc, player, event);
+		}
+		if (event.startsWith("tp_YourRaidBoss"))//location of the teleport
+		{
+			player.teleToLocation(213447, -115136, -1636);
+		}
                if (event.startsWith("Baium"))
	{

@@ +172,12 - 176, 5 @@

		y=16623;
		z = 10085;
	}
+		if (command.equals("YourRaidBoss"))
+		{
+			x= YourLocationX;
+			y=-YourLocationY;
+			z = YourLocationZ;
+		}
	if (command.equals("Valakas"))
	{
		x=213447;

@@ +130, 1 - 157,9 @@
		return ppl;
	}
+		if (command.equals("YourRaidBoss"))
+		{
+			int ppl = getPlayerInside(Zone Id ); //check data/zones/custom_boss_zones.xml
+			return ppl;
+		}
	if (command.equals("AntQueen"))
	{

@@ +160, 2 - 177,4 @@
		return pts;
	}
+		if (command.equals("YourRaidBoss"))
+		{
+			int pts = getPartiesInside(Zone Id); //check data/zones/custom_boss_zones.xml
+			return pts;
+		}
	if (command.equals("AntQueen"))
	{
@@ +187, 3 - 191,5 @@
                if (name.equals("Valakas"))
		id = _Valakas;
+		if (name.equals("YourRaidBoss"))
+			id = _YourRaidBoss;
	if (name.equals("AntQueen"))
		id = _AntQueen;

Index: L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/
===================================================================
--- L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/1.htm
+++ L2J_DataPack/dist/game/data/scripts/custom/RaidObserver/1.htm

<td align=center><img src="icon.accessory_necklace_of_valakas_i00" width=32 height=32>
</td>
</table>
+<br><img src="L2UI.SquareGray" width=155 height=1><br>
+<table>
+<tr>
+<td align=center><img src="icon.accessory_earring_of_antaras_i00" width=32 height=32>
+</td>
+<td align=center><button value="Antharas" action="bypass -h Quest RaidObserver Antharas" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
+</td>
+<td align=center><button value="Queen Ant" action="bypass -h Quest RaidObserver AntQueen" width=90 height=32 back="L2UI_CT1.Button_DF_Calculator_Over" fore="L2UI_CT1.Button_DF_Calculator_Over">
+</td>
+<td align=center><img src="icon.accessory_ring_of_queen_ant_i00" width=32 height=32>
+</td>
+</table>
+<br><img src="L2UI.SquareGray" width=155 height=1><br>
<table>
<tr>
<td align=center><img src="icon.accessory_earring_of_antaras_i00" width=32 height=32>

 

After that all the texts will be ready, you have just to edit which functions must be excecuted for which command.

 

Credits & Idea: `Heroin

Posted

Observe system is kinda old and implemented in l2j since years ago. Also you can do the same thing w/ a simple html, bypass -h npc_%objectId%_observe X Y Z except your extra features.

Posted

You do great job in every single share good job mate. Rewarded

Thanks a lot marwan!  O0

 

Observe system is kinda old and implemented in l2j since years ago. Also you can do the same thing w/ a simple html, bypass -h npc_%objectId%_observe X Y Z except your extra features.

You can do with html...I already did it and posted before. You can see in my topic where i did it...Just read it carefully..However, this is not only an observer manager, it says how many people  parties are in raidboss, you can teleport there...etc etc

Posted

this is high five right?

just delete values() and press after ctrl+space and see available methods. I think it is like getValues on high five :P

Posted

game\data\scripts\custom\RaidObserver\RaidObserver.java

java.lang.NullPointerException

at custom.RaidObserver.RaidObserver.onFirstTalk(RaidObserver.java:207)

at com.l2jserver.gameserver.model.quest.Quest.notifyFirstTalk(Quest.java:792)

at handlers.actionhandlers.L2NpcAction.action(L2NpcAction.java:148)

at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:277)

at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:269)

at com.l2jserver.gameserver.network.clientpackets.Action.runImpl(Action.java:137)

at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:70)

at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1100)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

 

I hate this problem...

Posted

game\data\scripts\custom\RaidObserver\RaidObserver.java

java.lang.NullPointerException

at custom.RaidObserver.RaidObserver.onFirstTalk(RaidObserver.java:207)

at com.l2jserver.gameserver.model.quest.Quest.notifyFirstTalk(Quest.java:792)

at handlers.actionhandlers.L2NpcAction.action(L2NpcAction.java:148)

at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:277)

at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:269)

at com.l2jserver.gameserver.network.clientpackets.Action.runImpl(Action.java:137)

at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:70)

at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1100)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

 

I hate this problem...

 

Where it shows this message? I mean it does not speak the NPC at all, or when you press a button?

Posted

Where it shows this message? I mean it does not speak the NPC at all, or when you press a button?

 

the npc doesent speak at all, this error i get in GS Console

Posted

I modified only the problem from Hi5 server as u told there let me show u....

 

from this: for (L2Character character : zone.getCharactersInside().values())

 

to this: for (Object character : zone.getCharactersInside().toArray())

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...