/*
* 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 com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
/**
*
* @author devScarlet & mrTJO
*/
public final class ServerObjectInfo extends L2GameServerPacket
{
private static final String _S__92_SERVEROBJECTINFO = "[S] 92 ServerObjectInfo";
private L2Npc _activeChar;
private int _x, _y, _z, _heading;
private int _idTemplate;
private boolean _isAttackable;
private double _collisionHeight, _collisionRadius;
private String _name;
public ServerObjectInfo(L2Npc activeChar, L2Character actor)
{
_activeChar = activeChar;
_idTemplate = _activeChar.getTemplate().idTemplate;
_isAttackable = _activeChar.isAutoAttackable(actor);
_collisionHeight = _activeChar.getCollisionHeight();
_collisionRadius = _activeChar.getCollisionRadius();
_x = _activeChar.getX();
_y = _activeChar.getY();
_z = _activeChar.getZ();
_heading = _activeChar.getHeading();
_name = _activeChar.getTemplate().serverSideName ? _activeChar.getTemplate().name : "";
}
/**
* @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
*/
@Override
protected final void writeImpl()
{
writeC(0x92);
writeD(_activeChar.getObjectId());
writeD(_idTemplate+1000000);
writeS(_name); // name
writeD(_isAttackable ? 1 : 0);
writeD(_x);
writeD(_y);
writeD(_z);
writeD(_heading);
writeF(1.0); // movement multiplier
writeF(1.0); // attack speed multiplier
writeF(_collisionRadius);
writeF(_collisionHeight);
writeD((int) (_isAttackable ? _activeChar.getCurrentHp() : 0));
writeD(_isAttackable ? _activeChar.getMaxVisibleHp() : 0);
writeD(0x01); // object type
writeD(0x00); // special effects
}
/**
* @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
*/
@Override
public String getType()
{
return _S__92_SERVEROBJECTINFO;
}
}