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..

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

    • General Trackers :   IPTorrents invite IPTorrents account 1 tb TorrentLeech invite Torrentleech account 1 tb buffer  InTheShaDow ( ITS ) account Acid-lounge invite Torrentday invite Crnaberza account Abn.Lol account Limit-of-eden account Norbits account Xspeeds account Xspeeds invite Bemaniso invite Wigornot account Bithumen invite Filelist account Funfile invite AvistaZ invite Potuk.net invite ResurrectThe.Net invite GrabThe.Info invite Greek-Team invite LinkoManija invite Fano.in account TreZzoR account Speed.cd invite Arab-torrents.net account Arabscene.me account Scenetime account 4thd.xyz invite Btarg.com.ar account Dedbit invite Estone.cc account Speedapp invite Finvip invite Fluxzone account GigaTorrents account Gimmepeers account Haidan.video invite Mojblink account Mycarpathians invite Newinsane.info account Oscarworld.xyz account Peers.FM invite Pt.msg.vg account Ransackedcrew account Redemption invite Scene-rush account Seedfile.io invite Teracod invite Torrent.ai account Torrentmasters invite Ttsweb invite X-files invite X-ite invite Ncore account TorrentHR account Rptorrents account BwTorrents account Superbits invite Krazyzone account Immortalseed account Tntracker invite Pt.eastgame.org account Bitturk account Rstorrent account Tracker.btnext invite Torrent-turk.de account BeiTai.PT account Pt.keepfrds account 52pt.site account Pthome account Torrentseeds account Aystorrent account Blues-brothers.biz invite Divteam account Thesceneplace invite CinemaMovies.pl account Brasiltracker account Patiodebutacas account Newheaven.nl account  Swarmazon.club invite Bc-reloaded account Crazyspirits account Silentground invite Omg.wtftrackr invite Milkie.cc invite Breathetheword invite Madsrevolution account Chilebt account Yubraca account Uniongang.tv account Frboard account Exvagos account Diablotorrent account Microbit account Carp-hunter.hu account Majomparade.eu account Theshinning.me account Youiv.info account Dragonworld-reloaded account Sharewood.tv account Partis.si account Digitalcore.club invite Fuzer.me account R3vuk.wtf invite Ztracker account 1 tb buffer 3changtrai account Best-core.info account Bitsite.us account Eliteunitedcrew invite Exitorrent.org account Tophos invite Torrent.lt account Sktorrent.eu account Oshen account Blackhattorrent account Pirata.digital account Esharenet account Ohmenarikgi.la Pirate-share account Immortuos account Kiesbits account Cliente.amigos-share.club account Broadcity invite Ilovetorzz account Torrentbytes account Polishsource account Portugas invite Shareisland account ArabaFenice account Hudbt.hust.edu.cn account Audiences account Nanyangpt account Pt.sjtu.edu.cn account Pt.zhixing.bjtu.edu.cn account Byr.pt invite Ptfiles invite Red-bits account Pt.hdpost.top account Irrenhaus.dyndns.dk (NewPropaganda) account Mnvv2.info (MaxNewVision V2) account 1ptba.com account Spidertk.top account Film-paleis account Generation-free account Aftershock-tracker account Twilightsdreams account Back-ups.me invite Sor-next.tk ( Spirit Of Revolution ) account Tfa.tf ( The Falling Angels ) account Hdmayi account S-f-p.dyndns.dk ( Share Friends Projekt ) account Unlimitz.biz account Pttime account St-tracker.eu account New-retro.eu account Zbbit account Tigers-dl.net account Jptvts.us account Lat-team account Club.hares.top account Falkonvision-team account Concen account Drugari account T.ceskeforum account Peeratiko.org account Zamunda.se account Central-torrent.eu account h-o-d.org account Torrentleech.pl account Demonoid invite Lst.gg account Fakedoor.store account LaidBackManor account Vrbsharezone.co.uk invite Torrenteros account Arenaelite account Datascene account Tracker.0day.community Tapochek.net invite Ptchina invite Lesaloon account Exyusubs account Therebels.tv account Ubits.club invite Zmpt.cc account Turktorrent.us account Dasunerwarte account Hawke.uno account Monikadesign account Fearnopeer account Alpharatio account Wukongwendao.top account Chinapyg account Azusa.wiki account Yggtorrent.top account Torrentdd account Cyanbug.net invite Hhanclub.top account Wintersakura.net account Xthor account Tctg.pm account Finelite invite Agsvpt.com account Pt.0ff.cc invite Qingwapt.com account Xingtan.one account Movies Trackers :   Anthelion account Pixelhd account Cinemageddon account DVDSeed account Cinemageddon account Cinemaz account Retroflix account Classix-unlimited - invite Movie-Torrentz (m2g.link) invite Punck-tracker.net account Tmghub account Tb-asian account Cathode-ray.tube account Greatposterwall account Telly account Arabicsource.net account Upload.cx account Crabpt.vip invite   HD Trackers :   Hdf.world account Torrentland.li account HdSky account Hdchina account Chdbits account Totheglory account Hdroute account Hdhome account TorrentCCF aka et8.org account 3DTorrents invite HD-Torrents account Bit-HDTV account HDME.eu invite Hdarea.co account Asiancinema.me account JoyHD invite HDSpace invite CrazyHD invite Bluebird-hd invite Htpt.cc account Hdtime invite Ourbits.club account Hd4fans account Siambit account Privatehd account Springsunday account Tjupt account Hdcity.leniter invite Ccfbits account Discfan account Pt.btschool.club account Ptsbao.club invite Hdzone.me invite Danishbytes account Zonaq.pw account Tracker.tekno3d account Arabp2p account Hd-united account Reelflix.xyz account Hdatmos.club account Anasch.cc invite Tigris-t account Nethd.org account Hd.ai invite Hitpt.com account Hdmonkey account Dragonhd.xyz account Hdclub.eu account Forum.bluraycd.com account Carpt account Hdfun.me invite Pt.hdupt invite Puntotorrent account Ultrahd account Rousi.zip account Bearbit account Hdturk.club account Asiandvdclub account   Music Trackers :   Dicmusic account Music-Vid account Open.cd account LzTr account ProAudioTorrents invite Jpopsuki invite TranceTraffic invite Audionews invite Kraytracker invite Libble.me invite Losslessclub invite Indietorrents.com invite Dimeadozen account Funkytorrents invite Karaokedl account zombtracker.the-zomb account Concertos invite Sugoimusic account Satclubbing.club invite Metal.iplay invite Psyreactor invite Panda.cd account Adamsfile account Freehardmusic account Tracker.hqmusic.vn accouunt Twilightzoom account 3 tb buffer Hiresmusic account Metalguru account   E-Learning Trackers :   BitSpyder invite Brsociety account Learnbits invite Myanonamouse account Libranet account 420Project account Learnflakes account Pt.soulvoice.club account P2pelite account Aaaaarg.fail invite Ebooks-shares.org account Abtorrents account Pt.tu88.men invite   TV-Trackers :   Skipthecommericals Cryptichaven account TV-Vault invite Shazbat.TV account Myspleen account Tasmanit.es invite Tvstore.me account Tvchaosuk account Jptv.club account Tvroad.info   XXX - Porn Trackers :   FemdomCult account Pornbay account Pussytorrents account Adult-cinema-network account Bootytape account 1 Tb buffer Exoticaz account Bitporn account Kufirc account Gaytorrent.ru invite Nicept account Gay-torrents.org invite Ourgtn account Pt.hdbd.us account BitSexy account Happyfappy.org account Kamept.com account   Gaming Trackers :   Mteam.fr account BitGamer invite Retrowithin invite Gamegamept account   Cartoon/Anime/Comic Trackers :   Animeworld account Oldtoons.world account U2.dmhy account CartoonChaos invite Animetorrents account Mononoke account Totallykids.tv account Bakabt.me invite Revanime account Ansktracker account Tracker.shakaw.com.br invite Bt.mdan.org account Skyey2.com account Animetracker.cc Adbt.it.cx invite Sports Trackers :   MMA-Tracker invite T3nnis.tv invite AcrossTheTasman account RacingForMe invite Sportscult invite Ultimatewrestlingtorrents account Worldboxingvideoarchive invite CyclingTorrents account Xtremewrestlingtorrents account Tc-boxing invite Mma-torrents account Aussierul invite Xwt-classics account Racing4everyone account Talk.tenyardtracker account Stalker.societyglitch invite Extremebits invite   Software/Apps Trackers :   Brokenstones account Appzuniverse invite Teamos.xyz account Graphics Trackers: Forum.Cgpersia account Gfxpeers account Forum.gfxdomain account Documentary Trackers: Forums.mvgroup account   Others   Fora.snahp.eu account Board4all.biz account Filewarez.tv account Makingoff.org/forum account Xrel.to account Undergunz.su account Corebay account Endoftheinter.net ( EOTI ) account Thismight.be invite Skull.facefromouter.space account Avxhm.se (AvaxHome) account Ssdforum account Notfake.vip account Intotheinter.net account Tildes.net invite Thetoonz account Usinavirtual account Hdclasico invite HispaShare account Valentine.wtf account Adit-hd account Forum-andr.net account Warezforums account Justanothermusic.site account Forbiddenlibrary.moe account Senturion.to account Movieparadise account Militaryzone account Dcdnet.ru account Sftdevils.net account Heavy-r.com account New-team.org account   NZB :   Drunkenslug account Drunkenslug invite Usenet-4all account Brothers-of-Usenet account Dognzb.cr invite Kleverig account Nzb.cat account Nzbplanet.net invite Ng4you.com account Nzbsa.co.za account Bd25.eu account NZB.to account Samuraiplace account Tabula-rasa.pw account   Prices start from 3 $ to 100 $   Payment methods: Crypto, Neteller, Webmoney, Revolut   If you want to buy something send me a pm or contact me on:   Email: morrison2102@gmail.com   Discord: LFC4LIFE#4173   Telegram: https://t.me/LFC4LIFE4173   Skype: morrison2102@hotmail.com
    • always wondered by that, but we should not judge a book by the cover on this case     (i holded back enough) fuck i cant... !signature move:
    • Messed with configs for hours, but nothing changed until I tried splitting the slots differently and testing with just a few items first. Kind of like checking what actually works before going full scale. Came across https://www.mega888reviews.com/ while taking a break, and reading through their simple, clear tips made me think maybe less complicated approaches often work best.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock