Jump to content

Recommended Posts

Posted

Hi all, this is my first post here in Max Cheaters, and I apologize if my share is already posted here, but if it isn't...lets go :)

 

The DIFFs are here...what does it do? Well, it morphs any normal NPC to a PC, where you can set as PK, PvP, Hero, Nobless, set Clan, Ally, give Weapons, Armors, morph only one NPC, or all of that ID, use random weapons, random armors, race, class, etc...

 

If you don't set any class, it sort a random, and each NPC you spawn, comes with a different template ( Human, Orc, Dwarf, Kamael, etc ), if you don't set any armor/weapon, it sorts too..you can set a enchant to the weapon too, and random sex too

 

Index: F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/CustomNpcInfo.java
===================================================================
--- F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/CustomNpcInfo.java	(revision 0)
+++ F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/CustomNpcInfo.java	(revision 0)
@@ -0,0 +1,160 @@
+/*
+ * 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 net.sf.l2j.gameserver.network.serverpackets;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
+import net.sf.l2j.gameserver.datatables.CharTemplateTable;
+public class CustomNpcInfo extends L2GameServerPacket
+{
+
+	private static final String _S__31_CUSTOMNPCINFO = "[s] 31 CustomNpcInfo [dddddsddd dddddddddddd dddddddd hhhh d hhhhhhhhhhhh d hhhh hhhhhhhhhhhhhhhh dddddd dddddddd ffff ddd s ddddd ccccccc h c d c h ddd cc d ccc ddddddddddd]";
+	private L2NpcInstance _activeChar;
+
+	/**
+	 * @param custom npcs that look like players
+	 */
+	public CustomNpcInfo(L2NpcInstance cha)
+	{
+		_activeChar = cha;
+		_activeChar.setClientX(_activeChar.getPosition().getX());
+		_activeChar.setClientY(_activeChar.getPosition().getY());
+		_activeChar.setClientZ(_activeChar.getPosition().getZ());
+
+	}
+
+	@Override
+	protected final void writeImpl()
+	{
+		writeC(0x31);
+		writeD(_activeChar.getX());
+		writeD(_activeChar.getY());
+		writeD(_activeChar.getZ());
+		writeD(_activeChar.getHeading());
+		writeD(_activeChar.getObjectId());
+		writeS(_activeChar.getCustomNpcInstance().getName());
+		writeD(_activeChar.getCustomNpcInstance().getRace());
+		writeD(_activeChar.getCustomNpcInstance().isFemaleSex()? 1 : 0);
+		writeD(_activeChar.getCustomNpcInstance().getClassId());
+		write('D',0, 2);
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_RHAND());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_LHAND());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_GLOVES());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_CHEST());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_LEGS());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_FEET());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_HAIR());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_RHAND());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_HAIR());
+		writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_HAIR2());
+
+		write('D',0, 8);
+		write('H',0, 4);
+		writeD(0);
+		write('H',0,12);
+		writeD(0);
+		write('H',0,20);
+		
+		writeD(_activeChar.getCustomNpcInstance().getPvpFlag() ? 1 : 0);
+		writeD(_activeChar.getCustomNpcInstance().getKarma());
+
+		writeD(_activeChar.getMAtkSpd());
+		writeD(_activeChar.getPAtkSpd());
+		
+		writeD(_activeChar.getCustomNpcInstance().getPvpFlag() ? 1 : 0);
+		writeD(_activeChar.getCustomNpcInstance().getKarma());
+
+		writeD(_activeChar.getRunSpeed());
+		writeD(_activeChar.getRunSpeed()/2);
+		writeD(_activeChar.getRunSpeed()/3);
+		writeD(_activeChar.getRunSpeed()/3);
+		writeD(_activeChar.getRunSpeed());
+		writeD(_activeChar.getRunSpeed());
+		writeD(_activeChar.getRunSpeed());
+		writeD(_activeChar.getRunSpeed());
+		writeF(_activeChar.getStat().getMovementSpeedMultiplier());
+		writeF(_activeChar.getStat().getAttackSpeedMultiplier());
+
+		writeF(CharTemplateTable.getInstance().getTemplate(_activeChar.getCustomNpcInstance().getClassId()).getCollisionRadius());
+		writeF(CharTemplateTable.getInstance().getTemplate(_activeChar.getCustomNpcInstance().getClassId()).getCollisionHeight());
+		
+		writeD(_activeChar.getCustomNpcInstance().getHairStyle());
+		writeD(_activeChar.getCustomNpcInstance().getHairColor());
+		writeD(_activeChar.getCustomNpcInstance().getFace());
+		
+		writeS(_activeChar.getCustomNpcInstance().getTitle());
+		
+		writeD(_activeChar.getCustomNpcInstance().getClanId());
+		writeD(_activeChar.getCustomNpcInstance().getClanCrestId());
+		writeD(_activeChar.getCustomNpcInstance().getAllyId());
+		writeD(_activeChar.getCustomNpcInstance().getAllyCrestId());
+		writeD(0);
+		writeC(1);
+		writeC(_activeChar.isRunning() ? 1 : 0);
+		writeC(_activeChar.isInCombat() ? 1 : 0);
+		writeC(_activeChar.isAlikeDead() ? 1 : 0);
+		write('C',0, 3);
+		writeH(0);
+		writeC(0);
+		writeD(_activeChar.getAbnormalEffect());
+		writeC(0);
+		writeH(0);
+		writeD(_activeChar.getCustomNpcInstance().getClassId());
+		writeD(_activeChar.getMaxCp());
+		writeD((int)_activeChar.getStatus().getCurrentCp());
+		writeC(_activeChar.getCustomNpcInstance().getEnchantWeapon());
+		writeC(0);
+		writeD(0); 
+		writeC(_activeChar.getCustomNpcInstance().isNoble() ? 1 : 0);  
+		writeC(_activeChar.getCustomNpcInstance().isHero()  ? 1 : 0);
+		writeC(0);
+
+		write('D',0, 3);
+		writeD(_activeChar.getCustomNpcInstance().nameColor());
+		writeD(0); 
+		writeD(_activeChar.getCustomNpcInstance().getPledgeClass()); 
+		writeD(0);
+		writeD(_activeChar.getCustomNpcInstance().titleColor());
+		writeD(_activeChar.getCustomNpcInstance().getCursedWeaponLevel());
+		write('D',0, 2);
+	}
+	
+	/* (non-Javadoc)
+	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
+	 */
+	@Override
+	public String getType()
+	{
+		return _S__31_CUSTOMNPCINFO;
+	}
+	
+	private final void write(char type, int value , int times)
+	{
+		for (int i=0 ; i<times ; i++)
+		{
+			switch(type)
+			{
+			case 'C': writeC(value);
+			          break;
+			case 'D': writeD(value);
+			          break;
+			case 'F': writeF(value);
+			          break;
+			case 'H': writeH(value);
+			          break;
+			}
+		}
+	}
+	
+}
Index: F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfo.java
===================================================================
--- F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfo.java	(revision 2970)
+++ F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfo.java	(working copy)
@@ -48,6 +49,18 @@
	 */
	public NpcInfo(L2NpcInstance cha, L2Character attacker)
	{
+		if (cha.getCustomNpcInstance() != null)
+		{
+			attacker.sendPacket(new CustomNpcInfo(cha));
+			return;
+}
	_activeChar = cha;
	_idTemplate = cha.getTemplate().getIdTemplate();
	_isAttackable = cha.isAutoAttackable(attacker);
@@ -183,6 +188,8 @@
	@Override
	protected final void writeImpl()
	{
+		if (_activeChar == null)
+			   return;
		if (_idTemplate > 13070 && _idTemplate < 13077)
		{
			L2PcInstance owner = ((L2Decoy) _activeChar).getOwner();
Index: F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
===================================================================
--- F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java	(revision 2970)
+++ F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java	(working copy)
@@ -40,6 +40,7 @@
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.BaiumManager;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
+import net.sf.l2j.gameserver.instancemanager.CustomNpcInstanceManager;
import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;
import net.sf.l2j.gameserver.instancemanager.QuestManager;
import net.sf.l2j.gameserver.instancemanager.TownManager;
@@ -120,6 +121,9 @@
    /** The interaction distance of the L2NpcInstance(is used as offset in MovetoLocation method) */
    public static final int INTERACTION_DISTANCE = 150;
    
+    /** The Polymorph object that manage this L2NpcInstance's morph to a PcInstance... I wrote this line too =P Darki699 */
+    private L2CustomNpcInstance _customNpcInstance;
+    
    /** The L2Spawn object that manage this L2NpcInstance */
    private L2Spawn _spawn;

@@ -200,8 +204,10 @@
     */
    public void onRandomAnimation()
    {
-        // Send a packet SocialAction to all L2PcInstance in the _KnownPlayers of the L2NpcInstance
-        SocialAction sa = new SocialAction(getObjectId(), Rnd.get(2, 3));
+        int min = (_customNpcInstance != null) ? 1  : 2;
+        int max = (_customNpcInstance != null) ? 13 : 3;
+    	// Send a packet SocialAction to all L2PcInstance in the _KnownPlayers of the L2NpcInstance
+        SocialAction sa = new SocialAction(getObjectId(), Rnd.get(min, max));
        broadcastPacket(sa);
    }

@@ -793,7 +801,9 @@
                html1.append("Respawn Time: " + (getSpawn()!=null ? (getSpawn().getRespawnDelay() / 1000)+"  Seconds<br>" : "?  Seconds<br>"));
            
            html1.append("<table border=\"0\" width=\"100%\">");
-            html1.append("<tr><td>Object ID</td><td>"+getObjectId()+"</td><td>NPC ID</td><td>"+getTemplate().getNpcId()+"</td></tr>");
+            html1.append("<tr><td>Object ID</td><td>"+getObjectId()+"</td></tr>");
+            html1.append("<tr><td>NPC ID</td><td>"+getTemplate().getNpcId()+"</td></tr>");
+            html1.append("<tr><td>Spawn ID</td><td>"+getSpawn().getId()+"</td></tr>");
            html1.append("<tr><td>Castle</td><td>"+getCastle().getCastleId()+"</td><td>Coords</td><td>"+getX()+","+getY()+","+getZ()+"</td></tr>");
            html1.append("<tr><td>Level</td><td>"+getLevel()+"</td><td>Aggro</td><td>"+((this instanceof L2Attackable)? ((L2Attackable)this).getAggroRange() : 0)+"</td></tr>");
            html1.append("</table><br>");
@@ -2574,6 +2584,14 @@
    public void setSpawn(L2Spawn spawn)
    {
        _spawn = spawn;
+        // Does this Npc morph into a PcInstance?
+        if (_spawn != null)
+        {
+            if (CustomNpcInstanceManager.getInstance().isThisL2CustomNpcInstance(_spawn.getId() , getNpcId()))
+            {
+            	new L2CustomNpcInstance(this);
+            }
+        }
    }

    @Override
@@ -2711,8 +2729,18 @@
+    public L2CustomNpcInstance getCustomNpcInstance()
+    {
+    	return _customNpcInstance;
+    }
+    
+    public void setCustomNpcInstance(L2CustomNpcInstance arg)
+    {
+    	_customNpcInstance = arg;
+    }
}

 

Continue in the next post!

Posted

Index: F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/instancemanager/CustomNpcInstanceManager.java
===================================================================
--- F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/instancemanager/CustomNpcInstanceManager.java	(revision 0)
+++ F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/instancemanager/CustomNpcInstanceManager.java	(revision 0)
@@ -0,0 +1,305 @@
+/*
+ * 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 net.sf.l2j.gameserver.instancemanager;
+/**
+ * @author Darki699
+ */
+
+/** *****************************************- imports -******************************************** */
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import javolution.util.FastMap;
+import net.sf.l2j.L2DatabaseFactory;
+
+import net.sf.l2j.gameserver.datatables.SpawnTable;
+import net.sf.l2j.gameserver.model.actor.instance.L2CustomNpcInstance;
+import net.sf.l2j.gameserver.model.L2Spawn;
+
+import net.sf.l2j.tools.random.Rnd;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** *************************- main class + global class values -*********************************** */
+
+/**
+ * control for Custom Npcs that look like players.
+ * 
+ * @version 1.00
+ * @author Darki699
+ */
+
+public final class CustomNpcInstanceManager
+{
+	
+	private final static Log				_log = LogFactory.getLog(CustomNpcInstanceManager.class.getName());
+	private static CustomNpcInstanceManager _instance;
+	private FastMap<Integer,customInfo> spawns; 	// <Object id , info>
+	private FastMap<Integer,customInfo> templates; 	// <Npc Template Id , info>
+	
+	/**
+	 * Small class to keep the npc poly data...
+	 * Pretty code =)
+	 * @author Darki699
+	 */
+	public final class customInfo
+	{
+		public String   stringData [] = new String [ 2];
+		public int      integerData[] = new int    [27];
+		public boolean  booleanData[] = new boolean[ 8];
+	}
+	
+	/**
+	 * Constructor
+	 * Calls to load the data
+	 */
+	CustomNpcInstanceManager()
+	{
+		
+		load();
+	}
+	
+	/**
+	 * Initiates the manager (if not initiated yet) and/or returns <b>this</b> manager instance 
+	 * @return CustomNpcInstanceManager _instance
+	 */
+	public final static CustomNpcInstanceManager getInstance()
+	{
+		if (_instance == null)
+		{
+			_instance = new CustomNpcInstanceManager();
+		}
+		return _instance;
+	}
+	
+	/**
+	 * Flush the old data, and load new data
+	 */
+	public final void reload()
+	{
+		if (spawns    != null)    spawns.clear();
+		if (templates != null) templates.clear();
+		spawns    = null;
+		templates = null;
+		
+		load();
+
+		for ( L2Spawn spawn : SpawnTable.getInstance().getAllTemplates().values())
+		{
+			if (spawn == null) continue;
+			else if (spawn.getLastSpawn() == null) continue;
+			else 
+			{
+				new L2CustomNpcInstance(spawn.getLastSpawn());
+			}
+		}
+	}
+	
+	/**
+	 * Just load the data for mysql...
+	 */
+	private final void load()
+	{
+		if (spawns == null || templates == null)
+		{
+			spawns    = new FastMap<Integer,customInfo>();
+			templates = new FastMap<Integer,customInfo>();
+		}
+		
+		String[] SQL_ITEM_SELECTS = { 
+    		"SELECT" + 
+    		" spawn,template,name,title,class_id,female,hair_style,hair_color,face,name_color,title_color," +
+    		" noble,hero,pvp,karma,wpn_enchant,right_hand,left_hand,gloves,chest,legs,feet,hair,hair2," +
+    		" pledge,cw_level,clan_id,ally_id,clan_crest,ally_crest,rnd_class,rnd_appearance,rnd_weapon,rnd_armor,max_rnd_enchant" +
+    		" FROM npc_to_pc" , 
+    	};
+    	
+        java.sql.Connection con = null;
+        try
+        {
+            int count = 0;
+        	con = L2DatabaseFactory.getInstance().getConnection(con);
+            for (String selectQuery : SQL_ITEM_SELECTS)
+            {
+                PreparedStatement statement = con.prepareStatement(selectQuery);
+                ResultSet rset = statement.executeQuery();
+
+                while(rset.next())
+                {
+                	count++;
+                	customInfo ci = new customInfo();
+                    ci.integerData[26] =rset.getInt("spawn");
+            		ci.integerData[25] =rset.getInt("template");
+                	try
+                    {
+                		ci.stringData [ 0] =rset.getString("name");
+                		ci.stringData [ 1] =rset.getString("title");
+                		ci.integerData[ 7] =rset.getInt("class_id");
+                		
+                		int PcSex = rset.getInt("female");
+                		switch(PcSex)
+                		{
+                			case 0: ci.booleanData[3] = false;
+                			break;
+                			case 1: ci.booleanData[3] = true;
+                			break;
+                			default: ci.booleanData[3] = (Rnd.get(100)>50) ? true : false;
+                			break;
+                		}
+                		                		
+                		ci.integerData[19] =rset.getInt("hair_style");
+                		ci.integerData[20] =rset.getInt("hair_color");
+                		ci.integerData[21] =rset.getInt("face");
+                		ci.integerData[22] =rset.getInt("name_color");
+                		ci.integerData[23] =rset.getInt("title_color");
+                		ci.booleanData[ 1] =(rset.getInt("noble") > 0) ? true : false;
+                		ci.booleanData[ 2] =(rset.getInt("hero") > 0) ? true : false;
+                		ci.booleanData[ 0] =(rset.getInt("pvp") > 0) ? true : false;
+                		ci.integerData[ 1] =rset.getInt("karma");
+                		ci.integerData[ 8] =rset.getInt("wpn_enchant");
+                		ci.integerData[11] =rset.getInt("right_hand");
+                		ci.integerData[12] =rset.getInt("left_hand");
+                		ci.integerData[13] =rset.getInt("gloves");
+                		ci.integerData[14] =rset.getInt("chest");
+                		ci.integerData[15] =rset.getInt("legs");
+                		ci.integerData[16] =rset.getInt("feet");
+                		ci.integerData[17] =rset.getInt("hair");
+                		ci.integerData[18] =rset.getInt("hair2");
+                		ci.integerData[ 9] =rset.getInt("pledge");
+                		ci.integerData[10] =rset.getInt("cw_level");
+                		ci.integerData[ 2] =rset.getInt("clan_id");
+                		ci.integerData[ 3] =rset.getInt("ally_id");
+                		ci.integerData[ 4] =rset.getInt("clan_crest");
+                		ci.integerData[ 5] =rset.getInt("ally_crest");
+                		ci.booleanData[ 4] =(rset.getInt("rnd_class") > 0) ? true : false;
+                		ci.booleanData[ 5] =(rset.getInt("rnd_appearance") > 0) ? true : false;
+                		ci.booleanData[ 6] =(rset.getInt("rnd_weapon") > 0) ? true : false;
+                		ci.booleanData[ 7] =(rset.getInt("rnd_armor") > 0) ? true : false;
+                		ci.integerData[24] =rset.getInt("max_rnd_enchant");
+                		// Same object goes in twice:
+                		if (ci.integerData[25] != 0 && !templates.containsKey(ci.integerData[25])) 
+                			templates.put(ci.integerData[25], ci);
+                		if (ci.integerData[25] == 0 && !spawns.containsKey(ci.integerData[26])) 
+                			spawns.put(ci.integerData[26], ci);
+                    }
+                    catch (Throwable t)
+                    {
+                    	_log.warn("Failed to load Npc Morph data for Object Id: "+ci.integerData[26] + " template: "+ci.integerData[25]);
+                    }
+                }
+                rset.close();
+                statement.close();
+            }
+            _log.info("CustomNpcInstanceManager: loaded "+count+" NPC to PC polymorphs.");
+        }
+        catch (Exception e)
+        {
+            _log.warn( "Failed to initialize CustomNpcInstanceManager: ", e);
+        }
+        finally { try { con.close(); } catch (Exception e) {} }
+	}
+	
+	/**
+	 * Checks if the L2NpcInstance calling this function has polymorphing data 
+	 * @param objId - L2NpcInstance's unique Object id
+	 * @param npcId - L2NpcInstance's npc template id
+	 * @return
+	 */
+	public final boolean isThisL2CustomNpcInstance(int spwnId , int npcId)
+	{
+		if (spwnId == 0 || npcId == 0) return false;
+		else if (spawns.containsKey(spwnId)) return true;
+		else if (templates.containsKey(npcId)) return true;
+		else return false;
+	}
+	
+	/**
+	 * Return the polymorphing data for this L2NpcInstance if the data exists
+	 * @param objId - NpcInstance's unique Object Id
+	 * @param npcId - NpcInstance's npc template Id
+	 * @return customInfo type data pack, or null if no such data exists.
+	 */
+	public final customInfo getCustomData(int spwnId , int npcId)
+	{
+		if (spwnId == 0 || npcId == 0) return null;
+
+		//First check individual spawn objects - incase they have different values than their template
+		for (customInfo ci : spawns.values())
+		    if (ci != null && ci.integerData[26] == spwnId) return ci;
+
+		//Now check if templates contains the morph npc template
+		for (customInfo ci : templates.values())
+		    if (ci != null && ci.integerData[25] == npcId) return ci;
+
+		return null;
+	}
+	
+	/**
+	 * @return all template morphing queue
+	 */
+	public final FastMap<Integer,customInfo> getAllTemplates()
+	{
+		return templates;
+	}
+	
+	/**
+	 * @return all spawns morphing queue
+	 */
+	public final FastMap<Integer,customInfo> getAllSpawns()
+	{
+		return spawns;
+	}
+	
+	/**
+	 * Already removed customInfo - Changeb is saved in the DB
+	 * <b>NOT IMPLEMENTED YET!</b>
+	 * @param ciToRemove
+	 */
+	public final void updateRemoveInDB(customInfo ciToRemove)
+	{
+		//
+	}
+
+	public final void AddInDB(customInfo ciToAdd)
+	{
+		String Query = 
+	    		"REPLACE INTO npc_to_pc VALUES" + 
+	    		" spawn,template,name,title,class_id,female,hair_style,hair_color,face,name_color,title_color," +
+	    		" noble,hero,pvp,karma,wpn_enchant,right_hand,left_hand,gloves,chest,legs,feet,hair,hair2," +
+	    		" pledge,cw_level,clan_id,ally_id,clan_crest,ally_crest,rnd_class,rnd_appearance,rnd_weapon,rnd_armor,max_rnd_enchant" +
+	    		" FROM npc_to_pc" ; 
+
+	    	
+	        try
+	        {
+		        java.sql.Connection con = L2DatabaseFactory.getInstance().getConnection(null);
+                PreparedStatement statement = con.prepareStatement(Query);
+	            ResultSet rset = statement.executeQuery();
+	                
+                while(rset.next())
+                {
+                	customInfo ci = new customInfo();
+                    ci.integerData[26] =rset.getInt("spawn");
+            		ci.integerData[25] =rset.getInt("template");
+                }
+	        }
+	        catch (Throwable t)
+	        {
+	        	_log.warn("Could not add Npc Morph info into the DB: ",t);
+	        }
+	}
+}

Continue..

Posted

Index: F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2CustomNpcInstance.java
===================================================================
--- F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2CustomNpcInstance.java	(revision 0)
+++ F:/Server/NEWWork/L2_GameServer_CT1/src/main/java/net/sf/l2j/gameserver/model/actor/instance/L2CustomNpcInstance.java	(revision 0)
@@ -0,0 +1,616 @@
+/*
+ * 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 net.sf.l2j.gameserver.model.actor.instance;
+
+import net.sf.l2j.tools.random.Rnd;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.datatables.ItemTable;
+import net.sf.l2j.gameserver.instancemanager.CustomNpcInstanceManager;
+import net.sf.l2j.gameserver.model.base.ClassId;
+import net.sf.l2j.gameserver.model.base.Race;
+import net.sf.l2j.gameserver.templates.L2Armor;
+import net.sf.l2j.gameserver.templates.L2ArmorType;
+import net.sf.l2j.gameserver.templates.L2Item;
+import net.sf.l2j.gameserver.templates.L2Weapon;
+import net.sf.l2j.gameserver.templates.L2WeaponType;
+
+/**
+ * This class manages Npc Polymorph into player instances, they look like regular players.
+ * This effect will show up on all clients.
+ * @author Darki699
+ */
+public final class L2CustomNpcInstance
+{
+
+  private       boolean			_allowRandomWeapons     = true; //Default value
+  private       boolean			_allowRandomClass       = true; //Default value
+  private 		boolean			_allowRandomArmorSets   = true; //Default value
+  private		boolean			_allowRandomAppearance  = true; //Default value
+  private 		int				_randomMaxEnchant       = 8;    //Default value
+  private 		String			_name;
+  private 		String			_title;
+  
+  private 		int				_int[];                         // PcInstance integer stats
+  private 		boolean			_boolean[];                     // PcInstance booolean stats
+  private 		L2NpcInstance	_NpcInstance;                   // Reference to Npc with this stats
+  private		ClassId			_classId;                       // ClassId of this (N)Pc
+  
+  /**
+   * A constructor
+   * @param myNpc - Receives the L2NpcInstance as a reference.
+   */
+  public L2CustomNpcInstance(L2NpcInstance myNpc)
+  {
+	  _NpcInstance = myNpc;
+	  if (_NpcInstance == null) return;
+	  else if (_NpcInstance.getSpawn() == null) return;
+	  else initialize();  
+  }
+
+  /**
+   * Initializes the semi PcInstance stats for this NpcInstance, making it appear as 
+   * a PcInstance on all clients
+   */
+  private final void initialize()
+  {
+	  _int = new int[25];
+	  // karma=1, clanId=2, allyId=3, clanCrest=4, allyCrest=5, race=6, classId=7
+	  // EnchantWeapon=8, PledgeClass=9, CursedWeaponLevel=10
+	  // RightHand=11, LeftHand=12, Gloves=13, Chest=14, Legs=15, Feet=16, Hair1=17, Hair2=18
+	  // HairStyle=19, HairColor=20, Face=21
+	  // NameColor=22, TitleColor=23
+	  
+	  _boolean = new boolean[4];
+	  //pvp=0 , noble=1, hero=2, isFemaleSex=3
+	  
+	  // load the Pc Morph Data
+	  CustomNpcInstanceManager.customInfo ci = CustomNpcInstanceManager.getInstance().getCustomData(_NpcInstance.getSpawn().getId(), _NpcInstance.getNpcId());
+
+	  if (ci == null)
+	  {
+		  _NpcInstance.setCustomNpcInstance(null);
+		  _NpcInstance = null;
+		  return;
+	  }
+	  
+	  _NpcInstance.setCustomNpcInstance(this);
+	  
+	  setPcInstanceData(ci);
+	  
+	  if (_allowRandomClass) chooseRandomClass();
+	  if (_allowRandomAppearance) chooseRandomAppearance();
+	  if (_allowRandomWeapons) chooseRandomWeapon();
+	  if (_allowRandomArmorSets) chooseRandomArmorSet();
+  }
+
+  /**
+   * @return the custom npc's name, or the original npc name if no custom name is provided
+   */
+  public final String getName()
+  {
+	  return (_name == null) ? _NpcInstance.getName() : _name;
+  }
+
+  /**
+   * @return the custom npc's title, or the original npc title if no custom title is provided
+   */
+  public final String getTitle()
+  {
+	  return (_title == null) ? _NpcInstance.getTitle() : 
+             (_NpcInstance.isChampion()) ? "The Champion " + _title : _title;
+  }
+
+  /**
+   * @return the npc's karma or aggro range if he has any...
+   */
+  public final int getKarma()
+  {
+	  return (_int[1] > 0) ? _int[1] : _NpcInstance.getAggroRange();
+  }
+ 
+  /**
+   * @return the clan Id
+   */
+  public final int getClanId()
+  {
+	  return _int[2];
+  }
+  
+  /**
+   * @return the ally Id
+   */
+  public final int getAllyId()
+  {
+	  return _int[3];
+  }
+  
+  /**
+   * @return the clan crest Id
+   */
+  public final int getClanCrestId()
+  {
+	  return _int[4];
+  }
+  
+  /**
+   * @return the ally crest Id
+   */
+  public final int getAllyCrestId()
+  {
+	  return _int[5];
+  }
+  
+  /**
+   * @return the Race ordinal
+   */
+  public final int getRace()
+  {
+	  return _int[6];
+  }
+
+  /**
+   * @return the class id, e.g.: fighter, warrior, mystic muse...
+   */
+  public final int getClassId()
+  {
+	  return _int[7];
+  }
+  
+  /**
+   * @return the enchant level of the equipped weapon, if one is equipped (max = 127)
+   */
+  public final int getEnchantWeapon()
+  {
+	  return (PAPERDOLL_RHAND() == 0 || getCursedWeaponLevel()!=0)? 0 : 
+		     (_int[8] > 127) ? 127 : _int[8];
+  }
+  
+  /**
+   * @return the pledge class identifier, e.g. vagabond, baron, marquiz
+   * @remark Champion mobs are always Marquiz 
+   */
+  public final int getPledgeClass()
+  {
+	  return (_NpcInstance.isChampion())? 8 : _int[9];
+  }
+  
+  /**
+   * @return the cursed weapon level, if one is equipped
+   */
+  public final int getCursedWeaponLevel()
+  {
+	  return (PAPERDOLL_RHAND() == 0 || _int[8] > 0) ? 0 : _int[10];
+  }
+  
+  /**
+   * @return the item id for the item in the right hand, if a custom item is not equipped the value returned is the original npc right-hand weapon id
+   */
+  public final int PAPERDOLL_RHAND()
+  {
+	  return (_int[11] != 0) ? _int[11] : _NpcInstance.getRightHandItem();
+  }
+  
+  /**
+   * @return the item id for the item in the left hand, 
+   * if a custom item is not equipped the value returned is the original npc left-hand weapon id.
+   * Setting this value _int[12] = -1 will not allow a npc to have anything in the left hand
+   */
+  public final int PAPERDOLL_LHAND()
+  {
+	  return (_int[12] > 0) ? _int[12] : (_int[12] == 0) ? _NpcInstance.getLeftHandItem() : 0;
+  }
+
+  /**
+   * @return the item id for the gloves
+   */
+  public final int PAPERDOLL_GLOVES()
+  {
+	  return _int[13];
+  }
+
+  /**
+   * @return the item id for the chest armor
+   */
+  public final int PAPERDOLL_CHEST()
+  {
+	  return _int[14];
+  }
+
+  /**
+   * @return the item id for the leg armor, or 0 if wearing a full armor
+   */
+  public final int PAPERDOLL_LEGS()
+  {
+	  return _int[15];
+  }
+  
+  /**
+   * @return the item id for feet armor
+   */
+  public final int PAPERDOLL_FEET()
+  {
+	  return _int[16];
+  }
+  
+  /**
+   * @return the item id for the 1st hair slot, or all hair
+   */
+  public final int PAPERDOLL_HAIR()
+  {
+	  return _int[17];
+  }
+
+  /**
+   * @return the item id for the 2nd hair slot
+   */
+  public final int PAPERDOLL_HAIR2()
+  {
+	  return _int[18];
+  }
+
+  /**
+   * @return the npc's hair style appearance
+   */
+  public final int getHairStyle()
+  {
+	  return _int[19];
+  }
+  
+  /**
+   * @return the npc's hair color appearance
+   */
+  public final int getHairColor()
+  {
+	  return _int[20];
+  }
+  
+  /**
+   * @return the npc's face appearance
+   */
+  public final int getFace()
+  {
+	  return _int[21];
+  }
+
+  /**
+   * @return the npc's name color (in hexadecimal), 0xFFFFFF is the default value
+   */
+  public final int nameColor()
+  {
+	  return (_int[22]==0) ? 0xFFFFFF : _int[22];
+  }
+
+  /**
+   * @return the npc's title color (in hexadecimal), 0xFFFF77 is the default value
+   */
+  public final int titleColor()
+  {
+	  return (_int[23]==0) ? 0xFFFF77 : _int[23];
+  }
+
+  
+  /**
+   * @return is npc in pvp mode?
+   */
+  public final boolean getPvpFlag()
+  {
+	  return _boolean[0];
+  }
+  
+  /**
+   * @return true if npc is a noble
+   */
+  public final boolean isNoble()
+  {
+	  return _boolean[1];
+  }
+  
+  /**
+   * @return true if hero glow should show up
+   * @remark A Champion mob will always have hero glow
+   */
+  public final boolean isHero()
+  {
+	  return (_NpcInstance.isChampion()) ? true : _boolean[2];
+  }
+  
+  /**
+   * @return true if female, false if male
+   * @remark In the DB, if you set 
+   * @MALE value=0
+   * @FEMALE value=1
+   * @MAYBE  value=2 % chance for the <b>Entire Template</b> to become male or female (it's a maybe value)
+   * If female, all template will be female, if Male, all template will be male 
+   */
+  public final boolean isFemaleSex()
+  {
+	  return _boolean[3];
+  }
+
+  /**
+   * Choose a random weapon for this L2CustomNpcInstance  
+   */
+  private final void chooseRandomWeapon()
+  {
+	  L2WeaponType wpnType = null;
+	  if (_NpcInstance.getTemplate().getBaseAtkRange() > 100)
+	  {
+		  wpnType = (Rnd.get(100)>40) ? L2WeaponType.BOW : L2WeaponType.CROSSBOW;
+	      if (!Config.HUMAN_CAN_USE_CROSSBOW && wpnType == L2WeaponType.CROSSBOW && _classId.getRace() == Race.Human)
+	      {
+	    	  wpnType = L2WeaponType.BOW;
+	      }
+	  }
+	  else
+	  {
+		  while (true) // Choose correct weapon TYPE
+		  {
+			  wpnType = L2WeaponType.values()[Rnd.get(L2WeaponType.values().length)];
+			  if (wpnType == null)
+				  continue;
+			  else if (wpnType == L2WeaponType.BOW || wpnType == L2WeaponType.CROSSBOW)
+				  continue;
+			  else if (_classId.getRace() == Race.Human)
+			  {
+				  if ((!Config.HUMAN_CAN_USE_ANCIENT && wpnType == L2WeaponType.ANCIENT_SWORD) ||
+				      (!Config.HUMAN_CAN_USE_RAPIER && wpnType == L2WeaponType.RAPIER))
+					  continue;
+			  }
+			  break;
+	 	  }
+	  }
+	  
+	  for (L2Weapon wpn : ItemTable.getInstance().getWeapons().values())
+	  {
+		  if (wpn.getItemType() != wpnType)
+			  continue;
+		  else if (wpn.getBodyPart() != L2Item.SLOT_R_HAND && wpn.getBodyPart() != L2Item.SLOT_LR_HAND)
+			  continue;
+		  else if (wpn.getCrystalCount() == 0)
+			  continue;
+		  
+		  _int[11] = wpn.getItemId();
+		  
+		  if (_NpcInstance.getLevel()<20 && wpn.getCrystalType() > L2Weapon.CRYSTAL_NONE)
+			  continue;
+		  else if (_NpcInstance.getLevel()<40 && wpn.getCrystalType() > L2Weapon.CRYSTAL_C)
+			  continue;
+		  else if (_NpcInstance.getLevel()<52 && wpn.getCrystalType() > L2Weapon.CRYSTAL_B)
+			  continue;
+		  else if (_NpcInstance.getLevel()<61 && wpn.getCrystalType() > L2Weapon.CRYSTAL_A)
+			  continue;
+		  else if (_NpcInstance.getLevel()<76 && wpn.getCrystalType() > L2Weapon.CRYSTAL_S)
+			  continue;
+		  
+		  if (Rnd.get(100)<10)
+		  {
+			  break;
+		  }
+	  }
+	  
+	  if (PAPERDOLL_RHAND() != 0) // Has a Weapon
+	  {
+		  _int[8] = (_randomMaxEnchant > 0) ? Rnd.get(_randomMaxEnchant) : _int[8];
+		  if (ItemTable.getInstance().getTemplate(PAPERDOLL_RHAND()).getBodyPart() == L2Item.SLOT_R_HAND && Rnd.get(100)<25)
+		  {
+			  chooseRandomShield();
+		  }
+	  }
+	  else if (PAPERDOLL_RHAND() == 0 && Rnd.get(100)<50) // Doesn't have a weapon
+	  {
+		  chooseRandomShield();
+	  }
+	  
+	  if (PAPERDOLL_RHAND() > 0)
+	  {
+		  if (PAPERDOLL_LHAND() > 0 && ItemTable.getInstance().getTemplate(PAPERDOLL_RHAND()).getBodyPart() == L2Item.SLOT_LR_HAND)
+		  {
+			  _int[12] = -1;
+		  }
+	  }
+  }
+  
+  /**
+   * Choose random shield for this L2CustomNpcInstance, if one is suggested  
+   */
+  private final void chooseRandomShield()
+  {
+	  _int[12] = -1; // Choose not to have a shield
+	  if (!Config.KAMAEL_CAN_USE_SHIELD && _classId.getRace() == Race.Kamael)
+	  {
+		  return;
+	  }
+	  for (L2Weapon shield : ItemTable.getInstance().getWeapons().values())
+	  {
+		  if (shield.getBodyPart() != L2Item.SLOT_L_HAND)
+			  continue;
+		  else if (shield.getCrystalCount() == 0)
+			  continue;
+		  else if (_NpcInstance.getLevel()<20 && shield.getCrystalType() > L2Weapon.CRYSTAL_D)
+			  continue;
+		  else if (_NpcInstance.getLevel()<40 && shield.getCrystalType() >= L2Weapon.CRYSTAL_C)
+			  continue;
+		  else if (_NpcInstance.getLevel()<52 && shield.getCrystalType() >= L2Weapon.CRYSTAL_B)
+			  continue;
+		  else if (_NpcInstance.getLevel()<61 && shield.getCrystalType() >= L2Weapon.CRYSTAL_A)
+			  continue;
+		  else if (_NpcInstance.getLevel()<76 && shield.getCrystalType() >= L2Weapon.CRYSTAL_S)
+			  continue;
+		  
+		  _int[12] = shield.getItemId();
+		  if (Rnd.get(100)<10)
+		  {
+			  break;
+		  }
+	  }
+  }
+  
+  /**
+   * Choose random armor clothings for this L2CustomNpcInstance  
+   */
+  private final void chooseRandomArmorSet()
+  {
+	  L2ArmorType type = L2ArmorType.MAGIC;
+	  if (_classId.isMage()) type = L2ArmorType.MAGIC;
+	  else if (_classId.getRace() == Race.Kamael)
+	  {
+		  if (!Config.KAMAEL_CAN_USE_HEAVY && !Config.KAMAEL_CAN_USE_MAGIC)
+			  type = L2ArmorType.LIGHT;
+		  else if (!Config.KAMAEL_CAN_USE_HEAVY)
+			  type = (Rnd.get(100) < 60) ? L2ArmorType.LIGHT : L2ArmorType.MAGIC;
+		  else if (!Config.KAMAEL_CAN_USE_MAGIC)
+			  type = (Rnd.get(100) < 60) ? L2ArmorType.LIGHT : L2ArmorType.HEAVY;
+	  }
+	  else type = (Rnd.get(100) < 50) ? L2ArmorType.LIGHT : L2ArmorType.HEAVY;
+	  for (L2Armor shield : ItemTable.getInstance().getArmors().values())
+	  {
+		  if (shield.getBodyPart() == L2Item.SLOT_CHEST && shield.getItemType() != type)
+			  continue;
+		  else if (shield.getCrystalCount() == 0)
+			  continue;
+		  else if (_NpcInstance.getLevel()<20 && shield.getCrystalType() > L2Weapon.CRYSTAL_D)
+			  continue;
+		  else if (_NpcInstance.getLevel()<40 && shield.getCrystalType() >= L2Weapon.CRYSTAL_C)
+			  continue;
+		  else if (_NpcInstance.getLevel()<52 && shield.getCrystalType() >= L2Weapon.CRYSTAL_B)
+			  continue;
+		  else if (_NpcInstance.getLevel()<61 && shield.getCrystalType() >= L2Weapon.CRYSTAL_A)
+			  continue;
+		  else if (_NpcInstance.getLevel()<76 && shield.getCrystalType() >= L2Weapon.CRYSTAL_S)
+			  continue;
+		  else if (Rnd.get(100)>25)
+			  continue;
+		  //Gloves=13, Chest=14, Legs=15, Feet=16, Hair1=17, Hair2=18
+		  else if (shield.getBodyPart() == L2Item.SLOT_FULL_ARMOR && _int[14] == 0)
+			  _int[14] = _int[15] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_GLOVES && _int[13] == 0)
+			  _int[13] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_CHEST && _int[14] == 0)
+			  _int[14] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_LEGS && _int[15] == 0)
+			  _int[15] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_FEET && _int[16] == 0)
+			  _int[16] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_HAIRALL && _int[17] == 0)
+			  _int[17] = _int[18] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_HAIR && _int[17] == 0)
+			  _int[17] = shield.getItemId();
+		  else if (shield.getBodyPart() == L2Item.SLOT_HAIR2 && _int[18] == 0)
+			  _int[18] = shield.getItemId();
+		  else if (_int[13] != 0 && _int[14] != 0 && _int[15] != 0 && _int[16] != 0 && _int[17] != 0 && _int[18] != 0)
+			  break;
+	  }
+	  if (_int[14] == _int[15]) _int[15]=0; //Full Armor
+	  if (_int[17] == _int[18]) _int[18]=0; //All Hair
+	  if (Rnd.get(100) < 75) _int[17] = _int[18] = 0;
+  }
+  
+  /**
+   * Choose a random class & race for this L2CustomNpcInstance 
+   */
+  private final void chooseRandomClass()
+  {
+	  while (true)
+	  {
+		  _classId = ClassId.values()[Rnd.get(ClassId.values().length)];
+		  if (_classId == null)
+			  continue;
+		  else if (_classId.getRace() != null && _classId.getParent() != null)
+			  break;
+	  }
+	  _int[6] = _classId.getRace().ordinal();
+	  _int[7] = _classId.getId();
+  }
+  
+  /**
+   * Choose random appearance for this L2CustomNpcInstance 
+   */
+  private final void chooseRandomAppearance()
+  {
+	  // Karma=1, PledgeClass=9
+	  // HairStyle=19, HairColor=20, Face=21
+	  // NameColor=22, TitleColor=23
+	  // noble=1, hero=2, isFemaleSex=3
+	  _boolean[1] = (Rnd.get(100) < 15) ? true : false;
+	  _boolean[3] = (Rnd.get(100) < 50)	? true : false;
+	  _int[22] = _int[23] = 0;
+	  if (Rnd.get(100) < 5)		 _int[22] = 0x0000FF;
+	  else if (Rnd.get(100) < 5) _int[22] = 0x00FF00;
+	  if (Rnd.get(100) < 5)      _int[23] = 0x0000FF;
+	  else if (Rnd.get(100) < 5) _int[23] = 0x00FF00;
+	  _int[ 1] = (Rnd.get(100) > 95) ? 0 : (Rnd.get(100) > 10) ? 50 : 1000;
+	  _int[19] = (Rnd.get(100) < 34) ? 0 : (Rnd.get(100) < 34) ?  1 :    2;
+	  _int[20] = (Rnd.get(100) < 34) ? 0 : (Rnd.get(100) < 34) ?  1 :    2;
+	  _int[21] = (Rnd.get(100) < 34) ? 0 : (Rnd.get(100) < 34) ?  1 :    2;
+	  
+	  int pledgeLevel = Rnd.get(100);
+	  // 30% is left for either pledge=0 or default sql data
+	  // Only Marqiz are Champion mobs 
+	  if (pledgeLevel > 30) _int[9] = 1;
+	  if (pledgeLevel > 50) _int[9] = 2;
+	  if (pledgeLevel > 60) _int[9] = 3;
+	  if (pledgeLevel > 80) _int[9] = 4;
+	  if (pledgeLevel > 90) _int[9] = 5;
+	  if (pledgeLevel > 95) _int[9] = 6;
+	  if (pledgeLevel > 98) _int[9] = 7;
+  }
+  
+  /**
+   * Sets the data received from the CustomNpcInstanceManager
+   * @param ci the customInfo data
+   */
+  public void setPcInstanceData(CustomNpcInstanceManager.customInfo ci)
+  {
+	  if (ci == null) return;
+	  
+	  // load the "massive" data
+	  for (int i=0 ; i<25 ; i++)     _int[i] = ci.integerData[i];
+	  for (int i=0 ; i< 4 ; i++) _boolean[i] = ci.booleanData[i];
+	  
+	  // random variables to apply to this L2NpcInstance polymorph 
+	  _allowRandomClass      = ci.booleanData[4];
+	  _allowRandomAppearance = ci.booleanData[5];
+	  _allowRandomWeapons    = ci.booleanData[6];
+	  _allowRandomArmorSets  = ci.booleanData[7];
+	  _randomMaxEnchant      = ci.integerData[24];
+	  
+	  // name & title override
+	  _name                  = ci.stringData [ 0];
+	  _title                 = ci.stringData [ 1];
+	  if (_name  != null && _name.equals(""))  _name  = null;
+	  if (_title != null && _title.equals("")) _title = null;	  
+	  
+	  // Not really necessary but maybe called upon on wrong random settings:
+	  // Initiate this PcInstance class id to the correct pcInstance class.
+	  ClassId ids[] = ClassId.values();
+	  if (ids != null)
+	  {
+		  for (int i=0 ; i < ids.length ; i++)
+			  if (ids[i] == null)
+				  continue;
+			  else if (ids[i].getId() == _int[7])
+			  {
+				  _classId = ids[i];
+				  _int[6]  = ids[i].getRace().ordinal(); 
+				  break;
+			  }
+	  }
+  }
+
+  // Did I forget anything?
+  // You're welcome :*
+  // Darki699
+}

 

