Jump to content
  • 0

create npc top pvp / pk for l2jmobius interlude


Question

Posted

 

I would like to know if someone can generate a guide for me to create or adapt a npc top pvp / pk for l2jmobius interlude .. I have already tried it for days and I have not succeeded .. I would appreciate your help.

I'm going crazy with this ... and I also want to create the npc for the raid bosses ... from now on I thank you very much for your attention

2 answers to this question

Recommended Posts

  • 0
Posted

Sup dude, i'm using mobius to and i recommendation its just use the things you have on that pack, trying to add new npcs its a nightmare. The only way you can get new npcs and so on its paying for support and unlock more hidden post on mobius forum, ofc you will have to pay 120 euros.

  • 0
Posted (edited)
/*
 * 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 org.l2jmobius.gameserver.model.actor.instance;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;

import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 * @author Drazeal
 */
public class StatusInstance extends NpcInstance
{
	
	private class PlayerInfo
	{
		public PlayerInfo(int pos, String n, int pvps, int pks, int ontime, Boolean iso)
		{
			position = pos;
			Nick = n;
			pvpCount = pvps;
			pkCount = pks;
			onlineTime = ontime;
			isOnline = iso;
		}
		
		public int position;
		public String Nick;
		public int pvpCount;
		public int pkCount;
		public int onlineTime;
		public Boolean isOnline;
	}
	
	// delay interval (in minutes):
	private final int delayForCheck = 5;
	
	// number of players to be listed
	private final int pvpListCount = 10;
	private final int pkListCount = 10;
	private final int onlineListCount = 10;
	
	private final PlayerInfo[] topPvPList = new PlayerInfo[pvpListCount];
	private final PlayerInfo[] topPkList = new PlayerInfo[pkListCount];
	private final PlayerInfo[] topOnlineList = new PlayerInfo[onlineListCount];
	
	public StatusInstance(NpcTemplate template)
	{
		super(template);
		setInstanceType(InstanceType.StatusInstance);
		ThreadPool.scheduleAtFixedRate(new RefreshAllLists(), 10000, delayForCheck * 60000);
	}
	
	private class RefreshAllLists implements Runnable
	{
		@Override
		public void run()
		{
			ReloadData();
		}
	}
	
	private void ReloadData()
	{
		try (Connection con = DatabaseFactory.getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT char_name, pvpkills, online FROM characters ORDER BY pvpkills DESC, char_name ASC LIMIT 10");
			ResultSet result = statement.executeQuery();
			
			// refreshing top pvp list
			int i = 0; // index of array
			
			while (result.next())
			{
				topPvPList[i] = new PlayerInfo(i + 1, result.getString("char_name"), result.getInt("pvpkills"), 0, 0, result.getBoolean("online"));
				i++;
			}
			
			// refreshing top pk list
			statement = con.prepareStatement("SELECT char_name, pkkills, online FROM characters ORDER BY pkkills DESC, char_name ASC LIMIT 10");
			result = statement.executeQuery();
			
			i = 0; // index of array
			while (result.next())
			{
				topPkList[i] = new PlayerInfo(i + 1, result.getString("char_name"), 0, result.getInt("pkkills"), 0, result.getBoolean("online"));
				i++;
			}
			
			// refreshing top online list
			statement = con.prepareStatement("SELECT char_name, onlinetime, online FROM characters ORDER BY onlinetime DESC, char_name ASC LIMIT 10");
			result = statement.executeQuery();
			
			i = 0; // index of array
			while (result.next())
			{
				topOnlineList[i] = new PlayerInfo(i + 1, result.getString("char_name"), 0, 0, result.getInt("onlinetime"), result.getBoolean("online"));
				i++;
			}
			
			result.close();
			statement.close();
			
		}
		catch (SQLException e)
		{
			LOGGER.warning("ranking (status): could not load statistics informations" + e.getMessage());
		}
	}
	
	@Override
	public void onSpawn()
	{
		ReloadData();
	}
	
	@Override
	public void showChatWindow(PlayerInstance player)
	{
		GeneratePvPList(player);
	}
	
