Advertisement
Guest User

Untitled

a guest
Sep 26th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.02 KB | None | 0 0
  1. package su.westeros.gameserver.serverpackets;
  2.  
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5.  
  6. import su.westeros.gameserver.Config;
  7. import su.westeros.gameserver.instancemanager.CursedWeaponsManager;
  8. import su.westeros.gameserver.instancemanager.ReflectionManager;
  9. import su.westeros.gameserver.model.base.pc.ClassId;
  10. import su.westeros.gameserver.model.base.TeamType;
  11. import su.westeros.gameserver.model.general.Creature;
  12. import su.westeros.gameserver.model.general.Player;
  13. import su.westeros.gameserver.model.general.Decoy;
  14. import su.westeros.gameserver.model.items.Inventory;
  15. import su.westeros.gameserver.model.items.PcInventory;
  16. import su.westeros.gameserver.model.matching.MatchingRoom;
  17. import su.westeros.gameserver.model.pledge.Alliance;
  18. import su.westeros.gameserver.model.pledge.Clan;
  19. import su.westeros.gameserver.skills.effects.EffectCubic;
  20. import su.westeros.gameserver.utils.Location;
  21.  
  22. public class CharInfo extends L2GameServerPacket
  23. {
  24.     private static final Logger _log = LoggerFactory.getLogger(CharInfo.class);
  25.     public static final int[] PAPERDOLL_ORDER =
  26.     {
  27.     Inventory.PAPERDOLL_UNDER, Inventory.PAPERDOLL_HEAD, Inventory.PAPERDOLL_RHAND, Inventory.PAPERDOLL_LHAND,
  28.     Inventory.PAPERDOLL_GLOVES, Inventory.PAPERDOLL_CHEST, Inventory.PAPERDOLL_LEGS, Inventory.PAPERDOLL_FEET,
  29.     Inventory.PAPERDOLL_BACK, Inventory.PAPERDOLL_LRHAND, Inventory.PAPERDOLL_HAIR, Inventory.PAPERDOLL_DHAIR,
  30.     Inventory.PAPERDOLL_RBRACELET, Inventory.PAPERDOLL_LBRACELET, Inventory.PAPERDOLL_DECO1, Inventory.PAPERDOLL_DECO2,
  31.     Inventory.PAPERDOLL_DECO3, Inventory.PAPERDOLL_DECO4, Inventory.PAPERDOLL_DECO5, Inventory.PAPERDOLL_DECO6,
  32.     Inventory.PAPERDOLL_BELT
  33.     };
  34.     private int[][] _inv;
  35.     private boolean _isPartyRoomLeader, _isFlying;
  36.     private Location _loc, _fishLoc;
  37.     private int _mAtkSpd, _pAtkSpd, mevasion, maccuracy, mCritRate;
  38.     private String _name, _title;
  39.     private int _nameColor, _title_color, _transform, _agathion, _clanBoatObjectId;
  40.     private int _noble, _hero, _fishing, mount_type;
  41.     private int _objId, _race, _sex, base_class, pvp_flag, karma, rec_have;
  42.     private int _runSpd, _walkSpd, _swimSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd;
  43.     private int _sit, _run, _combat, _dead, private_store, _enchant;
  44.     private TeamType _team;
  45.     private int clan_id, clan_crest_id, large_clan_crest_id, ally_id, ally_crest_id, class_id;
  46.     private EffectCubic[] cubics;
  47.     private int curHP, maxHP, curMP, maxMP;
  48.     private int hair_style, hair_color, face, _abnormalEffect, _abnormalEffect2;
  49.     private int plg_class, pledge_type, clan_rep_score, cw_level, mount_id;
  50.     private double speed_move, speed_atack, col_radius, col_height;
  51.  
  52.     public CharInfo(Creature cha)
  53.     {
  54.     if (cha == null)
  55.     {
  56.         System.out.println("CharInfo: cha is null!");
  57.         Thread.dumpStack();
  58.  
  59.         return;
  60.     }
  61.  
  62.     if (cha.isInvisible())
  63.     {
  64.         return;
  65.     }
  66.  
  67.     if (cha.isDeleted())
  68.     {
  69.         return;
  70.     }
  71.  
  72.     Player player = cha.getPlayer();
  73.  
  74.     if (player == null)
  75.     {
  76.         return;
  77.     }
  78.  
  79.     if (player.isInBoat())
  80.     {
  81.         _loc = player.getInBoatPosition();
  82.  
  83.         if (player.isClanAirShipDriver())
  84.         {
  85.         _clanBoatObjectId = player.getBoat().getBoatId();
  86.         }
  87.     }
  88.  
  89.     if (_loc == null)
  90.     {
  91.         _loc = cha.getLoc();
  92.     }
  93.  
  94.     _objId = cha.getObjectId();
  95.  
  96.     // Проклятое оружие и трансформации для ТВ скрывают имя и все остальные опознавательные знаки
  97.     if ((player.getTransformationName() != null)
  98.            || ((player.getReflection() == ReflectionManager.GIRAN_HARBOR)
  99.            || (player.getReflection() == ReflectionManager.PARNASSUS)) && (player.getPrivateStoreType()
  100.            != Player.STORE_PRIVATE_NONE))
  101.     {
  102.         _name = (player.getTransformationName() != null) ? player.getTransformationName() : player.getName();
  103.         _title = "";
  104.         clan_id = 0;
  105.         clan_crest_id = 0;
  106.         ally_id = 0;
  107.         ally_crest_id = 0;
  108.         large_clan_crest_id = 0;
  109.  
  110.         if (player.isCursedWeaponEquipped())
  111.         {
  112.         cw_level = CursedWeaponsManager.getInstance().getLevel(player.getCursedWeaponEquippedId());
  113.         }
  114.     }
  115.     else
  116.     {
  117.         _name = player.getName();
  118.  
  119.         if (player.getPrivateStoreType() != Player.STORE_PRIVATE_NONE)
  120.         {
  121.         _title = "";
  122.         }
  123.         else if (!player.isConnected())
  124.         {
  125.         _title = "NO CARRIER";
  126.         _title_color = 255;
  127.         }
  128.         else
  129.         {
  130.         _title = player.getTitle();
  131.         _title_color = player.getTitleColor();
  132.         }
  133.  
  134.         Clan clan = player.getClan();
  135.         Alliance alliance = (clan == null) ? null : clan.getAlliance();
  136.  
  137.         //
  138.         clan_id = (clan == null) ? 0 : clan.getClanId();
  139.         clan_crest_id = (clan == null) ? 0 : clan.getCrestId();
  140.         large_clan_crest_id = (clan == null) ? 0 : clan.getCrestLargeId();
  141.  
  142.         //
  143.         ally_id = (alliance == null) ? 0 : alliance.getAllyId();
  144.         ally_crest_id = (alliance == null) ? 0 : alliance.getAllyCrestId();
  145.         cw_level = 0;
  146.     }
  147.  
  148.     if (player.isMounted())
  149.     {
  150.         _enchant = 0;
  151.         mount_id = player.getMountNpcId() + 1000000;
  152.         mount_type = player.getMountType();
  153.     }
  154.     else
  155.     {
  156.         _enchant = player.getEnchantEffect();
  157.         mount_id = 0;
  158.         mount_type = 0;
  159.     }
  160.  
  161.     _inv = new int[PcInventory.PAPERDOLL_MAX][2];
  162.  
  163.     for (int PAPERDOLL_ID : PAPERDOLL_ORDER)
  164.     {
  165.         _inv[PAPERDOLL_ID][0] = player.getInventory().getPaperdollItemId(PAPERDOLL_ID);
  166.         _inv[PAPERDOLL_ID][1] = player.getInventory().getPaperdollAugmentationId(PAPERDOLL_ID);
  167.     }
  168.  
  169.     _mAtkSpd = player.getMAtkSpd();
  170.     _pAtkSpd = player.getPAtkSpd();
  171.     speed_move = player.getMovementSpeedMultiplier();
  172.     _runSpd = (int) (player.getRunSpeed() / speed_move);
  173.     _walkSpd = (int) (player.getWalkSpeed() / speed_move);
  174.     _flRunSpd = 0;    // TODO
  175.     _flWalkSpd = 0;    // TODO
  176.  
  177.     if (player.isFlying())
  178.     {
  179.         _flyRunSpd = _runSpd;
  180.         _flyWalkSpd = _walkSpd;
  181.     }
  182.     else
  183.     {
  184.         _flyRunSpd = 0;
  185.         _flyWalkSpd = 0;
  186.     }
  187.  
  188.     _swimSpd = player.getSwimSpeed();
  189.     _race = player.getRace().ordinal();
  190.     _sex = player.getSex();
  191.    
  192.     base_class = player.getBaseClassId().getOrdinalClass().getId();
  193.    
  194.     pvp_flag = player.getPvpFlag();
  195.     karma = player.getKarma();
  196.     speed_atack = player.getAttackSpeedMultiplier();
  197.     col_radius = player.getColRadius();
  198.     col_height = player.getColHeight();
  199.     hair_style = player.getHairStyle();
  200.     hair_color = player.getHairColor();
  201.     face = player.getFace();
  202.  
  203.     if ((clan_id > 0) && (player.getClan() != null))
  204.     {
  205.         clan_rep_score = player.getClan().getReputationScore();
  206.     }
  207.     else
  208.     {
  209.         clan_rep_score = 0;
  210.     }
  211.  
  212.     _sit = player.isSitting() ? 0 : 1;    // standing = 1 sitting = 0
  213.     _run = player.isRunning() ? 1 : 0;    // running = 1 walking = 0
  214.     _combat = player.isInCombat() ? 1 : 0;
  215.     _dead = player.isAlikeDead() ? 1 : 0;
  216.     private_store = player.isInObserverMode() ? Player.STORE_OBSERVING_GAMES : player.getPrivateStoreType();
  217.     cubics = player.getCubics().toArray(new EffectCubic[player.getCubics().size()]);
  218.     _abnormalEffect = player.getAbnormalEffect();
  219.     _abnormalEffect2 = player.getAbnormalEffect2();
  220.     rec_have = player.isGM() ? 0 : player.getRecomHave();
  221.     class_id = player.getClassId().getDisplayId();
  222.     _team = player.getTeam();
  223.     _noble = player.isNoble() ? 1 : 0;    // 0x01: symbol on char menu ctrl+I
  224.     _hero = (player.isHero() || (player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0;    // 0x01: Hero Aura
  225.     _fishing = player.isFishing() ? 1 : 0;
  226.     _fishLoc = player.getFishLoc();
  227.     _nameColor = player.getNameColor();    // New C5
  228.     plg_class = player.getSocialRank().ordinal();
  229.     pledge_type = player.getPledgeType();
  230.     _transform = player.getTransformation();
  231.     _agathion = player.getAgathionId();
  232.     _isPartyRoomLeader = (player.getMatchingRoom() != null)
  233.            && (player.getMatchingRoom().getType() == MatchingRoom.PARTY_MATCHING)
  234.            && (player.getMatchingRoom().getLeader() == player);
  235.     _isFlying = player.isInFlyingTransform();
  236.     mevasion = player.getMEvasionRate(null);
  237.     maccuracy = player.getMAccuracy();
  238.     mCritRate = (int) player.getMagicCriticalHit(null, null);
  239.     curHP = (int) player.getCurrentHp();
  240.     maxHP = player.getMaxHp();
  241.     curMP = (int) player.getCurrentMp();
  242.     maxMP = player.getMaxMp();
  243.     }
  244.  
  245.     public CharInfo(Decoy cha)
  246.     {
  247.     this((Creature) cha);
  248.     }
  249.  
  250.     public CharInfo(Player cha)
  251.     {
  252.     this((Creature) cha);
  253.     }
  254.  
  255.     @Override
  256.     protected final void writeImpl()
  257.     {
  258.     Player activeChar = getClient().getActiveChar();
  259.  
  260.     if (activeChar == null)
  261.     {
  262.         return;
  263.     }
  264.  
  265.     if (_objId == 0)
  266.     {
  267.         return;
  268.     }
  269.  
  270.     if (activeChar.getObjectId() == _objId)
  271.     {
  272.         _log.error("You cant send CharInfo about his character to active user!!!");
  273.  
  274.         return;
  275.     }
  276.  
  277.     writeC(0x31);
  278.     writeD(_loc.x);
  279.     writeD(_loc.y);
  280.     writeD(_loc.z + Config.CLIENT_Z_SHIFT);
  281.     writeD(_clanBoatObjectId);
  282.     writeD(_objId);
  283.     writeS(_name);
  284.     writeD(_race);
  285.     writeD(_sex);
  286.     writeD(base_class);
  287.  
  288.     for (int PAPERDOLL_ID : PAPERDOLL_ORDER)
  289.     {
  290.         writeD(_inv[PAPERDOLL_ID][0]);
  291.     }
  292.  
  293.     for (int PAPERDOLL_ID : PAPERDOLL_ORDER)
  294.     {
  295.         writeD(_inv[PAPERDOLL_ID][1]);
  296.     }
  297.  
  298.     writeD(0x01);    // TODO talisman count(VISTALL)
  299.     writeD(0x00);    // TODO cloak status(VISTALL)
  300.     writeD(pvp_flag);
  301.     writeD(karma);
  302.     writeD(mevasion);
  303.     writeD(maccuracy);
  304.     writeD(mCritRate);
  305.     writeD(_mAtkSpd);
  306.     writeD(_pAtkSpd);
  307.     writeD(0x00);
  308.     writeD(_runSpd);
  309.     writeD(_walkSpd);
  310.     writeD(_swimSpd);
  311.     writeD(_swimSpd);
  312.     writeD(_flRunSpd);
  313.     writeD(_flWalkSpd);
  314.     writeD(_flyRunSpd);
  315.     writeD(_flyWalkSpd);
  316.     writeF(speed_move);    // _cha.getProperMultiplier()
  317.     writeF(speed_atack);    // _cha.getAttackSpeedMultiplier()
  318.     writeF(col_radius);
  319.     writeF(col_height);
  320.     writeD(hair_style);
  321.     writeD(hair_color);
  322.     writeD(face);
  323.     writeS(_title);
  324.     writeD(clan_id);
  325.     writeD(clan_crest_id);
  326.     writeD(ally_id);
  327.     writeD(ally_crest_id);
  328.     writeC(_sit);
  329.     writeC(_run);
  330.     writeC(_combat);
  331.     writeC(_dead);
  332.     writeC(0x00);    // is invisible
  333.     writeC(mount_type);    // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
  334.     writeC(private_store);
  335.     writeH(cubics.length);
  336.  
  337.     for (EffectCubic cubic : cubics)
  338.     {
  339.         writeH((cubic == null) ? 0 : cubic.getId());
  340.     }
  341.  
  342.     writeC(_isPartyRoomLeader ? 0x01 : 0x00);    // find party members
  343.     writeD(_abnormalEffect);
  344.     writeC(_isFlying ? 0x02 : 0x00);
  345.     writeH(rec_have);
  346.     writeD(mount_id);
  347.     writeD(class_id);
  348.     writeD(0x00);    // unknown
  349.     writeC(_enchant);
  350.     writeC(_team.ordinal());    // team circle around feet 1 = Blue, 2 = red
  351.     writeD(large_clan_crest_id);
  352.     writeC(_noble);
  353.     writeC(_hero);
  354.     writeC(_fishing);
  355.     writeD(_fishLoc.x);
  356.     writeD(_fishLoc.y);
  357.     writeD(_fishLoc.z);
  358.     writeD(_nameColor);
  359.     writeD(_loc.h);
  360.     writeD(plg_class);
  361.     writeD(pledge_type);
  362.     writeD(_title_color);
  363.     writeD(cw_level);
  364.     writeD(clan_rep_score);
  365.     writeD(_transform);
  366.     writeD(_agathion);
  367.     writeD(0x01);    // T2
  368.     writeD(_abnormalEffect2);
  369.     writeD(0x00);    // Unknown1 (GOD)
  370.     writeD(0x00);    // Unknown2 (GOD)
  371.     writeD(0x00);    // Unknown3 (GOD)
  372.     writeD(0x00);    // Unknown4 (GOD)
  373.     writeD(curHP);
  374.     writeD(maxHP);
  375.     writeD(curMP);
  376.     writeD(maxMP);
  377.     writeD(0x00);    // Unknown9 (GOD)
  378.     writeC(0x00);    // Unknown10 (GOD)
  379.     }
  380. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement