Updated Die serverpacket.
This commit is contained in:
parent
603cbf4492
commit
5a24b99391
@ -16,10 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
@ -31,25 +27,18 @@ import org.l2jmobius.gameserver.model.entity.Fort;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, Nos
|
||||
* @author Mobius
|
||||
*/
|
||||
public class Die implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _objectId;
|
||||
private boolean _toVillage;
|
||||
private boolean _toClanHall;
|
||||
private boolean _toCastle;
|
||||
private boolean _toOutpost;
|
||||
private final boolean _isSweepable;
|
||||
private boolean _useFeather;
|
||||
private boolean _toFortress;
|
||||
private boolean _hideAnimation;
|
||||
private List<Integer> _items = null;
|
||||
private boolean _itemsEnabled;
|
||||
private int _flags = 0;
|
||||
|
||||
public Die(Creature creature)
|
||||
{
|
||||
_objectId = creature.getObjectId();
|
||||
_isSweepable = creature.isAttackable() && creature.isSweepActive();
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final Clan clan = creature.getActingPlayer().getClan();
|
||||
@ -70,47 +59,32 @@ public class Die implements IClientOutgoingPacket
|
||||
isInFortDefense = (siegeClan == null) && fort.getSiege().checkIsDefender(clan);
|
||||
}
|
||||
|
||||
_toVillage = creature.canRevive() && !creature.isPendingRevive();
|
||||
_toClanHall = (clan != null) && (clan.getHideoutId() > 0);
|
||||
_toCastle = ((clan != null) && (clan.getCastleId() > 0)) || isInCastleDefense;
|
||||
_toOutpost = ((siegeClan != null) && !isInCastleDefense && !isInFortDefense && !siegeClan.getFlag().isEmpty());
|
||||
_useFeather = creature.getAccessLevel().allowFixedRes() || creature.getInventory().haveItemForSelfResurrection();
|
||||
_toFortress = ((clan != null) && (clan.getFortId() > 0)) || isInFortDefense;
|
||||
// ClanHall check.
|
||||
if ((clan != null) && (clan.getHideoutId() > 0))
|
||||
{
|
||||
_flags += 2;
|
||||
}
|
||||
// Castle check.
|
||||
if (((clan != null) && (clan.getCastleId() > 0)) || isInCastleDefense)
|
||||
{
|
||||
_flags += 4;
|
||||
}
|
||||
// Fortress check.
|
||||
if (((clan != null) && (clan.getFortId() > 0)) || isInFortDefense)
|
||||
{
|
||||
_flags += 8;
|
||||
}
|
||||
// Outpost check.
|
||||
if (((siegeClan != null) && !isInCastleDefense && !isInFortDefense && !siegeClan.getFlag().isEmpty()))
|
||||
{
|
||||
_flags += 16;
|
||||
}
|
||||
// Feather check.
|
||||
if (creature.getAccessLevel().allowFixedRes() || creature.getInventory().haveItemForSelfResurrection())
|
||||
{
|
||||
_flags += 32;
|
||||
}
|
||||
}
|
||||
|
||||
_isSweepable = creature.isAttackable() && creature.isSweepActive();
|
||||
}
|
||||
|
||||
public void setHideAnimation(boolean val)
|
||||
{
|
||||
_hideAnimation = val;
|
||||
}
|
||||
|
||||
public void addItem(int itemId)
|
||||
{
|
||||
if (_items == null)
|
||||
{
|
||||
_items = new ArrayList<>(8);
|
||||
}
|
||||
|
||||
if (_items.size() < 8)
|
||||
{
|
||||
_items.add(itemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IndexOutOfBoundsException("Die packet doesn't support more then 8 items!");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Integer> getItems()
|
||||
{
|
||||
return _items != null ? _items : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void setItemsEnabled(boolean val)
|
||||
{
|
||||
_itemsEnabled = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,20 +93,10 @@ public class Die implements IClientOutgoingPacket
|
||||
OutgoingPackets.DIE.writeId(packet);
|
||||
|
||||
packet.writeD(_objectId);
|
||||
packet.writeD(_toVillage ? 0x01 : 0x00);
|
||||
packet.writeD(_toClanHall ? 0x01 : 0x00);
|
||||
packet.writeD(_toCastle ? 0x01 : 0x00);
|
||||
packet.writeD(_toOutpost ? 0x01 : 0x00);
|
||||
packet.writeD(_isSweepable ? 0x01 : 0x00);
|
||||
packet.writeD(_useFeather ? 0x01 : 0x00);
|
||||
packet.writeD(_toFortress ? 0x01 : 0x00);
|
||||
packet.writeD(0x00); // Disables use Feather button for X seconds
|
||||
packet.writeD(0x00); // Adventure's Song
|
||||
packet.writeC(_hideAnimation ? 0x01 : 0x00);
|
||||
|
||||
packet.writeD(_itemsEnabled ? 0x01 : 0x00);
|
||||
packet.writeD(getItems().size());
|
||||
getItems().forEach(packet::writeD);
|
||||
packet.writeC(_flags);
|
||||
packet.writeC(0);
|
||||
packet.writeC(_isSweepable ? 1 : 0);
|
||||
packet.writeC(0); // 1: Resurrection during siege.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user