Jump to content

[Share] Npc to Pc Morph


Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
+}

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • Contact me: Disrcord : https://discord.gg/fJ5geYMu Skype: pparik2451 Email: golbergsoft@gmail.com You are welcome
    • Add Premium Account features. Add Weight Limit
    • This post originally appeared on MmoGah.   CatsEyeXI is a private server for Final Fantasy XI. CatsEyeXI Gil is the in-game currency used by players to trade, purchase items, and generally progress within the game. It's similar to the role of money in real life or gold in many other online games. Players have several ways to earn gil. Since the economy in CatsEyeXI is player-driven, understanding how to efficiently make gil can greatly enhance your gameplay experience. Here, we will introduce several ways.       Using Sparks of Eminence One of the fastest ways to make gil in CatsEyeXI is by exchanging Sparks of Eminence for items that you can sell to NPCs or on the Auction House (AH). The exchange amount of Sparks is capped at 150,000 per week, and this cap resets every Sunday. Below is a step-by-step guide.   Earn Sparks of Eminence: Participate in various activities, such as completing Records of Eminence objectives, which can range from defeating certain enemies to exploring new areas. Check the Exchange Rate: Before exchanging your Sparks, check the current exchange rate for items on the CatsEyeXI server. This will help you determine which items will give you the most gil for your Sparks. Select the Right Items: Choose items that have a high NPC sell value or are in demand on the Auction House. Some items may have a better sell rate to NPCs, while others might fetch a higher price from other players. Visit the Sparks NPC: Go to the designated NPC that allows you to exchange Sparks for items. This NPC is usually found in major cities. Exchange and Sell: Exchange your Sparks for the selected items and then sell them either to an NPC or on the Auction House, depending on where you'll get the best return. Weekly Cap: Remember that there is a weekly cap on how many Sparks you can earn, so plan your farming accordingly to maximize your gil income. Repeat: Continue earning and exchanging Sparks each week to maintain a steady flow of gil.   Farming in Castle Oztroja Castle Oztroja, which is located in the Meriphataud Mountains region, is a renowned location for farming vendor items in CatsEyeXI. The castle is home to a variety of mobs, including Yagudos, which are known for dropping valuable items. You can look for items like Beastmen's Seals, Yagudo Necklaces, and Chest Keys that can be sold for a good amount of gil. Treasure chests can also contain rare and valuable items; keep an eye out for them. To maximize your profit, you can also check the Item Search on the CatsEyeXI server to see which mobs drop which items and their drop rates before farming.   In addition, there are two safety tips for you. One is to be cautious not to attract too many mobs at once, as it could lead to an untimely defeat. The other is that, if possible, farm with a party to handle tougher mobs and increase drop rates.   Crafting Crafting in CatsEyeXI is an intricate system that allows players to create a wide range of items, from basic materials to high-end gear. Each craft has its own nuances and market demands. It is a lucrative way to make gil. The server has adjusted rates from retail, making it more accessible to skill-up crafts.   First, select a craft that aligns with your interests and the current market needs. Popular choices include Alchemy (Potions, Elixirs, and Status Remedies), Smithing (Weapons, Armor, and Tools), Clothcraft (Robes, Hats, and Bags), and Cooking (Food Buffs and Beverages).   The main craft level cap is 110, and the sub craft level cap is 70. Here are some tips to help level up your crafting.   Start with recipes that are within your skill level to ensure a higher success rate. Use the /lastsynth command to repeat the last synthesis, which is helpful for mass-producing items. Take advantage of skill-ups over natural recipe caps, allowing you to skill up 11 levels over the item's natural cap. Crafting torques can provide a significant skill boost when equipped. Setting up a crafting stall in your mog house grants a +5 skill bonus to your craft. Consuming food that boosts your crafting or fishing skills can increase your success rate and skill-up frequency. For levels 1-50, consider using crafting kits sold at guilds, which provide all the necessary materials for specific recipes. Joining a crafting guild can provide access to resources, shared knowledge, and a community of crafters. This crafting guide provides suggested recipes for each craft to maximize skill-ups and minimize costs.   Participating in Server Events Keep an eye out for server events that might offer gil or items that can be sold for gil.   Holiday Events: These are seasonal and often offer unique items that can be sold for gil. Special Hunts: Targeted hunts for rare monsters that drop valuable loot Contests: Competitions like fishing derbies or screenshot contests that reward gil or rare items   Quests and Missions Quests and missions are a great way to earn gil and other valuable rewards.   Content Quests: These quests often provide unique items and gil as rewards. For example, the Featherweight quest in Windurst requires players to collect certain items and, in return, grants access to the Yagudo Arena and a reward of 500 gil per entrance. Daily Quest System: Players can complete up to five quests every real-life day and earn Obsidian Fragments, a unique currency that can be exchanged for rewards. These quests reset daily. Rhapsodies of Vana'diel: While the missions in CatsEyeXI are retail accurate, there are some exceptions with Rhapsodies of Vana'diel. Certain rewards have been modified; Trust ciphers and Rhapsodies Key Items (KIs) are received by ACE/CW accounts, while other rewards are available to all account types. Crystal Warrior Quests: Exclusive new armor sets and other rewards are available to Crystal Warriors through the use of Milestone Points earned by progressing through the game.
    • link off @Celestine can you reupload it?
    • Hey everyone 👋,   As my title says are l2 players waiting for the next l2 server listing? I saw several topics that Blame more or less topzone and hopzone. I see same old web designs like they  stopped in the distant year 2004. If you are a server owner do you want to join on a brand new website with a modern design, more stats, tools e.g. file translation tool that will translate yours xml, xlf or something else files (suggestions are appreciated), or you won't because?     - Example: I'm used to the ones on the market and don't want to experiment. It will be appreciated the translation tool but I do not need a new listing.                
  • Topics

×
×
  • Create New...