Sync with L2jServer HighFive May 19th 2015.

This commit is contained in:
MobiusDev
2015-05-19 14:57:13 +00:00
parent 0337dd64a2
commit 6b9ed81821
17 changed files with 146 additions and 124 deletions

View File

@ -19,18 +19,18 @@
package handlers.actionhandlers;
import com.l2jserver.Config;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.handler.IActionHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.L2Event;
import com.l2jserver.gameserver.model.events.EventDispatcher;
import com.l2jserver.gameserver.model.events.EventType;
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.MoveToPawn;
import com.l2jserver.util.Rnd;
@ -79,23 +79,27 @@ public class L2NpcAction implements IActionHandler
else if (interact)
{
// Check if the activeChar is attackable (without a forced attack) and isn't dead
if (target.isAutoAttackable(activeChar) && !((L2Character) target).isAlikeDead())
if (target.isAutoAttackable(activeChar) && !((L2Npc) target).isAlikeDead())
{
// Check the height difference
if (Math.abs(activeChar.getZ() - target.getZ()) < 400) // this max heigth difference might need some tweaking
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
// Set the L2PcInstance Intention to AI_INTENTION_ATTACK
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
// activeChar.startAttack(this);
}
else
{
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
final Location destination = GeoData.getInstance().moveCheck(activeChar, target);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
}
}
else if (!target.isAutoAttackable(activeChar))
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
final Location destination = GeoData.getInstance().moveCheck(activeChar, target);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
return true;
}
// Calculate the distance between the L2PcInstance and the L2Npc
if (!((L2Npc) target).canInteract(activeChar))
{

View File

@ -25,7 +25,6 @@ import com.l2jserver.gameserver.enums.PrivateStoreType;
import com.l2jserver.gameserver.handler.IActionHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
@ -33,6 +32,8 @@ import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
public class L2PcInstanceAction implements IActionHandler
{
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/**
* Manage actions when a player click on this L2PcInstance.<BR>
* <BR>
@ -83,50 +84,48 @@ public class L2PcInstanceAction implements IActionHandler
}
else if (interact)
{
final L2PcInstance player = target.getActingPlayer();
// Check if this L2PcInstance has a Private Store
if (((L2PcInstance) target).getPrivateStoreType() != PrivateStoreType.NONE)
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
{
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, player);
}
else
{
// Check if this L2PcInstance is autoAttackable
if (target.isAutoAttackable(activeChar))
if (player.isAutoAttackable(activeChar))
{
// activeChar with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack activeChars with lvl < 21
if ((((L2PcInstance) target).isCursedWeaponEquipped() && (activeChar.getLevel() < 21)) || (activeChar.isCursedWeaponEquipped() && (((L2Character) target).getLevel() < 21)))
if ((player.isCursedWeaponEquipped() && (activeChar.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (activeChar.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
}
else
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
if (GeoData.getInstance().canSeeTarget(activeChar, player))
{
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
activeChar.onActionRequest();
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
}
else
{
final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId());
final Location destination = GeoData.getInstance().moveCheck(activeChar, player);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
activeChar.onActionRequest();
}
activeChar.onActionRequest();
}
}
else
{
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
if (GeoData.getInstance().canSeeTarget(activeChar, target))
if (GeoData.getInstance().canSeeTarget(activeChar, player))
{
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
}
else
{
final Location destination = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), target.getX(), target.getY(), target.getZ(), activeChar.getInstanceId());
final Location destination = GeoData.getInstance().moveCheck(activeChar, player);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, destination);
activeChar.onActionRequest();
}
}
}