Advertisement
what_is_ever

Untitled

Dec 20th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.34 KB | None | 0 0
  1. /*
  2.  * This program is free software: you can redistribute it and/or modify it under
  3.  * the terms of the GNU General Public License as published by the Free Software
  4.  * Foundation, either version 3 of the License, or (at your option) any later
  5.  * version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful, but WITHOUT
  8.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10.  * details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License along with
  13.  * this program. If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15. package ru.catssoftware.gameserver.network.serverpackets;
  16.  
  17. import ru.catssoftware.Config;
  18. import ru.catssoftware.gameserver.HellsingConf;
  19. import ru.catssoftware.gameserver.model.L2Character;
  20. import ru.catssoftware.gameserver.model.L2Summon;
  21. import ru.catssoftware.gameserver.model.actor.instance.L2MonsterInstance;
  22. import ru.catssoftware.gameserver.model.actor.instance.L2NpcInstance;
  23. import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
  24. import ru.catssoftware.gameserver.model.actor.instance.L2SiegeFlagInstance;
  25. import ru.catssoftware.gameserver.network.L2GameClient;
  26.  
  27. /**
  28.  * This class ...
  29.  *
  30.  * @version $Revision: 1.7.2.4.2.9 $ $Date: 2005/04/11 10:05:54 $
  31.  */
  32. public class NpcInfo extends L2GameServerPacket
  33. {
  34.     //   ddddddddddddddddddffffdddcccccSSddd dddddc
  35.     //   ddddddddddddddddddffffdddcccccSSddd dddddccffd
  36.  
  37.     private static final String _S__22_NPCINFO  = "[S] 16 NpcInfo";
  38.     private L2Character         _activeChar;
  39.     private int                 _x, _y, _z, _heading;
  40.     private int                 _idTemplate;
  41.     private boolean             _isSummoned;
  42.     private int                 _mAtkSpd, _pAtkSpd;
  43.     private int                 _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd;
  44.     @SuppressWarnings("unused")
  45.     private int                 _rhand, _lhand, _chest, _val;
  46.     private int                 _collisionHeight, _collisionRadius;
  47.     private String              _name           = "";
  48.     private String              _title          = "";
  49.     @SuppressWarnings("unused")
  50.     private int                 _form           = 0;
  51.  
  52.     public NpcInfo(L2NpcInstance cha)
  53.     {
  54.         _activeChar = cha;
  55.         _idTemplate = cha.getTemplate().getIdTemplate();
  56.         _rhand = cha.getRightHandItem();
  57.         _lhand = cha.getLeftHandItem();
  58.         _isSummoned = cha.isShowSummonAnimation();
  59.         _collisionHeight = cha.getCollisionHeight();
  60.         _collisionRadius = cha.getCollisionRadius();
  61.         _name = cha.getName();
  62.  
  63.         if (cha.isChampion())
  64.             _title = (Config.CHAMPION_TITLE);
  65.         else
  66.             _title = cha.getTitle();
  67.  
  68.         if (Config.SHOW_NPC_LVL && _activeChar instanceof L2MonsterInstance)
  69.         {
  70.             String t = "Lv " + cha.getLevel() + (cha.getAggroRange() > 0 ? "*" : "");
  71.             if (_title != null && !_title.isEmpty())
  72.                 t += " " + _title;
  73.  
  74.             _title = t;
  75.         }
  76.         if (_activeChar instanceof L2SiegeFlagInstance)
  77.             _title = cha.getTitle();
  78.  
  79.         _x = _activeChar.getX();
  80.         _y = _activeChar.getY();
  81.         _z = _activeChar.getZ();
  82.         _heading = _activeChar.getHeading();
  83.         _mAtkSpd = _activeChar.getMAtkSpd();
  84.         _pAtkSpd = _activeChar.getPAtkSpd();
  85.         _runSpd = _activeChar.getTemplate().getBaseRunSpd();
  86.         _walkSpd = _activeChar.getTemplate().getBaseWalkSpd();
  87.         _swimRunSpd = _flRunSpd = _flyRunSpd = _runSpd;
  88.         _swimWalkSpd = _flWalkSpd = _flyWalkSpd = _walkSpd;
  89.     }
  90.  
  91.     public NpcInfo(L2Summon cha, int val)
  92.     {
  93.         _activeChar = cha;
  94.         _idTemplate = cha.getTemplate().getIdTemplate();
  95.         _rhand = cha.getWeapon();
  96.         _lhand = 0;
  97.         _chest = cha.getArmor();
  98.         _val = val;
  99.         _collisionHeight = _activeChar.getTemplate().getCollisionHeight();
  100.         _collisionRadius = _activeChar.getTemplate().getCollisionRadius();
  101.  
  102.         _name = cha.getName();
  103.         _title = cha.getOwner() != null ? (cha.getOwner().isOnline() == 0 ? "" : cha.getOwner().getName()) : ""; // when owner online, summon will show in title owner name
  104.         int npcId = cha.getTemplate().getNpcId();
  105.         if (npcId == 16041 || npcId == 16042)
  106.         {
  107.             if (cha.getLevel() > 84)
  108.                 _form = 3;
  109.             else if (cha.getLevel() > 79)
  110.                 _form = 2;
  111.             else if (cha.getLevel() > 74)
  112.                 _form = 1;
  113.         }
  114.         else if (npcId == 16025 || npcId == 16037)
  115.         {
  116.             if (cha.getLevel() > 69)
  117.                 _form = 3;
  118.             else if (cha.getLevel() > 64)
  119.                 _form = 2;
  120.             else if (cha.getLevel() > 59)
  121.                 _form = 1;
  122.         }
  123.  
  124.         _x = _activeChar.getX();
  125.         _y = _activeChar.getY();
  126.         _z = _activeChar.getZ();
  127.         _heading = _activeChar.getHeading();
  128.         _mAtkSpd = _activeChar.getMAtkSpd();
  129.         _pAtkSpd = _activeChar.getPAtkSpd();
  130.         _runSpd = cha.getPetSpeed();
  131.         _walkSpd = cha.isMountable() ? 45 : 30;
  132.         _swimRunSpd = _flRunSpd = _flyRunSpd = _runSpd;
  133.         _swimWalkSpd = _flWalkSpd = _flyWalkSpd = _walkSpd;
  134.     }
  135.  
  136.  
  137.     @Override
  138.     protected void writeImpl(L2GameClient client, L2PcInstance activeChar)
  139.     {
  140.         if(_activeChar instanceof L2Summon)
  141.             if(((L2Summon) _activeChar).getOwner() != null && ((L2Summon) _activeChar).getOwner().getAppearance().isInvisible())
  142.                 return;
  143.         writeC(0x16);
  144.         writeD(_activeChar.getObjectId());
  145.         writeD(_idTemplate + 1000000); // npctype id
  146.         writeD(_activeChar.isAutoAttackable(activeChar) ? 1 : 0);
  147.         writeD(_x);
  148.         writeD(_y);
  149.         writeD(_z);
  150.         writeD(_heading);
  151.         writeD(0x00);
  152.         writeD(_mAtkSpd);
  153.         writeD(_pAtkSpd);
  154.         writeD(_runSpd);
  155.         writeD(_walkSpd);
  156.         writeD(_swimRunSpd/*0x32*/); // swimspeed
  157.         writeD(_swimWalkSpd/*0x32*/); // swimspeed
  158.         writeD(_flRunSpd);
  159.         writeD(_flWalkSpd);
  160.         writeD(_flyRunSpd);
  161.         writeD(_flyWalkSpd);
  162.         writeF(1.1/*_activeChar.getProperMultiplier()*/);
  163.         //writeF(1/*_activeChar.getAttackSpeedMultiplier()*/);
  164.         writeF(_pAtkSpd / 277.478340719);
  165.         writeF(_collisionRadius);
  166.         writeF(_collisionHeight);
  167.         writeD(_rhand); // right hand weapon
  168.         writeD(0);
  169.         writeD(_lhand); // left hand weapon
  170.         writeC(1); // name above char 1=true ... ??
  171.         writeC(_activeChar.isRunning() ? 1 : 0);
  172.         writeC(_activeChar.isInCombat() ? 1 : 0);
  173.         writeC(_activeChar.isAlikeDead() ? 1 : 0);
  174.         writeC(_isSummoned ? 2 : 0); // invisible ?? 0=false  1=true   2=summoned (only works if model has a summon animation)
  175.         writeS(_name);
  176.         writeS(_idTemplate == HellsingConf.Trash2Id ? activeChar.getTitle() : _title);
  177.  
  178.         if(_activeChar instanceof L2Summon)
  179.         {
  180.             writeD(0x01);// Title color 0=client default
  181.             writeD(((L2Summon)_activeChar).getPvpFlag());
  182.             writeD(((L2Summon)_activeChar).getKarma());
  183.         }
  184.         else
  185.         {
  186.             writeD(0);
  187.             writeD(0);
  188.             writeD(0);
  189.         }
  190.  
  191.         writeD(_activeChar.getAbnormalEffect()); // C2
  192.         writeD(0000); // C2
  193.         writeD(0000); // C2
  194.         writeD(0000); // C2
  195.         writeD(0000); // C2
  196.         writeC(0000); // C2
  197.  
  198.         //writeC(_activeChar.getTeam()); // C3  team circle 1-blue, 2-red
  199.         if (Config.CHAMPION_ENABLE)
  200.         {
  201.             writeC(_activeChar.isChampion() ? Config.L2JMOD_CHAMPION_ENABLE_AURA : 0);
  202.         }
  203.         else
  204.         {
  205.             writeC(0);
  206.         }
  207.         writeF(_collisionRadius);
  208.         writeF(_collisionHeight);
  209.         writeD(0x00); // C4
  210.         writeD(0x00); // C6
  211.     }
  212.  
  213.     @Override
  214.     public boolean canBroadcast(L2PcInstance activeChar)
  215.     {
  216.         if (_activeChar instanceof L2Summon && ((L2Summon) _activeChar).getOwner() == activeChar)
  217.             return false;
  218.  
  219.         if (activeChar==null /*|| !activeChar.canSee(_activeChar)*/)
  220.             return false;
  221.  
  222.         return true;
  223.     }
  224.  
  225.     /* (non-Javadoc)
  226.      * @see ru.catssoftware.gameserver.serverpackets.ServerBasePacket#getType()
  227.      */
  228.     @Override
  229.     public String getType()
  230.     {
  231.         return _S__22_NPCINFO;
  232.     }
  233. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement