Jump to content

KaL

Members
  • Posts

    160
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by KaL

  1. Here is a new rate to change the drop of normal mobs from boss mobs ( Includes manage the rate of big boss drop jewels! ) Index: config/rates.properties =================================================================== --- config/rates.properties (revision 5132) +++ config/rates.properties (working copy) @@ -7,8 +7,19 @@ RatePartyXp = 1. RatePartySp = 1. RateDropAdena = 1. +# Adane Drop Rate For Raidboss,Boss +RateDropAdenaBoss = 1. +RateDropAdenaRaid = 1. RateDropItems = 1. +# Item Drop Rate For Raidboss,Boss +RateDropItemsBoss = 1. +RateDropItemsRaid = 1. +# Jewels Drop Rate For Boss Jewels +RateDropItemsJewel = 1. RateDropSpoil = 1. +# Spoil Rate For Raidboss,Boss +RateDropSpoilRaid = 1. +RateDropSpoilBoss = 1. RateDropManor = 1 # Fishing rates RateExtractFish = 1 Index: src/main/java/com/l2jfree/Config.java =================================================================== --- src/main/java/com/l2jfree/Config.java (revision 5132) +++ src/main/java/com/l2jfree/Config.java (working copy) @@ -450,13 +450,24 @@ public static float RATE_QUESTS_REWARD_ADENA; public static float RATE_QUESTS_REWARD_ITEMS; public static float RATE_DROP_ADENA; + // Adane Drop Rate For Raidboss,Boss + public static float RATE_DROP_ADENA_RAID; + public static float RATE_DROP_ADENA_BOSS; public static float RATE_CONSUMABLE_COST; public static float RATE_CRAFT_COST; public static int RATE_MASTERWORK; public static int RATE_CRITICAL_CRAFT_CHANCE; public static int RATE_CRITICAL_CRAFT_MULTIPLIER; public static float RATE_DROP_ITEMS; + // Item Drop Rate For Raidboss,Boss + public static float RATE_DROP_ITEMS_BOSS; + public static float RATE_DROP_ITEMS_RAID; + // Jewels Drop Rate For Boss Jewels + public static float RATE_DROP_ITEMS_JEWEL; public static float RATE_DROP_SPOIL; + // Spoil Rate For Raidboss,Boss + public static float RATE_DROP_SPOIL_BOSS; + public static float RATE_DROP_SPOIL_RAID; public static int RATE_DROP_MANOR; public static float RATE_DROP_QUEST; public static int RATE_EXTR_FISH; @@ -512,13 +523,24 @@ RATE_QUESTS_REWARD_ITEMS = Float.parseFloat(ratesSettings.getProperty("RateQuestsRewardItems", "1.")); RATE_DROP_ADENA = Float.parseFloat(ratesSettings.getProperty("RateDropAdena", "1.")); + // Adane Drop Rate For Raidboss,Boss + RATE_DROP_ADENA_BOSS = Float.parseFloat(ratesSettings.getProperty("RateDropAdenaBoss", "1.")); + RATE_DROP_ADENA_RAID = Float.parseFloat(ratesSettings.getProperty("RateDropAdenaRaid", "1.")); RATE_CONSUMABLE_COST = Float.parseFloat(ratesSettings.getProperty("RateConsumableCost", "1.")); RATE_CRAFT_COST = Float.parseFloat(ratesSettings.getProperty("RateCraftCost", "1.")); RATE_MASTERWORK = Integer.parseInt(ratesSettings.getProperty("RateMasterwork", "20")); RATE_CRITICAL_CRAFT_CHANCE = Integer.parseInt(ratesSettings.getProperty("RateCriticalCraftChance", "5")); RATE_CRITICAL_CRAFT_MULTIPLIER = Integer.parseInt(ratesSettings.getProperty("RateCriticalCraftMutliplier", "2")); RATE_DROP_ITEMS = Float.parseFloat(ratesSettings.getProperty("RateDropItems", "1.")); + // Item Drop Rate For Raidboss,Boss + RATE_DROP_ITEMS_RAID = Float.parseFloat(ratesSettings.getProperty("RateDropItemsRaid", "1.")); + RATE_DROP_ITEMS_BOSS = Float.parseFloat(ratesSettings.getProperty("RateDropItemsBoss", "1.")); + // Jewels Drop Rate For Boss Jewels + RATE_DROP_ITEMS_JEWEL = Float.parseFloat(ratesSettings.getProperty("RateDropItemsJewels", "1.")); RATE_DROP_SPOIL = Float.parseFloat(ratesSettings.getProperty("RateDropSpoil", "1.")); + // Spoil Rate For Raidboss,Boss + RATE_DROP_SPOIL_BOSS = Float.parseFloat(ratesSettings.getProperty("RateDropSpoilBoss", "1.")); + RATE_DROP_SPOIL_RAID = Float.parseFloat(ratesSettings.getProperty("RateDropSpoilRaid", "1.")); RATE_DROP_MANOR = Integer.parseInt(ratesSettings.getProperty("RateDropManor", "1")); RATE_DROP_QUEST = Float.parseFloat(ratesSettings.getProperty("RateDropQuest", "1.")); RATE_EXTR_FISH = Integer.parseInt(ratesSettings.getProperty("RateExtractFish", "1")); @@ -3259,12 +3281,30 @@ RATE_QUESTS_REWARD_ITEMS = Float.parseFloat(pValue); else if (pName.equalsIgnoreCase("RateDropAdena")) RATE_DROP_ADENA = Float.parseFloat(pValue); + // Adane Drop Rate For Raidboss,Boss + else if (pName.equalsIgnoreCase("RateDropAdenaBoss")) + RATE_DROP_ADENA_BOSS = Float.parseFloat(pValue); + else if (pName.equalsIgnoreCase("RateDropAdenaRaid")) + RATE_DROP_ADENA_RAID = Float.parseFloat(pValue); else if (pName.equalsIgnoreCase("RateConsumableCost")) RATE_CONSUMABLE_COST = Float.parseFloat(pValue); else if (pName.equalsIgnoreCase("RateDropItems")) RATE_DROP_ITEMS = Float.parseFloat(pValue); + // Item Drop Rate For Raidboss,Boss + else if (pName.equalsIgnoreCase("RateDropItemsBoss")) + RATE_DROP_ITEMS_BOSS = Float.parseFloat(pValue); + else if (pName.equalsIgnoreCase("RateDropItemsRaid")) + RATE_DROP_ITEMS_RAID = Float.parseFloat(pValue); + // Jewels Drop Rate For Boss Jewels + else if (pName.equalsIgnoreCase("RateDropItemsJewels")) + RATE_DROP_ITEMS_JEWEL = Float.parseFloat(pValue); else if (pName.equalsIgnoreCase("RateDropSpoil")) RATE_DROP_SPOIL = Float.parseFloat(pValue); + // Spoil Rate For Raidboss,Boss + else if (pName.equalsIgnoreCase("RateDropSpoilBoss")) + RATE_DROP_SPOIL_BOSS = Float.parseFloat(pValue); + else if (pName.equalsIgnoreCase("RateDropSpoilRaid")) + RATE_DROP_SPOIL_RAID = Float.parseFloat(pValue); else if (pName.equalsIgnoreCase("RateDropManor")) RATE_DROP_MANOR = Integer.parseInt(pValue); else if (pName.equalsIgnoreCase("RateDropQuest")) Index: src/main/java/com/l2jfree/gameserver/model/L2Attackable.java =================================================================== --- src/main/java/com/l2jfree/gameserver/model/L2Attackable.java (revision 5132) +++ src/main/java/com/l2jfree/gameserver/model/L2Attackable.java (working copy) @@ -37,12 +37,14 @@ import com.l2jfree.gameserver.datatables.EventDroplist.DateDrop; import com.l2jfree.gameserver.instancemanager.CursedWeaponsManager; import com.l2jfree.gameserver.model.actor.instance.L2ChestInstance; +import com.l2jfree.gameserver.model.actor.instance.L2GrandBossInstance; import com.l2jfree.gameserver.model.actor.instance.L2MinionInstance; import com.l2jfree.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jfree.gameserver.model.actor.instance.L2NpcInstance; import com.l2jfree.gameserver.model.actor.instance.L2PcInstance; import com.l2jfree.gameserver.model.actor.instance.L2PetInstance; import com.l2jfree.gameserver.model.actor.instance.L2PlayableInstance; +import com.l2jfree.gameserver.model.actor.instance.L2RaidBossInstance; import com.l2jfree.gameserver.model.actor.instance.L2SiegeGuardInstance; import com.l2jfree.gameserver.model.actor.instance.L2SummonInstance; import com.l2jfree.gameserver.model.actor.knownlist.AttackableKnownList; @@ -1257,12 +1259,25 @@ } // Applies Drop rates - if (drop.getItemId() == 57) - dropChance *= Config.RATE_DROP_ADENA; - else if (isSweep) - dropChance *= Config.RATE_DROP_SPOIL; - else - dropChance *= Config.RATE_DROP_ITEMS; + if (drop.getItemId() == 57) + { + if (this instanceof L2RaidBossInstance) dropChance *= Config.RATE_DROP_ADENA_RAID; //other raid boss + else if (this instanceof L2GrandBossInstance) dropChance *= Config.RATE_DROP_ADENA_BOSS; //Baium , Antharas , Valakas..... + else dropChance *= Config.RATE_DROP_ADENA; + } + else if (isSweep) + { + if (this instanceof L2RaidBossInstance) dropChance *= Config.RATE_DROP_SPOIL_RAID; + else if (this instanceof L2GrandBossInstance) dropChance *= Config.RATE_DROP_SPOIL_BOSS; + else dropChance *= Config.RATE_DROP_SPOIL; + } + else + { + if (drop.getItemId() == 6656 || drop.getItemId() == 6657 || drop.getItemId() == 6658 || drop.getItemId() == 6659 || drop.getItemId() == 6660 || drop.getItemId() == 6661 || drop.getItemId() == 6662 || drop.getItemId() == 8191 ) dropChance *= Config.RATE_DROP_ITEMS_JEWEL; + else if (this instanceof L2RaidBossInstance) dropChance *= Config.RATE_DROP_ITEMS_RAID; + else if (this instanceof L2GrandBossInstance) dropChance *= Config.RATE_DROP_ITEMS_BOSS; + else dropChance *= Config.RATE_DROP_ITEMS; + } // Round drop chance dropChance = Math.round(dropChance) * champRate; @@ -1354,7 +1369,9 @@ categoryDropChance = ((categoryDropChance - ((categoryDropChance * levelModifier) / 100)) / deepBlueDrop); // Applies Drop rates - categoryDropChance *= Config.RATE_DROP_ITEMS; + if (this instanceof L2RaidBossInstance) categoryDropChance *= Config.RATE_DROP_ITEMS_RAID; + else if (this instanceof L2GrandBossInstance) categoryDropChance *= Config.RATE_DROP_ITEMS_BOSS; + else categoryDropChance *= Config.RATE_DROP_ITEMS; // Round drop chance categoryDropChance = Math.round(categoryDropChance); @@ -1399,10 +1416,20 @@ } int dropChance = drop.getChance(); - if (drop.getItemId() == 57) - dropChance *= Config.RATE_DROP_ADENA; - else - dropChance *= Config.RATE_DROP_ITEMS; + dropChance *= champRate; + if (drop.getItemId() == 57) + { + if (this instanceof L2RaidBossInstance) dropChance *= Config.RATE_DROP_ADENA_RAID; + else if (this instanceof L2GrandBossInstance) dropChance *= Config.RATE_DROP_ADENA_BOSS; + else dropChance *= Config.RATE_DROP_ADENA; + } + else + { + if (drop.getItemId() == 6656 || drop.getItemId() == 6657 || drop.getItemId() == 6658 || drop.getItemId() == 6659 || drop.getItemId() == 6660 || drop.getItemId() == 6661 || drop.getItemId() == 6662 || drop.getItemId() == 8191 ) dropChance *= Config.RATE_DROP_ITEMS_JEWEL; + else if (this instanceof L2RaidBossInstance) dropChance *= Config.RATE_DROP_ITEMS_RAID; + else if (this instanceof L2GrandBossInstance) dropChance *= Config.RATE_DROP_ITEMS_BOSS; + else dropChance *= Config.RATE_DROP_ITEMS; + } dropChance = Math.round(dropChance) * champRate; Works fine in L2jFree 1.2.11
  2. Well, I'm not sure if it works...need test, but I set this in the code ( Nothing exeptional...just for information to the player, not needed )
  3. Oh...I forgot, I tested it in L2jFree 1.2.11...but it might work in all other plataforms ;)
  4. Great, very usefull, but isn't the any way to make it checks all items enchanted when character updates the inventory? I'm trying to generate a source code, but it is too long, and not efficient :S How can I make it checks for every inventory update? At this way, it blocks any over-enchanted items...checking trading lists, but/sell, pick/drop, etc...if you login with an over-enchanted item, you get block automatically, if you pass for this, it checks for items equipped or not, in trade lists, if you try to drop any over-enchanted item, it bans you and doesn't drop the item ( return false; ) I changed the code, now it deletes the item, it's like this : L2PcInstance player = getClient().getActiveChar(); if (item.getEnchantLevel() > Config.MAX_ENCHANT) { activeChar.setAccountAccesslevel(-100); activeChar.sendMessage("You have been banned for using an item over-enchanted! Damn funcking noob!"); _log.warn("Player " + player.getName() + " had an over-enchanted item and got banned! The item was: " + item.getName() +"+" + item.getEnchantLevel() +". He is banned now!"); activeChar.closeNetConnection(); activeChar.destroyItem("Destroying your over-enchanted item!", item, activeChar, true); activeChar.getInventory().updateDatabase(); return; } It works fine, but only in equip/unequip...
  5. 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
  6. 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 +}
  7. 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..
  8. 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!
×
×
  • 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