	@Override
	public void onBypassFeedback(PlayerInstance player, String command)
	{
		StringTokenizer st = new StringTokenizer(command, " ");
		String currentCommand = st.nextToken();
		
		if (currentCommand.startsWith("pvplist"))
		{
			GeneratePvPList(player);
		}
		
		else if (currentCommand.startsWith("pklist"))
		{
			GeneratePKList(player);
		}
		else if (currentCommand.startsWith("onlinelist"))
		{
			GenerateOnlineList(player);
		}
		
		super.onBypassFeedback(player, command);
	}
	
	private void GeneratePvPList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topPvPList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + player.pvpCount + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 0, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%pvplist%", _PVPranking.toString());
		/* html.replace("%online%", String.valueOf(p.getUptime())); */
		p.sendPacket(html);
	}
	
	private void GeneratePKList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topPkList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + player.pkCount + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 2, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%pklist%", _PVPranking.toString());
		p.sendPacket(html);
	}
	
	private void GenerateOnlineList(PlayerInstance p)
	{
		StringBuilder _PVPranking = new StringBuilder();
		for (PlayerInfo player : topOnlineList)
		{
			if (player == null)
			{
				break;
			}
			
			_PVPranking.append("<table width=\"290\"><tr>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("<td FIXWIDTH=\"17\" align=\"center\">" + player.position + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"158\" align=\"center\">" + player.Nick + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"90\" align=\"center\">" + ConverTime(player.onlineTime) + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"50\" align=\"center\">" + ((player.isOnline) ? "<font color=\"00FF00\">online</font>" : "<font color=\"CC0000\">offline</font>") + "</td>");
			_PVPranking.append("<td FIXWIDTH=\"2\" align=\"center\"></td>");
			_PVPranking.append("</tr></table>");
			_PVPranking.append("<img src=\"L2UI.Squaregray\" width=\"300\" height=\"1\">");
		}
		
		final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
		html.setFile(p, getHtmlPath(getId(), 3, p));
		html.replace("%objectId%", getObjectId());
		html.replace("%onlinelist%", _PVPranking.toString());
		p.sendPacket(html);
	}
	
	private String ConverTime(long seconds)
	{
		long remainder = seconds;
		int days = (int) remainder / (24 * 3600);
		remainder = remainder - (days * 3600 * 24);
		
		int hours = (int) (remainder / 3600);
		remainder = remainder - (hours * 3600);
		
		int minutes = (int) (remainder / 60);
		remainder = remainder - (hours * 60);
		
		seconds = remainder;
		
		String timeInText = "";
		
		if (days > 0)
		{
			timeInText = days + "<font color=\"LEVEL\">D</font> ";
		}
		if (hours > 0)
		{
			timeInText = timeInText + hours + "<font color=\"LEVEL\">H</font> ";
		}
		if (minutes > 0)
		{
			timeInText = timeInText + minutes + "<font color=\"LEVEL\">M</font>";
		}
		
		if (timeInText == "")
		{
			if (seconds > 0)
			{
				timeInText = seconds + "<font color=\"LEVEL\">S</font>";
			}
			else
			{
				timeInText = "N/A";
			}
		}
		return timeInText;
	}
	
	@Override
	public String getHtmlPath(int npcId, int val, PlayerInstance player)
	{
		String filename;
		
		if (val == 0)
		{
			filename = "data/html/Status/" + npcId + ".htm";
		}
		else
		{
			filename = "data/html/Status/" + npcId + "-" + val + ".htm";
		}
		
		if (HtmCache.getInstance().isLoadable(filename))
		{
			return filename;
		}
		
		return "data/html/Status/" + npcId + ".htm";
	}
	
}

 

 

found this somewhere in here so credits to that giy.

i just modified it to work on Mobius. 

create the Htmls, not hard.

my knowledge on coding is shit so plz dont judge.

at least it works fine with no errors.

 

this is for Classic IL. you dont need to change a lot of things to make it work for IL.

