* @see com.l2jfrozen.gameserver.model.L2Object#onActionShift(com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance)
*/
@Override
public void onActionShift(L2PcInstance player)
{
L2Weapon currentWeapon = player.getActiveWeaponItem();
if (player.isGM())
{
if (this != player.getTarget())
{
player.setTarget(this);
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
if (player != this)
{
player.sendPacket(new ValidateLocation(this));
// To be sure update also the pvp flag / war tag status
if (!player.inObserverMode())
this.broadcastUserInfo();
}
}
else
{
AdminEditChar.gatherCharacterInfo(player, this, "charinfo.htm");
}
}
else
// Like L2OFF set the target of the L2PcInstance player
{
if (((TvT.is_started() || TvT.is_teleport()) && !Config.TVT_ALLOW_INTERFERENCE) || ((CTF.is_started() || CTF.is_teleport()) && !Config.CTF_ALLOW_INTERFERENCE) || ((DM.is_started() || DM.is_teleport()) && !Config.DM_ALLOW_INTERFERENCE))
{
if ((_inEventTvT && !player._inEventTvT) || (!_inEventTvT && player._inEventTvT))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((_inEventCTF && !player._inEventCTF) || (!_inEventCTF && player._inEventCTF))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((_inEventDM && !player._inEventDM) || (!_inEventDM && player._inEventDM))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
// Check if the L2PcInstance is confused
if (player.isOutOfControl())
{
// Send a Server->Client packet ActionFailed to the player
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Check if the player already target this L2PcInstance
if (player.getTarget() != this)
{
// Set the target of the player
player.setTarget(this);
// Send a Server->Client packet MyTargetSelected to the player
// The color to display in the select window is White
player.sendPacket(new MyTargetSelected(getObjectId(), 0));
if (player != this)
{
player.sendPacket(new ValidateLocation(this));
}
}
else
{
if (player != this)
{
player.sendPacket(new ValidateLocation(this));
}
// Check if this L2PcInstance has a Private Store
if (getPrivateStoreType() != 0)
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
// Calculate the distance between the L2PcInstance
if (canInteract(player))
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
}
}
else
{
// Check if this L2PcInstance is autoAttackable
// if (isAutoAttackable(player) || (player._inEventTvT && TvT._started) || (player._inEventCTF && CTF._started) || (player._inEventDM && DM._started) || (player._inEventVIP && VIP._started))
if (isAutoAttackable(player))
{
if (Config.ALLOW_CHAR_KILL_PROTECT)
{
Siege siege = SiegeManager.getInstance().getSiege(player);
if (siege != null && siege.getIsInProgress())
{
if (player.getLevel() > 20 && ((L2Character) player.getTarget()).getLevel() < 20)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() > 40 && ((L2Character) player.getTarget()).getLevel() < 40)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() > 52 && ((L2Character) player.getTarget()).getLevel() < 52)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() > 61 && ((L2Character) player.getTarget()).getLevel() < 61)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() > 76 && ((L2Character) player.getTarget()).getLevel() < 76)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() < 20 && ((L2Character) player.getTarget()).getLevel() > 20)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() < 40 && ((L2Character) player.getTarget()).getLevel() > 40)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() < 52 && ((L2Character) player.getTarget()).getLevel() > 52)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() < 61 && ((L2Character) player.getTarget()).getLevel() > 61)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
if (player.getLevel() < 76 && ((L2Character) player.getTarget()).getLevel() > 76)
{
player.sendMessage("Your target is not in your grade!");
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
siege = null;
}
if (player.getLevel() < Config.ALT_PLAYER_PROTECTION_LEVEL || getLevel() < Config.ALT_PLAYER_PROTECTION_LEVEL)
{
player.sendMessage("You Can't Hit a Player That Is Lower Level From You. Target's Level: " + String.valueOf(Config.ALT_PLAYER_PROTECTION_LEVEL));
player.sendPacket(ActionFailed.STATIC_PACKET);
}
// Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21
if (isCursedWeaponEquiped() && player.getLevel() < 21 || player.isCursedWeaponEquiped() && getLevel() < 21)
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
else
{
if (Config.GEODATA > 0)
{
if (GeoData.getInstance().canSeeTarget(player, this))
{
// Calculate the distance between the L2PcInstance
// Only archer can hit from long
if (currentWeapon != null && currentWeapon.getItemType() == L2WeaponType.BOW)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
player.onActionRequest();
}
else if (canInteract(player))
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
player.onActionRequest();
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}
else
{
// Calculate the distance between the L2PcInstance
// Only archer can hit from long
if (currentWeapon != null && currentWeapon.getItemType() == L2WeaponType.BOW)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
player.onActionRequest();
}
else if (canInteract(player))
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
player.onActionRequest();
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}
}
else
{
if (Config.GEODATA > 0)
{
if (GeoData.getInstance().canSeeTarget(player, this))
{
// Calculate the distance between the L2PcInstance
// Only archer can hit from long
if (currentWeapon != null && currentWeapon.getItemType() == L2WeaponType.BOW)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
}
else if (canInteract(player))
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
}
else
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
}
else
{
// Calculate the distance between the L2PcInstance
// Only archer can hit from long
if (currentWeapon != null && currentWeapon.getItemType() == L2WeaponType.BOW)
{
player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
}
else if (canInteract(player))
{