From c9c46a8c2a778e3f409c5d493d856ea8a4af8840 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 30 Jun 2020 01:45:28 +0000 Subject: [PATCH] Refactored fake player system. --- ...c_to_pc_polymorph.sql => fake_players.sql} | 4 +- .../datatables/sql/FakePlayerTable.java | 20 +-- ...cInstance.java => FakePlayerInstance.java} | 17 +- .../model/actor/instance/NpcInstance.java | 24 +-- .../network/serverpackets/CustomNpcInfo.java | 147 ------------------ .../network/serverpackets/FakePlayerInfo.java | 112 +++++++++++++ .../network/serverpackets/NpcInfo.java | 5 +- ...c_to_pc_polymorph.sql => fake_players.sql} | 4 +- .../datatables/sql/FakePlayerTable.java | 20 +-- ...cInstance.java => FakePlayerInstance.java} | 17 +- .../model/actor/instance/NpcInstance.java | 24 +-- .../network/serverpackets/CustomNpcInfo.java | 147 ------------------ .../network/serverpackets/FakePlayerInfo.java | 143 +++++++++++++++++ .../network/serverpackets/NpcInfo.java | 5 +- 14 files changed, 325 insertions(+), 364 deletions(-) rename L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/{npc_to_pc_polymorph.sql => fake_players.sql} (92%) rename L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java => L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java (86%) rename L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/{CustomNpcInstance.java => FakePlayerInstance.java} (90%) delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java rename L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/{npc_to_pc_polymorph.sql => fake_players.sql} (92%) rename L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java => L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java (86%) rename L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/{CustomNpcInstance.java => FakePlayerInstance.java} (90%) delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/npc_to_pc_polymorph.sql b/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/fake_players.sql similarity index 92% rename from L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/npc_to_pc_polymorph.sql rename to L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/fake_players.sql index 978e4f7347..8613cf5322 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/npc_to_pc_polymorph.sql +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/db_installer/sql/game/fake_players.sql @@ -1,7 +1,7 @@ -- --------------------------- --- Table structure for `npc_to_pc_polymorph` +-- Table structure for `fake_players` -- --------------------------- -CREATE TABLE IF NOT EXISTS `npc_to_pc_polymorph` ( +CREATE TABLE IF NOT EXISTS `fake_players` ( `spawn` int(9) NOT NULL default '0', `template` int(9) NOT NULL default '0', `name` varchar(35) default NULL, diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java similarity index 86% rename from L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java rename to L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java index 655eebc1ce..2738b06afe 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.instancemanager; +package org.l2jmobius.gameserver.datatables.sql; import java.sql.Connection; import java.sql.PreparedStatement; @@ -27,13 +27,13 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Rnd; /** - * control for Custom Npcs that look like players. + * Table for custom NPCs that look like players. * @version 1.00 * @author Darki699 */ -public class CustomNpcInstanceManager +public class FakePlayerTable { - private static final Logger LOGGER = Logger.getLogger(CustomNpcInstanceManager.class.getName()); + private static final Logger LOGGER = Logger.getLogger(FakePlayerTable.class.getName()); private Map spawns; // private Map templates; // @@ -52,7 +52,7 @@ public class CustomNpcInstanceManager /** * Constructor Calls to load the data */ - CustomNpcInstanceManager() + FakePlayerTable() { load(); } @@ -75,7 +75,7 @@ public class CustomNpcInstanceManager } /** - * Just load the data for mysql... + * Just load the data from mysql... */ private final void load() { @@ -88,7 +88,7 @@ public class CustomNpcInstanceManager try (Connection con = DatabaseFactory.getConnection()) { int count = 0; - final PreparedStatement statement = con.prepareStatement("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_polymorph"); + final PreparedStatement statement = con.prepareStatement("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 fake_players"); final ResultSet rset = statement.executeQuery(); while (rset.next()) @@ -265,7 +265,7 @@ public class CustomNpcInstanceManager { try (Connection con = DatabaseFactory.getConnection()) { - final PreparedStatement statement = con.prepareStatement("REPLACE INTO npc_to_pc_polymorph 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_polymorph"); + final PreparedStatement statement = con.prepareStatement("REPLACE INTO fake_players 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 fake_players"); final ResultSet rset = statement.executeQuery(); statement.close(); @@ -284,13 +284,13 @@ public class CustomNpcInstanceManager } } - public static CustomNpcInstanceManager getInstance() + public static FakePlayerTable getInstance() { return SingletonHolder.INSTANCE; } private static class SingletonHolder { - protected static final CustomNpcInstanceManager INSTANCE = new CustomNpcInstanceManager(); + protected static final FakePlayerTable INSTANCE = new FakePlayerTable(); } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java similarity index 90% rename from L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java rename to L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java index 09791853ad..bb371896a7 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java @@ -17,15 +17,15 @@ package org.l2jmobius.gameserver.model.actor.instance; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.instancemanager.CustomNpcInstanceManager; +import org.l2jmobius.gameserver.datatables.sql.FakePlayerTable; import org.l2jmobius.gameserver.model.base.ClassId; import org.l2jmobius.gameserver.model.items.type.WeaponType; /** - * This class manages Npc Polymorph into player instances, they look like regular players. This effect will show up on all clients. + * This class manages Fake Player instances, they look like regular players. This effect will show up on all clients. * @author Darki699 */ -public class CustomNpcInstance +public class FakePlayerInstance { private boolean _allowRandomWeapons = true; // Default value private boolean _allowRandomClass = true; // Default value @@ -39,10 +39,9 @@ public class CustomNpcInstance private ClassId _classId; // ClassId of this (N)Pc /** - * A constructor * @param myNpc - Receives the NpcInstance as a reference. */ - public CustomNpcInstance(NpcInstance myNpc) + public FakePlayerInstance(NpcInstance myNpc) { _npcInstance = myNpc; if ((_npcInstance != null) && (_npcInstance.getSpawn() != null)) @@ -65,15 +64,15 @@ public class CustomNpcInstance _boolean = new boolean[4]; // pvp=0 , noble=1, hero=2, isFemaleSex=3 // load the Pc Morph Data - final CustomNpcInstanceManager.customInfo ci = CustomNpcInstanceManager.getInstance().getCustomData(_npcInstance.getSpawn().getId(), _npcInstance.getNpcId()); + final FakePlayerTable.customInfo ci = FakePlayerTable.getInstance().getCustomData(_npcInstance.getSpawn().getId(), _npcInstance.getNpcId()); if (ci == null) { - _npcInstance.setCustomNpcInstance(null); + _npcInstance.setFakePlayerInstance(null); _npcInstance = null; return; } - _npcInstance.setCustomNpcInstance(this); + _npcInstance.setFakePlayerInstance(this); setPcInstanceData(ci); @@ -445,7 +444,7 @@ public class CustomNpcInstance * Sets the data received from the CustomNpcInstanceManager * @param ci the customInfo data */ - public void setPcInstanceData(CustomNpcInstanceManager.customInfo ci) + public void setPcInstanceData(FakePlayerTable.customInfo ci) { if (ci == null) { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java index 1ef61b876a..c01978e2df 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java @@ -29,6 +29,7 @@ import org.l2jmobius.gameserver.datatables.ItemTable; import org.l2jmobius.gameserver.datatables.MobGroupTable; import org.l2jmobius.gameserver.datatables.SkillTable; import org.l2jmobius.gameserver.datatables.sql.ClanTable; +import org.l2jmobius.gameserver.datatables.sql.FakePlayerTable; import org.l2jmobius.gameserver.datatables.sql.HelperBuffTable; import org.l2jmobius.gameserver.datatables.sql.SpawnTable; import org.l2jmobius.gameserver.datatables.xml.MultisellData; @@ -36,7 +37,6 @@ import org.l2jmobius.gameserver.datatables.xml.ZoneData; import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.idfactory.IdFactory; import org.l2jmobius.gameserver.instancemanager.CastleManager; -import org.l2jmobius.gameserver.instancemanager.CustomNpcInstanceManager; import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager; import org.l2jmobius.gameserver.instancemanager.FortManager; import org.l2jmobius.gameserver.instancemanager.QuestManager; @@ -108,7 +108,7 @@ public class NpcInstance extends Creature protected static final Logger LOGGER = Logger.getLogger(NpcInstance.class.getName()); public static final int INTERACTION_DISTANCE = 150; - private CustomNpcInstance _customNpcInstance; + private FakePlayerInstance _fakePlayerInstance; private Spawn _spawn; private boolean _isBusy = false; private String _busyMessage = ""; @@ -2683,9 +2683,9 @@ public class NpcInstance extends Creature { _spawn = spawn; // Does this Npc morph into a PlayerInstance? - if ((_spawn != null) && CustomNpcInstanceManager.getInstance().isCustomNpcInstance(_spawn.getId(), getNpcId())) + if ((_spawn != null) && FakePlayerTable.getInstance().isCustomNpcInstance(_spawn.getId(), getNpcId())) { - new CustomNpcInstance(this); + new FakePlayerInstance(this); } } @@ -2867,21 +2867,21 @@ public class NpcInstance extends Creature } /** - * Gets the custom npc instance. - * @return the custom npc instance + * Gets the fake player instance. + * @return the fake player instance */ - public CustomNpcInstance getCustomNpcInstance() + public FakePlayerInstance getFakePlayerInstance() { - return _customNpcInstance; + return _fakePlayerInstance; } /** - * Sets the custom npc instance. - * @param arg the new custom npc instance + * Sets the fake player instance. + * @param value the new fake player instance */ - public void setCustomNpcInstance(CustomNpcInstance arg) + public void setFakePlayerInstance(FakePlayerInstance value) { - _customNpcInstance = arg; + _fakePlayerInstance = value; } @Override diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java deleted file mode 100644 index 9b9b1b9b7b..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver.network.serverpackets; - -import org.l2jmobius.gameserver.datatables.xml.PlayerTemplateData; -import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; - -public class CustomNpcInfo extends GameServerPacket -{ - private final NpcInstance _activeChar; - - /** - * @param cha - */ - public CustomNpcInfo(NpcInstance cha) - { - _activeChar = cha; - _activeChar.setClientX(_activeChar.getPosition().getX()); - _activeChar.setClientY(_activeChar.getPosition().getY()); - _activeChar.setClientZ(_activeChar.getPosition().getZ()); - } - - @Override - protected final void writeImpl() - { - writeC(0x03); - 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()); - writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_HAIR()); - writeD(0); - 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('H', 0, 24); - 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(PlayerTemplateData.getInstance().getTemplate(_activeChar.getCustomNpcInstance().getClassId()).getCollisionRadius()); - writeF(PlayerTemplateData.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(0x00); - writeD(_activeChar.getAbnormalEffect()); - writeC(0); - writeH(0); - writeD(_activeChar.getCustomNpcInstance().getClassId()); - writeD(_activeChar.getMaxCp()); - writeD((int) _activeChar.getStatus().getCurrentCp()); - writeC(_activeChar.getCustomNpcInstance().getEnchantWeapon()); - writeC(0x00); - writeD(0); // clan crest - 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(0x00); - } - - 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; - } - } - } - } -} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java new file mode 100644 index 0000000000..d18b8295dc --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java @@ -0,0 +1,112 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets; + +import org.l2jmobius.gameserver.datatables.xml.PlayerTemplateData; +import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; + +public class FakePlayerInfo extends GameServerPacket +{ + private final NpcInstance _activeChar; + + public FakePlayerInfo(NpcInstance cha) + { + _activeChar = cha; + _activeChar.setClientX(_activeChar.getPosition().getX()); + _activeChar.setClientY(_activeChar.getPosition().getY()); + _activeChar.setClientZ(_activeChar.getPosition().getZ()); + } + + @Override + protected final void writeImpl() + { + writeC(0x03); + writeD(_activeChar.getX()); + writeD(_activeChar.getY()); + writeD(_activeChar.getZ()); + writeD(_activeChar.getHeading()); + writeD(_activeChar.getObjectId()); + writeS(_activeChar.getFakePlayerInstance().getName()); + writeD(_activeChar.getFakePlayerInstance().getRace()); + writeD(_activeChar.getFakePlayerInstance().isFemaleSex() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().getClassId()); + writeD(0); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_RHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_LHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_GLOVES()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_CHEST()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_LEGS()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_FEET()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_RHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR()); + + writeD(_activeChar.getFakePlayerInstance().getPvpFlag() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().getKarma()); + writeD(_activeChar.getMAtkSpd()); + writeD(_activeChar.getPAtkSpd()); + writeD(_activeChar.getFakePlayerInstance().getPvpFlag() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().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(PlayerTemplateData.getInstance().getTemplate(_activeChar.getFakePlayerInstance().getClassId()).getCollisionRadius()); + writeF(PlayerTemplateData.getInstance().getTemplate(_activeChar.getFakePlayerInstance().getClassId()).getCollisionHeight()); + writeD(_activeChar.getFakePlayerInstance().getHairStyle()); + writeD(_activeChar.getFakePlayerInstance().getHairColor()); + writeD(_activeChar.getFakePlayerInstance().getFace()); + writeS(_activeChar.getFakePlayerInstance().getTitle()); + writeD(_activeChar.getFakePlayerInstance().getClanId()); + writeD(_activeChar.getFakePlayerInstance().getClanCrestId()); + writeD(_activeChar.getFakePlayerInstance().getAllyId()); + writeD(_activeChar.getFakePlayerInstance().getAllyCrestId()); + writeD(0); + writeC(1); + writeC(_activeChar.isRunning() ? 1 : 0); + writeC(_activeChar.isInCombat() ? 1 : 0); + writeC(_activeChar.isAlikeDead() ? 1 : 0); + writeC(0); + writeC(0); + writeC(0); + writeH(0); + writeC(0); + writeD(_activeChar.getAbnormalEffect()); + writeC(0); + writeH(0); + writeD(_activeChar.getFakePlayerInstance().getClassId()); + writeD(_activeChar.getMaxCp()); + writeD((int) _activeChar.getStatus().getCurrentCp()); + writeC(_activeChar.getFakePlayerInstance().getEnchantWeapon()); + writeC(0); + writeD(0); // clan crest + writeC(_activeChar.getFakePlayerInstance().isNoble() ? 1 : 0); + writeC(_activeChar.getFakePlayerInstance().isHero() ? 1 : 0); + writeC(0); + writeD(0); + writeD(0); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().nameColor()); + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java index 7e58f304de..3ab1b5fdd3 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java @@ -61,12 +61,13 @@ public class NpcInfo extends GameServerPacket */ public NpcInfo(NpcInstance cha, Creature attacker) { - if (cha.getCustomNpcInstance() != null) + if (cha.getFakePlayerInstance() != null) { - attacker.sendPacket(new CustomNpcInfo(cha)); + attacker.sendPacket(new FakePlayerInfo(cha)); attacker.broadcastPacket(new FinishRotation(cha)); return; } + _creature = cha; _displayId = cha.getTemplate().getDisplayId(); _isAttackable = cha.isAutoAttackable(attacker); diff --git a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/npc_to_pc_polymorph.sql b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/fake_players.sql similarity index 92% rename from L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/npc_to_pc_polymorph.sql rename to L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/fake_players.sql index 978e4f7347..8613cf5322 100644 --- a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/npc_to_pc_polymorph.sql +++ b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/fake_players.sql @@ -1,7 +1,7 @@ -- --------------------------- --- Table structure for `npc_to_pc_polymorph` +-- Table structure for `fake_players` -- --------------------------- -CREATE TABLE IF NOT EXISTS `npc_to_pc_polymorph` ( +CREATE TABLE IF NOT EXISTS `fake_players` ( `spawn` int(9) NOT NULL default '0', `template` int(9) NOT NULL default '0', `name` varchar(35) default NULL, diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java similarity index 86% rename from L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java rename to L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java index 655eebc1ce..2738b06afe 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/instancemanager/CustomNpcInstanceManager.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/sql/FakePlayerTable.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.gameserver.instancemanager; +package org.l2jmobius.gameserver.datatables.sql; import java.sql.Connection; import java.sql.PreparedStatement; @@ -27,13 +27,13 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.util.Rnd; /** - * control for Custom Npcs that look like players. + * Table for custom NPCs that look like players. * @version 1.00 * @author Darki699 */ -public class CustomNpcInstanceManager +public class FakePlayerTable { - private static final Logger LOGGER = Logger.getLogger(CustomNpcInstanceManager.class.getName()); + private static final Logger LOGGER = Logger.getLogger(FakePlayerTable.class.getName()); private Map spawns; // private Map templates; // @@ -52,7 +52,7 @@ public class CustomNpcInstanceManager /** * Constructor Calls to load the data */ - CustomNpcInstanceManager() + FakePlayerTable() { load(); } @@ -75,7 +75,7 @@ public class CustomNpcInstanceManager } /** - * Just load the data for mysql... + * Just load the data from mysql... */ private final void load() { @@ -88,7 +88,7 @@ public class CustomNpcInstanceManager try (Connection con = DatabaseFactory.getConnection()) { int count = 0; - final PreparedStatement statement = con.prepareStatement("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_polymorph"); + final PreparedStatement statement = con.prepareStatement("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 fake_players"); final ResultSet rset = statement.executeQuery(); while (rset.next()) @@ -265,7 +265,7 @@ public class CustomNpcInstanceManager { try (Connection con = DatabaseFactory.getConnection()) { - final PreparedStatement statement = con.prepareStatement("REPLACE INTO npc_to_pc_polymorph 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_polymorph"); + final PreparedStatement statement = con.prepareStatement("REPLACE INTO fake_players 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 fake_players"); final ResultSet rset = statement.executeQuery(); statement.close(); @@ -284,13 +284,13 @@ public class CustomNpcInstanceManager } } - public static CustomNpcInstanceManager getInstance() + public static FakePlayerTable getInstance() { return SingletonHolder.INSTANCE; } private static class SingletonHolder { - protected static final CustomNpcInstanceManager INSTANCE = new CustomNpcInstanceManager(); + protected static final FakePlayerTable INSTANCE = new FakePlayerTable(); } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java similarity index 90% rename from L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java rename to L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java index 09791853ad..bb371896a7 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/CustomNpcInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/FakePlayerInstance.java @@ -17,15 +17,15 @@ package org.l2jmobius.gameserver.model.actor.instance; import org.l2jmobius.commons.util.Rnd; -import org.l2jmobius.gameserver.instancemanager.CustomNpcInstanceManager; +import org.l2jmobius.gameserver.datatables.sql.FakePlayerTable; import org.l2jmobius.gameserver.model.base.ClassId; import org.l2jmobius.gameserver.model.items.type.WeaponType; /** - * This class manages Npc Polymorph into player instances, they look like regular players. This effect will show up on all clients. + * This class manages Fake Player instances, they look like regular players. This effect will show up on all clients. * @author Darki699 */ -public class CustomNpcInstance +public class FakePlayerInstance { private boolean _allowRandomWeapons = true; // Default value private boolean _allowRandomClass = true; // Default value @@ -39,10 +39,9 @@ public class CustomNpcInstance private ClassId _classId; // ClassId of this (N)Pc /** - * A constructor * @param myNpc - Receives the NpcInstance as a reference. */ - public CustomNpcInstance(NpcInstance myNpc) + public FakePlayerInstance(NpcInstance myNpc) { _npcInstance = myNpc; if ((_npcInstance != null) && (_npcInstance.getSpawn() != null)) @@ -65,15 +64,15 @@ public class CustomNpcInstance _boolean = new boolean[4]; // pvp=0 , noble=1, hero=2, isFemaleSex=3 // load the Pc Morph Data - final CustomNpcInstanceManager.customInfo ci = CustomNpcInstanceManager.getInstance().getCustomData(_npcInstance.getSpawn().getId(), _npcInstance.getNpcId()); + final FakePlayerTable.customInfo ci = FakePlayerTable.getInstance().getCustomData(_npcInstance.getSpawn().getId(), _npcInstance.getNpcId()); if (ci == null) { - _npcInstance.setCustomNpcInstance(null); + _npcInstance.setFakePlayerInstance(null); _npcInstance = null; return; } - _npcInstance.setCustomNpcInstance(this); + _npcInstance.setFakePlayerInstance(this); setPcInstanceData(ci); @@ -445,7 +444,7 @@ public class CustomNpcInstance * Sets the data received from the CustomNpcInstanceManager * @param ci the customInfo data */ - public void setPcInstanceData(CustomNpcInstanceManager.customInfo ci) + public void setPcInstanceData(FakePlayerTable.customInfo ci) { if (ci == null) { diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java index a78d006fe0..0be8e6f73b 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java @@ -29,6 +29,7 @@ import org.l2jmobius.gameserver.datatables.ItemTable; import org.l2jmobius.gameserver.datatables.MobGroupTable; import org.l2jmobius.gameserver.datatables.SkillTable; import org.l2jmobius.gameserver.datatables.sql.ClanTable; +import org.l2jmobius.gameserver.datatables.sql.FakePlayerTable; import org.l2jmobius.gameserver.datatables.sql.HelperBuffTable; import org.l2jmobius.gameserver.datatables.sql.SpawnTable; import org.l2jmobius.gameserver.datatables.xml.MultisellData; @@ -36,7 +37,6 @@ import org.l2jmobius.gameserver.datatables.xml.ZoneData; import org.l2jmobius.gameserver.enums.ChatType; import org.l2jmobius.gameserver.idfactory.IdFactory; import org.l2jmobius.gameserver.instancemanager.CastleManager; -import org.l2jmobius.gameserver.instancemanager.CustomNpcInstanceManager; import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager; import org.l2jmobius.gameserver.instancemanager.FortManager; import org.l2jmobius.gameserver.instancemanager.QuestManager; @@ -110,7 +110,7 @@ public class NpcInstance extends Creature protected static final Logger LOGGER = Logger.getLogger(NpcInstance.class.getName()); public static final int INTERACTION_DISTANCE = 150; - private CustomNpcInstance _customNpcInstance; + private FakePlayerInstance _fakePlayerInstance; private Spawn _spawn; private boolean _isBusy = false; private String _busyMessage = ""; @@ -2886,9 +2886,9 @@ public class NpcInstance extends Creature { _spawn = spawn; // Does this Npc morph into a PlayerInstance? - if ((_spawn != null) && CustomNpcInstanceManager.getInstance().isCustomNpcInstance(_spawn.getId(), getNpcId())) + if ((_spawn != null) && FakePlayerTable.getInstance().isCustomNpcInstance(_spawn.getId(), getNpcId())) { - new CustomNpcInstance(this); + new FakePlayerInstance(this); } } @@ -3070,21 +3070,21 @@ public class NpcInstance extends Creature } /** - * Gets the custom npc instance. - * @return the custom npc instance + * Gets the fake player instance. + * @return the fake player instance */ - public CustomNpcInstance getCustomNpcInstance() + public FakePlayerInstance getFakePlayerInstance() { - return _customNpcInstance; + return _fakePlayerInstance; } /** - * Sets the custom npc instance. - * @param arg the new custom npc instance + * Sets the fake player instance. + * @param value the new fake player instance */ - public void setCustomNpcInstance(CustomNpcInstance arg) + public void setFakePlayerInstance(FakePlayerInstance value) { - _customNpcInstance = arg; + _fakePlayerInstance = value; } @Override diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java deleted file mode 100644 index 9b9b1b9b7b..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/CustomNpcInfo.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.gameserver.network.serverpackets; - -import org.l2jmobius.gameserver.datatables.xml.PlayerTemplateData; -import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; - -public class CustomNpcInfo extends GameServerPacket -{ - private final NpcInstance _activeChar; - - /** - * @param cha - */ - public CustomNpcInfo(NpcInstance cha) - { - _activeChar = cha; - _activeChar.setClientX(_activeChar.getPosition().getX()); - _activeChar.setClientY(_activeChar.getPosition().getY()); - _activeChar.setClientZ(_activeChar.getPosition().getZ()); - } - - @Override - protected final void writeImpl() - { - writeC(0x03); - 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()); - writeD(_activeChar.getCustomNpcInstance().PAPERDOLL_HAIR()); - writeD(0); - 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('H', 0, 24); - 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(PlayerTemplateData.getInstance().getTemplate(_activeChar.getCustomNpcInstance().getClassId()).getCollisionRadius()); - writeF(PlayerTemplateData.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(0x00); - writeD(_activeChar.getAbnormalEffect()); - writeC(0); - writeH(0); - writeD(_activeChar.getCustomNpcInstance().getClassId()); - writeD(_activeChar.getMaxCp()); - writeD((int) _activeChar.getStatus().getCurrentCp()); - writeC(_activeChar.getCustomNpcInstance().getEnchantWeapon()); - writeC(0x00); - writeD(0); // clan crest - 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(0x00); - } - - 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; - } - } - } - } -} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java new file mode 100644 index 0000000000..07b7f01d15 --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/FakePlayerInfo.java @@ -0,0 +1,143 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.gameserver.network.serverpackets; + +import org.l2jmobius.gameserver.datatables.xml.PlayerTemplateData; +import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; + +public class FakePlayerInfo extends GameServerPacket +{ + private final NpcInstance _activeChar; + + public FakePlayerInfo(NpcInstance cha) + { + _activeChar = cha; + _activeChar.setClientX(_activeChar.getPosition().getX()); + _activeChar.setClientY(_activeChar.getPosition().getY()); + _activeChar.setClientZ(_activeChar.getPosition().getZ()); + } + + @Override + protected final void writeImpl() + { + writeC(0x03); + writeD(_activeChar.getX()); + writeD(_activeChar.getY()); + writeD(_activeChar.getZ()); + writeD(_activeChar.getHeading()); + writeD(_activeChar.getObjectId()); + writeS(_activeChar.getFakePlayerInstance().getName()); + writeD(_activeChar.getFakePlayerInstance().getRace()); + writeD(_activeChar.getFakePlayerInstance().isFemaleSex() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().getClassId()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR()); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_RHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_LHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_GLOVES()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_CHEST()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_LEGS()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_FEET()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_RHAND()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR()); + writeD(_activeChar.getFakePlayerInstance().PAPERDOLL_HAIR2()); + + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + writeH(0); + + writeD(_activeChar.getFakePlayerInstance().getPvpFlag() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().getKarma()); + writeD(_activeChar.getMAtkSpd()); + writeD(_activeChar.getPAtkSpd()); + writeD(_activeChar.getFakePlayerInstance().getPvpFlag() ? 1 : 0); + writeD(_activeChar.getFakePlayerInstance().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(PlayerTemplateData.getInstance().getTemplate(_activeChar.getFakePlayerInstance().getClassId()).getCollisionRadius()); + writeF(PlayerTemplateData.getInstance().getTemplate(_activeChar.getFakePlayerInstance().getClassId()).getCollisionHeight()); + writeD(_activeChar.getFakePlayerInstance().getHairStyle()); + writeD(_activeChar.getFakePlayerInstance().getHairColor()); + writeD(_activeChar.getFakePlayerInstance().getFace()); + writeS(_activeChar.getFakePlayerInstance().getTitle()); + writeD(_activeChar.getFakePlayerInstance().getClanId()); + writeD(_activeChar.getFakePlayerInstance().getClanCrestId()); + writeD(_activeChar.getFakePlayerInstance().getAllyId()); + writeD(_activeChar.getFakePlayerInstance().getAllyCrestId()); + writeD(0); + writeC(1); + writeC(_activeChar.isRunning() ? 1 : 0); + writeC(_activeChar.isInCombat() ? 1 : 0); + writeC(_activeChar.isAlikeDead() ? 1 : 0); + writeC(0); + writeC(0); + writeC(0); + writeH(0); + writeC(0); + writeD(_activeChar.getAbnormalEffect()); + writeC(0); + writeH(0); + writeD(_activeChar.getFakePlayerInstance().getClassId()); + writeD(_activeChar.getMaxCp()); + writeD((int) _activeChar.getStatus().getCurrentCp()); + writeC(_activeChar.getFakePlayerInstance().getEnchantWeapon()); + writeC(0); + writeD(0); // clan crest + writeC(_activeChar.getFakePlayerInstance().isNoble() ? 1 : 0); + writeC(_activeChar.getFakePlayerInstance().isHero() ? 1 : 0); + writeC(0); + writeD(0); + writeD(0); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().nameColor()); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().getPledgeClass()); + writeD(0); + writeD(_activeChar.getFakePlayerInstance().titleColor()); + writeD(0x00); + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java index 814a11abb3..337df82fa4 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/NpcInfo.java @@ -61,12 +61,13 @@ public class NpcInfo extends GameServerPacket */ public NpcInfo(NpcInstance cha, Creature attacker) { - if (cha.getCustomNpcInstance() != null) + if (cha.getFakePlayerInstance() != null) { - attacker.sendPacket(new CustomNpcInfo(cha)); + attacker.sendPacket(new FakePlayerInfo(cha)); attacker.broadcastPacket(new FinishRotation(cha)); return; } + _creature = cha; _displayId = cha.getTemplate().getDisplayId(); _isAttackable = cha.isAutoAttackable(attacker);