Posted

The SQL File :

 

-- ---------------------------
-- Table structure for `characters`
-- ---------------------------
CREATE TABLE IF NOT EXISTS `npc_to_pc` (
 `spawn` int(9) NOT NULL default '0',
 `template` int(9) NOT NULL default '0',
 `name` varchar(35) default NULL,
 `title` varchar(35) default NULL,
 `class_id` int(3) NOT NULL default '0',
 `female` int(1) NOT NULL default '0',
 `hair_style` int(1) NOT NULL default '0',
 `hair_color` int(1) NOT NULL default '0',
 `face` int(1) NOT NULL default '0',
 `name_color` int(7) NOT NULL default '0',
 `title_color` int(7) NOT NULL default '0',
 `noble` int(1) NOT NULL default '0',
 `hero` int(1) NOT NULL default '0',
 `pvp` int(1) NOT NULL default '0',
 `karma` int(7) NOT NULL default '0',
 `wpn_enchant` int(7) NOT NULL default '0',
 `right_hand` int(7) NOT NULL default '0',
 `left_hand` int(7) NOT NULL default '0',
 `gloves` int(7) NOT NULL default '0',
 `chest` int(7) NOT NULL default '0',
 `legs` int(7) NOT NULL default '0',
 `feet` int(7) NOT NULL default '0',
 `hair` int(7) NOT NULL default '0',
 `hair2` int(7) NOT NULL default '0',
 `pledge` int(2) NOT NULL default '0',
 `cw_level` int(3) NOT NULL default '0',
 `clan_id` int(9) NOT NULL default '0',
 `ally_id` int(9) NOT NULL default '0',
 `clan_crest` int(9) NOT NULL default '0',
 `ally_crest` int(9) NOT NULL default '0',
 `rnd_class` int(1) NOT NULL default '0',
 `rnd_appearance` int(1) NOT NULL default '0',
 `rnd_weapon` int(1) NOT NULL default '0',
 `rnd_armor` int(1) NOT NULL default '0',
 `max_rnd_enchant` int(7) NOT NULL default '0',
 KEY `spawn` (`spawn`),
 KEY `template` (`template`)
) DEFAULT CHARSET=utf8;

 

