|
@@ -19,8 +19,11 @@ import java.util.logging.Logger;
|
|
|
|
|
|
import com.l2jserver.Config;
|
|
|
import com.l2jserver.gameserver.GameTimeController;
|
|
|
+import com.l2jserver.gameserver.ai.CtrlEvent;
|
|
|
import com.l2jserver.gameserver.ai.CtrlIntention;
|
|
|
import com.l2jserver.gameserver.ai.L2SummonAI;
|
|
|
+import com.l2jserver.gameserver.ai.NextAction;
|
|
|
+import com.l2jserver.gameserver.ai.NextAction.NextActionCallback;
|
|
|
import com.l2jserver.gameserver.datatables.PetDataTable;
|
|
|
import com.l2jserver.gameserver.datatables.SkillTable;
|
|
|
import com.l2jserver.gameserver.datatables.SummonSkillsTable;
|
|
@@ -76,8 +79,7 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
@Override
|
|
|
protected void runImpl()
|
|
|
{
|
|
|
- L2PcInstance activeChar = getClient().getActiveChar();
|
|
|
-
|
|
|
+ final L2PcInstance activeChar = getClient().getActiveChar();
|
|
|
if (activeChar == null)
|
|
|
return;
|
|
|
|
|
@@ -110,8 +112,8 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- L2Summon pet = activeChar.getPet();
|
|
|
- L2Object target = activeChar.getTarget();
|
|
|
+ final L2Summon pet = activeChar.getPet();
|
|
|
+ final L2Object target = activeChar.getTarget();
|
|
|
|
|
|
if (Config.DEBUG)
|
|
|
_log.info("Requested Action ID: " + String.valueOf(_actionId));
|
|
@@ -119,23 +121,26 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
switch (_actionId)
|
|
|
{
|
|
|
case 0: // Sit/Stand
|
|
|
- if (activeChar.getMountType() != 0)
|
|
|
- break;
|
|
|
-
|
|
|
- if (target != null && !activeChar.isSitting() && target instanceof L2StaticObjectInstance && ((L2StaticObjectInstance) target).getType() == 1 && CastleManager.getInstance().getCastle(target) != null
|
|
|
- && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false))
|
|
|
+ if (activeChar.isSitting() || !activeChar.isMoving())
|
|
|
{
|
|
|
- final ChairSit cs = new ChairSit(activeChar, ((L2StaticObjectInstance) target).getStaticObjectId());
|
|
|
- activeChar.sendPacket(cs);
|
|
|
- activeChar.sitDown();
|
|
|
- activeChar.broadcastPacket(cs);
|
|
|
- break;
|
|
|
+ useSit(activeChar, target);
|
|
|
}
|
|
|
-
|
|
|
- if (activeChar.isSitting())
|
|
|
- activeChar.standUp();
|
|
|
else
|
|
|
- activeChar.sitDown();
|
|
|
+ {
|
|
|
+ // Sit when arrive using next action.
|
|
|
+ // Creating next action class.
|
|
|
+ final NextAction nextAction = new NextAction(CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, new NextActionCallback()
|
|
|
+ {
|
|
|
+ @Override
|
|
|
+ public void doWork()
|
|
|
+ {
|
|
|
+ useSit(activeChar, target);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Binding next action to AI.
|
|
|
+ activeChar.getAI().setNextAction(nextAction);
|
|
|
+ }
|
|
|
|
|
|
if (Config.DEBUG)
|
|
|
_log.fine("new wait type: " + (activeChar.isSitting() ? "SITTING" : "STANDING"));
|
|
@@ -148,7 +153,7 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
activeChar.setRunning();
|
|
|
|
|
|
if (Config.DEBUG)
|
|
|
- _log.fine("new move type: " + (activeChar.isRunning() ? "RUNNING" : "WALKIN"));
|
|
|
+ _log.fine("New move type: " + (activeChar.isRunning() ? "RUNNING" : "WALKING"));
|
|
|
break;
|
|
|
case 10: // Private Store - Sell
|
|
|
activeChar.tryOpenPrivateSellStore(false);
|
|
@@ -181,7 +186,7 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
|
|
|
if (activeChar.isInOlympiadMode() && !activeChar.isOlympiadStart())
|
|
|
{
|
|
|
- // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
|
|
|
+ // If L2PcInstance is in Olympiad and the match isn't already start, send a Server->Client packet ActionFailed
|
|
|
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
|
|
return;
|
|
|
}
|
|
@@ -763,10 +768,50 @@ public final class RequestActionUse extends L2GameClientPacket
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
+ /**
|
|
|
+ * @param activeChar the player trying to sit.
|
|
|
+ * @param target the target to sit, throne, bench or chair.
|
|
|
+ * @return {@code true} if the player can sit, {@code false} otherwise.
|
|
|
+ */
|
|
|
+ private boolean useSit(L2PcInstance activeChar, L2Object target)
|
|
|
+ {
|
|
|
+ if (activeChar.getMountType() != 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((target != null) && !activeChar.isSitting() && (target instanceof L2StaticObjectInstance) && (((L2StaticObjectInstance) target).getType() == 1) && (CastleManager.getInstance().getCastle(target) != null)
|
|
|
+ && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false))
|
|
|
+ {
|
|
|
+ final ChairSit cs = new ChairSit(activeChar, ((L2StaticObjectInstance) target).getStaticObjectId());
|
|
|
+ activeChar.sendPacket(cs);
|
|
|
+ activeChar.sitDown();
|
|
|
+ activeChar.broadcastPacket(cs);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (activeChar.isSitting())
|
|
|
+ {
|
|
|
+ activeChar.standUp();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ activeChar.sitDown();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Config.DEBUG)
|
|
|
+ {
|
|
|
+ _log.fine("New wait type: " + (activeChar.isSitting() ? "SITTING" : "STANDING"));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Cast a skill for active pet/servitor.
|
|
|
* Target is specified as a parameter but can be
|
|
|
* overwrited or ignored depending on skill type.
|
|
|
+ * @param skillId
|
|
|
+ * @param target
|
|
|
*/
|
|
|
private void useSkill(int skillId, L2Object target)
|
|
|
{
|