Edited by Drazeal

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ⚡ Weekend Stock Refresh! Fast order fulfillment is active. Get Gemini Pro Advanced + Google One cloud storage activated on your own personal email within minutes.
    • New Release World & atmosphere A complete dynamic weather system has arrived, with Clear, Light Rain, Rain, Heavy Rain, Storm, Snow, and Windy presets. Rain and snow react to roofs, wind moves foliage, lightning illuminates storms, exposed ground becomes wet and develops puddles, and snow builds up and melts over time. Weather includes Low to Ultra quality levels and advanced controls for precipitation, wind, cloud cover, lightning, surface wetness, puddles, and snow. The game server can also select or restore the current weather while local quality settings continue to control rendering cost. The weather can be controlled from the server with custom packets. For more details use Shift+Alt+P. Enhanced lighting now allows authored lamps, fires, and other light sources to illuminate towns and interiors. Lights can pulse, flicker, blink, and strobe, flames produce warm dynamic light, and lamps display depth-aware halos. Remastered emissive surfaces are now supported, beginning with illuminated windows in Giran that glow and cast light into their surroundings. Broadcasting Towers now use their correct original scale and animated rings and glow effects. Map, quests & navigation A complete quest journal has been added, with active and completed quests, expandable stages, descriptions, requirements, item progress, quest inventory integration, location controls, and quest cancellation. Quest objectives now appear through flashing minimap and world-map markers, an overhead directional guide, a notification button beside chat, and rotating quest symbols above eligible NPCs. Server-directed radar markers now work across the live minimap and world map, including the original overhead guidance effect and arrival behavior. The original tutorial system now works, including scrollable tutorial pages, animated illustrations, the flashing question button, tutorial links, and movement, camera, pickup, and sit/rest progression events. Server-opened town maps now display their original artwork and the supplied player marker. Shops, storage & items Personal, clan, castle, and freight warehouses now work, including deposits, withdrawals, stack quantities, fees, weight and capacity previews, tooltips, and the original warning and empty-storage dialogs. Account freight now works through the original recipient picker and delivery window, allowing items to be sent to another character on the same account. Multisell exchanges now work, with paged recipe lists, product details, required materials, quantity selection, warnings, and server-backed completion. Manor seed purchasing is now supported through the shop interface, including availability and pricing. Inventory items can now be dragged to the trash button and destroyed after the appropriate warning or quantity prompt. The original in-game calculator now works with mouse and keyboard input. Community The Community Board is now available from the system menu or Alt+B, with Home, Favorites, Region, Clan, Memo, Mail, and Friends sections, retained navigation, forms, scrolling, minimization, and server-provided pages. Characters, cameras & events Striders and Wyverns now render as fully animated mounts with the rider attached correctly. Striders remain ground-based, while Wyverns support three-dimensional flight. Characters now enter a proper falling state after high drops or airborne dismounts, with falling animations and server-authoritative landing and fall-damage handling. Players can now sit on authored world chairs using the correct sit, wait, and stand animations. Server-driven special camera sequences now work, including target tracking, interpolation, duration, widescreen bars, and restoration to the normal camera. GM camera mode and server-authorized ///fly movement are now supported. The original 102-second Kamael teaser sequence has been restored with its complete slideshow, transitions, panning artwork, localized subtitles, and narration. Hats, masks, circlets, and other hair accessories now use their authored head placement and correctly adjust the character's hairstyle. Timed server confirmation dialogs, short-duration status effects, regeneration previews, and the seasonal Christmas Seal presentation are now supported. Interface & performance Character creation has been refined with corrected description wrapping, clipping, layout, and name-entry presentation. Tutorial and NPC dialog windows now use polished proportional scrollbars, improved HTML layout, and correctly sized illustrations and controls. A new independent 3D render-resolution setting offers Native, 720p, 900p, 1080p, 1440p, and 4K choices while keeping the window, HUD, text, and FermaUI at native resolution. Major rendering optimizations reduce unnecessary work in local lighting, shadows, visibility, exposure, bloom, post-processing, and GPU diagnostics. Download from the launcher you have installed, or at https://updates.fermata.gg/ if you don't have the launcher. Fermata Light Engine Preview All lights can be baked in the client, shipped to the users, and exported and imported as .femlight files.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..