package Alfa.game.serverpackets;
import javolution.util.FastList;
import Alfa.Config;
import Alfa.game.instancemanager.CursedWeaponsManager;
import Alfa.game.model.Inventory;
import Alfa.game.model.L2Player;
import Alfa.game.model.L2Skill;
import Alfa.game.model.PcInventory;
import Alfa.game.tables.NpcTable;
import Alfa.util.Location;
public class UserInfo extends L2GameServerPacket
{
private static final String _S__04_USERINFO = "[S] 04 UserInfo";
private boolean can_writeImpl = false;
private final L2Player _cha;
private int _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd, _relation;
private float move_speed, attack_speed, col_radius, col_height;
private PcInventory _inv;
private Location _loc, _fishLoc;
private int obj_id, _race, sex, base_class, level, curCp, maxCp, _enchant;
private long _exp;
private int curHp, maxHp, curMp, maxMp, curLoad, maxLoad, rec_left, rec_have;
private int _str, _con, _dex, _int, _wit, _men, _sp, ClanPrivs, InventoryLimit;
private int _patk, _patkspd, _pdef, evasion, accuracy, crit, _matk, _matkspd;
private int _mdef, pvp_flag, karma, hair_style, hair_color, face, gm_commands;
private int clan_id, clan_crest_id, ally_id, ally_crest_id, large_clan_crest_id;
private int private_store, can_crystalize, pk_kills, pvp_kills, class_id, agathion, vitalityLevel, fame;
private int team, AbnormalEffect, noble, hero, fishing, mount_id, cw_level;
private int name_color, running, pledge_class, pledge_type, title_color, transformation;
private int DefenceFire, DefenceWater, DefenceWind, DefenceEarth, DefenceHoly, DefenceUnholy;
private byte mount_type;
private String _name, title;
private FastList<Integer> _cubics;
private int[] attackElement;
public UserInfo(L2Player cha)
{
_cha = cha;
}
@Override
final public void runImpl()
{
L2Player activeChar = getClient().getActiveChar();
if(activeChar == null)
return;
if(!activeChar.equals(_cha))
return;
if(_cha.isCursedWeaponEquipped())
{
_name = _cha.getTransformationName();
clan_crest_id = 0;
ally_crest_id = 0;
large_clan_crest_id = 0;
cw_level = CursedWeaponsManager.getInstance().getLevel(_cha.getCursedWeaponEquippedId());
}
else
{
_name = _cha.getName();
clan_crest_id = _cha.getClanCrestId();
ally_crest_id = _cha.getAllyCrestId();
large_clan_crest_id = _cha.getClanCrestLargeId();
cw_level = 0;
}
if(_cha.isMounted())
{
_enchant = 0;
mount_id = _cha.getMountNpcId() + 1000000;
mount_type = (byte) _cha.getMountType();
}
else
{
_enchant = (byte) _cha.getEnchantEffect();
mount_id = 0;
mount_type = 0;
}
move_speed = _cha.getMovementSpeedMultiplier();
_runSpd = (int) (_cha.getRunSpeed() / move_speed);
_walkSpd = (int) (_cha.getWalkSpeed() / move_speed);
_flRunSpd = _flyRunSpd = _runSpd;
_flWalkSpd = _flyWalkSpd = _walkSpd;
_swimRunSpd = _cha.getSwimSpeed();
_swimWalkSpd = _cha.getSwimSpeed();
_inv = _cha.getInventory();
_relation = _cha.isClanLeader() ? 0x40 : 0;
if(_cha.getSiegeState() == 1)
_relation |= 0x180;
else if(_cha.getSiegeState() == 2)
_relation |= 0x80;
_loc = _cha.getLoc();
obj_id = _cha.getObjectId();
_race = _cha.getRace().ordinal();
sex = _cha.getSex();
base_class = _cha.getBaseClass();
level = _cha.getLevel();
_exp = _cha.getExp();
_str = _cha.getSTR();
_dex = _cha.getDEX();
_con = _cha.getCON();
_int = _cha.getINT();
_wit = _cha.getWIT();
_men = _cha.getMEN();
curHp = (int) _cha.getCurrentHp();
maxHp = _cha.getMaxHp();
curMp = (int) _cha.getCurrentMp();
maxMp = _cha.getMaxMp();
curLoad = _cha.getCurrentLoad();
maxLoad = _cha.getMaxLoad();
_sp = _cha.getSp();
_patk = _cha.getPAtk(null);
_patkspd = _cha.getPAtkSpd();
_pdef = _cha.getPDef(null);
evasion = _cha.getEvasionRate(null);
accuracy = _cha.getAccuracy();
crit = _cha.getCriticalHit(null, null);
_matk = _cha.getMAtk(null, null);
_matkspd = _cha.getMAtkSpd();
_mdef = _cha.getMDef(null, null);
pvp_flag = _cha.getPvpFlag(); // 0=white, 1=purple, 2=purpleblink
karma = _cha.getKarma();
attack_speed = _cha.getAttackSpeedMultiplier();
col_radius = _cha.getColRadius();
col_height = _cha.getColHeight();
hair_style = _cha.getHairStyle();
hair_color = _cha.getHairColor();
face = _cha.getFace();
gm_commands = _cha.getPlayerAccess().IsGM || _cha.getPlayerAccess().UseGMComand || Config.ALLOW_SPECIAL_COMMANDS ? 1 : 0;
// builder level активирует в клиенте админские команды
title = _cha.getTitle();
if(_cha.isInvisible())
title = "Invisible";
if(_cha.isPolymorphed())
title += " - " + NpcTable.getTemplate(_cha.getPolyid()).name;
clan_id = _cha.getClanId();
ally_id = _cha.getAllyId();
private_store = _cha.getPrivateStoreType();
can_crystalize = _cha.getSkillLevel(L2Skill.SKILL_CRYSTALLIZE) > 0 ? 1 : 0;
pk_kills = _cha.getPkKills();
pvp_kills = _cha.getPvpKills();
_cubics = new FastList<Integer>();
for(int id : _cha.getCubics().keySet())
_cubics.add(id);
AbnormalEffect = _cha.getAbnormalEffect();
ClanPrivs = _cha.getClanPrivileges();
rec_left = _cha.getRecomLeft(); //c2 recommendations remaining
rec_have = _cha.getPlayerAccess().IsGM ? 0 : _cha.getRecomHave(); //c2 recommendations received
InventoryLimit = _cha.getInventoryLimit();
class_id = _cha.getClassId().getId();
maxCp = _cha.getMaxCp();
curCp = (int) _cha.getCurrentCp();
team = _cha.getTeam(); //team circle around feet 1= Blue, 2 = red
noble = _cha.isNoble() || _cha.isGM() && Config.GM_HERO_AURA ? 1 : 0; //0x01: symbol on char menu ctrl+I
hero = _cha.isHero() || _cha.isGM() && Config.GM_HERO_AURA ? 1 : 0; //0x01: Hero Aura and symbol
fishing = _cha.isFishing() ? 1 : 0; // Fishing Mode
_fishLoc = _cha.getFishLoc();
name_color = _cha.getNameColor();
running = _cha.isRunning() ? 0x01 : 0x00; //changes the Speed display on Status Window
pledge_class = _cha.getPledgeClass();
pledge_type = _cha.getPledgeType();
title_color = _cha.getTitleColor();
transformation = _cha.getTransformation();
attackElement = _cha.getAttackElement();
DefenceFire = _cha.getDefenceFire();
DefenceWater = _cha.getDefenceWater();
DefenceWind = _cha.getDefenceWind();
DefenceEarth = _cha.getDefenceEarth();
DefenceHoly = _cha.getDefenceHoly();
DefenceUnholy = _cha.getDefenceUnholy();
agathion = _cha.getAgathion() != null ? _cha.getAgathion().getId() : 0; //агнишен
vitalityLevel = _cha.getVitalityLevel();
fame = _cha.getFame();
_cha.refreshSavedStats();
if(_cha.isMounted())
getClient().sendPacket(new Ride(_cha));
can_writeImpl = true;
}
@Override
protected final void writeImpl()
{
if(!can_writeImpl)
return;
writeC(0x32);
writeD(_loc.x);
writeD(_loc.y);
writeD(_loc.z);
writeD(_loc.h < 7 ? 7 : _loc.h / 7 * 7); // мальенькая хитрость препятствующая использованию патча на других серверах
writeD(obj_id);
writeS(_name);
writeD(_race);
writeD(sex);
writeD(base_class);
writeD(level);
writeQ(_exp);
writeD(_str);
writeD(_dex);
writeD(_con);
writeD(_int);
writeD(_wit);
writeD(_men);
writeD(maxHp);
writeD(curHp);
writeD(maxMp);
writeD(curMp);
writeD(_sp);
writeD(curLoad);
writeD(maxLoad);
writeD(0x28); // unknown. В снифе бывает 0х28 и 0х14
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_UNDER));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_CHEST));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LEGS));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_FEET));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
writeD(0);//writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LRHAND));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DHAIR));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_RBRACELET));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_LBRACELET));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[0]));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[1]));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[2]));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[3]));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[4]));
writeD(_inv.getPaperdollObjectId(Inventory.PAPERDOLL_DECO[5]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_UNDER));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_REAR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_NECK));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(0);//writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DHAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[0]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[1]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[2]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[3]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[4]));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO[5]));
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
//TODO: Не совсем верная, должны быть H для аугмента.
writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_RHAND));
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeH(0x00);
writeD(_patk);
writeD(_patkspd);
writeD(_pdef);
writeD(evasion);
writeD(accuracy);
writeD(crit);
writeD(_matk);
writeD(_matkspd);
writeD(_patkspd);
writeD(_mdef);
writeD(pvp_flag);
writeD(karma);
writeD(_runSpd);
writeD(_walkSpd);
writeD(_swimRunSpd); // swimspeed
writeD(_swimWalkSpd); // swimspeed
writeD(_flRunSpd);
writeD(_flWalkSpd);
writeD(_flyRunSpd);
writeD(_flyWalkSpd);
writeF(move_speed);
writeF(attack_speed);
writeF(col_radius);
writeF(col_height);
writeD(hair_style);
writeD(hair_color);
writeD(face);
writeD(gm_commands);
writeS(title);
writeD(clan_id);
writeD(clan_crest_id);
writeD(ally_id);
writeD(ally_crest_id);
// 0x40 leader rights
// siege flags: attacker - 0x180 sword over name, defender - 0x80 shield, 0xC0 crown (|leader), 0x1C0 flag (|leader)
writeD(_relation);
writeC(mount_type); // mount type
writeC(private_store);
writeC(can_crystalize);
writeD(pk_kills);
writeD(pvp_kills);
writeH(_cubics.size());
while(_cubics.size() > 0)
writeH(_cubics.removeFirst());
writeC(0x00); //1-find party members
writeD(AbnormalEffect);
writeC(0x11);
writeD(ClanPrivs);
writeH(rec_left);
writeH(rec_have);
writeD(mount_id);
writeH(InventoryLimit);
writeD(class_id);
writeD(0x00); // special effects? circles around player...
writeD(maxCp);
writeD(curCp);
writeC(_enchant);
writeC(team);
writeD(large_clan_crest_id);
writeC(noble);
writeC(hero);
writeC(fishing);
writeD(_fishLoc.x);
writeD(_fishLoc.y);
writeD(_fishLoc.z);
writeD(name_color);
writeC(running);
writeD(pledge_class);
writeD(pledge_type);
writeD(title_color);
writeD(cw_level);
writeD(transformation); // Transformation id
// AttackElement (0 - Fire, 1 - Water, 2 - Wind, 3 - Earth, 4 - Holy, 5 - Dark, -2 - None)
writeD(attackElement == null ? -2 : attackElement[0]);
writeD(attackElement == null ? 0 : attackElement[1]); // AttackElementValue
writeD(DefenceFire); // DefAttrFire
writeD(DefenceWater); // DefAttrWater
writeD(DefenceWind); // DefAttrWind
writeD(DefenceEarth); // DefAttrEarth
writeD(DefenceHoly); // DefAttrHoly
writeD(DefenceUnholy); // DefAttrUnholy
writeD(agathion);
writeD(fame); // Fame
writeD(0x00); // Unknown
writeD(vitalityLevel); // Vitality Level
}
@Override
public String getType()
{
return _S__04_USERINFO;
}
}