Another SQL with Morphed NPCs, and where you can learn how to use it :

 

 INSERT INTO npc_to_pc VALUES
 (0, 31674, "Town Patrol", "Guard", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4222, 7868, 7867, 0, 7869, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),
 (0, 31673, "Town Patrol", "Archer", 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 4, 0, 0, 7868, 7867, 0, 7869, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
 (30256, 0, "Royal Guard", "Captain", 133, 2, 2, 1, 2, 0, 0, 0, 1, 0, 0, 8, 6617, 0, 6380, 6379, 0, 6381, 9204, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
 (0, 18342, "Evil Dwarf", "NULL", 53, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5),
 (0, 35350, "NULL", "NULL", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 7),
 (0, 35351, "NULL", "NULL", 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 7),
 (0, 35343, "NULL", "NULL", 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 8);

 

If you don't set any name or title, the one will be the set in npc table, if you set, will be the new...pledge is the class, lvl 8 are champions ( Marquis only ), in Female, 0 to set male, 1 to female and 2 to random. Title is set in RGB colors, class_id you put the class, 92 for Sarggitarius, for exemple, and it will be a human...hair columns are set in numbers, 1=A, 2=B and etc..face too...name_color is in RGB colors...if you set pvp higher than 0, the name gets flag color. If you set any of items as 0, it will be random ( wpn, leg, armor, etc )

 

-- * 1: Transform all Guard(patrols) with the id  31674 in humanos using appela and random weapons.

-- * 2: Transform all Guard(patrols) with the id 31673 in humanos using appela and using bows

-- * 3: Transform ONE especific spawn (random Guard(patrols)) in a hero kamael using draconic and a infinity dagger (PC sex is random!)

-- * 4: Changes all Dwarven to PC "Evil Dwarfs" with Karma with random armors, weapons, sex and Karma level

-- * 5-7: Morph all Goddard Siege NPCs in Random PCPlayers

 

I hope it was usefull...sorry for the big post, but it is too large and couldn't be posted in only 1 =X

 

Credits to Darki699

Posted

Need test...I only tested on Gracia...might work, but I belive will ask for some changes...not many I hope..

can you make tose changes for Intelrude l2jfree?
Posted

I don't use Interlude anymore, if you show the errors that you have when implementing the code, I can try help you...

Guest
This topic is now closed to further replies.


  • Posts

    • Very nice and passionate effort. Good luck.
    • SX.ORG is a global proxy platform offering residential, mobile and datacenter IPs for SEO, web scraping, ad verification and multi-account management. It provides flexible IP rotation, precise geo-targeting, HTTP(S)/SOCKS5 support, API access and pay-as-you-go pricing based only on the traffic you use.
    • L2-IMBA — SEASON 2  Custom PvP / PvE Interlude · Every Class Playable BETA — LIVE NOW GRAND START — 11 September 2026, 20:00 GMT+2 https://l2-imba.com · https://discord.com/invite/jmhVpj8ySv ═══════════════════════════════════════ RATES & CORE SETTINGS ═══════════════════════════════════════ Chronicle — Interlude XP / SP — x45, level-adjusted curve Adena — x1 Max level — 90 Subclass — 1, to level 80 Starting hub — Giran Skills — Auto-learn, post-80 via custom trainers Loot — Auto-loot with low-value filtering Buffs — Extended duration, expanded slots, saved schemes Client limit — NO DUAL-BOXING, one client per player Automation — Built-in auto-farm with daily time limit Offline — Trading and crafting enabled Current beta configuration. Final values confirmed at launch sign-off. ═══════════════════════════════════════ All 31 third classes are developed to level 90 through five specialized trainers — there are no dead classes here. Tanks, daggers, archers, warriors, summoners, healers, buffers and crafters all have real post-80 progression and a role worth playing. Full PvE progression through ten farm zones, thirty-five themed encounters and eighteen tracked raids, feeding into gear-equalized Team vs Team and open-world PvP. This isn't a stat patch with a new name. L2-IMBA keeps the combat, classes and world of Interlude and builds a new endgame on top of it — new equipment branches, custom class development past level 80, purpose-built farm ecosystems, boss progression, crafting, and augmentation, all connected into one progression loop. Level and develop your class → choose an armor identity → clear themed farm content → collect materials and boss resources → craft and upgrade without abandoning your build → compete in equalized and open-world PvP → reach God's equipment. ═══════════════════════════════════════ ROLE MASTERY ARMOR ═══════════════════════════════════════ Starting at Dynasty, armor becomes a real build choice instead of a mandatory set everyone wears. Each armor type offers three role masteries plus a flexible Universal path — twelve paths per tier, sixty full-set configurations across the progression. The chest piece selects your mastery; a matching five-piece set activates it. HEAVY   Juggernaut — frontline wall, shield synergy, reflection   Spellbreaker — anti-magic fortress, spell disruption   Slayer — heavy armor turned offensive, vampiric sustain LIGHT   Bowmaster — ranged pressure, kiting, accuracy   Assassin — positional burst, blow reliability, dagger lethals   Berserker — high-risk carry, power rises as HP falls ROBE   Arcanist — rapid-fire critical casting   Invoker — high-impact nuking and debuffs   Oracle — dedicated healing and support Upgrade recipes preserve your chosen path through every tier: Dynasty → Zariche → Valakas → Cursed → God's The system is gear-driven, not class-locked. Build creatively. ═══════════════════════════════════════ LEVEL 90 CLASS DEVELOPMENT ═══════════════════════════════════════ Max level extended to 90. Five specialized trainers — Archer, Tank, Rogue, Warrior, Mystic — cover all 31 third classes in post-80 progression, with 470+ learning entries. Every race gets a custom passive from level one. Tanks get distinct Human/Elf/Dark Elf identities. Duelist gains a two-handed greatsword path. Fortune Seeker becomes a real fighter without losing its spoil identity. Maestro gets a durable frontline route. Summoners, cubics and servitors get deeper combat logic rather than stat scaling. This is backed by server-side combat work — dedicated handling for debuff proficiency, PvE skill damage, blows, lethals, bow reuse, vampirism and reflection. ═══════════════════════════════════════ THE FARMING WORLD ═══════════════════════════════════════ Ten dedicated farm destinations via Global Gatekeeper: Farm Coins 1 & 2, Holy, Fire/Water, Wind, Earth, Unholy, Golden, Chaotic and Night zones. Seven themed enemy families — Undead, Demon, Angel, Beast, Bug, Water, Fire — each with four stages and a mini-boss. Thirty-five distinct encounters, each with its own resource identity feeding crafting. Eighteen tracked raids — twelve Farm Raid Bosses and six Custom Epic Raid Bosses. Plus a scheduled group-based Party Zone with dynamically managed normal and rare spawns. ═══════════════════════════════════════ CRAFTING & ENDGAME ═══════════════════════════════════════ SOUL FORGE — recycle old weapons into tier resources, convert boss and farm materials, craft Legendary components. Old gear becomes input, not warehouse clutter. CURATED AUGMENTATION — data-driven Top-Grade and Legendary profiles with meaningful stat, active and passive pools. Active effects are categorized so the same effect can't be stacked through equipment swapping. EXTENDED ENCHANT — Custom Crystal and Legendary stages. On the Legendary route, a failed enchant does not destroy the item or reduce its enchant level. Long-term progression, not an all-or-nothing gamble. TREASURE CHESTS — Rare, Immortal, Epic and Legendary tiers feeding gear growth, crafting and augmentation. ═══════════════════════════════════════ PvP ═══════════════════════════════════════ Gear-equalized Team vs Team on a recurring schedule — your equipment is snapshotted and restored, so the fight is about play, not who farmed longest. Open-world PvP with rewards and ranks alongside it. ═══════════════════════════════════════ QUALITY OF LIFE ═══════════════════════════════════════ - No dual-boxing — one client per player, enforced - Built-in auto-farm with a daily time limit — no third-party software needed, and third-party automation is bannable - Auto-learn skills, auto-loot with low-value drop filtering - Extended-duration buffs, expanded slots, saved schemes - Offline trading and crafting - Global Gatekeeper, global class change - Offline combat automation disabled ═══════════════════════════════════════ BY THE NUMBERS ═══════════════════════════════════════ 380+ custom item definitions · 110+ weapons and shields · 210+ armor and wearables · 250+ custom skill definitions · 2,700+ custom monster placements · 90+ shop and exchange catalogs · 1,100+ offers ═══════════════════════════════════════ BETA ═══════════════════════════════════════ Core systems, progression identities and content routes are in place. Exact item bonuses, mastery values, skill strength, reuse times, augment pools, enchant chances, drop rates and crafting costs remain subject to testing. Beta changes will refine balance without removing the defining role of each mastery or the overall progression structure. All beta characters are wiped at full launch. Beta testers keep their rewards. ═══════════════════════════════════════ OPEN BETA — 4 SEPTEMBER 2026 · 18:00 GMT+2 Website: https://l2-imba.com Wiki: https://l2-imba.com/wiki Register: https://l2-imba.com/account Download: https://l2-imba.com/start-playing Discord:  https://discord.com/invite/jmhVpj8ySv
    • 🛡️ 100% Safe on your personal Gmail. Zero VPN required and works globally. Grab yours directly on klouditem.com! 🚀 Daily Restock Complete! All 12–18 Month Gemini Pro activations are active with instant setup.
  • 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..